Skip to content

Commit

Permalink
Refactor Value and Types
Browse files Browse the repository at this point in the history
Suffix all Value TS-types with 'Value'.
Put all Types in a 'Type' namespace.

This keeps naming consistent, closer to WGSL, and clears the way for Type.array.
  • Loading branch information
ben-clayton committed Mar 7, 2024
1 parent ac1af68 commit b9fda01
Show file tree
Hide file tree
Showing 187 changed files with 1,628 additions and 1,993 deletions.
216 changes: 108 additions & 108 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "cfc28768",
"webgpu/shader/execution/binary/af_logical.bin": "ae9b9ba0",
"webgpu/shader/execution/binary/af_division.bin": "30839274",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "e43d31a5",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "fbec81c8",
"webgpu/shader/execution/binary/af_multiplication.bin": "19681c0c",
"webgpu/shader/execution/binary/af_remainder.bin": "fb9c916",
"webgpu/shader/execution/binary/af_subtraction.bin": "6f448b72",
"webgpu/shader/execution/binary/f16_addition.bin": "83ac7e89",
"webgpu/shader/execution/binary/f16_logical.bin": "6c9cdfe8",
"webgpu/shader/execution/binary/f16_division.bin": "487729fe",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "54aa39b",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "3a4159f8",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "fceaaf1f",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "92151406",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "d920f7ec",
"webgpu/shader/execution/binary/f16_multiplication.bin": "fc8c2a0f",
"webgpu/shader/execution/binary/f16_remainder.bin": "6e60c5d0",
"webgpu/shader/execution/binary/f16_subtraction.bin": "4277226e",
"webgpu/shader/execution/binary/f32_addition.bin": "5b9c4270",
"webgpu/shader/execution/binary/f32_logical.bin": "32188047",
"webgpu/shader/execution/binary/f32_division.bin": "22edca65",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "62107e07",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "9e5677c9",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "d69476cb",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "c429b29b",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "ded0240e",
"webgpu/shader/execution/binary/f32_multiplication.bin": "f088c036",
"webgpu/shader/execution/binary/f32_remainder.bin": "dcb44e72",
"webgpu/shader/execution/binary/f32_subtraction.bin": "dab334aa",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "2b48d275",
"webgpu/shader/execution/binary/i32_comparison.bin": "f2c3cd37",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "7ec7b66",
"webgpu/shader/execution/binary/u32_comparison.bin": "50ab2f61",
"webgpu/shader/execution/abs.bin": "e37fc25a",
"webgpu/shader/execution/acos.bin": "4dc16324",
"webgpu/shader/execution/acosh.bin": "1f999f3c",
"webgpu/shader/execution/asin.bin": "a653cf5b",
"webgpu/shader/execution/asinh.bin": "515e83f7",
"webgpu/shader/execution/atan.bin": "95006a05",
"webgpu/shader/execution/atan2.bin": "3cc4efac",
"webgpu/shader/execution/atanh.bin": "e2985906",
"webgpu/shader/execution/bitcast.bin": "bda67f6d",
"webgpu/shader/execution/ceil.bin": "5d285a4",
"webgpu/shader/execution/clamp.bin": "cd0271cf",
"webgpu/shader/execution/cos.bin": "dfd7be1f",
"webgpu/shader/execution/cosh.bin": "8a9b86a5",
"webgpu/shader/execution/cross.bin": "80fe94ce",
"webgpu/shader/execution/degrees.bin": "d9a6c350",
"webgpu/shader/execution/determinant.bin": "2e19c9bd",
"webgpu/shader/execution/distance.bin": "64daad1a",
"webgpu/shader/execution/dot.bin": "c78ce327",
"webgpu/shader/execution/exp.bin": "c1b5a4fd",
"webgpu/shader/execution/exp2.bin": "63ac077",
"webgpu/shader/execution/faceForward.bin": "92b334a6",
"webgpu/shader/execution/floor.bin": "7e1bf2c3",
"webgpu/shader/execution/fma.bin": "701a86c6",
"webgpu/shader/execution/fract.bin": "c29aadce",
"webgpu/shader/execution/frexp.bin": "5ae6ca4",
"webgpu/shader/execution/inverseSqrt.bin": "9563f18d",
"webgpu/shader/execution/ldexp.bin": "f005b4b5",
"webgpu/shader/execution/length.bin": "ee8e5573",
"webgpu/shader/execution/log.bin": "29c4187b",
"webgpu/shader/execution/log2.bin": "9ce20393",
"webgpu/shader/execution/max.bin": "7516dbff",
"webgpu/shader/execution/min.bin": "75e9d526",
"webgpu/shader/execution/mix.bin": "b224306a",
"webgpu/shader/execution/modf.bin": "ba63df78",
"webgpu/shader/execution/normalize.bin": "9842b756",
"webgpu/shader/execution/pack2x16float.bin": "5dee8700",
"webgpu/shader/execution/pow.bin": "81bac0a9",
"webgpu/shader/execution/quantizeToF16.bin": "6973d05d",
"webgpu/shader/execution/radians.bin": "128a0639",
"webgpu/shader/execution/reflect.bin": "5de2177e",
"webgpu/shader/execution/refract.bin": "de1e1ade",
"webgpu/shader/execution/round.bin": "70a9da36",
"webgpu/shader/execution/saturate.bin": "e8daa151",
"webgpu/shader/execution/sign.bin": "503847e9",
"webgpu/shader/execution/sin.bin": "51df6447",
"webgpu/shader/execution/sinh.bin": "dbc469f3",
"webgpu/shader/execution/smoothstep.bin": "16cdfbe9",
"webgpu/shader/execution/sqrt.bin": "b59d4606",
"webgpu/shader/execution/step.bin": "5df4b04b",
"webgpu/shader/execution/tan.bin": "f1535f0c",
"webgpu/shader/execution/tanh.bin": "6e653c6d",
"webgpu/shader/execution/transpose.bin": "41ff2823",
"webgpu/shader/execution/trunc.bin": "7c3baf7",
"webgpu/shader/execution/unpack2x16float.bin": "f994910",
"webgpu/shader/execution/unpack2x16snorm.bin": "df36ee6f",
"webgpu/shader/execution/unpack2x16unorm.bin": "ac195462",
"webgpu/shader/execution/unpack4x8snorm.bin": "39a4743a",
"webgpu/shader/execution/unpack4x8unorm.bin": "ecae6fe5",
"webgpu/shader/execution/unary/af_arithmetic.bin": "9800df7f",
"webgpu/shader/execution/unary/af_assignment.bin": "85c4d516",
"webgpu/shader/execution/unary/bool_conversion.bin": "85664e85",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "3e0dea1",
"webgpu/shader/execution/unary/f16_conversion.bin": "c1f37dd1",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "f2cd5bd2",
"webgpu/shader/execution/unary/f32_conversion.bin": "b4174de",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "b327298b",
"webgpu/shader/execution/unary/i32_conversion.bin": "ebdc408a",
"webgpu/shader/execution/unary/u32_conversion.bin": "aafe3d79",
"webgpu/shader/execution/unary/ai_assignment.bin": "ef0b469b",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "b22511b9",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "67c3d3b6",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "b72f2c53",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "7f328797",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "b34a4a2b"
"webgpu/shader/execution/binary/af_addition.bin": "45a00f48",
"webgpu/shader/execution/binary/af_logical.bin": "458eba4",
"webgpu/shader/execution/binary/af_division.bin": "ed6916d6",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "ddeaa1d3",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "bdc18f23",
"webgpu/shader/execution/binary/af_multiplication.bin": "e6e11b40",
"webgpu/shader/execution/binary/af_remainder.bin": "61849bd4",
"webgpu/shader/execution/binary/af_subtraction.bin": "6afd0c9a",
"webgpu/shader/execution/binary/f16_addition.bin": "118a69b1",
"webgpu/shader/execution/binary/f16_logical.bin": "53cbe093",
"webgpu/shader/execution/binary/f16_division.bin": "6cf5db74",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "37b3e5b1",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "f9f9c546",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "10c32980",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "4a992ee0",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "3969786a",
"webgpu/shader/execution/binary/f16_multiplication.bin": "27375c0a",
"webgpu/shader/execution/binary/f16_remainder.bin": "1e5d8fc7",
"webgpu/shader/execution/binary/f16_subtraction.bin": "daffd0ed",
"webgpu/shader/execution/binary/f32_addition.bin": "384766d0",
"webgpu/shader/execution/binary/f32_logical.bin": "d4f9fd6a",
"webgpu/shader/execution/binary/f32_division.bin": "760f650f",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "504aac15",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "740e31c4",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "3c5abc3c",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "c41fee39",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "43bfea5a",
"webgpu/shader/execution/binary/f32_multiplication.bin": "d6b990a9",
"webgpu/shader/execution/binary/f32_remainder.bin": "53f7d8e9",
"webgpu/shader/execution/binary/f32_subtraction.bin": "f644082",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "8ce49cc7",
"webgpu/shader/execution/binary/i32_comparison.bin": "ac0e960f",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "68560dc0",
"webgpu/shader/execution/binary/u32_comparison.bin": "ec9ec4c6",
"webgpu/shader/execution/abs.bin": "d7043582",
"webgpu/shader/execution/acos.bin": "a7a01d03",
"webgpu/shader/execution/acosh.bin": "3bfd9ebc",
"webgpu/shader/execution/asin.bin": "f91850f1",
"webgpu/shader/execution/asinh.bin": "19169ea3",
"webgpu/shader/execution/atan.bin": "51a04ddb",
"webgpu/shader/execution/atan2.bin": "e732e242",
"webgpu/shader/execution/atanh.bin": "4763b613",
"webgpu/shader/execution/bitcast.bin": "195c00a7",
"webgpu/shader/execution/ceil.bin": "9856b786",
"webgpu/shader/execution/clamp.bin": "5a700a65",
"webgpu/shader/execution/cos.bin": "ff14c921",
"webgpu/shader/execution/cosh.bin": "21c587ad",
"webgpu/shader/execution/cross.bin": "c159771f",
"webgpu/shader/execution/degrees.bin": "b0de92be",
"webgpu/shader/execution/determinant.bin": "83d642d4",
"webgpu/shader/execution/distance.bin": "e65d0cb7",
"webgpu/shader/execution/dot.bin": "dc57a00c",
"webgpu/shader/execution/exp.bin": "f0c6b19",
"webgpu/shader/execution/exp2.bin": "5d3dd4e0",
"webgpu/shader/execution/faceForward.bin": "3979a4de",
"webgpu/shader/execution/floor.bin": "3fecf76d",
"webgpu/shader/execution/fma.bin": "e7fe86b8",
"webgpu/shader/execution/fract.bin": "71caa066",
"webgpu/shader/execution/frexp.bin": "ed72dcec",
"webgpu/shader/execution/inverseSqrt.bin": "383e6e9c",
"webgpu/shader/execution/ldexp.bin": "bedfc1d5",
"webgpu/shader/execution/length.bin": "38e35ab4",
"webgpu/shader/execution/log.bin": "2517404c",
"webgpu/shader/execution/log2.bin": "a833136",
"webgpu/shader/execution/max.bin": "8c2f7c51",
"webgpu/shader/execution/min.bin": "7f732adb",
"webgpu/shader/execution/mix.bin": "982c982c",
"webgpu/shader/execution/modf.bin": "743632fc",
"webgpu/shader/execution/normalize.bin": "52adf424",
"webgpu/shader/execution/pack2x16float.bin": "2c879955",
"webgpu/shader/execution/pow.bin": "ba686c94",
"webgpu/shader/execution/quantizeToF16.bin": "e704252d",
"webgpu/shader/execution/radians.bin": "afe57c6e",
"webgpu/shader/execution/reflect.bin": "332e001e",
"webgpu/shader/execution/refract.bin": "246f6c0b",
"webgpu/shader/execution/round.bin": "e555383f",
"webgpu/shader/execution/saturate.bin": "9dce4047",
"webgpu/shader/execution/sign.bin": "3ef39d2e",
"webgpu/shader/execution/sin.bin": "8546b36c",
"webgpu/shader/execution/sinh.bin": "72ae8d37",
"webgpu/shader/execution/smoothstep.bin": "79eca0b6",
"webgpu/shader/execution/sqrt.bin": "ac8f95e9",
"webgpu/shader/execution/step.bin": "34ce6432",
"webgpu/shader/execution/tan.bin": "928e0e2f",
"webgpu/shader/execution/tanh.bin": "be078de7",
"webgpu/shader/execution/transpose.bin": "2ce22a5b",
"webgpu/shader/execution/trunc.bin": "26115486",
"webgpu/shader/execution/unpack2x16float.bin": "d052cda6",
"webgpu/shader/execution/unpack2x16snorm.bin": "a3ab8e29",
"webgpu/shader/execution/unpack2x16unorm.bin": "f42b9498",
"webgpu/shader/execution/unpack4x8snorm.bin": "5c90b367",
"webgpu/shader/execution/unpack4x8unorm.bin": "ef24abbe",
"webgpu/shader/execution/unary/af_arithmetic.bin": "28b510fa",
"webgpu/shader/execution/unary/af_assignment.bin": "4f4d507a",
"webgpu/shader/execution/unary/bool_conversion.bin": "5cbbd5e2",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "55ff626f",
"webgpu/shader/execution/unary/f16_conversion.bin": "e16712e2",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "672609de",
"webgpu/shader/execution/unary/f32_conversion.bin": "daa3ffb8",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "eecbb027",
"webgpu/shader/execution/unary/i32_conversion.bin": "c3f19a9",
"webgpu/shader/execution/unary/u32_conversion.bin": "b58b1876",
"webgpu/shader/execution/unary/ai_assignment.bin": "326020c6",
"webgpu/shader/execution/binary/ai_arithmetic.bin": "40123e00",
"webgpu/shader/execution/unary/ai_arithmetic.bin": "37ffc69",
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "35e08b61",
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "6f31c22f",
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "7b17ec2a"
}
14 changes: 7 additions & 7 deletions src/unittests/conversion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ import {
i32,
kFloat16Format,
kFloat32Format,
Matrix,
MatrixValue,
numbersApproximatelyEqual,
pack2x16float,
pack2x16snorm,
pack2x16unorm,
pack4x8snorm,
pack4x8unorm,
packRGB9E5UFloat,
Scalar,
ScalarValue,
toMatrix,
u32,
unpackRGB9E5UFloat,
vec2,
vec3,
vec4,
Vector,
VectorValue,
} from '../webgpu/util/conversion.js';

import { UnitTest } from './unit_test.js';
Expand Down Expand Up @@ -191,7 +191,7 @@ g.test('floatBitsToULPFromZero,32').fn(t => {
});

g.test('scalarWGSL').fn(t => {
const cases: Array<[Scalar, string]> = [
const cases: Array<[ScalarValue, string]> = [
[f32(0.0), '0.0f'],
// The number -0.0 can be remapped to 0.0 when stored in a Scalar
// object. It is not possible to guarantee that '-0.0f' will
Expand Down Expand Up @@ -227,7 +227,7 @@ expect: ${expect}`
});

g.test('vectorWGSL').fn(t => {
const cases: Array<[Vector, string]> = [
const cases: Array<[VectorValue, string]> = [
[vec2(f32(42.0), f32(24.0)), 'vec2(42.0f, 24.0f)'],
[vec2(f16Bits(0x5140), f16Bits(0x4e00)), 'vec2(42.0h, 24.0h)'],
[vec2(u32(42), u32(24)), 'vec2(42u, 24u)'],
Expand Down Expand Up @@ -261,7 +261,7 @@ expect: ${expect}`
});

g.test('matrixWGSL').fn(t => {
const cases: Array<[Matrix, string]> = [
const cases: Array<[MatrixValue, string]> = [
[
toMatrix(
[
Expand Down Expand Up @@ -391,7 +391,7 @@ g.test('constructorMatrix')
return [...Array(rows).keys()].map(r => scalar_builder(c * cols + r));
});

const got = new Matrix(elements);
const got = new MatrixValue(elements);
const got_type = got.type;
t.expect(
got_type.cols === cols,
Expand Down
12 changes: 6 additions & 6 deletions src/webgpu/api/operation/render_pipeline/sample_mask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { assert, range } from '../../../../common/util/util.js';
import { GPUTest, TextureTestMixin } from '../../../gpu_test.js';
import { checkElementsPassPredicate, checkElementsEqual } from '../../../util/check_contents.js';
import { TypeF32, TypeU32 } from '../../../util/conversion.js';
import { Type } from '../../../util/conversion.js';
import { TexelView } from '../../../util/texture/texel_view.js';

const kColors = [
Expand Down Expand Up @@ -438,7 +438,7 @@ class F extends TextureTestMixin(GPUTest) {
fragmentShaderOutputMask: number
) {
const buffer = this.copy2DTextureToBufferUsingComputePass(
TypeF32, // correspond to 'rgba8unorm' format
Type.f32, // correspond to 'rgba8unorm' format
4,
texture.createView(),
sampleCount
Expand All @@ -464,7 +464,7 @@ class F extends TextureTestMixin(GPUTest) {
const buffer = this.copy2DTextureToBufferUsingComputePass(
// Use f32 as the scalar type for depth (depth24plus, depth32float)
// Use u32 as the scalar type for stencil (stencil8)
aspect === 'depth-only' ? TypeF32 : TypeU32,
aspect === 'depth-only' ? Type.f32 : Type.u32,
1,
depthStencilTexture.createView({ aspect }),
sampleCount
Expand Down Expand Up @@ -705,7 +705,7 @@ color' <= color.
);

const colorBuffer = t.copy2DTextureToBufferUsingComputePass(
TypeF32, // correspond to 'rgba8unorm' format
Type.f32, // correspond to 'rgba8unorm' format
4,
color.createView(),
sampleCount
Expand All @@ -717,7 +717,7 @@ color' <= color.
colorResultPromises.push(colorResult);

const depthBuffer = t.copy2DTextureToBufferUsingComputePass(
TypeF32, // correspond to 'depth24plus-stencil8' format
Type.f32, // correspond to 'depth24plus-stencil8' format
1,
depthStencil.createView({ aspect: 'depth-only' }),
sampleCount
Expand All @@ -729,7 +729,7 @@ color' <= color.
depthResultPromises.push(depthResult);

const stencilBuffer = t.copy2DTextureToBufferUsingComputePass(
TypeU32, // correspond to 'depth24plus-stencil8' format
Type.u32, // correspond to 'depth24plus-stencil8' format
1,
depthStencil.createView({ aspect: 'stencil-only' }),
sampleCount
Expand Down
20 changes: 10 additions & 10 deletions src/webgpu/shader/execution/expression/binary/af_addition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export const description = `
Execution Tests for non-matrix AbstractFloat addition expression
Execution Tests for non-matrix abstract-float addition expression
`;

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

import { d } from './af_addition.cache.js';
Expand All @@ -26,8 +26,8 @@ Accuracy: Correctly rounded
await run(
t,
abstractFloatBinary('+'),
[TypeAbstractFloat, TypeAbstractFloat],
TypeAbstractFloat,
[Type.abstractFloat, Type.abstractFloat],
Type.abstractFloat,
t.params,
cases
);
Expand All @@ -49,8 +49,8 @@ Accuracy: Correctly rounded
await run(
t,
abstractFloatBinary('+'),
[TypeAbstractFloat, TypeAbstractFloat],
TypeAbstractFloat,
[Type.abstractFloat, Type.abstractFloat],
Type.abstractFloat,
t.params,
cases
);
Expand All @@ -71,8 +71,8 @@ Accuracy: Correctly rounded
await run(
t,
abstractFloatBinary('+'),
[TypeVec(dim, TypeAbstractFloat), TypeAbstractFloat],
TypeVec(dim, TypeAbstractFloat),
[Type.vec(dim, Type.abstractFloat), Type.abstractFloat],
Type.vec(dim, Type.abstractFloat),
t.params,
cases
);
Expand All @@ -93,8 +93,8 @@ Accuracy: Correctly rounded
await run(
t,
abstractFloatBinary('+'),
[TypeAbstractFloat, TypeVec(dim, TypeAbstractFloat)],
TypeVec(dim, TypeAbstractFloat),
[Type.abstractFloat, Type.vec(dim, Type.abstractFloat)],
Type.vec(dim, Type.abstractFloat),
t.params,
cases
);
Expand Down
Loading

0 comments on commit b9fda01

Please sign in to comment.