diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js')
-rw-r--r-- | testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js new file mode 100644 index 0000000000..acfa6715e7 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/unary/logical_negation.spec.js @@ -0,0 +1,114 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/export const description = ` +Validation tests for logical negation expressions. +`;import { makeTestGroup } from '../../../../../common/framework/test_group.js'; +import { keysOf, objectsToRecord } from '../../../../../common/util/data_tables.js'; +import { kAllScalarsAndVectors, scalarTypeOf, Type } from '../../../../util/conversion.js'; +import { ShaderValidationTest } from '../../shader_validation_test.js'; + +export const g = makeTestGroup(ShaderValidationTest); + +// A list of scalar and vector types. +const kScalarAndVectorTypes = objectsToRecord(kAllScalarsAndVectors); + +g.test('scalar_vector'). +desc( + ` + Validates that scalar and vector logical negation expressions are only accepted for bool types. + ` +). +params((u) => u.combine('type', keysOf(kScalarAndVectorTypes)).beginSubcases()). +beforeAllSubcases((t) => { + if (scalarTypeOf(kScalarAndVectorTypes[t.params.type]) === Type.f16) { + t.selectDeviceOrSkipTestCase('shader-f16'); + } +}). +fn((t) => { + const type = kScalarAndVectorTypes[t.params.type]; + const elementTy = scalarTypeOf(type); + const hasF16 = elementTy === Type.f16; + const code = ` +${hasF16 ? 'enable f16;' : ''} +const rhs = ${type.create(0).wgsl()}; +const foo = !rhs; +`; + + t.expectCompileResult(elementTy === Type.bool, code); +}); + + + + + + + +const kInvalidTypes = { + mat2x2f: { + expr: 'm', + control: (e) => `bool(${e}[0][0])` + }, + + array: { + expr: 'arr', + control: (e) => `${e}[0]` + }, + + ptr: { + expr: '(&b)', + control: (e) => `*${e}` + }, + + atomic: { + expr: 'a', + control: (e) => `bool(atomicLoad(&${e}))` + }, + + texture: { + expr: 't', + control: (e) => `bool(textureLoad(${e}, vec2(), 0).x)` + }, + + sampler: { + expr: 's', + control: (e) => `bool(textureSampleLevel(t, ${e}, vec2(), 0).x)` + }, + + struct: { + expr: 'str', + control: (e) => `${e}.b` + } +}; + +g.test('invalid_types'). +desc( + ` + Validates that logical negation expressions are never accepted for non-scalar and non-vector types. + ` +). +params((u) => +u.combine('type', keysOf(kInvalidTypes)).combine('control', [true, false]).beginSubcases() +). +fn((t) => { + const type = kInvalidTypes[t.params.type]; + const expr = t.params.control ? type.control(type.expr) : type.expr; + const code = ` +@group(0) @binding(0) var t : texture_2d<f32>; +@group(0) @binding(1) var s : sampler; +@group(0) @binding(2) var<storage, read_write> a : atomic<i32>; + +struct S { b : bool } + +var<private> b : bool; +var<private> m : mat2x2f; +var<private> arr : array<bool, 4>; +var<private> str : S; + +@compute @workgroup_size(1) +fn main() { + let foo = !${expr}; +} +`; + + t.expectCompileResult(t.params.control, code); +});
\ No newline at end of file |