[naga spv-out] Gather array, matrix, and vector cases.

This commit is just code motion.
This commit is contained in:
Jim Blandy 2024-10-08 15:02:13 -07:00
parent f9075fc4b8
commit 57b8858f96

View File

@ -344,11 +344,36 @@ impl<'w> BlockContext<'w> {
crate::TypeInner::Vector { .. } => { crate::TypeInner::Vector { .. } => {
self.write_vector_access(expr_handle, base, index, block)? self.write_vector_access(expr_handle, base, index, block)?
} }
// Only binding arrays in the `Handle` address space will take this crate::TypeInner::Array {
// path, since we handled the `Pointer` case above. base: ty_element, ..
} => {
let index_id = self.cached[index];
let base_id = self.cached[base];
let base_ty = match self.fun_info[base].ty {
TypeResolution::Handle(handle) => handle,
TypeResolution::Value(_) => {
return Err(Error::Validation(
"Array types should always be in the arena",
))
}
};
let (id, variable) = self.writer.promote_access_expression_to_variable(
result_type_id,
base_id,
base_ty,
index_id,
ty_element,
block,
)?;
self.function.internal_variables.push(variable);
id
}
// wgpu#4337: Support `crate::TypeInner::Matrix`
crate::TypeInner::BindingArray { crate::TypeInner::BindingArray {
base: binding_type, .. base: binding_type, ..
} => { } => {
// Only binding arrays in the `Handle` address space will take
// this path, since we handled the `Pointer` case above.
let result_id = match self.write_expression_pointer( let result_id = match self.write_expression_pointer(
expr_handle, expr_handle,
block, block,
@ -384,31 +409,6 @@ impl<'w> BlockContext<'w> {
load_id load_id
} }
crate::TypeInner::Array {
base: ty_element, ..
} => {
let index_id = self.cached[index];
let base_id = self.cached[base];
let base_ty = match self.fun_info[base].ty {
TypeResolution::Handle(handle) => handle,
TypeResolution::Value(_) => {
return Err(Error::Validation(
"Array types should always be in the arena",
))
}
};
let (id, variable) = self.writer.promote_access_expression_to_variable(
result_type_id,
base_id,
base_ty,
index_id,
ty_element,
block,
)?;
self.function.internal_variables.push(variable);
id
}
// wgpu#4337: Support `crate::TypeInner::Matrix`
ref other => { ref other => {
log::error!( log::error!(
"Unable to access base {:?} of type {:?}", "Unable to access base {:?} of type {:?}",
@ -449,10 +449,11 @@ impl<'w> BlockContext<'w> {
)); ));
id id
} }
// Only binding arrays in the Handle address space will take this path (due to `is_intermediate`)
crate::TypeInner::BindingArray { crate::TypeInner::BindingArray {
base: binding_type, .. base: binding_type, ..
} => { } => {
// Only binding arrays in the `Handle` address space will take
// this path, since we handled the `Pointer` case above.
let result_id = match self.write_expression_pointer( let result_id = match self.write_expression_pointer(
expr_handle, expr_handle,
block, block,