Skip to content

Commit 990c238

Browse files
authored
Fix makeRandomDepthComparisonTexelGenerator (#4048)
This bug broke all textureXXCompare tests with unencodable depth formats.
1 parent 467c899 commit 990c238

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,8 @@ export function makeRandomDepthComparisonTexelGenerator(
11951195
},
11961196
comparison: GPUCompareFunction
11971197
) {
1198-
const rep = kTexelRepresentationInfo[info.format as EncodableTextureFormat];
1198+
const format = isUnencodableDepthFormat(info.format) ? 'depth32float' : info.format;
1199+
const rep = kTexelRepresentationInfo[format as EncodableTextureFormat];
11991200
const size = reifyExtent3D(info.size);
12001201

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

@@ -1225,7 +1226,7 @@ export function makeRandomDepthComparisonTexelGenerator(
12251226
size.depthOrArrayLayers
12261227
);
12271228
const normalized = clamp(rnd / 0xffffffff, { min: 0, max: 1 });
1228-
texel[component] = format(normalized);
1229+
texel[component] = encode(normalized);
12291230
}
12301231
return quantize(texel, rep);
12311232
};

0 commit comments

Comments
 (0)