mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-23 16:01:04 +01:00
Ray query expressions and special types
This commit is contained in:
1 parent
e46c53d212
commit
b856625821
25 files changed
+388
-46
No files matched your search
+11
-9
@@ -686,7 +686,7 @@ impl FunctionInfo {
|
||||
requirements: UniformityRequirements::empty(),
|
||||
},
|
||||
E::CallResult(function) => other_functions[function.index()].uniformity.clone(),
|
||||
E::AtomicResult { .. } => Uniformity {
|
||||
E::AtomicResult { .. } | E::RayQueryProceedResult => Uniformity {
|
||||
non_uniform_result: Some(handle),
|
||||
requirements: UniformityRequirements::empty(),
|
||||
},
|
||||
@@ -694,6 +694,13 @@ impl FunctionInfo {
|
||||
non_uniform_result: self.add_ref_impl(expr, GlobalUse::QUERY),
|
||||
requirements: UniformityRequirements::empty(),
|
||||
},
|
||||
E::RayQueryGetIntersection {
|
||||
query,
|
||||
committed: _,
|
||||
} => Uniformity {
|
||||
non_uniform_result: self.add_ref(query),
|
||||
requirements: UniformityRequirements::empty(),
|
||||
},
|
||||
};
|
||||
|
||||
let ty = resolve_context.resolve(expression, |h| Ok(&self[h].ty))?;
|
||||
@@ -934,14 +941,8 @@ impl ModuleInfo {
|
||||
expressions: vec![ExpressionInfo::new(); fun.expressions.len()].into_boxed_slice(),
|
||||
sampling: crate::FastHashSet::default(),
|
||||
};
|
||||
let resolve_context = ResolveContext {
|
||||
constants: &module.constants,
|
||||
types: &module.types,
|
||||
global_vars: &module.global_variables,
|
||||
local_vars: &fun.local_variables,
|
||||
functions: &module.functions,
|
||||
arguments: &fun.arguments,
|
||||
};
|
||||
let resolve_context =
|
||||
ResolveContext::with_locals(module, &fun.local_variables, &fun.arguments);
|
||||
|
||||
for (handle, expr) in fun.expressions.iter() {
|
||||
if let Err(source) = info.process_expression(
|
||||
@@ -1064,6 +1065,7 @@ fn uniform_control_flow() {
|
||||
let resolve_context = ResolveContext {
|
||||
constants: &constant_arena,
|
||||
types: &type_arena,
|
||||
special_types: &crate::SpecialTypes::default(),
|
||||
global_vars: &global_var_arena,
|
||||
local_vars: &Arena::new(),
|
||||
functions: &Arena::new(),
|
||||
|
||||
@@ -1427,6 +1427,7 @@ impl super::Validator {
|
||||
return Err(ExpressionError::InvalidArrayType(expr));
|
||||
}
|
||||
},
|
||||
E::RayQueryProceedResult | E::RayQueryGetIntersection { .. } => ShaderStages::all(),
|
||||
};
|
||||
Ok(stages)
|
||||
}
|
||||
|
||||
+15
-1
@@ -39,6 +39,7 @@ impl super::Validator {
|
||||
ref functions,
|
||||
ref global_variables,
|
||||
ref types,
|
||||
ref special_types,
|
||||
} = module;
|
||||
|
||||
// NOTE: Types being first is important. All other forms of validation depend on this.
|
||||
@@ -194,6 +195,13 @@ impl super::Validator {
|
||||
validate_function(Some(function_handle), function)?;
|
||||
}
|
||||
|
||||
if let Some(ty) = special_types.ray_desc {
|
||||
validate_type(ty)?;
|
||||
}
|
||||
if let Some(ty) = special_types.ray_intersection {
|
||||
validate_type(ty)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -379,10 +387,16 @@ impl super::Validator {
|
||||
handle.check_dep(function)?;
|
||||
}
|
||||
}
|
||||
crate::Expression::AtomicResult { .. } => (),
|
||||
crate::Expression::AtomicResult { .. } | crate::Expression::RayQueryProceedResult => (),
|
||||
crate::Expression::ArrayLength(array) => {
|
||||
handle.check_dep(array)?;
|
||||
}
|
||||
crate::Expression::RayQueryGetIntersection {
|
||||
query,
|
||||
committed: _,
|
||||
} => {
|
||||
handle.check_dep(query)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -440,7 +440,9 @@ impl super::Validator {
|
||||
match types[var.ty].inner {
|
||||
crate::TypeInner::Image { .. }
|
||||
| crate::TypeInner::Sampler { .. }
|
||||
| crate::TypeInner::BindingArray { .. } => {}
|
||||
| crate::TypeInner::BindingArray { .. }
|
||||
| crate::TypeInner::AccelerationStructure
|
||||
| crate::TypeInner::RayQuery => {}
|
||||
_ => {
|
||||
return Err(GlobalVariableError::InvalidType(var.space));
|
||||
}
|
||||
|
||||
+5
-1
@@ -622,10 +622,14 @@ impl super::Validator {
|
||||
Ti::Image { .. } | Ti::Sampler { .. } => {
|
||||
TypeInfo::new(TypeFlags::ARGUMENT, Alignment::ONE)
|
||||
}
|
||||
Ti::AccelerationStructure | Ti::RayQuery => {
|
||||
Ti::AccelerationStructure => {
|
||||
self.require_type_capability(Capabilities::RAY_QUERY)?;
|
||||
TypeInfo::new(TypeFlags::empty(), Alignment::ONE)
|
||||
}
|
||||
Ti::RayQuery => {
|
||||
self.require_type_capability(Capabilities::RAY_QUERY)?;
|
||||
TypeInfo::new(TypeFlags::DATA | TypeFlags::SIZED, Alignment::ONE)
|
||||
}
|
||||
Ti::BindingArray { .. } => TypeInfo::new(TypeFlags::empty(), Alignment::ONE),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user