Repository navigation
Translator: border address modes in the image_gather4_l emulation (SHADER-348) - #2025
Conversation
…ADER-348) Since ItsNotRexed#1567 made the game's S# words literals, 16 corpus gathers with CLAMP mode 6 (clamp border) failed as Unsupported. Modes 6 and 7 (mirror once border) now give a tap outside [0, n-1] the S# border colour's channel (BORDER_COLOR_TYPE, word 3 [31:30]: transparent black, opaque black, opaque white), for literal and run-time S#s; a table border colour stays Unsupported on a literal S#, and half-border modes 4 and 5 keep their old handling. GPU test ps_gather_border, translator tests and the contract row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Corpus recount for SHADER-348, done on
These are the 16 shaders from the #1567 regression finding. All of them use mode 6, and none needs a half-border mode or BORDER_COLOR_TYPE 3, which this PR still refuses on a literal S#. A full-corpus run of this PR against I read the translator diff and it looks right to me. One question for the contract row: at run time, BORDER_COLOR_TYPE 3 (table) falls back to transparent black. Should AI-assisted. No GPU run from me; your |
…roximations (SHADER-348) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @throny, 16/16 is what I hoped for. On your question: the row did say it ("Type 3 … is |
|
Thanks for the recount. Yes: 4833961 (now the head) says it in AI-assisted. |
|
Independent Radeon verification (AI-assisted, Codex) at On Windows 11 with a Ryzen 7 9800X3D Radeon iGPU (AMD driver 25.10.30.02), stock These are single-mip UNORM GPU fixtures. The Radeon result adds a second vendor to the author's RTX 4070 SUPER test and complements the separate 16-shader corpus recount. |
Flyander
left a comment
There was a problem hiding this comment.
Border taps do not apply Vulkan format component substitution to border colors. For R8, alpha gather with transparent black should return 1 after substitution, but this path selects 0; with opaque white, missing G should return 0, but this path selects 1. Please apply format-specific border component replacement, then missing-component substitution, before selecting the gather channel. Khronos spec: https://docs.vulkan.org/spec/latest/chapters/textures.html
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested be94645, Fedora 44, llvm-mc 22.1.8, NVIDIA RTX 4070 (driver 620.70.06):
So the corpus is back to 26,503 / 26,503. I re-translated only the 16 rejected shaders with this branch, not the whole corpus. AI-assisted (Claude Code). |
|
Tested 4833961 on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18), llvm-mc 23.1.5, SPIRV-Tools v2026.4: pass, with my own 1.0.2.1 copy (counts only). This is the "32-wide GPU; game copy" check from the coordination list. Corpus. A full
Repository suite, native build of runtime/ from this head:
Not covered here: whether the border colour the 16 shaders get matches the console (that needs their output, not their validity), and an AMD device. AI-assisted run (Claude). Counts only; nothing from the game leaves this machine. |
|
Tested
The new No game files. AI-assisted (Claude Code). 🤖 Generated with Claude Code |
|
Full-corpus counts from my own Xbox Series 1.0.2.1 copy (
That's the same 16 shaders as @throny's recount, and no shader that translated before is lost. AI-assisted. |
|
@Flyander thanks, you're right. Fixed in ba3aca5. A border tap now takes the border colour only for channels the texture's format has. The format is the T# FORMAT, word 1 [28:20], with its component count from the translator's I used the format rather than the T#'s DST_SEL because the emulation's other taps are Vulkan fetches through the view, so the border taps should match them. Tests (RTX 4070 SUPER, driver 621.01, Windows 11):
AI-assisted (Claude Code). |
|
Tested
Note: this and #2144 (SHADER-369, which replaces |
SHADER-348, claimed: #1902 (comment)
Found by @throny (finding); exposed by #1567.
What and why
Since #1567 tracks
s_mov_b64/s_movk_i32/SGPR copies, the S# word 0 of 16 corpus gathers is a literal, and the literal path refused CLAMP mode 6 (clamp border) withUnsupported: image_gather4_l address mode 6 (border). Before #1567 the same S# went down the run-time path, which treated modes 4..7 as clamp-to-edge. Following "fix, don't disable", this adds the border-colour rule instead of restoring the approximation.In the
image_gather4_l(_o)emulation (fourOpImageFetchin gather order):[0, n-1]on either axis takes the S# border colour's channel instead of the fetched texel. Mode 7 is mirror once in range.BORDER_COLOR_TYPE= S# word 3 [31:30] (Mesagfx10-rsrc.jsonSQ_IMG_SAMP_WORD3; valuesSQ_TEX_BORDER_COLOR_*ingfx6.json): 0 transparent black, 1 opaque black (alpha 1), 2 opaque white. An integer format gets 1, as Vulkan'sINT_OPAQUE_*.BORDER_COLOR_PTR) isUnsupportedon a literal S# and transparent black at run time.Unsupportedon a literal S# and clamp-to-edge at run time (not in the corpus), andFORCE_UNNORMALIZEDis unchanged.One thing worth knowing: llvm-mc prints a word 3 of exactly
0x40000000/0x80000000/0xC0000000as the inline floats 2.0/-2.0/-2.0, whichsgpr_immdoesn't record, so those S#s take the run-time path. That path gives the right colour; only the table case differs (transparent black instead ofUnsupported).Tests
runtime/test/shaders/ps_gather_border.asm, incheck.py'sTEXTURE_CONSTANTS(soscripts/run_gpu_tests.pyruns it too), with expected values derived by hand in its header. It has four cases: modes 6/6 literal (opaque white, R and G), modes 7/7 at run time (opaque white, a mirrored tap that lands outside), and modes 6/6 at run time (transparent black). Clamp-to-edge would give a different value in every case.vk_texture_test vs_ids.spv ps_gather_border.spv … 0 92 c00000 14500000 0gives all 4096 pixels = (32776, 34935, 34680, 28679) as expected.ps_gather_wrapstill passes there.tests/test_translate.py):test_gather4_l_literal_border_mode_selects_the_border_colourcovers modes 6/7 on each axis × transparent black, opaque black (R and A) and opaque white. Also..._border_colour_from_the_table_is_unsupportedand..._run_time_sampler_reads_the_border_type_from_word3. The old "border is Unsupported" test now covers half-border andFORCE_UNNORMALIZEDonly, and the run-time mode test counts the range checks.python -m pytest tests/test_translate.py: 500 passed, 2 skipped (llvm-mc 21.1.8, SPIRV-Tools from Vulkan SDK 1.4.363.1)python -m unittest discover -s tests/semantic: 1644 OKpython -I tests/test_run_gpu_tests.pyOK;compileallandmake_game.py --helpOKdocs/design.md"Other additions" row: the rule, its sources and the GPU check.I don't have the game, so I couldn't recount the corpus. @throny, your watch should show 26,503/26,503 again with this; I'd appreciate a count.
AI-assisted (Claude Code). No game files used.
🤖 Generated with Claude Code