diff --git a/naga/src/valid/mod.rs b/naga/src/valid/mod.rs index 6b4b514c6..fe45d3bfb 100644 --- a/naga/src/valid/mod.rs +++ b/naga/src/valid/mod.rs @@ -459,7 +459,19 @@ impl crate::TypeInner { } impl Validator { - /// Construct a new validator instance. + /// Create a validator for Naga [`Module`]s. + /// + /// The `flags` argument indicates which stages of validation the + /// returned `Validator` should perform. Skipping stages can make + /// validation somewhat faster, but the validator may not reject some + /// invalid modules. Regardless of `flags`, validation always returns + /// a usable [`ModuleInfo`] value on success. + /// + /// If `flags` contains everything in `ValidationFlags::default()`, + /// then the returned Naga [`Validator`] will reject any [`Module`] + /// that would use capabilities not included in `capabilities`. + /// + /// [`Module`]: crate::Module pub fn new(flags: ValidationFlags, capabilities: Capabilities) -> Self { let subgroup_operations = if capabilities.contains(Capabilities::SUBGROUP) { use SubgroupOperationSet as S; diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index a57714900..0780e7ccf 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -383,7 +383,19 @@ impl WebGpuError for MissingDownlevelFlags { } } -/// Create a validator with the given validation flags. +/// Create a validator for Naga [`Module`]s. +/// +/// Create a Naga [`Validator`] that ensures that each [`naga::Module`] +/// presented to it is valid, and uses no features not included in +/// `features` and `downlevel`. +/// +/// The validator can only catch invalid modules and feature misuse +/// reliably when the `flags` argument includes all the flags in +/// [`ValidationFlags::default()`]. +/// +/// [`Validator`]: naga::valid::Validator +/// [`Module`]: naga::Module +/// [`ValidationFlags::default()`]: naga::valid::ValidationFlags::default pub fn create_validator( features: wgt::Features, downlevel: wgt::DownlevelFlags,