@@ -933,3 +933,87 @@ webgpu:shader,execution,expression,call,builtin,textureGather:sampled_3d_coords:
933933 |
934934 layer: 5 mip(0), cube-layer: 0 (-z) un-sampled |
935935```
936+
937+ ------------------------------------------------------------------------------------------------------------
938+ * gpu: AMD Radeon Pro 560X (1002:67ef)
939+ * os: Mac-14.4.1
940+ * affected: ` textureSample ` (and probably other ` textureSampleXXX ` with ` lodClampMin ` set > 0 and mipmapFilter = 'linear'
941+
942+ The mip sampling level is not correctly clamped
943+
944+ Example failure:
945+
946+ Below we have an 8x8 texture with 3 mip levels. lodMinClamp = 0.25. The derivative based mip level is -0.8, clamped it should
947+ be 0.25. The GPU sampled level 0.1875 which is out of bounds for the lodMinClamp of 0.25 (see "mip level (1) weight:")
948+
949+ ```
950+ webgpu:shader,execution,expression,call,builtin,textureSample:sampled_2d_coords,lodClamp:format="rgba8unorm";filt="linear" - fail:
951+ --> EXPECTATION FAILED: subcase: samplePoints="texel-centre";baseMipLevel=0;lodMinClamp=0.25;lodMaxClamp=1.75
952+ result was not as expected:
953+ physical size: [8, 8, 1]
954+ baseMipLevel: 0
955+ mipLevelCount: 3
956+ baseArrayLayer: 0
957+ arrayLayerCount: 1
958+ physicalMipCount: 3
959+ lodMinClamp: 0.25 (effective)
960+ lodMaxClamp: 1.75 (effective)
961+ call: textureSample(texture: T, sampler: S, coords: vec2f(0.4375, 0.5625) + derivativeBase * derivativeMult(vec2f(0.5358867312681466, 0))) // #3
962+ : as texel coord @ mip level[0]: (3.500, 4.500)
963+ : as texel coord @ mip level[1]: (1.750, 2.250)
964+ : as texel coord @ mip level[2]: (0.875, 1.125)
965+ implicit derivative based mip level: -0.90000
966+ got: 0.46780, 0.85118, 0.33476, 0.36728
967+ expected: 0.48125, 0.81072, 0.34308, 0.37206
968+ max diff: 0.027450980392156862
969+ abs diffs: 0.01345, 0.04046, 0.00832, 0.00478
970+ rel diffs: 2.79%, 4.75%, 2.42%, 1.28%
971+ ulp diffs: 4, 10, 2, 1
972+
973+ sample points:
974+ expected: | got:
975+ |
976+ layer: 0 mip(0) | layer: 0 mip(0)
977+ 0 1 2 3 4 5 6 7 | 0 1 2 3 4 5 6 7
978+ ┌───┬───┬───┬───┬───┬───┬───┬───┐ | ┌───┬───┬───┬───┬───┬───┬───┬───┐
979+ 0 │ │ │ │ │ │ │ │ │ | 0 │ │ │ │ │ │ │ │ │
980+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
981+ 1 │ │ │ │ │ │ │ │ │ | 1 │ │ │ │ │ │ │ │ │
982+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
983+ 2 │ │ │ │ │ │ │ │ │ | 2 │ │ │ │ │ │ │ │ │
984+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
985+ 3 │ │ │ │ │ │ │ │ │ | 3 │ │ │ │ │ │ │ │ │
986+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
987+ 4 │ │ │ │ a │ │ │ │ │ | 4 │ │ │ │ a │ │ │ │ │
988+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
989+ 5 │ │ │ │ │ │ │ │ │ | 5 │ │ │ │ │ │ │ │ │
990+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
991+ 6 │ │ │ │ │ │ │ │ │ | 6 │ │ │ │ │ │ │ │ │
992+ ├───┼───┼───┼───┼───┼───┼───┼───┤ | ├───┼───┼───┼───┼───┼───┼───┼───┤
993+ 7 │ │ │ │ │ │ │ │ │ | 7 │ │ │ │ │ │ │ │ │
994+ └───┴───┴───┴───┴───┴───┴───┴───┘ | └───┴───┴───┴───┴───┴───┴───┴───┘
995+ a: mip(0) at: [ 3, 4, 0], weight: 0.75000 | a: mip(0) at: [ 3, 4, 0], weight: 0.81250
996+ a: value: R: 0.42745, G: 0.97255, B: 0.30980, A: 0.35294 | a: value: R: 0.42745, G: 0.97255, B: 0.30980, A: 0.35294
997+ mip level (0) weight: 0.75000 | mip level (0) weight: 0.81250
998+ |
999+ layer: 0 mip(1) | layer: 0 mip(1)
1000+ 0 1 2 3 | 0 1 2 3
1001+ ┌───┬───┬───┬───┐ | ┌───┬───┬───┬───┐
1002+ 0 │ │ │ │ │ | 0 │ │ │ │ │
1003+ ├───┼───┼───┼───┤ | ├───┼───┼───┼───┤
1004+ 1 │ │ b │ c │ │ | 1 │ │ b │ c │ │
1005+ ├───┼───┼───┼───┤ | ├───┼───┼───┼───┤
1006+ 2 │ │ d │ e │ │ | 2 │ │ d │ e │ │
1007+ ├───┼───┼───┼───┤ | ├───┼───┼───┼───┤
1008+ 3 │ │ │ │ │ | 3 │ │ │ │ │
1009+ └───┴───┴───┴───┘ | └───┴───┴───┴───┘
1010+ b: mip(1) at: [ 1, 1, 0], weight: 0.04688 | b: mip(1) at: [ 1, 1, 0], weight: 0.03516
1011+ c: mip(1) at: [ 2, 1, 0], weight: 0.01563 | c: mip(1) at: [ 2, 1, 0], weight: 0.01172
1012+ d: mip(1) at: [ 1, 2, 0], weight: 0.14063 | d: mip(1) at: [ 1, 2, 0], weight: 0.10547
1013+ e: mip(1) at: [ 2, 2, 0], weight: 0.04688 | e: mip(1) at: [ 2, 2, 0], weight: 0.03516
1014+ b: value: R: 0.89804, G: 0.21176, B: 0.29804, A: 0.47843 | b: value: R: 0.89804, G: 0.21176, B: 0.29804, A: 0.47843
1015+ c: value: R: 0.95294, G: 0.01569, B: 0.29804, A: 0.88235 | c: value: R: 0.95294, G: 0.01569, B: 0.29804, A: 0.88235
1016+ d: value: R: 0.56078, G: 0.21569, B: 0.40000, A: 0.42353 | d: value: R: 0.56078, G: 0.21569, B: 0.40000, A: 0.42353
1017+ e: value: R: 0.52941, G: 0.87059, B: 0.76471, A: 0.24706 | e: value: R: 0.52941, G: 0.87059, B: 0.76471, A: 0.24706
1018+ mip level (1) weight: 0.25000 | mip level (1) weight: 0.18750
1019+ ```
0 commit comments