Gather operations

This commit is contained in:
Dzmitry Malyshau committed 2021-12-18 11:46:49 -05:00
1 parent db98743a5a
commit 8caa2bd87e
24 files changed
+484 -41

No files matched your search

+1
View File
@@ -462,6 +462,7 @@ impl FunctionInfo {
E::ImageSample {
image,
sampler,
gather: _,
coordinate,
array_index,
offset: _,
+27
View File
@@ -99,6 +99,12 @@ pub enum ExpressionError {
InvalidDepthReference(Handle<crate::Expression>),
#[error("Depth sample level can only be Auto or Zero")]
InvalidDepthSampleLevel,
#[error("Gather level can only be Zero")]
InvalidGatherLevel,
#[error("Gather component {0:?} doesn't exist in the image")]
InvalidGatherComponent(crate::SwizzleComponent),
#[error("Gather can't be done for image dimension {0:?}")]
InvalidGatherDimension(crate::ImageDimension),
#[error("Sample level (exact) type {0:?} is not a scalar float")]
InvalidSampleLevelExactType(Handle<crate::Expression>),
#[error("Sample level (bias) type {0:?} is not a scalar float")]
@@ -343,6 +349,7 @@ impl super::Validator {
E::ImageSample {
image,
sampler,
gather,
coordinate,
array_index,
offset,
@@ -466,6 +473,26 @@ impl super::Validator {
}
}
if let Some(component) = gather {
match dim {
crate::ImageDimension::D2 | crate::ImageDimension::Cube => {}
crate::ImageDimension::D1 | crate::ImageDimension::D3 => {
return Err(ExpressionError::InvalidGatherDimension(dim))
}
};
let max_component = match class {
crate::ImageClass::Depth { .. } => crate::SwizzleComponent::X,
_ => crate::SwizzleComponent::W,
};
if component > max_component {
return Err(ExpressionError::InvalidGatherComponent(component));
}
match level {
crate::SampleLevel::Zero => {}
_ => return Err(ExpressionError::InvalidGatherLevel),
}
}
// check level properties
match level {
crate::SampleLevel::Auto => ShaderStages::FRAGMENT,