Skip to content

Commit

Permalink
Texture Utils, log bad weights only if debugging (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman authored Dec 5, 2024
1 parent 096f9fd commit 79e72c0
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 79e72c0

Please sign in to comment.