[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
This commit is contained in:
PyryM
2023-03-30 10:02:54 -04:00
committed by GitHub
parent 53d62b9ede
commit 52043be004
3 changed files with 3 additions and 8 deletions

View File

@@ -1627,12 +1627,7 @@ impl<'w> BlockContext<'w> {
size: u32,
block: &mut Block,
) {
let const_null = self.gen_id();
block
.body
.push(Instruction::constant_null(result_type_id, const_null));
let mut partial_sum = const_null;
let mut partial_sum = self.writer.write_constant_null(result_type_id);
let last_component = size - 1;
for index in 0..=last_component {
// compute the product of the current components

View File

@@ -23,10 +23,10 @@ OpExecutionMode %74 LocalSize 1 1 1
%15 = OpTypeVector %7 4
%18 = OpTypeFunction %12
%26 = OpTypeFunction %7
%75 = OpTypeFunction %2
%31 = OpConstantNull %7
%42 = OpConstantNull %9
%57 = OpConstantNull %7
%75 = OpTypeFunction %2
%17 = OpFunction %12 None %18
%16 = OpLabel
OpBranch %19

View File

@@ -24,12 +24,12 @@ OpEntryPoint Vertex %18 "main"
%19 = OpTypeFunction %2
%27 = OpConstantComposite %14 %5 %5 %5 %5
%28 = OpConstantComposite %14 %3 %3 %3 %3
%31 = OpConstantNull %7
%42 = OpConstant %9 32
%50 = OpTypeVector %9 2
%53 = OpConstantComposite %50 %42 %42
%65 = OpConstant %7 31
%71 = OpConstantComposite %15 %65 %65
%31 = OpConstantNull %7
%18 = OpFunction %2 None %19
%17 = OpLabel
OpBranch %20