@@ -3,6 +3,18 @@ Operational tests for the 'texture-component-swizzle' feature.
33
44Test that:
55* when the feature is on, swizzling is applied correctly.
6+
7+ Note: for texture_depth_xxx we only get f32
8+ What happens in the GPU (at least in Metal)
9+
10+ 1. we start with [depthOrCompareResult, depthOrCompareResult, depthOrCompareResult, 1]
11+ 2. we then swizzle
12+ 3. we then read the RED channel
13+
14+ Gather will do this 4 times and give us the result of step 3 in each channel.
15+
16+ The WebGPU spec says we should be starting with [depthOrCompare, 0, 0, 1] and the
17+ implementation should deal with this.
618` ;
719
820import { makeTestGroup } from '../../../../common/framework/test_group.js' ;
@@ -332,18 +344,17 @@ ${sampledColors.map((c, i) => `${i % 2}, ${(i / 2) | 0}, ${JSON.stringify(c)}`).
332344
333345 const testData = [ swizzle , otherSwizzle ] . map ( swizzle => {
334346 const swizzledColors = readColors . map ( readColor => swizzleTexel ( readColor , swizzle ) ) ;
335- const expRGBAColor = isBuiltinGather ( func )
347+ const expColor = isBuiltinGather ( func )
336348 ? gather ( swizzledColors , channel )
349+ : isSingleChannelInput ( input )
350+ ? {
351+ R : swizzledColors [ 0 ] . R ,
352+ G : swizzledColors [ 0 ] . R ,
353+ B : swizzledColors [ 0 ] . R ,
354+ A : swizzledColors [ 0 ] . R ,
355+ }
337356 : swizzledColors [ 0 ] ;
338- const expColor =
339- ! isBuiltinGather ( func ) && isSingleChannelInput ( input )
340- ? {
341- R : expRGBAColor . R ,
342- G : expRGBAColor . R ,
343- B : expRGBAColor . R ,
344- A : expRGBAColor . R ,
345- }
346- : expRGBAColor ;
357+
347358 const expTexelView = TexelView . fromTexelsAsColors ( expFormat , _coords => expColor ) ;
348359 const textureView = texture . createView ( {
349360 label : `swizzle texture view(${ swizzle } )` ,
@@ -534,6 +545,12 @@ ${testData
534545 const uniformValues = new ArrayBuffer ( uniformBuffer . size ) ;
535546 const asF32 = new Float32Array ( uniformValues ) ;
536547 asF32 . set ( [ tx / texture . width , ty / texture . height ] ) ;
548+ t . debug (
549+ ( ) =>
550+ `texcoords: ${ [ ...asF32 ] } tx = ${ tx } , ty = ${ ty } , size: ${ texture . width } , ${
551+ texture . height
552+ } `
553+ ) ;
537554 t . device . queue . writeBuffer ( uniformBuffer , 0 , new Uint32Array ( uniformValues ) ) ;
538555
539556 const bindGroup0 = t . device . createBindGroup ( {
0 commit comments