spirv_builder

Struct SpirvBuilder

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

pub fn new(path_to_crate: impl AsRef<Path>, target: impl Into<String>) -> Self

Source

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.

Source

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.

Source

pub fn deny_warnings(self, v: bool) -> Self

Source

pub fn release(self, v: bool) -> Self

Build in release. Defaults to true.

Source

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.

Source

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.

Source

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")].

Source

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")].

Source

pub fn shader_panic_strategy( self, shader_panic_strategy: ShaderPanicStrategy, ) -> Self

Change the shader panic! handling strategy (see ShaderPanicStrategy).

Source

pub fn relax_struct_store(self, v: bool) -> Self

Allow store from one struct type to a different type with compatible layout and members.

Source

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

Source

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.

Source

pub fn uniform_buffer_standard_layout(self, v: bool) -> Self

Enable VK_KHR_uniform_buffer_standard_layout when checking standard uniform buffer layouts.

Source

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.

Source

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.

Source

pub fn preserve_bindings(self, v: bool) -> Self

Preserve unused descriptor bindings. Useful for reflection.

Source

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.

Source

pub fn shader_crate_default_features(self, default_features: bool) -> Self

Set –default-features for the target shader crate.

Source

pub fn shader_crate_features( self, features: impl IntoIterator<Item = String>, ) -> Self

Set –features for the target shader crate.

Source

pub fn rustc_codegen_spirv_location( self, path_to_dylib: impl AsRef<Path>, ) -> Self

Source

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.

Source

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

Source§

fn clone(&self) -> SpirvBuilder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpirvBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SpirvBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SpirvBuilder

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SpirvBuilder

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,