Skip to content

Commit

Permalink
Fix makeRandomDepthComparisonTexelGenerator (#4048)
Browse files Browse the repository at this point in the history
This bug broke all textureXXCompare tests with unencodable depth formats.
  • Loading branch information
greggman authored Nov 19, 2024
1 parent 467c899 commit 990c238
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,8 @@ export function makeRandomDepthComparisonTexelGenerator(
},
comparison: GPUCompareFunction
) {
const rep = kTexelRepresentationInfo[info.format as EncodableTextureFormat];
const format = isUnencodableDepthFormat(info.format) ? 'depth32float' : info.format;
const rep = kTexelRepresentationInfo[format as EncodableTextureFormat];
const size = reifyExtent3D(info.size);

const comparisonIsEqualOrNotEqual = comparison === 'equal' || comparison === 'not-equal';
Expand All @@ -1207,7 +1208,7 @@ export function makeRandomDepthComparisonTexelGenerator(
// The problem with comparing equal is other than 0.0 and 1.0, no other
// values are guaranteed to be equal.
const fixedValues = [0, 0.6, 1, 1];
const format = comparisonIsEqualOrNotEqual
const encode = comparisonIsEqualOrNotEqual
? (norm: number) => fixedValues[(norm * (fixedValues.length - 1)) | 0]
: (norm: number) => norm;

Expand All @@ -1225,7 +1226,7 @@ export function makeRandomDepthComparisonTexelGenerator(
size.depthOrArrayLayers
);
const normalized = clamp(rnd / 0xffffffff, { min: 0, max: 1 });
texel[component] = format(normalized);
texel[component] = encode(normalized);
}
return quantize(texel, rep);
};
Expand Down

0 comments on commit 990c238

Please sign in to comment.