pub trait Compiler:
Sync
+ Send
+ 'static
+ Clone
+ Debug {
type Representation: Display;
type CompilationOptions: Send + Default + Debug;
// Required methods
fn compile(
&mut self,
kernel: KernelDefinition,
compilation_options: &Self::CompilationOptions,
) -> Result<Self::Representation, CompilationError>;
fn extension(&self) -> &'static str;
fn lang_tag(&self) -> &'static str;
// Provided method
fn buffer_io(_repr: &Self::Representation) -> Option<Vec<BufferIOAttr>> { ... }
}Expand description
Compiles the representation into its own representation that can be formatted into tokens.
Required Associated Types§
Sourcetype Representation: Display
type Representation: Display
The representation for the compiled code.
Sourcetype CompilationOptions: Send + Default + Debug
type CompilationOptions: Send + Default + Debug
The compilation options used to configure the compiler
Required Methods§
Sourcefn compile(
&mut self,
kernel: KernelDefinition,
compilation_options: &Self::CompilationOptions,
) -> Result<Self::Representation, CompilationError>
fn compile( &mut self, kernel: KernelDefinition, compilation_options: &Self::CompilationOptions, ) -> Result<Self::Representation, CompilationError>
Compiles the kernel definition into the compiler’s representation.
Sourcefn extension(&self) -> &'static str
fn extension(&self) -> &'static str
The default extension for the runtime’s kernel/shader code. Might change based on which compiler is used.
Sourcefn lang_tag(&self) -> &'static str
fn lang_tag(&self) -> &'static str
Short identifier of the language this compiler produces, such as
"wgsl" or "cuda".
What a PrecompiledSource has to
name to be accepted by this compiler.
Provided Methods§
Sourcefn buffer_io(_repr: &Self::Representation) -> Option<Vec<BufferIOAttr>>
fn buffer_io(_repr: &Self::Representation) -> Option<Vec<BufferIOAttr>>
What the compiled kernel does with each buffer binding, by buffer
position — the visibility analysis’s answer, when the representation
kept it (see BufferIOAttr).
None reads as every buffer both read and written, the conservative
direction. A compiler overriding this must answer from the IR
attributes the annotate pass stamped, never from what its shader
language kept — wgpu’s shader visibility, for one, is deliberately
forced wider than the kernel’s own behavior.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".