Struct naga::valid::Validator

source ·
pub struct Validator {
Show 14 fields flags: ValidationFlags, capabilities: Capabilities, subgroup_stages: ShaderStages, subgroup_operations: SubgroupOperationSet, types: Vec<TypeInfo>, layouter: Layouter, location_mask: BitSet, ep_resource_bindings: FastHashSet<ResourceBinding>, switch_values: FastHashSet<SwitchValue>, valid_expression_list: Vec<Handle<Expression>>, valid_expression_set: HandleSet<Expression>, override_ids: FastHashSet<u16>, allow_overrides: bool, needs_visit: HandleSet<Expression>,
}

Fields§

§flags: ValidationFlags§capabilities: Capabilities§subgroup_stages: ShaderStages§subgroup_operations: SubgroupOperationSet§types: Vec<TypeInfo>§layouter: Layouter§location_mask: BitSet§ep_resource_bindings: FastHashSet<ResourceBinding>§switch_values: FastHashSet<SwitchValue>§valid_expression_list: Vec<Handle<Expression>>§valid_expression_set: HandleSet<Expression>§override_ids: FastHashSet<u16>§allow_overrides: bool§needs_visit: HandleSet<Expression>

A checklist of expressions that must be visited by a specific kind of statement.

For example:

Be sure not to remove any Expression handle from this set unless you’ve explicitly checked that it is the right kind of expression for the visiting Statement.

Implementations§

source§

impl Validator

source

pub(super) fn validate_const_expression( &self, handle: Handle<Expression>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), ConstExpressionError>

source

pub(super) fn validate_expression( &self, root: Handle<Expression>, expression: &Expression, function: &Function, module: &Module, info: &FunctionInfo, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<ShaderStages, ExpressionError>

source

fn global_var_ty( module: &Module, function: &Function, expr: Handle<Expression>, ) -> Result<Handle<Type>, ExpressionError>

source

pub fn validate_literal(&self, literal: Literal) -> Result<(), LiteralError>

source§

impl Validator

source

fn validate_call( &mut self, function: Handle<Function>, arguments: &[Handle<Expression>], result: Option<Handle<Expression>>, context: &BlockContext<'_>, ) -> Result<ShaderStages, WithSpan<CallError>>

source

fn emit_expression( &mut self, handle: Handle<Expression>, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>

source

fn validate_atomic( &mut self, pointer: Handle<Expression>, fun: &AtomicFunction, value: Handle<Expression>, result: Option<Handle<Expression>>, span: Span, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>

source

fn validate_subgroup_operation( &mut self, op: &SubgroupOperation, collective_op: &CollectiveOperation, argument: Handle<Expression>, result: Handle<Expression>, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>

source

fn validate_subgroup_gather( &mut self, mode: &GatherMode, argument: Handle<Expression>, result: Handle<Expression>, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>

source

fn validate_block_impl( &mut self, statements: &Block, context: &BlockContext<'_>, ) -> Result<BlockInfo, WithSpan<FunctionError>>

source

fn validate_block( &mut self, statements: &Block, context: &BlockContext<'_>, ) -> Result<BlockInfo, WithSpan<FunctionError>>

source

fn validate_local_var( &self, var: &LocalVariable, gctx: GlobalCtx<'_>, fun_info: &FunctionInfo, local_expr_kind: &ExpressionKindTracker, ) -> Result<(), LocalVariableError>

source

pub(super) fn validate_function( &mut self, fun: &Function, module: &Module, mod_info: &ModuleInfo, entry_point: bool, global_expr_kind: &ExpressionKindTracker, ) -> Result<FunctionInfo, WithSpan<FunctionError>>

source§

impl Validator

source

pub(super) fn validate_module_handles( module: &Module, ) -> Result<(), ValidationError>

Validates that all handles within module are:

  • Valid, in the sense that they contain indices within each arena structure inside the crate::Module type.
  • No arena contents contain any items that have forward dependencies; that is, the value associated with a handle only may contain references to handles in the same arena that were constructed before it.

By validating the above conditions, we free up subsequent logic to assume that handle accesses are infallible.

§Errors

Errors returned by this method are intentionally sparse, for simplicity of implementation. It is expected that only buggy frontends or fuzzers should ever emit IR that fails this validation pass.

source

fn validate_type_handle( handle: Handle<Type>, types: &UniqueArena<Type>, ) -> Result<(), InvalidHandleError>

source

fn validate_constant_handle( handle: Handle<Constant>, constants: &Arena<Constant>, ) -> Result<(), InvalidHandleError>

source

fn validate_override_handle( handle: Handle<Override>, overrides: &Arena<Override>, ) -> Result<(), InvalidHandleError>

source

fn validate_expression_handle( handle: Handle<Expression>, expressions: &Arena<Expression>, ) -> Result<(), InvalidHandleError>

source

fn validate_function_handle( handle: Handle<Function>, functions: &Arena<Function>, ) -> Result<(), InvalidHandleError>

source

fn validate_const_expression_handles( (handle, expression): (Handle<Expression>, &Expression), constants: &Arena<Constant>, overrides: &Arena<Override>, types: &UniqueArena<Type>, ) -> Result<(), InvalidHandleError>

source

fn validate_expression_handles( (handle, expression): (Handle<Expression>, &Expression), constants: &Arena<Constant>, overrides: &Arena<Override>, global_expressions: &Arena<Expression>, types: &UniqueArena<Type>, local_variables: &Arena<LocalVariable>, global_variables: &Arena<GlobalVariable>, functions: &Arena<Function>, current_function: Option<Handle<Function>>, ) -> Result<(), InvalidHandleError>

source

fn validate_block_handles( block: &Block, expressions: &Arena<Expression>, functions: &Arena<Function>, ) -> Result<(), InvalidHandleError>

source§

impl Validator

source

pub(super) fn validate_global_var( &self, var: &GlobalVariable, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), GlobalVariableError>

source

pub(super) fn validate_entry_point( &mut self, ep: &EntryPoint, module: &Module, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<FunctionInfo, WithSpan<EntryPointError>>

source§

impl Validator

source

const fn require_type_capability( &self, capability: Capabilities, ) -> Result<(), TypeError>

source

pub(super) const fn check_width(&self, scalar: Scalar) -> Result<(), WidthError>

source

pub(super) fn reset_types(&mut self, size: usize)

source

pub(super) fn validate_type( &self, handle: Handle<Type>, gctx: GlobalCtx<'_>, ) -> Result<TypeInfo, TypeError>

source§

impl Validator

source

pub fn new(flags: ValidationFlags, capabilities: Capabilities) -> Self

Construct a new validator instance.

source

pub fn subgroup_stages(&mut self, stages: ShaderStages) -> &mut Self

source

pub fn subgroup_operations( &mut self, operations: SubgroupOperationSet, ) -> &mut Self

source

pub fn reset(&mut self)

Reset the validator internals

source

fn validate_constant( &self, handle: Handle<Constant>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), ConstantError>

source

fn validate_override( &mut self, handle: Handle<Override>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, ) -> Result<(), OverrideError>

source

pub fn validate( &mut self, module: &Module, ) -> Result<ModuleInfo, WithSpan<ValidationError>>

Check the given module to be valid.

source

pub fn validate_no_overrides( &mut self, module: &Module, ) -> Result<ModuleInfo, WithSpan<ValidationError>>

Check the given module to be valid.

With the additional restriction that overrides are not present.

source

fn validate_impl( &mut self, module: &Module, ) -> Result<ModuleInfo, WithSpan<ValidationError>>

Trait Implementations§

source§

impl Debug for Validator

source§

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

Formats the value using the given formatter. 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> 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.