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
impl Validator
pub(super) fn validate_const_expression( &self, handle: Handle<Expression>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo ) -> Result<(), ConstExpressionError>
pub(super) fn validate_expression( &self, root: Handle<Expression>, expression: &Expression, function: &Function, module: &Module, info: &FunctionInfo, mod_info: &ModuleInfo ) -> Result<ShaderStages, ExpressionError>
fn global_var_ty( module: &Module, function: &Function, expr: Handle<Expression> ) -> Result<Handle<Type>, ExpressionError>
pub fn validate_literal(&self, literal: Literal) -> Result<(), LiteralError>
source§impl Validator
impl Validator
fn validate_call( &mut self, function: Handle<Function>, arguments: &[Handle<Expression>], result: Option<Handle<Expression>>, context: &BlockContext<'_> ) -> Result<ShaderStages, WithSpan<CallError>>
fn emit_expression( &mut self, handle: Handle<Expression>, context: &BlockContext<'_> ) -> Result<(), WithSpan<FunctionError>>
fn validate_atomic( &mut self, pointer: Handle<Expression>, fun: &AtomicFunction, value: Handle<Expression>, result: Handle<Expression>, context: &BlockContext<'_> ) -> Result<(), WithSpan<FunctionError>>
fn validate_block_impl( &mut self, statements: &Block, context: &BlockContext<'_> ) -> Result<BlockInfo, WithSpan<FunctionError>>
fn validate_block( &mut self, statements: &Block, context: &BlockContext<'_> ) -> Result<BlockInfo, WithSpan<FunctionError>>
fn validate_local_var( &self, var: &LocalVariable, gctx: GlobalCtx<'_>, fun_info: &FunctionInfo, expression_constness: &ExpressionConstnessTracker ) -> Result<(), LocalVariableError>
pub(super) fn validate_function( &mut self, fun: &Function, module: &Module, mod_info: &ModuleInfo, entry_point: bool ) -> Result<FunctionInfo, WithSpan<FunctionError>>
source§impl Validator
impl Validator
sourcepub(super) fn validate_module_handles(
module: &Module
) -> Result<(), ValidationError>
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.
fn validate_type_handle( handle: Handle<Type>, types: &UniqueArena<Type> ) -> Result<(), InvalidHandleError>
fn validate_constant_handle( handle: Handle<Constant>, constants: &Arena<Constant> ) -> Result<(), InvalidHandleError>
fn validate_expression_handle( handle: Handle<Expression>, expressions: &Arena<Expression> ) -> Result<(), InvalidHandleError>
fn validate_function_handle( handle: Handle<Function>, functions: &Arena<Function> ) -> Result<(), InvalidHandleError>
fn validate_const_expression_handles( (handle, expression): (Handle<Expression>, &Expression), constants: &Arena<Constant>, types: &UniqueArena<Type> ) -> Result<(), InvalidHandleError>
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>
fn validate_block_handles( block: &Block, expressions: &Arena<Expression>, functions: &Arena<Function> ) -> Result<(), InvalidHandleError>
source§impl Validator
impl Validator
pub(super) fn validate_global_var( &self, var: &GlobalVariable, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo ) -> Result<(), GlobalVariableError>
pub(super) fn validate_entry_point( &mut self, ep: &EntryPoint, module: &Module, mod_info: &ModuleInfo ) -> Result<FunctionInfo, WithSpan<EntryPointError>>
source§impl Validator
impl Validator
const fn require_type_capability( &self, capability: Capabilities ) -> Result<(), TypeError>
pub(super) const fn check_width( &self, kind: ScalarKind, width: Bytes ) -> Result<(), WidthError>
pub(super) fn reset_types(&mut self, size: usize)
pub(super) fn validate_type( &self, handle: Handle<Type>, gctx: GlobalCtx<'_> ) -> Result<TypeInfo, TypeError>
source§impl Validator
impl Validator
sourcepub fn new(flags: ValidationFlags, capabilities: Capabilities) -> Self
pub fn new(flags: ValidationFlags, capabilities: Capabilities) -> Self
Construct a new validator instance.
fn validate_constant( &self, handle: Handle<Constant>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo ) -> Result<(), ConstantError>
sourcepub fn validate(
&mut self,
module: &Module
) -> Result<ModuleInfo, WithSpan<ValidationError>>
pub fn validate( &mut self, module: &Module ) -> Result<ModuleInfo, WithSpan<ValidationError>>
Check the given module to be valid.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Validator
impl Send for Validator
impl Sync for Validator
impl Unpin for Validator
impl UnwindSafe for Validator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more