From f8472c9ab5cb878832d3e20ec074ca634215fad6 Mon Sep 17 00:00:00 2001 From: Greggman Date: Thu, 22 Aug 2024 04:22:17 +0900 Subject: [PATCH] Print more info in certain asserts (#3911) This is useful for CQs where bots have different hardware then devs have locally. --- .../expression/call/builtin/texture_utils.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts index 3029235976c7..f996c6ce1c7e 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts @@ -226,12 +226,19 @@ async function initMipGradientValuesForDevice(t: GPUTest) { storageBuffer.destroy(); resultBuffer.destroy(); + const showWeights = () => weights.map((v, i) => `${i.toString().padStart(2)}: ${v}`).join('\n'); + // Validate the weights - assert(weights[0] === 0, 'weight 0 is 0'); - assert(weights[kMipGradientSteps] === 1, 'top weight is 1'); + assert(weights[0] === 0, `weight 0 expected 0 but was ${weights[0]}\n${showWeights()}`); + assert( + weights[kMipGradientSteps] === 1, + `top weight expected 1 but was ${weights[kMipGradientSteps]}\n${showWeights()}` + ); assert( Math.abs(weights[kMipGradientSteps / 2] - 0.5) < 0.0001, - 'middle weight is approximately 0.5' + `middle weight expected approximately 0.5 but was ${ + weights[kMipGradientSteps / 2] + }\n${showWeights()}` ); // Note: for 16 steps, these are the AMD weights