mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
[naga spv-out] Introduce Writer::get_resolution_pointer_id
.
Introduce a new helper function,
`naga:🔙:spv::Writer::get_resolution_pointer_id`. Use it in
`BlockContext::write_expression_pointer`.
This commit is contained in:
parent
0f17ad6455
commit
436ffba77a
@ -1721,14 +1721,9 @@ impl<'w> BlockContext<'w> {
|
||||
let resolution = &self.fun_info[expr_handle].ty;
|
||||
match type_adjustment {
|
||||
AccessTypeAdjustment::None => self.writer.get_expression_type_id(resolution),
|
||||
AccessTypeAdjustment::IntroducePointer(class) => match *resolution {
|
||||
TypeResolution::Handle(handle) => self.writer.get_pointer_id(handle, class),
|
||||
TypeResolution::Value(_) => {
|
||||
unreachable!(
|
||||
"IntroducePointer should only be used with images and samplers"
|
||||
);
|
||||
}
|
||||
},
|
||||
AccessTypeAdjustment::IntroducePointer(class) => {
|
||||
self.writer.get_resolution_pointer_id(resolution, class)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -274,6 +274,24 @@ impl Writer {
|
||||
}))
|
||||
}
|
||||
|
||||
/// Return a SPIR-V type for a pointer to `resolution`.
|
||||
///
|
||||
/// The given `resolution` must be one that we can represent
|
||||
/// either as a `LocalType::Pointer` or `LocalType::LocalPointer`.
|
||||
pub(super) fn get_resolution_pointer_id(
|
||||
&mut self,
|
||||
resolution: &TypeResolution,
|
||||
class: spirv::StorageClass,
|
||||
) -> Word {
|
||||
match *resolution {
|
||||
TypeResolution::Handle(handle) => self.get_pointer_id(handle, class),
|
||||
TypeResolution::Value(ref inner) => {
|
||||
let base = NumericType::from_inner(inner).unwrap();
|
||||
self.get_type_id(LookupType::Local(LocalType::LocalPointer { base, class }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn get_uint_type_id(&mut self) -> Word {
|
||||
let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar::U32));
|
||||
self.get_type_id(local_type.into())
|
||||
|
Loading…
Reference in New Issue
Block a user