-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wgsl: Implement AbstractInt comparison execution tests
Fixes #1627
- Loading branch information
Showing
5 changed files
with
144 additions
and
1 deletion.
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
Binary file not shown.
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
21 changes: 21 additions & 0 deletions
21
src/webgpu/shader/execution/expression/binary/ai_comparison.cache.ts
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,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])), | ||
}); |
115 changes: 115 additions & 0 deletions
115
src/webgpu/shader/execution/expression/binary/ai_comparison.spec.ts
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,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); | ||
}); |