Skip to content

feat(shader): accept the dlc cache bit on MIMG - #497

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/mimg-dlc
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/mimg-dlc

Conversation

@adriadam10

@adriadam10 adriadam10 commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

What

MIMG instructions other than the atomics now accept the dlc cache bit (word0 bit 7): loads, stores, sample, gather, resinfo. Before this, the decoder threw unsupported or reserved MIMG control bits on any MIMG instruction with dlc set. The modifier sweep over decoded opcodes found it. glc and slc on MIMG already pass on main.

dlc is the RDNA device-level cache policy bit. On image loads, stores and sampling it changes no result, so the decoder only stops rejecting it there and records it in instruction.dlc, as FLAT/MUBUF do. Image atomics with dlc still throw (see below). The other reserved bits (word0 bits 6, 14, 16 and 17, plus bit 12 on sample and gather ops; word1 bits 26-29) still throw.

Encoding checked with llvm-mc -mcpu=gfx1013 -show-encoding: image_load ... dlc = 0xf0000f80 (bit 7), image_sample ... dlc = 0xf0800f80.

Behaviour measured on HW

The two test kernels ran on a Radeon 660M (gfx1035, same MIMG encoding as gfx1013) over 32 lanes:

  • R32_UINT 2D storage image: image_store with dlc and with glc slc dlc, each read back through a returning atomic. Edge rows: 0, 1, 5, 0x7fffffff, 0x80000000, 0xffffffff.
  • R32_FLOAT 64x2 sampled image: image_sample with dlc and with glc slc dlc, image_gather4 dlc, image_get_resinfo dlc, image_sample_l dlc and image_load dlc.

All rows match a model where dlc changes nothing, with the texture in fine-grained and in coarse-grained GPU memory.

Image atomics with dlc depend on the memory: on fine-grained memory they apply normally, but on coarse-grained memory (VRAM) image_atomic_{add,swap,cmpswap,smax} with dlc and without slc are dropped (memory unchanged, wrong return), while slc dlc applies. Buffer and global atomics with dlc apply on both. The PS5's gfx1013 can't be measured here, so the decoder keeps refusing dlc on the image atomics.

Tested

Arch Linux, RADV (Radeon 660M) plus lavapipe (local Mesa and the CI version, Ubuntu Mesa 25.2.8). New execution test ImageCacheBits runs the same two kernels and compares every result with the HW rows, then checks that image_atomic_add glc dlc, image_atomic_swap dlc and image_atomic_cmpswap glc dlc are refused.

Negative checks: putting dlc back into either reserved mask (sample/gather or loads/stores) makes the test fail with the old decoder error; dropping it from the atomic mask makes the refusal check fail.
Full Release build plus ctest: everything passes except agc_driver_pixel_helper_lanes, which also fails on main on local RADV since #305.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 4, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator Author

Rebased on current main, and one change found while measuring the float image atomics: on the HW, image atomics with dlc (and no slc) are dropped when the texture is in coarse-grained GPU memory; my first measurement only covered fine-grained memory. dlc on MIMG atomics now keeps throwing, and the test checks that refusal. Loads, stores and sampling with dlc were re-measured on coarse-grained memory too and are unchanged. Description updated.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. The masks are right: llvm-mc puts MIMG dlc at word0 bit 7, so dropping 0x80 from the load/store and sample/gather masks while keeping it in the atomic mask does what the description says. Bits 6, 14, 16 and 17 (plus bit 12 on sample and gather) still throw. I disassembled the two test kernels and the three refused atomics with llvm-mc and they are the forms the description lists. Keeping dlc refused on image atomics is the safe call, given the coarse-grained result.

Setting instruction.dlc is only bookkeeping for images: the image translation doesn't read the MIMG cache bits (imageGlc/imageSlc have no users either), so no result changes. That matches the measurement.

agc_driver_image_cache_bits passes on my machine at this head. With only the test file on main's code it fails at the first image_store ... dlc ("unsupported or reserved MIMG control bits (words f0200188 00020408)"). None of my PPSA21564 shader dumps uses dlc on MIMG, so this doesn't change my runs.

@oneandonlydean
oneandonlydean merged commit d4c1bca into boykopovar:main Oct 4, 2026
3 checks passed
@adriadam10
adriadam10 deleted the feat/mimg-dlc branch October 5, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants