Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor shader/execution/expression/binary/* #4213

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix abstract-float addition expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_addition.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for the abstract-float comparison operations
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { allInputSources, run } from '../expression.js';

import { d } from './af_comparison.cache.js';
import { binary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('equals')
.specURL('https://www.w3.org/TR/WGSL/#comparison-expr')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix abstract-float division expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_division.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for matrix abstract-float addition expressions
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_matrix_addition.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('matrix')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for matrix-matrix AbstractFloat multiplication expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_matrix_matrix_multiplication.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('matrix_matrix')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for matrix-scalar and scalar-matrix AbstractFloat multiplication
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_matrix_scalar_multiplication.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('matrix_scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for matrix abstract-float subtraction expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_matrix_subtraction.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('matrix')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for matrix-vector and vector-matrix AbstractFloat multiplication
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_matrix_vector_multiplication.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('matrix_vector')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix abstract-float multiplication expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_multiplication.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix abstract float remainder expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_remainder.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix abstract-float subtraction expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './af_subtraction.cache.js';
import { abstractFloatBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for the abstract int arithmetic binary expression operations
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { onlyConstInputSource, run } from '../expression.js';

import { d } from './ai_arithmetic.cache.js';
import { abstractIntBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('addition')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Execution Tests for the abstract-int comparison expressions
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { bool, abstractInt, Type } from '../../../../util/conversion.js';
import { vectorI64Range } from '../../../../util/math.js';
import { Case } from '../case.js';
import { onlyConstInputSource, run } from '../expression.js';

import { binary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

/**
* @returns a test case for the provided left hand & right hand values and
Expand Down
4 changes: 2 additions & 2 deletions src/webgpu/shader/execution/expression/binary/bitwise.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Execution Tests for the bitwise binary expression operations

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { assert } from '../../../../../common/util/util.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import {
abstractIntBits,
i32Bits,
Expand All @@ -16,7 +16,7 @@ import { allInputSources, onlyConstInputSource, run } from '../expression.js';

import { abstractIntBinary, binary, compoundBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

/**
* Collection of functions and values required to implement bitwise tests for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Execution Tests for the bitwise shift binary expression operations

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { assert } from '../../../../../common/util/util.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { ScalarBuilder, ScalarValue, Type, abstractInt, u32 } from '../../../../util/conversion.js';
import { Case } from '../case.js';
import { allInputSources, onlyConstInputSource, run } from '../expression.js';

import { abstractIntBinary, binary, compoundBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

// Returns true if e1 << e2 is valid for const evaluation
function isValidConstShiftLeft(e1: ScalarValue, e2: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Execution Tests for the boolean binary logical expression operations
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { bool, Type } from '../../../../util/conversion.js';
import { allInputSources, run } from '../expression.js';

import { binary, compoundBinary } from './binary.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

// Short circuiting vs no short circuiting is not tested here, it is covered in
// src/webgpu/shader/execution/evaluation_order.spec.ts
Expand Down
28 changes: 8 additions & 20 deletions src/webgpu/shader/execution/expression/binary/f16_addition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Execution Tests for non-matrix f16 addition expression
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
import { Type } from '../../../../util/conversion.js';
import { allInputSources, run } from '../expression.js';

import { binary, compoundBinary } from './binary.js';
import { d } from './f16_addition.cache.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
Expand All @@ -21,10 +21,8 @@ Accuracy: Correctly rounded
`
)
.params(u => u.combine('inputSource', allInputSources))
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const'
);
Expand All @@ -40,10 +38,8 @@ Accuracy: Correctly rounded
`
)
.params(u => u.combine('inputSource', allInputSources).combine('vectorize', [2, 3, 4] as const))
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const' // Using vectorize to generate vector cases based on scalar cases
);
Expand All @@ -61,10 +57,8 @@ Accuracy: Correctly rounded
.params(u =>
u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const)
)
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const'
);
Expand All @@ -80,10 +74,8 @@ Accuracy: Correctly rounded
`
)
.params(u => u.combine('inputSource', allInputSources).combine('dim', [2, 3, 4] as const))
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const dim = t.params.dim;
const cases = await d.get(
t.params.inputSource === 'const' ? `vec${dim}_scalar_const` : `vec${dim}_scalar_non_const`
Expand All @@ -107,10 +99,8 @@ Accuracy: Correctly rounded
`
)
.params(u => u.combine('inputSource', allInputSources).combine('dim', [2, 3, 4] as const))
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const dim = t.params.dim;
const cases = await d.get(
t.params.inputSource === 'const' ? `vec${dim}_scalar_const` : `vec${dim}_scalar_non_const`
Expand All @@ -134,10 +124,8 @@ Accuracy: Correctly rounded
`
)
.params(u => u.combine('inputSource', allInputSources).combine('dim', [2, 3, 4] as const))
.beforeAllSubcases(t => {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
})
.fn(async t => {
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
const dim = t.params.dim;
const cases = await d.get(
t.params.inputSource === 'const' ? `scalar_vec${dim}_const` : `scalar_vec${dim}_non_const`
Expand Down
Loading