Struct naga::valid::Validator

source ·
pub struct Validator {
    flags: ValidationFlags,
    capabilities: Capabilities,
    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: BitSet,
}

Fields§

§flags: ValidationFlags§capabilities: Capabilities§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: BitSet

Implementations§

source§

impl Validator

source

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

source

pub(super) fn validate_expression( &self, root: Handle<Expression>, expression: &Expression, function: &Function, module: &Module, info: &FunctionInfo, mod_info: &ModuleInfo ) -> 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: 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, expression_constness: &ExpressionConstnessTracker ) -> Result<(), LocalVariableError>

source

pub(super) fn validate_function( &mut self, fun: &Function, module: &Module, mod_info: &ModuleInfo, entry_point: bool ) -> 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_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>, types: &UniqueArena<Type> ) -> Result<(), InvalidHandleError>

source

fn validate_expression_handles( (handle, expression): (Handle<Expression>, &Expression), constants: &Arena<Constant>, const_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 ) -> Result<(), GlobalVariableError>

source

pub(super) fn validate_entry_point( &mut self, ep: &EntryPoint, module: &Module, mod_info: &ModuleInfo ) -> 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, kind: ScalarKind, width: Bytes ) -> 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 reset(&mut self)

Reset the validator internals

source

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

source

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

Check the given module to be valid.

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.