-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WGSL] Add support for constant matrices
https://bugs.webkit.org/show_bug.cgi?id=263555 rdar://117371722 Reviewed by Mike Wyrzykowski. Implement ConstantMatrix as one of the variants in ConstantValue and implement all the constant functions that depend on it. * Source/WebGPU/WGSL/ConstantFunctions.h: (WGSL::zeroValue): (WGSL::constantMatrix): (WGSL::constantAdd): (WGSL::constantMultiply): (WGSL::constantDeterminant): (WGSL::constantTranspose): * Source/WebGPU/WGSL/ConstantValue.cpp: (WGSL::ConstantValue::dump const): * Source/WebGPU/WGSL/ConstantValue.h: (WGSL::ConstantMatrix::ConstantMatrix): (WGSL::ConstantValue::isMatrix const): (WGSL::ConstantValue::toVector const): * Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp: (WGSL::Metal::FunctionDefinitionWriter::serializeConstant): * Source/WebGPU/WGSL/tests/valid/constant-matrix.wgsl: Added. Canonical link: https://commits.webkit.org/269741@main
- Loading branch information
1 parent
29dde14
commit d041f3c
Showing
5 changed files
with
268 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// RUN: %metal-compile main | ||
// RUN: %metal main 2>&1 | %check | ||
|
||
|
||
@compute @workgroup_size(1) | ||
fn main() | ||
{ | ||
// CHECK-L: 8680 | ||
let x = determinant(mat4x4( | ||
15,2,34,4, | ||
18,2,3,4, | ||
1,72,32,4, | ||
17,2,3,4, | ||
)); | ||
|
||
// CHECK-L: 8680 | ||
let y = determinant(mat4x4( | ||
vec4(15,2,34,4), | ||
vec4(18,2,3,4), | ||
vec4(1,72,32,4), | ||
vec4(17,2,3,4), | ||
)); | ||
|
||
const m2 = mat2x2( | ||
1,2, | ||
3,4, | ||
); | ||
|
||
// CHECK-L: 1., 3., 2., 4. | ||
let tm2 = transpose(m2); | ||
|
||
// CHECK-L: 1., 4., 7., 2., 5., 8., 3., 6., 9. | ||
let tm3 = transpose(mat3x3( | ||
1,2,3, | ||
4,5,6, | ||
7,8,9, | ||
)); | ||
|
||
// CHECK-L: 2., 4., 6., 8. | ||
let x0 = m2 * 2; | ||
|
||
const m2x3 = mat2x3( | ||
1,2,3, | ||
4,5,6 | ||
); | ||
|
||
// CHECK-L: 1., 4., 2., 5., 3., 6. | ||
let x1 = transpose(m2x3); | ||
|
||
// CHECK-L: 10., 14., 18. | ||
let x2 = m2x3 * vec2(2); | ||
|
||
// CHECK-L: 12., 30. | ||
let x3 = vec3(2) * m2x3; | ||
|
||
// CHECK-L: 32 | ||
let x4 = dot(vec3(1,2,3), vec3(4,5,6)); | ||
|
||
// CHECK-L: 95., 128., 68., 92., 41., 56., 14., 20. | ||
let x5 = mat3x2(1,2,3,4,5,6) * mat4x3(12,11,10,9,8,7,6,5,4,3,2,1); | ||
} |