Skip to content

Commit 52043be

Browse files
authored
[spv-out] Fix invalid spirv being generated from integer dot products (#2291)
* Fix invalid spirv generation in int dotprod constants cannot be declared inside of a function block, so instead use `write_constant_null` to produce a correctly-declared constant 0. * autogenerated test snapshots
1 parent 53d62b9 commit 52043be

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/back/spv/block.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,7 @@ impl<'w> BlockContext<'w> {
16271627
size: u32,
16281628
block: &mut Block,
16291629
) {
1630-
let const_null = self.gen_id();
1631-
block
1632-
.body
1633-
.push(Instruction::constant_null(result_type_id, const_null));
1634-
1635-
let mut partial_sum = const_null;
1630+
let mut partial_sum = self.writer.write_constant_null(result_type_id);
16361631
let last_component = size - 1;
16371632
for index in 0..=last_component {
16381633
// compute the product of the current components

tests/out/spv/functions.spvasm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ OpExecutionMode %74 LocalSize 1 1 1
2323
%15 = OpTypeVector %7 4
2424
%18 = OpTypeFunction %12
2525
%26 = OpTypeFunction %7
26-
%75 = OpTypeFunction %2
2726
%31 = OpConstantNull %7
2827
%42 = OpConstantNull %9
2928
%57 = OpConstantNull %7
29+
%75 = OpTypeFunction %2
3030
%17 = OpFunction %12 None %18
3131
%16 = OpLabel
3232
OpBranch %19

tests/out/spv/math-functions.spvasm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ OpEntryPoint Vertex %18 "main"
2424
%19 = OpTypeFunction %2
2525
%27 = OpConstantComposite %14 %5 %5 %5 %5
2626
%28 = OpConstantComposite %14 %3 %3 %3 %3
27+
%31 = OpConstantNull %7
2728
%42 = OpConstant %9 32
2829
%50 = OpTypeVector %9 2
2930
%53 = OpConstantComposite %50 %42 %42
3031
%65 = OpConstant %7 31
3132
%71 = OpConstantComposite %15 %65 %65
32-
%31 = OpConstantNull %7
3333
%18 = OpFunction %2 None %19
3434
%17 = OpLabel
3535
OpBranch %20

0 commit comments

Comments
 (0)