mirror of
https://github.com/storytold/wgpu.git
synced 2026-12-01 10:34:57 +01:00
[spv] Fix OpImageQueries to allow Uints (#2404)
This commit is contained in:
1 parent
bac2d82a43
commit
5f8e4f6dea
5 files changed
+978
-1066
No files matched your search
+12
-77
@@ -1045,7 +1045,7 @@ impl<'w> BlockContext<'w> {
|
||||
};
|
||||
let extended_size_type_id = self.get_type_id(LookupType::Local(LocalType::Value {
|
||||
vector_size,
|
||||
kind: crate::ScalarKind::Sint,
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}));
|
||||
@@ -1077,24 +1077,7 @@ impl<'w> BlockContext<'w> {
|
||||
}
|
||||
block.body.push(inst);
|
||||
|
||||
let bitcast_type_id = self.get_type_id(
|
||||
LocalType::Value {
|
||||
vector_size,
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
let bitcast_id = self.gen_id();
|
||||
block.body.push(Instruction::unary(
|
||||
spirv::Op::Bitcast,
|
||||
bitcast_type_id,
|
||||
bitcast_id,
|
||||
id_extended,
|
||||
));
|
||||
|
||||
if result_type_id != bitcast_type_id {
|
||||
if result_type_id != extended_size_type_id {
|
||||
let id = self.gen_id();
|
||||
let components = match dim {
|
||||
// always pick the first component, and duplicate it for all 3 dimensions
|
||||
@@ -1104,42 +1087,26 @@ impl<'w> BlockContext<'w> {
|
||||
block.body.push(Instruction::vector_shuffle(
|
||||
result_type_id,
|
||||
id,
|
||||
bitcast_id,
|
||||
bitcast_id,
|
||||
id_extended,
|
||||
id_extended,
|
||||
components,
|
||||
));
|
||||
|
||||
id
|
||||
} else {
|
||||
bitcast_id
|
||||
id_extended
|
||||
}
|
||||
}
|
||||
Iq::NumLevels => {
|
||||
let query_id = self.gen_id();
|
||||
block.body.push(Instruction::image_query(
|
||||
spirv::Op::ImageQueryLevels,
|
||||
self.get_type_id(
|
||||
LocalType::Value {
|
||||
vector_size: None,
|
||||
kind: crate::ScalarKind::Sint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
result_type_id,
|
||||
query_id,
|
||||
image_id,
|
||||
));
|
||||
|
||||
let id = self.gen_id();
|
||||
block.body.push(Instruction::unary(
|
||||
spirv::Op::Bitcast,
|
||||
result_type_id,
|
||||
id,
|
||||
query_id,
|
||||
));
|
||||
|
||||
id
|
||||
query_id
|
||||
}
|
||||
Iq::NumLayers => {
|
||||
let vec_size = match dim {
|
||||
@@ -1149,7 +1116,7 @@ impl<'w> BlockContext<'w> {
|
||||
};
|
||||
let extended_size_type_id = self.get_type_id(LookupType::Local(LocalType::Value {
|
||||
vector_size: Some(vec_size),
|
||||
kind: crate::ScalarKind::Sint,
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}));
|
||||
@@ -1165,56 +1132,24 @@ impl<'w> BlockContext<'w> {
|
||||
|
||||
let extract_id = self.gen_id();
|
||||
block.body.push(Instruction::composite_extract(
|
||||
self.get_type_id(
|
||||
LocalType::Value {
|
||||
vector_size: None,
|
||||
kind: crate::ScalarKind::Sint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
result_type_id,
|
||||
extract_id,
|
||||
id_extended,
|
||||
&[vec_size as u32 - 1],
|
||||
));
|
||||
|
||||
let id = self.gen_id();
|
||||
block.body.push(Instruction::unary(
|
||||
spirv::Op::Bitcast,
|
||||
result_type_id,
|
||||
id,
|
||||
extract_id,
|
||||
));
|
||||
|
||||
id
|
||||
extract_id
|
||||
}
|
||||
Iq::NumSamples => {
|
||||
let query_id = self.gen_id();
|
||||
block.body.push(Instruction::image_query(
|
||||
spirv::Op::ImageQuerySamples,
|
||||
self.get_type_id(
|
||||
LocalType::Value {
|
||||
vector_size: None,
|
||||
kind: crate::ScalarKind::Sint,
|
||||
width: 4,
|
||||
pointer_space: None,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
result_type_id,
|
||||
query_id,
|
||||
image_id,
|
||||
));
|
||||
|
||||
let id = self.gen_id();
|
||||
block.body.push(Instruction::unary(
|
||||
spirv::Op::Bitcast,
|
||||
result_type_id,
|
||||
id,
|
||||
query_id,
|
||||
));
|
||||
|
||||
id
|
||||
query_id
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user