#[non_exhaustive]pub struct SpirvBuilder {Show 19 fields
pub path_to_crate: Option<PathBuf>,
pub print_metadata: MetadataPrintout,
pub release: bool,
pub target: Option<String>,
pub shader_crate_features: ShaderCrateFeatures,
pub deny_warnings: bool,
pub multimodule: bool,
pub spirv_metadata: SpirvMetadata,
pub capabilities: Vec<Capability>,
pub extensions: Vec<String>,
pub extra_args: Vec<String>,
pub rustc_codegen_spirv_location: Option<PathBuf>,
pub toolchain_overwrite: Option<String>,
pub toolchain_rustc_version: Option<Version>,
pub path_to_target_spec: Option<PathBuf>,
pub target_dir_path: Option<String>,
pub shader_panic_strategy: ShaderPanicStrategy,
pub validator: ValidatorOptions,
pub optimizer: OptimizerOptions,
}
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.path_to_crate: Option<PathBuf>
§print_metadata: MetadataPrintout
Whether to print build.rs cargo metadata (e.g. cargo:rustc-env=var=val). Defaults to MetadataPrintout::Full
.
release: bool
Build in release. Defaults to true.
target: Option<String>
The target triple, eg. spirv-unknown-vulkan1.2
shader_crate_features: ShaderCrateFeatures
Cargo features specification for building the shader crate.
deny_warnings: bool
Deny any warnings, as they may never be printed when building within a build script. Defaults to false.
multimodule: bool
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.
spirv_metadata: SpirvMetadata
Sets the level of metadata (primarily OpName
and OpLine
) included in the SPIR-V binary.
Including metadata significantly increases binary size.
capabilities: Vec<Capability>
Adds a capability to the SPIR-V module. Checking if a capability is enabled in code can be
done via #[cfg(target_feature = "TheCapability")]
.
extensions: Vec<String>
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")]
.
extra_args: Vec<String>
Set additional “codegen arg”. Note: the RUSTGPU_CODEGEN_ARGS
environment variable
takes precedence over any set arguments using this function.
rustc_codegen_spirv_location: Option<PathBuf>
§toolchain_overwrite: Option<String>
§toolchain_rustc_version: Option<Version>
§path_to_target_spec: Option<PathBuf>
The path of the “target specification” file.
For more info on “target specification” see this RFC.
target_dir_path: Option<String>
Set the target dir path within ./target
to use for building shaders. Defaults to spirv-builder
, resulting
in the path ./target/spirv-builder
.
shader_panic_strategy: ShaderPanicStrategy
Change the shader panic!
handling strategy (see ShaderPanicStrategy
).
validator: ValidatorOptions
spirv-val flags
optimizer: OptimizerOptions
spirv-opt flags
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 target_dir_path(self, name: impl Into<String>) -> Self
pub fn target_dir_path(self, name: impl Into<String>) -> Self
Set the target dir path within ./target
to use for building shaders. Defaults to spirv-builder
, resulting
in the path ./target/spirv-builder
.
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.
Trait Implementations§
Source§impl Clone for SpirvBuilder
impl Clone for SpirvBuilder
Source§fn clone(&self) -> SpirvBuilder
fn clone(&self) -> SpirvBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more