diff --git a/src/common/util/util.ts b/src/common/util/util.ts index e78c6d0c9b74..5421a2c08732 100644 --- a/src/common/util/util.ts +++ b/src/common/util/util.ts @@ -305,6 +305,7 @@ const TypedArrayBufferViewInstances = [ new Float32Array(), new Float64Array(), new BigInt64Array(), + new BigUint64Array(), ] as const; export type TypedArrayBufferView = (typeof TypedArrayBufferViewInstances)[number]; diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index fc5366067c59..81fa9b8adee8 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -1,109 +1,109 @@ { - "webgpu/shader/execution/binary/af_addition.bin": "4e31655d", - "webgpu/shader/execution/binary/af_logical.bin": "4fe85d71", - "webgpu/shader/execution/binary/af_division.bin": "8e82cb20", - "webgpu/shader/execution/binary/af_matrix_addition.bin": "82627a09", - "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "bff83051", - "webgpu/shader/execution/binary/af_multiplication.bin": "3ba1eb48", - "webgpu/shader/execution/binary/af_remainder.bin": "79c9a829", - "webgpu/shader/execution/binary/af_subtraction.bin": "4402c270", - "webgpu/shader/execution/binary/f16_addition.bin": "59872ddb", - "webgpu/shader/execution/binary/f16_logical.bin": "1d96f8bd", - "webgpu/shader/execution/binary/f16_division.bin": "ef052170", - "webgpu/shader/execution/binary/f16_matrix_addition.bin": "4d4f162b", - "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "7b59c338", - "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "3af8b0d9", - "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "a8e2c3a3", - "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "8114b72f", - "webgpu/shader/execution/binary/f16_multiplication.bin": "8f10e570", - "webgpu/shader/execution/binary/f16_remainder.bin": "fb21d47f", - "webgpu/shader/execution/binary/f16_subtraction.bin": "a29850e2", - "webgpu/shader/execution/binary/f32_addition.bin": "42a92071", - "webgpu/shader/execution/binary/f32_logical.bin": "52bf9f46", - "webgpu/shader/execution/binary/f32_division.bin": "a21ae41a", - "webgpu/shader/execution/binary/f32_matrix_addition.bin": "2bf16029", - "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "da555bf6", - "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "67b456c0", - "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "f3fff92e", - "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "c5229b92", - "webgpu/shader/execution/binary/f32_multiplication.bin": "1661b119", - "webgpu/shader/execution/binary/f32_remainder.bin": "cafe4c05", - "webgpu/shader/execution/binary/f32_subtraction.bin": "27965607", - "webgpu/shader/execution/binary/i32_arithmetic.bin": "c8f13fa1", - "webgpu/shader/execution/binary/i32_comparison.bin": "398ab129", - "webgpu/shader/execution/binary/u32_arithmetic.bin": "11c97723", - "webgpu/shader/execution/binary/u32_comparison.bin": "67e3b8e2", - "webgpu/shader/execution/abs.bin": "9c10bb27", - "webgpu/shader/execution/acos.bin": "5e3f5b3f", - "webgpu/shader/execution/acosh.bin": "42722376", - "webgpu/shader/execution/asin.bin": "f42dc48", - "webgpu/shader/execution/asinh.bin": "6213b465", - "webgpu/shader/execution/atan.bin": "5f8ca545", - "webgpu/shader/execution/atan2.bin": "2691235", - "webgpu/shader/execution/atanh.bin": "dc1348bf", - "webgpu/shader/execution/bitcast.bin": "783f49ea", - "webgpu/shader/execution/ceil.bin": "7093f2bf", - "webgpu/shader/execution/clamp.bin": "860409da", - "webgpu/shader/execution/cos.bin": "6b6ca56a", - "webgpu/shader/execution/cosh.bin": "ca339ade", - "webgpu/shader/execution/cross.bin": "ce90a02d", - "webgpu/shader/execution/degrees.bin": "a9c66097", - "webgpu/shader/execution/determinant.bin": "f3f3c2a1", - "webgpu/shader/execution/distance.bin": "1f27d964", - "webgpu/shader/execution/dot.bin": "f94869fa", - "webgpu/shader/execution/exp.bin": "3a6fde7a", - "webgpu/shader/execution/exp2.bin": "ce0acdf7", - "webgpu/shader/execution/faceForward.bin": "6f3b215f", - "webgpu/shader/execution/floor.bin": "856904f4", - "webgpu/shader/execution/fma.bin": "338008da", - "webgpu/shader/execution/fract.bin": "43aee5ae", - "webgpu/shader/execution/frexp.bin": "189c8258", - "webgpu/shader/execution/inverseSqrt.bin": "be6f1532", - "webgpu/shader/execution/ldexp.bin": "9df695d4", - "webgpu/shader/execution/length.bin": "e328ee19", - "webgpu/shader/execution/log.bin": "bfb1370f", - "webgpu/shader/execution/log2.bin": "a736cef7", - "webgpu/shader/execution/max.bin": "e40860fd", - "webgpu/shader/execution/min.bin": "b24f61da", - "webgpu/shader/execution/mix.bin": "3fe4e834", - "webgpu/shader/execution/modf.bin": "bad1fa21", - "webgpu/shader/execution/normalize.bin": "84a00e04", - "webgpu/shader/execution/pack2x16float.bin": "c219cc7", - "webgpu/shader/execution/pow.bin": "36c3cb66", - "webgpu/shader/execution/quantizeToF16.bin": "d97eb92d", - "webgpu/shader/execution/radians.bin": "18a4d2f0", - "webgpu/shader/execution/reflect.bin": "6f187488", - "webgpu/shader/execution/refract.bin": "55a38fcf", - "webgpu/shader/execution/round.bin": "a16fefce", - "webgpu/shader/execution/saturate.bin": "47759809", - "webgpu/shader/execution/sign.bin": "7c23aa83", - "webgpu/shader/execution/sin.bin": "ed21e66e", - "webgpu/shader/execution/sinh.bin": "f761b0ff", - "webgpu/shader/execution/smoothstep.bin": "c77f38b3", - "webgpu/shader/execution/sqrt.bin": "126747b1", - "webgpu/shader/execution/step.bin": "183448fd", - "webgpu/shader/execution/tan.bin": "70461ad1", - "webgpu/shader/execution/tanh.bin": "a7af6ba7", - "webgpu/shader/execution/transpose.bin": "7f436045", - "webgpu/shader/execution/trunc.bin": "62f8811e", - "webgpu/shader/execution/unpack2x16float.bin": "23b9a4ed", - "webgpu/shader/execution/unpack2x16snorm.bin": "804a8103", - "webgpu/shader/execution/unpack2x16unorm.bin": "fa3c026c", - "webgpu/shader/execution/unpack4x8snorm.bin": "90ccac22", - "webgpu/shader/execution/unpack4x8unorm.bin": "8f1c2733", - "webgpu/shader/execution/unary/af_arithmetic.bin": "92d18912", - "webgpu/shader/execution/unary/af_assignment.bin": "61c5bd5f", - "webgpu/shader/execution/unary/bool_conversion.bin": "bba5fa87", - "webgpu/shader/execution/unary/f16_arithmetic.bin": "b6599bfe", - "webgpu/shader/execution/unary/f16_conversion.bin": "5265641", - "webgpu/shader/execution/unary/f32_arithmetic.bin": "e3144d29", - "webgpu/shader/execution/unary/f32_conversion.bin": "336ea1f4", - "webgpu/shader/execution/unary/i32_arithmetic.bin": "10e94454", - "webgpu/shader/execution/unary/i32_complement.bin": "a204e8c1", - "webgpu/shader/execution/unary/i32_conversion.bin": "84dcc320", - "webgpu/shader/execution/unary/u32_complement.bin": "d1ff4ab7", - "webgpu/shader/execution/unary/u32_conversion.bin": "94c32843", - "webgpu/shader/execution/unary/ai_assignment.bin": "7af40f5c", - "webgpu/shader/execution/binary/ai_arithmetic.bin": "2f3b9c57", - "webgpu/shader/execution/unary/ai_arithmetic.bin": "bc3efadb" + "webgpu/shader/execution/binary/af_addition.bin": "72690af1", + "webgpu/shader/execution/binary/af_logical.bin": "6f90d890", + "webgpu/shader/execution/binary/af_division.bin": "19c99f54", + "webgpu/shader/execution/binary/af_matrix_addition.bin": "8958a252", + "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "10fd16f3", + "webgpu/shader/execution/binary/af_multiplication.bin": "32c587d6", + "webgpu/shader/execution/binary/af_remainder.bin": "b584f2ba", + "webgpu/shader/execution/binary/af_subtraction.bin": "5ddc5b48", + "webgpu/shader/execution/binary/f16_addition.bin": "9902fc34", + "webgpu/shader/execution/binary/f16_logical.bin": "d4267b82", + "webgpu/shader/execution/binary/f16_division.bin": "4837bed1", + "webgpu/shader/execution/binary/f16_matrix_addition.bin": "effc888d", + "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "72c3a382", + "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "5c59bfc2", + "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "66e58e31", + "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "1f40feee", + "webgpu/shader/execution/binary/f16_multiplication.bin": "287c6d1f", + "webgpu/shader/execution/binary/f16_remainder.bin": "8eb6ef4d", + "webgpu/shader/execution/binary/f16_subtraction.bin": "11bb1655", + "webgpu/shader/execution/binary/f32_addition.bin": "152455a7", + "webgpu/shader/execution/binary/f32_logical.bin": "673ceb6f", + "webgpu/shader/execution/binary/f32_division.bin": "dbc23caf", + "webgpu/shader/execution/binary/f32_matrix_addition.bin": "2a6877bd", + "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "ec447ef8", + "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "17d1f385", + "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "fa864cb9", + "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "93676a5f", + "webgpu/shader/execution/binary/f32_multiplication.bin": "38eb30c6", + "webgpu/shader/execution/binary/f32_remainder.bin": "ec03f08b", + "webgpu/shader/execution/binary/f32_subtraction.bin": "12a106e3", + "webgpu/shader/execution/binary/i32_arithmetic.bin": "77c30f31", + "webgpu/shader/execution/binary/i32_comparison.bin": "acb55d71", + "webgpu/shader/execution/binary/u32_arithmetic.bin": "8c21844", + "webgpu/shader/execution/binary/u32_comparison.bin": "47006c1e", + "webgpu/shader/execution/abs.bin": "6ead285a", + "webgpu/shader/execution/acos.bin": "93687808", + "webgpu/shader/execution/acosh.bin": "a2aa92cc", + "webgpu/shader/execution/asin.bin": "87201e31", + "webgpu/shader/execution/asinh.bin": "ad620dbe", + "webgpu/shader/execution/atan.bin": "3ff7601c", + "webgpu/shader/execution/atan2.bin": "8a804ba1", + "webgpu/shader/execution/atanh.bin": "9cb8ca11", + "webgpu/shader/execution/bitcast.bin": "da6b8297", + "webgpu/shader/execution/ceil.bin": "abd1dc5d", + "webgpu/shader/execution/clamp.bin": "7a913e5d", + "webgpu/shader/execution/cos.bin": "e6ed18ec", + "webgpu/shader/execution/cosh.bin": "9f8ed03e", + "webgpu/shader/execution/cross.bin": "8892b1bf", + "webgpu/shader/execution/degrees.bin": "1686810d", + "webgpu/shader/execution/determinant.bin": "4f957d78", + "webgpu/shader/execution/distance.bin": "16b5519a", + "webgpu/shader/execution/dot.bin": "5b37c584", + "webgpu/shader/execution/exp.bin": "1af09ef0", + "webgpu/shader/execution/exp2.bin": "d5aad02a", + "webgpu/shader/execution/faceForward.bin": "1bb667d9", + "webgpu/shader/execution/floor.bin": "5901a53f", + "webgpu/shader/execution/fma.bin": "3f087d5d", + "webgpu/shader/execution/fract.bin": "56eeebc7", + "webgpu/shader/execution/frexp.bin": "95c0ece3", + "webgpu/shader/execution/inverseSqrt.bin": "4b32fd45", + "webgpu/shader/execution/ldexp.bin": "42b10215", + "webgpu/shader/execution/length.bin": "511e20d5", + "webgpu/shader/execution/log.bin": "e1e6ccf1", + "webgpu/shader/execution/log2.bin": "c9ba1680", + "webgpu/shader/execution/max.bin": "2caa63b0", + "webgpu/shader/execution/min.bin": "24e91990", + "webgpu/shader/execution/mix.bin": "68a96b6f", + "webgpu/shader/execution/modf.bin": "ee4209fa", + "webgpu/shader/execution/normalize.bin": "46214cb5", + "webgpu/shader/execution/pack2x16float.bin": "37c8eb38", + "webgpu/shader/execution/pow.bin": "229545d2", + "webgpu/shader/execution/quantizeToF16.bin": "9a0eecbb", + "webgpu/shader/execution/radians.bin": "2644d5ee", + "webgpu/shader/execution/reflect.bin": "800d69f3", + "webgpu/shader/execution/refract.bin": "ada723fd", + "webgpu/shader/execution/round.bin": "42a63c10", + "webgpu/shader/execution/saturate.bin": "fbf8f20f", + "webgpu/shader/execution/sign.bin": "14fcb534", + "webgpu/shader/execution/sin.bin": "c4db78b3", + "webgpu/shader/execution/sinh.bin": "688698fc", + "webgpu/shader/execution/smoothstep.bin": "f88e2f74", + "webgpu/shader/execution/sqrt.bin": "14534d5a", + "webgpu/shader/execution/step.bin": "568e9f76", + "webgpu/shader/execution/tan.bin": "8c6347ae", + "webgpu/shader/execution/tanh.bin": "68765cc2", + "webgpu/shader/execution/transpose.bin": "d6788d8b", + "webgpu/shader/execution/trunc.bin": "9267a13f", + "webgpu/shader/execution/unpack2x16float.bin": "5bd8b265", + "webgpu/shader/execution/unpack2x16snorm.bin": "f1b7e3b4", + "webgpu/shader/execution/unpack2x16unorm.bin": "785355d9", + "webgpu/shader/execution/unpack4x8snorm.bin": "b0463363", + "webgpu/shader/execution/unpack4x8unorm.bin": "73cfc714", + "webgpu/shader/execution/unary/af_arithmetic.bin": "4897e3f5", + "webgpu/shader/execution/unary/af_assignment.bin": "b6131560", + "webgpu/shader/execution/unary/bool_conversion.bin": "70c51822", + "webgpu/shader/execution/unary/f16_arithmetic.bin": "25862540", + "webgpu/shader/execution/unary/f16_conversion.bin": "86abb519", + "webgpu/shader/execution/unary/f32_arithmetic.bin": "2e519bdc", + "webgpu/shader/execution/unary/f32_conversion.bin": "2b908c31", + "webgpu/shader/execution/unary/i32_arithmetic.bin": "cc125c13", + "webgpu/shader/execution/unary/i32_complement.bin": "c6c835bd", + "webgpu/shader/execution/unary/i32_conversion.bin": "fb4402f9", + "webgpu/shader/execution/unary/u32_complement.bin": "d00030a0", + "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" } \ No newline at end of file diff --git a/src/resources/cache/webgpu/shader/execution/bitcast.bin b/src/resources/cache/webgpu/shader/execution/bitcast.bin index 3c24c88e1ffb..d3954903ac89 100644 Binary files a/src/resources/cache/webgpu/shader/execution/bitcast.bin and b/src/resources/cache/webgpu/shader/execution/bitcast.bin differ diff --git a/src/webgpu/shader/execution/expression/binary/bitwise.spec.ts b/src/webgpu/shader/execution/expression/binary/bitwise.spec.ts index 0d8d77535244..76f15c8a81f4 100644 --- a/src/webgpu/shader/execution/expression/binary/bitwise.spec.ts +++ b/src/webgpu/shader/execution/expression/binary/bitwise.spec.ts @@ -3,59 +3,173 @@ 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 { i32, scalarType, u32 } from '../../../../util/conversion.js'; -import { allInputSources, run } from '../expression.js'; +import { + abstractIntBits, + i32, + i32Bits, + Scalar, + scalarType, + u32, + u32Bits, +} from '../../../../util/conversion.js'; +import { allInputSources, onlyConstInputSource, run } from '../expression.js'; -import { binary, compoundBinary } from './binary.js'; +import { abstractIntBinary, binary, compoundBinary } from './binary.js'; export const g = makeTestGroup(GPUTest); -function makeBitwiseOrCases(inputType: string) { - const V = inputType === 'i32' ? i32 : u32; - const cases = [ - // Static patterns +/** + * Collection of functions and values required to implement bitwise tests for a + * specific scalar type + */ +interface ScalarImpl { + // builder is a mostly a wrapper around type builders like 'i32Bits' that + // handles the (number|bigint) type check. + builder: (bits: bigint | number) => Scalar; + size: 32 | 64; +} + +const kScalarImpls = { + i32: { + builder: (bits: bigint | number): Scalar => { + assert(typeof bits === 'number'); + return i32Bits(bits); + }, + size: 32, + } as ScalarImpl, + u32: { + builder: (bits: bigint | number): Scalar => { + assert(typeof bits === 'number'); + return u32Bits(bits); + }, + size: 32, + } as ScalarImpl, + 'abstract-int': { + builder: (bits: bigint | number): Scalar => { + assert(typeof bits === 'bigint'); + return abstractIntBits(bits); + }, + size: 64, + } as ScalarImpl, +}; + +/** Wrapper for converting from input type strings to the appropriate implementation */ +function scalarImplForInputType(inputType: string): ScalarImpl { + assert(inputType === 'i32' || inputType === 'u32' || inputType === 'abstract-int'); + return kScalarImpls[inputType]; +} + +/** Manually calculated bitwise-or cases used a check that the CTS test is correct */ +const kBitwiseOrStaticPatterns = { + 32: [ { - input: [V(0b00000000000000000000000000000000), V(0b00000000000000000000000000000000)], - expected: V(0b00000000000000000000000000000000), + input: [0b00000000000000000000000000000000, 0b00000000000000000000000000000000], + expected: 0b00000000000000000000000000000000, }, { - input: [V(0b11111111111111111111111111111111), V(0b00000000000000000000000000000000)], - expected: V(0b11111111111111111111111111111111), + input: [0b11111111111111111111111111111111, 0b00000000000000000000000000000000], + expected: 0b11111111111111111111111111111111, }, { - input: [V(0b00000000000000000000000000000000), V(0b11111111111111111111111111111111)], - expected: V(0b11111111111111111111111111111111), + input: [0b00000000000000000000000000000000, 0b11111111111111111111111111111111], + expected: 0b11111111111111111111111111111111, }, { - input: [V(0b11111111111111111111111111111111), V(0b11111111111111111111111111111111)], - expected: V(0b11111111111111111111111111111111), + input: [0b11111111111111111111111111111111, 0b11111111111111111111111111111111], + expected: 0b11111111111111111111111111111111, }, { - input: [V(0b10100100010010100100010010100100), V(0b00000000000000000000000000000000)], - expected: V(0b10100100010010100100010010100100), + input: [0b10100100010010100100010010100100, 0b00000000000000000000000000000000], + expected: 0b10100100010010100100010010100100, }, { - input: [V(0b00000000000000000000000000000000), V(0b10100100010010100100010010100100)], - expected: V(0b10100100010010100100010010100100), + input: [0b00000000000000000000000000000000, 0b10100100010010100100010010100100], + expected: 0b10100100010010100100010010100100, }, { - input: [V(0b01010010001001010010001001010010), V(0b10100100010010100100010010100100)], - expected: V(0b11110110011011110110011011110110), + input: [0b01010010001001010010001001010010, 0b10100100010010100100010010100100], + expected: 0b11110110011011110110011011110110, }, - ]; - // Permute all combinations of a single bit being set for the LHS and RHS - for (let i = 0; i < 32; i++) { - const lhs = 1 << i; - for (let j = 0; j < 32; j++) { - const rhs = 1 << j; - cases.push({ - input: [V(lhs), V(rhs)], - expected: V(lhs | rhs), + ], + 64: [ + { + input: [ + 0b0000000000000000000000000000000000000000000000000000000000000000n, + 0b0000000000000000000000000000000000000000000000000000000000000000n, + ], + expected: 0b0000000000000000000000000000000000000000000000000000000000000000n, + }, + { + input: [ + 0b1111111111111111111111111111111111111111111111111111111111111111n, + 0b0000000000000000000000000000000000000000000000000000000000000000n, + ], + expected: 0b1111111111111111111111111111111111111111111111111111111111111111n, + }, + { + input: [ + 0b0000000000000000000000000000000000000000000000000000000000000000n, + 0b1111111111111111111111111111111111111111111111111111111111111111n, + ], + expected: 0b1111111111111111111111111111111111111111111111111111111111111111n, + }, + { + input: [ + 0b1111111111111111111111111111111111111111111111111111111111111111n, + 0b1111111111111111111111111111111111111111111111111111111111111111n, + ], + expected: 0b1111111111111111111111111111111111111111111111111111111111111111n, + }, + { + input: [ + 0b1010010001001010010001001010010010100100010010100100010010100100n, + 0b0000000000000000000000000000000000000000000000000000000000000000n, + ], + expected: 0b1010010001001010010001001010010010100100010010100100010010100100n, + }, + { + input: [ + 0b0000000000000000000000000000000000000000000000000000000000000000n, + 0b1010010001001010010001001010010010100100010010100100010010100100n, + ], + expected: 0b1010010001001010010001001010010010100100010010100100010010100100n, + }, + { + input: [ + 0b0101001000100101001000100101001010100100010010100100010010100100n, + 0b1010010001001010010001001010010010100100010010100100010010100100n, + ], + expected: 0b1111011001101111011001101111011010100100010010100100010010100100n, + }, + ], +}; + +/** @returns a set of bitwise-or cases for the specific input type */ +function makeBitBitwiseOrCases(inputType: string) { + const impl = scalarImplForInputType(inputType); + const indices = + impl.size === 64 ? [...Array(impl.size).keys()].map(BigInt) : [...Array(impl.size).keys()]; + + return [ + ...kBitwiseOrStaticPatterns[impl.size].map(c => { + return { + input: c.input.map(impl.builder), + expected: impl.builder(c.expected), + }; + }), + // Permute all combinations of a single bit being set for the LHS and RHS + ...indices.flatMap(i => { + const lhs = typeof i === 'bigint' ? 1n << i : 1 << i; + return indices.map(j => { + const rhs = typeof j === 'bigint' ? 1n << j : 1 << j; + assert(typeof lhs === typeof rhs); + const result = typeof lhs === 'bigint' ? lhs | (rhs as bigint) : lhs | (rhs as number); + return { input: [impl.builder(lhs), impl.builder(rhs)], expected: impl.builder(result) }; }); - } - } - return cases; + }), + ]; } g.test('bitwise_or') @@ -63,22 +177,25 @@ g.test('bitwise_or') .desc( ` e1 | e2: T -T is i32, u32, vecN, or vecN +T is i32, u32, abstractInt, vecN, vecN, or vecN Bitwise-or. Component-wise when T is a vector. ` ) .params(u => u - .combine('type', ['i32', 'u32'] as const) + .combine('type', ['i32', 'u32', 'abstract-int'] as const) .combine('inputSource', allInputSources) .combine('vectorize', [undefined, 2, 3, 4] as const) ) .fn(async t => { + t.skipIf( + t.params.type === 'abstract-int' && !onlyConstInputSource.includes(t.params.inputSource) + ); const type = scalarType(t.params.type); - const cases = makeBitwiseOrCases(t.params.type); - - await run(t, binary('|'), [type, type], type, t.params, cases); + const cases = makeBitBitwiseOrCases(t.params.type); + const builder = t.params.type === 'abstract-int' ? abstractIntBinary('|') : binary('|'); + await run(t, builder, [type, type], type, t.params, cases); }); g.test('bitwise_or_compound') @@ -99,7 +216,7 @@ Bitwise-or. Component-wise when T is a vector. ) .fn(async t => { const type = scalarType(t.params.type); - const cases = makeBitwiseOrCases(t.params.type); + const cases = makeBitBitwiseOrCases(t.params.type); await run(t, compoundBinary('|='), [type, type], type, t.params, cases); }); diff --git a/src/webgpu/util/conversion.ts b/src/webgpu/util/conversion.ts index 67cc666acf5a..ac6ff5bbea38 100644 --- a/src/webgpu/util/conversion.ts +++ b/src/webgpu/util/conversion.ts @@ -85,6 +85,7 @@ const workingDataI32 = new Int32Array(workingData); const workingDataI8 = new Int8Array(workingData); const workingDataF64 = new Float64Array(workingData); const workingDataI64 = new BigInt64Array(workingData); +const workingDataU64 = new BigUint64Array(workingData); const workingDataView = new DataView(workingData); /** @@ -1070,11 +1071,11 @@ function scalarFromValue( * reinterpreting it as an element of `workingDataLoadArray`. * Both working data arrays *must* be aliases of `workingData`. */ -function scalarFromBits( +function scalarFromBits( type: ScalarType, - workingDataStoreArray: TypedArrayBufferView, + workingDataStoreArray: A, workingDataLoadArray: TypedArrayBufferView, - bits: number + bits: ArrayElementType ): Scalar { // Clear all bits of the working data since `value` may be smaller; the upper bits should be 0. workingDataU32[1] = 0; @@ -1108,6 +1109,9 @@ export const f16Bits = (bits: number): Scalar => export const abstractInt = (value: bigint): Scalar => scalarFromValue(TypeAbstractInt, workingDataI64, value); +export const abstractIntBits = (bits: bigint): Scalar => + scalarFromBits(TypeAbstractInt, workingDataU64, workingDataI64, bits); + /** Create an i32 from a numeric value, a JS `number`. */ export const i32 = (value: number): Scalar => scalarFromValue(TypeI32, workingDataI32, value);