diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index 5cca979a570a..6a6c9271518f 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -103,5 +103,6 @@ "webgpu/shader/execution/unary/u32_conversion.bin": "579a043f", "webgpu/shader/execution/unary/ai_assignment.bin": "954223ff", "webgpu/shader/execution/binary/ai_arithmetic.bin": "6c440be0", - "webgpu/shader/execution/unary/ai_arithmetic.bin": "e89e9e9" + "webgpu/shader/execution/unary/ai_arithmetic.bin": "e89e9e9", + "webgpu/shader/execution/binary/ai_comparison.bin": "6d1aa87b" } \ No newline at end of file diff --git a/src/resources/cache/webgpu/shader/execution/binary/ai_comparison.bin b/src/resources/cache/webgpu/shader/execution/binary/ai_comparison.bin new file mode 100644 index 000000000000..76d149f05566 Binary files /dev/null and b/src/resources/cache/webgpu/shader/execution/binary/ai_comparison.bin differ diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 72b9bfdb09e7..64f974a294b5 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -898,6 +898,27 @@ "webgpu:idl,constructable:gpu_errors:*": { "subcaseMS": 0.101 }, "webgpu:idl,constructable:pipeline_errors:*": { "subcaseMS": 0.101 }, "webgpu:idl,constructable:uncaptured_error_event:*": { "subcaseMS": 0.101 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:addition:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:addition_scalar_vector:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:addition_vector_scalar:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:division:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:division_scalar_vector:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:division_vector_scalar:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication_scalar_vector:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:remainder:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:remainder_scalar_vector:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:remainder_vector_scalar:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:multiplication_vector_scalar:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_scalar_vector:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_arithmetic:subtraction_vector_scalar:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:equals:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:greater_equals:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:greater_than:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:less_equals:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:less_than:*": { "subcaseMS": 0 }, + "webgpu:shader,execution,expression,binary,ai_comparison:not_equals:*": { "subcaseMS": 0 }, "webgpu:shader,execution,expression,binary,af_addition:scalar:*": { "subcaseMS": 815.300 }, "webgpu:shader,execution,expression,binary,af_addition:scalar_vector:*": { "subcaseMS": 1803.434 }, "webgpu:shader,execution,expression,binary,af_addition:vector:*": { "subcaseMS": 719.600 }, diff --git a/src/webgpu/shader/execution/expression/binary/ai_comparison.cache.ts b/src/webgpu/shader/execution/expression/binary/ai_comparison.cache.ts new file mode 100644 index 000000000000..75d9f7ea4b32 --- /dev/null +++ b/src/webgpu/shader/execution/expression/binary/ai_comparison.cache.ts @@ -0,0 +1,21 @@ +import { abstractInt, bool } from '../../../../util/conversion.js'; +import { vectorI64Range } from '../../../../util/math.js'; +import { Case } from '../case.js'; +import { makeCaseCache } from '../case_cache.js'; + +/** + * @returns a test case for the provided left hand & right hand values and + * expected boolean result. + */ +function makeCase(lhs: bigint, rhs: bigint, expected_answer: boolean): Case { + return { input: [abstractInt(lhs), abstractInt(rhs)], expected: bool(expected_answer) }; +} + +export const d = makeCaseCache('binary/ai_comparison', { + equals: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] === v[1])), + not_equals: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] !== v[1])), + less_than: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] < v[1])), + less_equal: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] <= v[1])), + greater_than: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] > v[1])), + greater_equal: () => vectorI64Range(2).map(v => makeCase(v[0], v[1], v[0] >= v[1])), +}); diff --git a/src/webgpu/shader/execution/expression/binary/ai_comparison.spec.ts b/src/webgpu/shader/execution/expression/binary/ai_comparison.spec.ts new file mode 100644 index 000000000000..0f996b4df912 --- /dev/null +++ b/src/webgpu/shader/execution/expression/binary/ai_comparison.spec.ts @@ -0,0 +1,115 @@ +export const description = ` +Execution Tests for the abstract int comparison expressions +`; + +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; +import { GPUTest } from '../../../../gpu_test.js'; +import { TypeBool, TypeAbstractInt } from '../../../../util/conversion.js'; +import { onlyConstInputSource, run } from '../expression.js'; + +import { d } from './ai_comparison.cache.js'; +import { binary } from './binary.js'; + +export const g = makeTestGroup(GPUTest); + +g.test('equals') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x == y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('equals'); + await run(t, binary('=='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + }); + +g.test('not_equals') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x != y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('not_equals'); + await run(t, binary('!='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + }); + +g.test('less_than') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x < y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('less_than'); + await run(t, binary('<'), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + }); + +g.test('less_equals') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x <= y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('less_equal'); + await run(t, binary('<='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + }); + +g.test('greater_than') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x > y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('greater_than'); + await run(t, binary('>'), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + }); + +g.test('greater_equals') + .specURL('https://www.w3.org/TR/WGSL/#comparison-expr') + .desc( + ` +Expression: x >= y +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('greater_equal'); + await run(t, binary('>='), [TypeAbstractInt, TypeAbstractInt], TypeBool, t.params, cases); + });