Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
[spv-out] Fix invalid spirv being generated from integer dot products (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
PyryM authored Mar 30, 2023
1 parent 53d62b9 commit 52043be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/back/spv/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/out/spv/functions.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/out/spv/math-functions.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52043be

Please sign in to comment.