AGC: on gfx1100 image_sample_c compares only 16_UNORM and 32_FLOAT; every other color format answers 0 (emulated color comparison unmeasured on gfx103x) #7934
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T14:47:34Z.
What
On a gfx1100,
image_sample_c*compares at only two of the 63 GFX11 color formats, 16_UNORM and 32_FLOAT. Every other format reads its texels normally but answers 0 for every compare function, ALWAYS included. Measured with the hardware oracle.AnyPS5 emulates a real comparison for every float, unorm and snorm format except 8-bit UNORM and sRGB (Color comparison descriptor forms). That design follows #668, which says "AMD hardware compares a
sample_creference against the red channel of a colour texture". As far as I can find, that sentence was never measured. What was measured is the exception: on gfx1035, 8-bit UNORM and sRGB return 0 (#3438, #4267).#4267 moved the real-compare rows of
agc_driver_emulated_color_compareto16_16_UNORM, on the assumption that this format compares. On gfx1100,16_16_UNORManswers 0.This is RDNA3, not the console's gfx1013. The 8-bit result matches gfx1035, but whether gfx103x compares 16-bit, float or snorm color formats is still open. I'm reporting it so someone with an RDNA2 GPU can run the sweep below. I have not changed anything.
Results (gfx1100)
image_sample_c_lzon a 4x4 TYPE 9 (2D) T#, point and bilinear S#, clamp-to-last-texel, wave32 and wave64:image_sample_lzreadsAmong the formats that answer 0:
16_FLOAT,16_SNORM,16_16_UNORM,16_16_FLOAT,32_32_FLOAT,16_16_16_16_UNORM,8_8_8_8_SNORM,11_11_10_FLOAT. In every one of themimage_sample_lzreturns the expected texel through the same T# and S# (for example 0.129854 at 16_16_UNORM, 0.0102386 at 16_FLOAT), so the descriptor is valid and the zero comes from the compare.I checked nine of these formats again with
image_sample_c_l(explicit LOD 0) and plainimage_sample_c. Both matchimage_sample_c_lz: only 16_UNORM and 32_FLOAT compare. wave32 and wave64 agree on every row.GFX11 renumbers the formats past 29, so the codes are not the console's. The names come from
llvm-mc -mcpu=gfx1100 -disassembleontbufferencodings, whose format field shares the image numbering on GFX11. As a check, code 42 reads correct8_8_8_8_UNORMtexels.Also measured: native comparisons through a 2D T# with a 2D-array or 3D DIM
At 32_FLOAT, which does compare, I also measured the cases that two
shader.mdentries leave unmeasured: "Emulated comparison of a 2D-array access through a 2D T#", and comparisons of "3D image accesses bound to a 2D or 2D-array T#".Setup:
image_sample_c_lzwith DIM 2D_ARRAY and with DIM 3D on a 2D T#, against DIM 2D with the same reference and (u, v). Slices and r values were 0, 1, 2, 2.7, 3, -1, 5, 0.25 and 0.5, with u at texel centres, between texels and past both edges. The functions were LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL and GEQUAL. The references were the texel's value, the requested layer's texel value, 0.5 above and below them, the bilinear value, 0.5 and 1000. Point and bilinear, wave32 and wave64: 14,400 rows.reference OP texelon all 1,200 rows of each function. The reversed operand order only matches on ties.For the emulated formats, the hardware here answers 0 whatever the slice. So on gfx1100 the 2D-array entry's model ("samples the 2D image and ignores the slice") only matters at 16_UNORM and 32_FLOAT.
Sweep script (for RDNA2 owners)
Run it from the repository root with the oracle's requirements met:
python3 color_compare_sweep.py <gfx target, e.g. gfx1035>. It needsllvm-mcinPATHto name the formats. It prints every code with its ALWAYS, NEVER and EQUAL answers, then the list of formats that compare. Check whether the target numbers formats like GFX10 (gfx103x does): 16_16_UNORM is code 23 on both generations, but 8_8_8_8_UNORM is 56 on GFX10 and 42 on GFX11.color_compare_sweep.py
Environment
AMD Radeon RX 7900 XT (gfx1100), Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, ROCm HSA runtime through
tools/hw-oracle. Float controls on every run:ieee=0 dx10_clamp=1 denorm32=3 denorm16=3 round32=0 round16=0 fp16_overflow=0.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-19T16:26:32Z.
Native RDNA2 result for the requested sweep: gfx1036 agrees with the two-format split. This is the Ryzen 9 9950X iGPU (
1002:13c0), Linux kernel7.0.0-38-generic, using the HSA hardware oracle. The detected target isgfx1036; this is not the console's gfx1013, and no Vulkan sampling or emulated shader result is used here.I ran the supplied kernel for codes 1–63, then extended it through 77, since GFX10 also names codes 64–77 (
32_32_FLOATthrough32_32_32_32_FLOAT). Format names came from the localllvm-mc -mcpu=gfx1036disassembly. Point sampler, 4×4 TYPE 9 T#, 512 lanes per dispatch, both wave32 and wave64:16_UNORM32_FLOAT16_16_UNORM, 64 /32_32_FLOAT, 65 /16_16_16_16_UNORMAdditional controls:
image_sample_c_lz, explicit-LOD-zeroimage_sample_c_l, andimage_sample_cagree in both wave sizes for 11 formats:16_UNORM,16_SNORM,16_FLOAT,32_FLOAT,16_16_UNORM,16_16_FLOAT,8_8_8_8_UNORM,32_32_FLOAT,16_16_16_16_UNORM,16_16_16_16_FLOAT,32_32_32_32_FLOAT.image_sample_lzreads the expected component from the supplied bytes, checked per coordinate and format stride against CPU decoding within one f32 ULP. Thus the zero comparison at16_16_UNORM, for example, is not a zero/invalid ordinary texel read.v10with0x7fc01234before the compare still gives 1.0 at codes 7/22 and 0 at 23/65, across all three opcodes and both waves. The zero results overwrite the sentinel rather than leaving an untouched zero-initialized result register.Every dispatch used
ieee=0, dx10_clamp=1, denorm32=3, denorm16=3, round32=0, round16=0, fp16_overflow=0. Oracle sources are pinned at7220d35b77985454693538c78175493e5aa201a5; no repository source was changed. Full sweep output, control JSON and scripts retained.Scope: point sampling and the 2D descriptor above. I have not checked bilinear filtering, the 2D-array/3D-DIM cases, other float modes, a title, or gfx1013. No implementation change or console-equivalence claim is proposed.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T18:48:27Z.
The discrete RDNA 2 result agrees too: RX 6700 XT (gfx1031) through the HIP runtime of AMD's Windows driver, so the ISA runs as written. I used your kernel (4x4 TYPE 9 T#, point S#, clamp to the last texel, your texel bytes) for GFX10 codes 1 to 77, in wave32 and wave64, with a NaN sentinel preloaded in the result VGPR.
image_sample_c_lzcompares at codes 7 (16_UNORM) and 22 (32_FLOAT) only, in both wave sizes. Every other code answers 0 for ALWAYS, NEVER and EQUAL, whileimage_sample_lzthrough the same descriptors reads the expected texel. Examples: 0.129854 at16_16_UNORMand16_16_16_16_UNORM, 0.0102386 at16_FLOAT,16_16_FLOATand16_16_16_16_FLOAT, 0.259713 at16_SNORM, 2.93953 at32_32_FLOATand32_32_32_32_FLOAT.The open questions about the two formats that compare, point sampler. "ref" is the
image_sample_creference, "texel" the valueimage_sample_lzreturns:16_UNORM, texel 0.129932_FLOAT, texel 2.9395So the result is
ref OP texel. At16_UNORMa NaN reference behaves as 0 (LESS, LEQUAL and NOTEQUAL are true), so the reference is converted to the format's range before the compare. These references don't show whether -1 and 2 are clamped. At32_FLOATa NaN reference is unordered, so only NOTEQUAL is true.Bilinear S# at
32_FLOAT, texels 0, 0.25, 0.5, 1.0 along x: the result is the bilinear blend of the four per-texel comparisons, not a comparison of the filtered value. For example, LESS with ref 0.3 between the texels 0.25 and 0.5 gives 0, 0.125, 0.25, 0.375 as u moves toward the 0.5 texel, while the point result stays 0.So gfx1031, gfx1036 and gfx1100 agree: only the two depth formats compare, and every other format answers 0 whatever the function. That differs from the emulated color comparisons for the 16-bit, float and snorm color formats, and from
agc_driver_emulated_color_compare's real-compare rows at16_16_UNORM.Desktop RDNA 2, not the console's gfx1013. 2D T# only; I didn't repeat your 2D-array and 3D DIM cases.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T19:54:51Z.
I opened #8642 with the measured GFX10 color-comparison format split. It keeps codes 7 (
16_UNORM) and 22 (32_FLOAT) on the native path and returns zero for the other supported floating-sampled formats. The PR depends on #8625 for the separate array-layer, NaN and TRUNC_COORD corrections. Eligibility, intake, conventions, labels and report checks passed; automatic platform build jobs were skipped by path filtering, and my manual build dispatch was denied by repository permissions. The PR description records that no local runtime test was run.