Shaders: 16-bit image derivatives pack two to a dword; cd_g16 and gather4h names #69
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr--gone-20261201!69
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-69"
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?
@lcg007xd-c on GitHub · 2026-11-25 21:34 UTC · original
lcg007xd-c:fix/mimg-g16-decode→main· +100 −1 · 4 files · 2 commits · openWhat
image_addr_dwordscounted the derivatives of a_g16form (16-bit gradients) as whole dwords. For example,image_sample_d_g16on a 2D image was decoded as reading six address VGPRs, but the instruction has four (llvm-mcprintsv[0:3]). The same error hit everyd_g16variant in 2D, 3D, cube and the arrays._g16now packs the derivatives in pairs, the waya16already did. Nothing else changes.The MIMG table also gets the names LLVM uses for 0xE8–0xEF (
image_sample_cd_g16…image_sample_c_cd_cl_o_g16) and 0x61 (image_gather4h). None of them lowers yet. The lowering matches exact names, so they are refused as unsupported, and a test pins that.Today the lowering refuses
d_g16too, so the wrong count showed up only in the decodedFieldsand the SP3 text, plus the extra VGPRs the IR thought those instructions read. It matters as soon as someone lowers_g16.How it was checked
image_sample*/image_gather4*opcode in the table, in each of the dims that can be sampled (1D, 2D, 3D, cube, 1D array, 2D array), and compared the address size withllvm-mc -triple=amdgcn -mcpu=gfx1030 --disassemble. Before: 32 disagreements, all of them_g16. After: none. The MSAA dims differ for every sample form, because LLVM prints those oddly; you can't sample an MSAA image, so I left them out.g16_derivatives_pack_in_pairspins 14 of those words to LLVM's exact text, including the new names. It fails without thefields.rschange.g16_and_gather4h_forms_are_refusedchecks that the lowering returnsUnsupportedfor each of the new names and ford_g16.--target x86_64-pc-windows-msvc) pass locally.Not tested: Windows runtime, GPU, and the game. Nothing here changes generated DXIL.
Note: the Windows
checkjob fails on current main for an unrelated reason (5668b8b, missingLayout::bytes_from), which #64 fixes.🤖 Generated with Claude Code
@lmouz823-lang on GitHub · 2026-11-28 06:11 UTC · original
I can take native Windows metadata validation at exact head
14a9828e02e61bae3b460a5eb939faec283ea3a8. This follows the image-name cases recorded in #87. I will run the existing g16 text and unsupported-lowering regressions, then check focused address/register boundaries and supported dimension/flag controls through decoded fields or IR. I will report exact counts, negative controls, restored-source verification and omitted LLVM/GPU/game coverage with a minimal justified patch. AI-assisted with Codex.@lmouz823-lang on GitHub · 2026-11-28 06:21 UTC · original
Native Windows metadata and IR validation completed for exact head
14a9828e02e61bae3b460a5eb939faec283ea3a8. The existing SP3 test executes one exact test and passes, checking its 14 fixed text examples. The existingemit::lower::image::tests::g16_and_gather4h_forms_are_refusedalso executes one exact test and passes.I added one synthetic regression, 48 test-only added lines, through the normal GFX10 decode,
Instruction::fieldsandir::buildpath. It checks the contiguous address range inFields::Imageand exactly which high VGPRs the IR reads. Address registers start at v240 while data starts at v16, keeping those ranges separate.Six non-MSAA dimensions use fixed G16 dword counts, 3/4/7/5/4/5 with full-width coordinates and 3/3/6/4/3/4 with a16 coordinates. Two ordinary
image_sample_dcontrols use 2D and 3D counts 6/9 or a16 counts 3/6. Both a16 states and wave32/wave64 run for every row, giving 32 synthetic IR programs per invocation. Each program checks v240 through v255 for the precise read boundary. The encodings are hand-written from the existing MIMG encoder and opcode table.A temporary negative control drops image address reads in the IR by adding
.take(0)to its address iterator. Both original PR exact tests still pass, and the original seven IR tests also pass. The new exact test fails at the first G16 case because v240 is missing from its reads, with exit 101. After restoring that production line, I cleaned only the isolated shader-package target, confirmed a fresh 11.98-second compilation, and reran the final checks.As a separate read-only cross-check, the nine newly named forms match the names stored in #87's committed fixture at
b7104dbd13a005ff4a3942aef795d0fb7c85e15f. That fixture's SHA256 iscef83c381ac1edd37c7850143dff989563fe69d11196b7df19a9d3d5e83f2f96. This comparison uses the stored names and this head's MIMG opcode table. Local LLVM assembly or regeneration was outside the validation.Two preliminary run errors were excluded from acceptance. An incorrectly qualified Unsupported filter selected zero tests, which the runner rejected. The corrected full path above then executed one passing test. The first draft's ordinary control used opcode
0x028(image_sample_c) and failed its expected derivative count. Correcting it to0x022(image_sample_d) compiled and passed before the formal negative control. Those preliminary logs are retained separately.Environment was Windows 11, Rust 1.98.1 MSVC, the default test profile and an isolated target. Package Clippy with
--all-targets -- -D warnings, new-function rustfmt,git diff --checkand asset policy (196 files) pass. Whole-file rustfmt exits 1 on both the head and final IR source, with the same 18 existing formatting hunks after file/line headers are removed. Removing the added test reproduces the original source after newline normalization.Scope is decoding, operand metadata and SSA register reads. The original Unsupported test continues to require these G16/gather4h forms to be refused by lowering. GPU/DXIL execution, sampling correctness, actual game behavior, NSA-address variants, other platforms and the remaining shader/workspace suites remain unverified.
Reproduce after applying the attached patch.
AI assistance from Codex covered the synthetic regression, execution and this report.
Focused IR register-range regression
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.