Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2f1f2aab9d91e6a1875d5d43fbc94e8e076dbe71
      
https://github.com/WebKit/WebKit/commit/2f1f2aab9d91e6a1875d5d43fbc94e8e076dbe71
  Author: Tadeu Zagallo <[email protected]>
  Date:   2024-07-08 (Mon, 08 Jul 2024)

  Changed paths:
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/tests/valid/packing.wgsl

  Log Message:
  -----------
  [WebGPU] https://compute.toys/view/1203 fails to load (works in Chrome)
https://bugs.webkit.org/show_bug.cgi?id=276229
rdar://131126958

Reviewed by Mike Wyrzykowski.

Originally, we had a problem with the left-hand side of compound assignments 
getting
unpacked, so we changed it so that the packing of the right-hand had to match 
the
packing of the left (instead of always unpacking it). That works for some cases,
but not for arrays of vec3, since that uses PackedVec3, which can't be used in
operations with packed_vec3. e.g. `array[0] += vec3f(0)` would have type 
PackedVec3
on the lhs and a packed_vec3 in the rhs, which are incompatible. In order to fix
that, both the lhs and rhs should always be unpacked. The unfortunate part about
that is that during code generation the expression gets rewritten into `lhs = 
lhs + rhs`,
which should become `lhs = pack(unpack(lhs) + unpack(rhs))`, but it is not 
trivial
to rewrite that with our current API. We work around that by generating
`unpack(lhs) += unpack(rhs)`, then during code generation we skip the `unpack`
call on the lhs, resulting in the final code `lhs += unpack(lhs) + unpack(rhs)`.
Notice that this is missing the `pack` call on the rhs, that works since the 
packed
type can be implicitly constructed from the unpacked type.

* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::visit):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/tests/valid/packing.wgsl:

Canonical link: https://commits.webkit.org/280731@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to