From 6f2bd6fce693d952b8a894228a2d573b3aa29564 Mon Sep 17 00:00:00 2001
From: Gregg Tavares <github@greggman.com>
Date: Thu, 5 Dec 2024 13:59:20 +0900
Subject: [PATCH] Texture Utils, log bad weights only if debugging

---
 .../expression/call/builtin/texture_utils.ts         | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 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 175244697829..2e4123c6cfeb 100644
--- a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
+++ b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts
@@ -263,14 +263,16 @@ export function graphWeights(height: number, weights: number[]) {
 /**
  * Validates the weights go from 0 to 1 in increasing order.
  */
-function validateWeights(stage: string, weights: number[]) {
-  const showWeights = () => `
+function validateWeights(t: GPUTest, stage: string, weights: number[]) {
+  const showWeights = t.rec.debugging
+    ? () => `
 ${weights.map((v, i) => `${i.toString().padStart(2)}: ${v}`).join('\n')}
 
 e = expected
 A = actual
 ${graphWeights(32, weights)}
-`;
+`
+    : () => ``;
 
   // Validate the weights
   assert(
@@ -586,8 +588,8 @@ export async function queryMipLevelMixWeightsForDevice(t: GPUTest, stage: Shader
 
   const [sampleLevelWeights, gradWeights] = unzip(result, kNumWeightTypes, 4);
 
-  validateWeights(stage, sampleLevelWeights);
-  validateWeights(stage, gradWeights);
+  validateWeights(t, stage, sampleLevelWeights);
+  validateWeights(t, stage, gradWeights);
 
   texture.destroy();
   storageBuffer.destroy();