Skip to content

Commit

Permalink
[WGSL] Fix wgslc tests
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269238
rdar://122829420

Reviewed by Mike Wyrzykowski.

Some of the tests contained invalid code that started failing with validations
recently added. One was failing due to an unnecessary unpack call with arrays
of vec3, which can be implicitly converted.

* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::pack):
* Source/WebGPU/WGSL/tests/invalid/const-assert.wgsl:
* Source/WebGPU/WGSL/tests/valid/global-used-by-callee.wgsl:
* Source/WebGPU/WGSL/tests/valid/overload.wgsl:

Canonical link: https://commits.webkit.org/274538@main
  • Loading branch information
tadeuzagallo committed Feb 13, 2024
1 parent cd2168b commit a11d9bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ Packing RewriteGlobalVariables::pack(Packing expectedPacking, AST::Expression& e
if (std::holds_alternative<Types::Struct>(*type))
operation = packing & Packing::Packed ? "__unpack"_s : "__pack"_s;
else if (std::holds_alternative<Types::Array>(*type)) {
// array of vec3 can be implicitly converted
if (packing & Packing::Vec3)
return expectedPacking;
if (packing & Packing::Packed) {
operation = "__unpack"_s;
m_callGraph.ast().setUsesUnpackArray();
Expand Down
4 changes: 2 additions & 2 deletions Source/WebGPU/WGSL/tests/invalid/const-assert.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const_assert(x > y);

var<private> z = 3;

// CHECK-L: const assertion requires a const-expression
// CHECK-L: cannot use runtime value in constant expression
const_assert(x > z);

fn f()
Expand Down Expand Up @@ -57,7 +57,7 @@ fn f()

let z = 3;

// CHECK-L: const assertion requires a const-expression
// CHECK-L: cannot use runtime value in constant expression
const_assert(x > z);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebGPU/WGSL/tests/valid/global-used-by-callee.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn main()
// CHECK: function\d\(\)
_ = g();

// CHECK: function\d\(global\d, global\d\)
// CHECK: function\d\(global\d, \(\d+\)\)
_ = h();

// CHECK: function\d\(global\d\)
Expand Down
10 changes: 5 additions & 5 deletions Source/WebGPU/WGSL/tests/valid/overload.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -4148,11 +4148,11 @@ fn testDerivativeFunctions()
@group(0) @binding(21) var ts3d: texture_storage_3d<rgba32float, write>;
@group(0) @binding(22) var te: texture_external;

var td2d: texture_depth_2d;
var td2da: texture_depth_2d_array;
var tdc: texture_depth_cube;
var tdca: texture_depth_cube_array;
var tdms2d: texture_depth_multisampled_2d;
@group(0) @binding(23) var td2d: texture_depth_2d;
@group(0) @binding(24) var td2da: texture_depth_2d_array;
@group(0) @binding(25) var tdc: texture_depth_cube;
@group(0) @binding(26) var tdca: texture_depth_cube_array;
@group(0) @binding(27) var tdms2d: texture_depth_multisampled_2d;

// 16.7.1
// RUN: %metal-compile testTextureDimensions
Expand Down

0 comments on commit a11d9bd

Please sign in to comment.