[webkit-changes] [WebKit/WebKit] 3a7160: [WGSL] Implement comparison operator overload and ...

Dan Glastonbury noreply at github.com
Wed Apr 12 22:10:26 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3a71603352dcd72cfd85c308e4bea671cff8c56a
      https://github.com/WebKit/WebKit/commit/3a71603352dcd72cfd85c308e4bea671cff8c56a
  Author: Dan Glastonbury <djg at apple.com>
  Date:   2023-04-12 (Wed, 12 Apr 2023)

  Changed paths:
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/Overload.cpp
    M Source/WebGPU/WGSL/Overload.h
    M Source/WebGPU/WGSL/TypeDeclarations.rb
    M Source/WebGPU/WGSL/generator/main.rb
    M Source/WebGPU/WGSL/tests/valid/overload.wgsl

  Log Message:
  -----------
  [WGSL] Implement comparison operator overload and codegen
https://bugs.webkit.org/show_bug.cgi?id=255321
rdar://107923257

Reviewed by Tadeu Zagallo.

Implement comparison operator overload and codegen for WGSL.

This change was complicated by needing to teach the overload matching generator
to handle `vecN<bool>`. Adding a constraint type `Boolean` with one valid type
`Bool` didn't work when using `Vector[S < Boolean, N]` as the return type of an
operator.

To accept `Vector[Bool, N]` aka `vecN<bool>`, A new type `AbstractScalarType` is
introduced that can hold a concrete type or a type variable. `materialize`,
`calculateRank` and `unify` are updated to handle `AbstractType`,
`AbstractScalarType`, and `AbstractValue`. The "hack" in the generator that
selects between `ParameterizedAbstractType` or `Constructor` is extended to
selected `ParameterizedAbstractType` when any argument is a `Variable` to be
able to handle a vector of a concrete type but with a variable number of
elements.

For completeness, `AbstractMatrix` element was also updated.

* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/Overload.cpp:
(WGSL::OverloadResolver::materialize const):
(WGSL::OverloadResolver::calculateRank):
(WGSL::OverloadResolver::unify):
(WTF::printInternal):
* Source/WebGPU/WGSL/Overload.h:
* Source/WebGPU/WGSL/TypeDeclarations.rb:
* Source/WebGPU/WGSL/generator/main.rb:
* Source/WebGPU/WGSL/tests/valid/overload.wgsl:

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




More information about the webkit-changes mailing list