Struct naga::back::spv::Writer

source ·
pub struct Writer {
Show 22 fields physical_layout: PhysicalLayout, logical_layout: LogicalLayout, id_gen: IdGenerator, capabilities_available: Option<FastHashSet<Capability>>, capabilities_used: FastIndexSet<Capability>, extensions_used: FastIndexSet<&'static str>, debugs: Vec<Instruction>, annotations: Vec<Instruction>, flags: WriterFlags, bounds_check_policies: BoundsCheckPolicies, zero_initialize_workgroup_memory: ZeroInitializeWorkgroupMemoryMode, void_type: Word, lookup_type: FastHashMap<LookupType, Word>, lookup_function: FastHashMap<Handle<Function>, Word>, lookup_function_type: FastHashMap<LookupFunctionType, Word>, constant_ids: HandleVec<Expression, Word>, cached_constants: FastHashMap<CachedConstant, Word>, global_variables: HandleVec<GlobalVariable, GlobalVariable>, binding_map: BindingMap, saved_cached: CachedExpressions, gl450_ext_inst_id: Word, temp_list: Vec<Word>,
}

Fields§

§physical_layout: PhysicalLayout§logical_layout: LogicalLayout§id_gen: IdGenerator§capabilities_available: Option<FastHashSet<Capability>>

The set of capabilities modules are permitted to use.

This is initialized from Options::capabilities.

§capabilities_used: FastIndexSet<Capability>

The set of capabilities used by this module.

If capabilities_available is Some, then this is always a subset of that.

§extensions_used: FastIndexSet<&'static str>

The set of spirv extensions used.

§debugs: Vec<Instruction>§annotations: Vec<Instruction>§flags: WriterFlags§bounds_check_policies: BoundsCheckPolicies§zero_initialize_workgroup_memory: ZeroInitializeWorkgroupMemoryMode§void_type: Word§lookup_type: FastHashMap<LookupType, Word>§lookup_function: FastHashMap<Handle<Function>, Word>§lookup_function_type: FastHashMap<LookupFunctionType, Word>§constant_ids: HandleVec<Expression, Word>

Indexed by const-expression handle indexes

§cached_constants: FastHashMap<CachedConstant, Word>§global_variables: HandleVec<GlobalVariable, GlobalVariable>§binding_map: BindingMap§saved_cached: CachedExpressions§gl450_ext_inst_id: Word§temp_list: Vec<Word>

Implementations§

source§

impl Writer

source

fn write_epilogue_position_y_flip( &mut self, position_id: Word, body: &mut Vec<Instruction>, ) -> Result<(), Error>

source

fn write_epilogue_frag_depth_clamp( &mut self, frag_depth_id: Word, body: &mut Vec<Instruction>, ) -> Result<(), Error>

source

fn write_entry_point_return( &mut self, value_id: Word, ir_result: &FunctionResult, result_members: &[ResultMember], body: &mut Vec<Instruction>, ) -> Result<(), Error>

source§

impl Writer

source

pub fn new(options: &Options<'_>) -> Result<Self, Error>

source

fn reset(&mut self)

Reset Writer to its initial state, retaining any allocations.

Why not just implement Recyclable for Writer? By design, Recyclable::recycle requires ownership of the value, not just &mut; see the trait documentation. But we need to use this method from functions like Writer::write, which only have &mut Writer. Workarounds include unsafe code (std::ptr::read, then write, ugh) or something like a Default impl that returns an oddly-initialized Writer, which is worse.

source

pub(super) fn require_any( &mut self, what: &'static str, capabilities: &[Capability], ) -> Result<(), Error>

Indicate that the code requires any one of the listed capabilities.

If nothing in capabilities appears in the available capabilities specified in the Options from which this Writer was created, return an error. The what string is used in the error message to explain what provoked the requirement. (If no available capabilities were given, assume everything is available.)

The first acceptable capability will be added to this Writer’s capabilities_used table, and an OpCapability emitted for it in the result. For this reason, more specific capabilities should be listed before more general.

source

pub(super) fn use_extension(&mut self, extension: &'static str)

Indicate that the code uses the given extension.

source

pub(super) fn get_type_id(&mut self, lookup_ty: LookupType) -> Word

source

pub(super) fn get_expression_lookup_type( &mut self, tr: &TypeResolution, ) -> LookupType

source

pub(super) fn get_expression_type_id(&mut self, tr: &TypeResolution) -> Word

source

pub(super) fn get_pointer_id( &mut self, handle: Handle<Type>, class: StorageClass, ) -> Word

source

pub(super) fn get_resolution_pointer_id( &mut self, resolution: &TypeResolution, class: StorageClass, ) -> Word

Return a SPIR-V type for a pointer to resolution.

The given resolution must be one that we can represent either as a LocalType::Pointer or LocalType::LocalPointer.

source

pub(super) fn get_uint_type_id(&mut self) -> Word

source

pub(super) fn get_float_type_id(&mut self) -> Word

source

pub(super) fn get_uint3_type_id(&mut self) -> Word

source

pub(super) fn get_float_pointer_type_id(&mut self, class: StorageClass) -> Word

source

pub(super) fn get_uint3_pointer_type_id(&mut self, class: StorageClass) -> Word

source

pub(super) fn get_bool_type_id(&mut self) -> Word

source

pub(super) fn get_bool3_type_id(&mut self) -> Word

source

pub(super) fn decorate( &mut self, id: Word, decoration: Decoration, operands: &[Word], )

source

fn write_function( &mut self, ir_function: &Function, info: &FunctionInfo, ir_module: &Module, interface: Option<FunctionInterface<'_>>, debug_info: &Option<DebugInfoInner<'_>>, ) -> Result<Word, Error>

source

fn write_execution_mode( &mut self, function_id: Word, mode: ExecutionMode, ) -> Result<(), Error>

source

fn write_entry_point( &mut self, entry_point: &EntryPoint, info: &FunctionInfo, ir_module: &Module, debug_info: &Option<DebugInfoInner<'_>>, ) -> Result<Instruction, Error>

source

fn make_scalar(&mut self, id: Word, scalar: Scalar) -> Instruction

source

fn request_type_capabilities(&mut self, inner: &TypeInner) -> Result<(), Error>

source

fn write_numeric_type_declaration_local( &mut self, id: Word, numeric: NumericType, )

source

fn write_type_declaration_local(&mut self, id: Word, local_ty: LocalType)

source

fn write_type_declaration_arena( &mut self, arena: &UniqueArena<Type>, handle: Handle<Type>, ) -> Result<Word, Error>

source

fn request_image_format_capabilities( &mut self, format: ImageFormat, ) -> Result<(), Error>

source

pub(super) fn get_index_constant(&mut self, index: Word) -> Word

source

pub(super) fn get_constant_scalar_with( &mut self, value: u8, scalar: Scalar, ) -> Result<Word, Error>

source

pub(super) fn get_constant_scalar(&mut self, value: Literal) -> Word

source

fn write_constant_scalar( &mut self, id: Word, value: &Literal, debug_name: Option<&String>, )

source

pub(super) fn get_constant_composite( &mut self, ty: LookupType, constituent_ids: &[Word], ) -> Word

source

fn write_constant_composite( &mut self, id: Word, ty: LookupType, constituent_ids: &[Word], debug_name: Option<&String>, )

source

pub(super) fn get_constant_null(&mut self, type_id: Word) -> Word

source

pub(super) fn write_constant_null(&mut self, type_id: Word) -> Word

source

fn write_constant_expr( &mut self, handle: Handle<Expression>, ir_module: &Module, mod_info: &ModuleInfo, ) -> Result<Word, Error>

source

pub(super) fn write_barrier(&mut self, flags: Barrier, block: &mut Block)

source

fn generate_workgroup_vars_init_block( &mut self, entry_id: Word, ir_module: &Module, info: &FunctionInfo, local_invocation_id: Option<Word>, interface: &mut FunctionInterface<'_>, function: &mut Function, ) -> Option<Word>

source

fn write_varying( &mut self, ir_module: &Module, stage: ShaderStage, class: StorageClass, debug_name: Option<&str>, ty: Handle<Type>, binding: &Binding, ) -> Result<Word, Error>

Generate an OpVariable for one value in an EntryPoint’s IO interface.

The Bindings of the arguments and result of an EntryPoint’s Function describe a SPIR-V shader interface. In SPIR-V, the interface is represented by global variables in the Input and Output storage classes, with decorations indicating which builtin or location each variable corresponds to.

This function emits a single global OpVariable for a single value from the interface, and adds appropriate decorations to indicate which builtin or location it represents, how it should be interpolated, and so on. The class argument gives the variable’s SPIR-V storage class, which should be either Input or Output.

source

fn write_global_variable( &mut self, ir_module: &Module, global_variable: &GlobalVariable, ) -> Result<Word, Error>

source

fn decorate_struct_member( &mut self, struct_id: Word, index: usize, member: &StructMember, arena: &UniqueArena<Type>, ) -> Result<(), Error>

Write the necessary decorations for a struct member.

Emit decorations for the index’th member of the struct type designated by struct_id, described by member.

source

fn get_function_type( &mut self, lookup_function_type: LookupFunctionType, ) -> Word

source

fn write_physical_layout(&mut self)

source

fn write_logical_layout( &mut self, ir_module: &Module, mod_info: &ModuleInfo, ep_index: Option<usize>, debug_info: &Option<DebugInfo<'_>>, ) -> Result<(), Error>

source

pub fn write( &mut self, ir_module: &Module, info: &ModuleInfo, pipeline_options: Option<&PipelineOptions>, debug_info: &Option<DebugInfo<'_>>, words: &mut Vec<Word>, ) -> Result<(), Error>

source

pub const fn get_capabilities_used(&self) -> &FastIndexSet<Capability>

Return the set of capabilities the last module written used.

source

pub fn decorate_non_uniform_binding_array_access( &mut self, id: Word, ) -> Result<(), Error>

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl RefUnwindSafe for Writer

§

impl Send for Writer

§

impl Sync for Writer

§

impl Unpin for Writer

§

impl UnwindSafe for Writer

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.