Skip to content

Commit 09cfffd

Browse files
committed
asm vector: fix float packing
1 parent 254f92c commit 09cfffd

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

crates/spirv-std/src/float.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ pub fn f16x2_to_vec2<V: Vector<f32, 2>>(int: u32) -> V {
4949
unsafe {
5050
asm!(
5151
"%glsl = OpExtInstImport \"GLSL.std.450\"",
52-
"%float = OpTypeFloat 32",
53-
"%vec2 = OpTypeVector %float 2",
5452
// 62 = UnpackHalf2x16
55-
"%result = OpExtInst %vec2 %glsl 62 {int}",
53+
"%result = OpExtInst typeof*{result} %glsl 62 {int}",
5654
"OpStore {result} %result",
5755
int = in(reg) int,
5856
result = in(reg) &mut result,
@@ -164,10 +162,8 @@ pub fn u8x4_to_vec4_snorm<V: Vector<f32, 4>>(int: u32) -> V {
164162
unsafe {
165163
asm!(
166164
"%glsl = OpExtInstImport \"GLSL.std.450\"",
167-
"%float = OpTypeFloat 32",
168-
"%vec4 = OpTypeVector %float 4",
169165
// 63 = UnpackSnorm4x8
170-
"%result = OpExtInst %vec4 %glsl 63 {int}",
166+
"%result = OpExtInst typeof*{result} %glsl 63 {int}",
171167
"OpStore {result} %result",
172168
int = in(reg) int,
173169
result = in(reg) &mut result,
@@ -185,10 +181,8 @@ pub fn u8x4_to_vec4_unorm<V: Vector<f32, 4>>(int: u32) -> V {
185181
unsafe {
186182
asm!(
187183
"%glsl = OpExtInstImport \"GLSL.std.450\"",
188-
"%float = OpTypeFloat 32",
189-
"%vec4 = OpTypeVector %float 4",
190184
// 64 = UnpackUnorm4x8
191-
"%result = OpExtInst %vec4 %glsl 64 {int}",
185+
"%result = OpExtInst typeof*{result} %glsl 64 {int}",
192186
"OpStore {result} %result",
193187
int = in(reg) int,
194188
result = in(reg) &mut result,
@@ -206,10 +200,8 @@ pub fn u16x2_to_vec2_snorm<V: Vector<f32, 2>>(int: u32) -> V {
206200
unsafe {
207201
asm!(
208202
"%glsl = OpExtInstImport \"GLSL.std.450\"",
209-
"%float = OpTypeFloat 32",
210-
"%vec2 = OpTypeVector %float 2",
211203
// 60 = UnpackSnorm2x16
212-
"%result = OpExtInst %vec2 %glsl 60 {int}",
204+
"%result = OpExtInst typeof*{result} %glsl 60 {int}",
213205
"OpStore {result} %result",
214206
int = in(reg) int,
215207
result = in(reg) &mut result,
@@ -227,10 +219,8 @@ pub fn u16x2_to_vec2_unorm<V: Vector<f32, 2>>(int: u32) -> V {
227219
unsafe {
228220
asm!(
229221
"%glsl = OpExtInstImport \"GLSL.std.450\"",
230-
"%float = OpTypeFloat 32",
231-
"%vec2 = OpTypeVector %float 2",
232222
// 61 = UnpackUnorm2x16
233-
"%result = OpExtInst %vec2 %glsl 61 {int}",
223+
"%result = OpExtInst typeof*{result} %glsl 61 {int}",
234224
"OpStore {result} %result",
235225
int = in(reg) int,
236226
result = in(reg) &mut result,

0 commit comments

Comments
 (0)