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:
CallResult
expressions must be visited by aCall
statement.AtomicResult
expressions must be visited by anAtomic
statement.
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
impl Validator
pub(super) fn validate_const_expression( &self, handle: Handle<Expression>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), ConstExpressionError>
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>
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: Option<Handle<Expression>>, span: Span, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>
fn validate_subgroup_operation( &mut self, op: &SubgroupOperation, collective_op: &CollectiveOperation, argument: Handle<Expression>, result: Handle<Expression>, context: &BlockContext<'_>, ) -> Result<(), WithSpan<FunctionError>>
fn validate_subgroup_gather( &mut self, mode: &GatherMode, argument: 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, local_expr_kind: &ExpressionKindTracker, ) -> Result<(), LocalVariableError>
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
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_override_handle( handle: Handle<Override>, overrides: &Arena<Override>, ) -> 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>, overrides: &Arena<Override>, types: &UniqueArena<Type>, ) -> Result<(), InvalidHandleError>
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>
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, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), GlobalVariableError>
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
impl Validator
const fn require_type_capability( &self, capability: Capabilities, ) -> Result<(), TypeError>
pub(super) const fn check_width(&self, scalar: Scalar) -> 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.
pub fn subgroup_stages(&mut self, stages: ShaderStages) -> &mut Self
pub fn subgroup_operations( &mut self, operations: SubgroupOperationSet, ) -> &mut Self
fn validate_constant( &self, handle: Handle<Constant>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, global_expr_kind: &ExpressionKindTracker, ) -> Result<(), ConstantError>
fn validate_override( &mut self, handle: Handle<Override>, gctx: GlobalCtx<'_>, mod_info: &ModuleInfo, ) -> Result<(), OverrideError>
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.
sourcepub fn validate_no_overrides(
&mut self,
module: &Module,
) -> Result<ModuleInfo, WithSpan<ValidationError>>
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.