Validate image queries and valid shader stages for derivatives

This commit is contained in:
Dzmitry Malyshau authored and Dzmitry Malyshau committed 2021-03-24 12:32:32 -04:00
1 parent ee43776c08
commit 7a246f6a14
8 files changed
+127 -29

No files matched your search

+13 -1
View File
@@ -1,6 +1,6 @@
use super::{
analyzer::{FunctionInfo, GlobalUse},
Disalignment, FunctionError, ModuleInfo, TypeFlags,
Disalignment, FunctionError, ModuleInfo, ShaderStages, TypeFlags,
};
use crate::arena::{Arena, Handle};
@@ -56,6 +56,8 @@ pub enum EntryPointError {
UnexpectedWorkgroupSize,
#[error("Workgroup size is out of range")]
OutOfRangeWorkgroupSize,
#[error("Uses operations forbidden at this stage")]
ForbiddenStageOperations,
#[error("Global variable {0:?} is used incorrectly as {1:?}")]
InvalidGlobalUsage(Handle<crate::GlobalVariable>, GlobalUse),
#[error("Bindings for {0:?} conflict with other resource")]
@@ -370,8 +372,18 @@ impl super::Validator {
return Err(EntryPointError::UnexpectedWorkgroupSize);
}
let stage_bit = match ep.stage {
crate::ShaderStage::Vertex => ShaderStages::VERTEX,
crate::ShaderStage::Fragment => ShaderStages::FRAGMENT,
crate::ShaderStage::Compute => ShaderStages::COMPUTE,
};
let info = self.validate_function(&ep.function, module, &mod_info)?;
if !info.available_stages.contains(stage_bit) {
return Err(EntryPointError::ForbiddenStageOperations);
}
self.location_mask.clear();
for (index, fa) in ep.function.arguments.iter().enumerate() {
let ctx = VaryingContext {