mod conv; mod help; mod keywords; mod storage; mod writer;
use std::fmt::Error as FmtError; use thiserror::Error;
usecrate::{back, proc};
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] pubstruct BindTarget { pub space: u8, pub register: u32, /// If the binding is an unsized binding array, this overrides the size. pub binding_array_size: Option<u32>,
}
// Using `BTreeMap` instead of `HashMap` so that we can hash itself. pubtype BindingMap = std::collections::BTreeMap<crate::ResourceBinding, BindTarget>;
/// Configuration used in the [`Writer`]. #[derive(Clone, Debug, Hash, PartialEq, Eq)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", serde(default))] pubstruct Options { /// The hlsl shader model to be used pub shader_model: ShaderModel, /// Map of resources association to binding locations. pub binding_map: BindingMap, /// Don't panic on missing bindings, instead generate any HLSL. pub fake_missing_bindings: bool, /// Add special constants to `SV_VertexIndex` and `SV_InstanceIndex`, /// to make them work like in Vulkan/Metal, with help of the host. pub special_constants_binding: Option<BindTarget>, /// Bind target of the push constant buffer pub push_constants_target: Option<BindTarget>, /// Should workgroup variables be zero initialized (by polyfilling)? pub zero_initialize_workgroup_memory: bool, /// Should we restrict indexing of vectors, matrices and arrays? pub restrict_indexing: bool,
}
/// Reflection info for entry point names. #[derive(Default)] pubstruct ReflectionInfo { /// Mapping of the entry point names. /// /// Each item in the array corresponds to an entry point index. The real entry point name may be different if one of the /// reserved words are used. /// /// Note: Some entry points may fail translation because of missing bindings. pub entry_point_names: Vec<Result<String, EntryPointError>>,
}
#[derive(Error, Debug)] pubenum Error { #[error(transparent)]
IoError(#[from] FmtError), #[error("A scalar with an unsupported width was requested: {0:?}")]
UnsupportedScalar(crate::Scalar), #[error("{0}")]
Unimplemented(String), // TODO: Error used only during development #[error("{0}")]
Custom(String), #[error("overrides should not be present at this stage")] Override,
}
/// A fragment entry point to be considered when generating HLSL for the output interface of vertex /// entry points. /// /// This is provided as an optional parameter to [`Writer::write`]. /// /// If this is provided, vertex outputs will be removed if they are not inputs of this fragment /// entry point. This is necessary for generating correct HLSL when some of the vertex shader /// outputs are not consumed by the fragment shader. pubstruct FragmentEntryPoint<'a> {
module: &'a crate::Module,
func: &'a crate::Function,
}
impl<'a> FragmentEntryPoint<'a> { /// Returns `None` if the entry point with the provided name can't be found or isn't a fragment /// entry point. pubfn new(module: &'a crate::Module, ep_name: &'a str) -> Option<Self> {
module
.entry_points
.iter()
.find(|ep| ep.name == ep_name)
.filter(|ep| ep.stage == crate::ShaderStage::Fragment)
.map(|ep| Self {
module,
func: &ep.function,
})
}
}
pubstruct Writer<'a, W> {
out: W,
names: crate::FastHashMap<proc::NameKey, String>,
namer: proc::Namer, /// HLSL backend options
options: &'a Options, /// Information about entry point arguments and result types.
entry_point_io: Vec<writer::EntryPointInterface>, /// Set of expressions that have associated temporary variables
named_expressions: crate::NamedExpressions,
wrapped: Wrapped,
continue_ctx: back::continue_forward::ContinueCtx,
/// A reference to some part of a global variable, lowered to a series of /// byte offset calculations. /// /// See the [`storage`] module for background on why we need this. /// /// Each [`SubAccess`] in the vector is a lowering of some [`Access`] or /// [`AccessIndex`] expression to the level of byte strides and offsets. See /// [`SubAccess`] for details. /// /// This field is a member of [`Writer`] solely to allow re-use of /// the `Vec`'s dynamic allocation. The value is no longer needed /// once HLSL for the access has been generated. /// /// [`Storage`]: crate::AddressSpace::Storage /// [`SubAccess`]: storage::SubAccess /// [`Access`]: crate::Expression::Access /// [`AccessIndex`]: crate::Expression::AccessIndex
temp_access_chain: Vec<storage::SubAccess>,
need_bake_expressions: back::NeedBakeExpressions,
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.