Struct spirv_builder::SpirvBuilder
source · pub struct SpirvBuilder {
pub shader_panic_strategy: ShaderPanicStrategy,
pub relax_struct_store: bool,
pub relax_logical_pointer: bool,
pub relax_block_layout: bool,
pub uniform_buffer_standard_layout: bool,
pub scalar_block_layout: bool,
pub skip_block_layout: bool,
pub preserve_bindings: bool,
/* private fields */
}
Fields§
§shader_panic_strategy: ShaderPanicStrategy
§relax_struct_store: bool
§relax_logical_pointer: bool
§relax_block_layout: bool
§uniform_buffer_standard_layout: bool
§scalar_block_layout: bool
§skip_block_layout: bool
§preserve_bindings: bool
Implementations§
source§impl SpirvBuilder
impl SpirvBuilder
pub fn new(path_to_crate: impl AsRef<Path>, target: impl Into<String>) -> Self
sourcepub fn target_spec(self, p: impl AsRef<Path>) -> Self
pub fn target_spec(self, p: impl AsRef<Path>) -> Self
Sets the path of the “target specification” file.
For more info on “target specification” see this RFC.
sourcepub fn print_metadata(self, v: MetadataPrintout) -> Self
pub fn print_metadata(self, v: MetadataPrintout) -> Self
Whether to print build.rs cargo metadata (e.g. cargo:rustc-env=var=val). Defaults to MetadataPrintout::Full
.
pub fn deny_warnings(self, v: bool) -> Self
sourcepub fn multimodule(self, v: bool) -> Self
pub fn multimodule(self, v: bool) -> Self
Splits the resulting SPIR-V file into one module per entry point. This is useful in cases where ecosystem tooling has bugs around multiple entry points per module - having all entry points bundled into a single file is the preferred system.
sourcepub fn spirv_metadata(self, v: SpirvMetadata) -> Self
pub fn spirv_metadata(self, v: SpirvMetadata) -> Self
Sets the level of metadata (primarily OpName
and OpLine
) included in the SPIR-V binary.
Including metadata significantly increases binary size.
sourcepub fn capability(self, capability: Capability) -> Self
pub fn capability(self, capability: Capability) -> Self
Adds a capability to the SPIR-V module. Checking if a capability is enabled in code can be
done via #[cfg(target_feature = "TheCapability")]
.
sourcepub fn extension(self, extension: impl Into<String>) -> Self
pub fn extension(self, extension: impl Into<String>) -> Self
Adds an extension to the SPIR-V module. Checking if an extension is enabled in code can be
done via #[cfg(target_feature = "ext:the_extension")]
.
sourcepub fn shader_panic_strategy(
self,
shader_panic_strategy: ShaderPanicStrategy
) -> Self
pub fn shader_panic_strategy( self, shader_panic_strategy: ShaderPanicStrategy ) -> Self
Change the shader panic!
handling strategy (see ShaderPanicStrategy
).
sourcepub fn relax_struct_store(self, v: bool) -> Self
pub fn relax_struct_store(self, v: bool) -> Self
Allow store from one struct type to a different type with compatible layout and members.
sourcepub fn relax_logical_pointer(self, v: bool) -> Self
pub fn relax_logical_pointer(self, v: bool) -> Self
Allow allocating an object of a pointer type and returning a pointer value from a function in logical addressing mode
sourcepub fn relax_block_layout(self, v: bool) -> Self
pub fn relax_block_layout(self, v: bool) -> Self
Enable VK_KHR_relaxed_block_layout
when checking standard uniform, storage buffer, and
push constant layouts. This is the default when targeting Vulkan 1.1 or later.
sourcepub fn uniform_buffer_standard_layout(self, v: bool) -> Self
pub fn uniform_buffer_standard_layout(self, v: bool) -> Self
Enable VK_KHR_uniform_buffer_standard_layout
when checking standard uniform buffer
layouts.
sourcepub fn scalar_block_layout(self, v: bool) -> Self
pub fn scalar_block_layout(self, v: bool) -> Self
Enable VK_EXT_scalar_block_layout
when checking standard uniform, storage buffer, and
push constant layouts. Scalar layout rules are more permissive than relaxed block layout so
in effect this will override the –relax-block-layout option.
sourcepub fn skip_block_layout(self, v: bool) -> Self
pub fn skip_block_layout(self, v: bool) -> Self
Skip checking standard uniform/storage buffer layout. Overrides any –relax-block-layout or –scalar-block-layout option.
sourcepub fn preserve_bindings(self, v: bool) -> Self
pub fn preserve_bindings(self, v: bool) -> Self
Preserve unused descriptor bindings. Useful for reflection.
sourcepub fn extra_arg(self, arg: impl Into<String>) -> Self
pub fn extra_arg(self, arg: impl Into<String>) -> Self
Set additional “codegen arg”. Note: the RUSTGPU_CODEGEN_ARGS
environment variable
takes precedence over any set arguments using this function.
sourcepub fn shader_crate_default_features(self, default_features: bool) -> Self
pub fn shader_crate_default_features(self, default_features: bool) -> Self
Set –default-features for the target shader crate.
sourcepub fn shader_crate_features(
self,
features: impl IntoIterator<Item = String>
) -> Self
pub fn shader_crate_features( self, features: impl IntoIterator<Item = String> ) -> Self
Set –features for the target shader crate.
pub fn rustc_codegen_spirv_location( self, path_to_dylib: impl AsRef<Path> ) -> Self
sourcepub fn build(self) -> Result<CompileResult, SpirvBuilderError>
pub fn build(self) -> Result<CompileResult, SpirvBuilderError>
Builds the module. If print_metadata
is MetadataPrintout::Full
, you usually don’t have to inspect the path
in the result, as the environment variable for the path to the module will already be set.