Skip to content

Commit

Permalink
Fix compound assignment storage_rw when resultType != storage(resultT…
Browse files Browse the repository at this point in the history
…ype) (gpuweb#3846)

In the storage_rw case, when the result type is not the same as
storage(result type) then generate the full expansion (stylistically):

     var ret = LHSType(LHS);
     ret {op}= RHSType(RHS);
     outputs.value = ret;

instead of:

     outputs.value = {storageType}(LHS);
     outputs.value {op}= ret;

This situation occurs when the value type is bool or bool-vec. In
that case the result type is u32, and there are no mixed overloads for &
and | such as:

   u32 & bool
   u32 | bool

Fixes: gpuweb#3845
  • Loading branch information
dneto0 authored Jul 8, 2024
1 parent 1f393f9 commit ef3d3c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/webgpu/shader/execution/expression/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ ${body}
// Runtime eval
//////////////////////////////////////////////////////////////////////////
let operation = '';
if (inputSource === 'storage_rw') {
if (inputSource === 'storage_rw' && objectEquals(resultType, storageType(resultType))) {
operation = `
outputs[i].value = ${storageType(resultType)}(inputs[i].lhs);
outputs[i].value ${op} ${rhsType}(inputs[i].rhs);`;
Expand Down

0 comments on commit ef3d3c1

Please sign in to comment.