[webkit-changes] [WebKit/WebKit] f19946: [WGSL] Vector constants are incorrect

Tadeu Zagallo noreply at github.com
Wed Sep 27 02:37:38 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f19946127d6320625b638893878aad89de7af7e1
      https://github.com/WebKit/WebKit/commit/f19946127d6320625b638893878aad89de7af7e1
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-09-27 (Wed, 27 Sep 2023)

  Changed paths:
    M Source/WebGPU/WGSL/ConstantFunctions.h
    M Source/WebGPU/WGSL/ConstantRewriter.cpp
    M Source/WebGPU/WGSL/ConstantValue.h
    M Source/WebGPU/WGSL/tests/valid/global-constant-vector.wgsl

  Log Message:
  -----------
  [WGSL] Vector constants are incorrect
https://bugs.webkit.org/show_bug.cgi?id=262125
rdar://116063871

Reviewed by Mike Wyrzykowski.

The current implementation the constant vector constructor only works for the case
where the vector is constructor from N simple types (e.g. vec3(0,0)), but it doesn't
work when the constructor has to clone a single value (e.g. vec3(0)) or when the
constructor takes other vectors as an argument (e.g. vec3(vec2(0), 0) or vec3(vec3(0))).

This patch implements the constructor correctly, handling all of these cases. In order to
do, it also introduces the correct "zero values" for all types, according to the spec[1].

It also simplifies ConstantValue by removing the type from it, which wasn't necessary
and complicated the creation of values.

[1]: https://www.w3.org/TR/WGSL/#zero-value-builtin-function

* Source/WebGPU/WGSL/ConstantFunctions.h:
(WGSL::constantPow):
(WGSL::zeroValue):
(WGSL::constantVector):
(WGSL::constantVector2):
(WGSL::constantVector3):
(WGSL::constantVector4):
* Source/WebGPU/WGSL/ConstantRewriter.cpp:
(WGSL::ConstantRewriter::ConstantRewriter):
(WGSL::ConstantRewriter::visit):
(WGSL::ConstantRewriter::evaluate):
(WGSL::ConstantRewriter::materialize):
* Source/WebGPU/WGSL/ConstantValue.h:
(WGSL::ConstantValue::toBool const):
(WGSL::ConstantValue::toInt const):
(WGSL::ConstantValue::toDouble const):
(WGSL::ConstantValue::ConstantValue): Deleted.
(WGSL::ConstantValue::constructDeletedValue): Deleted.
(WGSL::ConstantValue::isDeletedValue): Deleted.
* Source/WebGPU/WGSL/tests/valid/global-constant-vector.wgsl:

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




More information about the webkit-changes mailing list