[webkit-changes] [WebKit/WebKit] a70e52: [WGSL] Modulo of floats should use fmod

Tadeu Zagallo noreply at github.com
Fri Apr 21 06:49:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a70e521f46a53876070d542bf4ef188bfbe1f096
      https://github.com/WebKit/WebKit/commit/a70e521f46a53876070d542bf4ef188bfbe1f096
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-04-21 (Fri, 21 Apr 2023)

  Changed paths:
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp

  Log Message:
  -----------
  [WGSL] Modulo of floats should use fmod
https://bugs.webkit.org/show_bug.cgi?id=255725
rdar://108317779

Reviewed by Mike Wyrzykowski.

Right now, we just serialize all operators 1:1 to metal. That's not always correct,
and one such example is for modulo of floats. WGSL supports using the modulo operator
(i.e. `x % y`) for any kinds of numbers, or between vectors of numbers. That is not
allowed in Metal, and we must use `fmod(x, y)` for floats. During serialization we
use the inferred type to verify we are operating on floats an emit fmod instead of
the binary operator.

* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):

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




More information about the webkit-changes mailing list