mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-out] deduplicate image types
This commit is contained in:
committed by
Dzmitry Malyshau
parent
1cc770a7d8
commit
7ec90512a8
@@ -123,8 +123,13 @@ enum LocalType {
|
||||
base: Handle<crate::Type>,
|
||||
class: spirv::StorageClass,
|
||||
},
|
||||
Image {
|
||||
dim: crate::ImageDimension,
|
||||
arrayed: bool,
|
||||
class: crate::ImageClass,
|
||||
},
|
||||
SampledImage {
|
||||
image_type: Handle<crate::Type>,
|
||||
image_type_id: Word,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -167,6 +172,15 @@ impl PhysicalLayout {
|
||||
width,
|
||||
pointer_class: Some(map_storage_class(class)),
|
||||
},
|
||||
crate::TypeInner::Image {
|
||||
dim,
|
||||
arrayed,
|
||||
class,
|
||||
} => LocalType::Image {
|
||||
dim,
|
||||
arrayed,
|
||||
class,
|
||||
},
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -763,8 +777,9 @@ impl Writer {
|
||||
)?;
|
||||
Instruction::type_pointer(id, class, type_id)
|
||||
}
|
||||
LocalType::SampledImage { image_type } => {
|
||||
let image_type_id = self.get_type_id(arena, LookupType::Handle(image_type))?;
|
||||
// all the image types go through `write_type_declaration_arena`
|
||||
LocalType::Image { .. } => unreachable!(),
|
||||
LocalType::SampledImage { image_type_id } => {
|
||||
Instruction::type_sampled_image(id, image_type_id)
|
||||
}
|
||||
};
|
||||
@@ -1951,9 +1966,11 @@ impl Writer {
|
||||
};
|
||||
|
||||
// OpTypeSampledImage
|
||||
let image_type_id =
|
||||
self.get_type_id(&ir_module.types, LookupType::Handle(image_type))?;
|
||||
let sampled_image_type_id = self.get_type_id(
|
||||
&ir_module.types,
|
||||
LookupType::Local(LocalType::SampledImage { image_type }),
|
||||
LookupType::Local(LocalType::SampledImage { image_type_id }),
|
||||
)?;
|
||||
|
||||
let sampler_id = self.get_expression_global(ir_function, sampler);
|
||||
|
||||
Reference in New Issue
Block a user