Request Shader Model 6.6 for non-pixel implicit texture samples #368
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!368
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-368"
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?
@lex021 on GitHub · 2026-11-24 16:43 UTC · original
lex021:pr/compute-sampling-sm66→main· +3 −0 · 1 files · 1 commits · openSummary
Select Shader Model 6.6 when a compute, mesh, or amplification shader emits an implicit-derivative texture sample. DirectX Shader Compiler rejects those operations at earlier shader models. Pixel shaders and explicit-LOD samples retain their existing profile selection.
Validation
cargo test --offline --locked -p tombox-xshader --libon Windows (116 passed, 3 ignored).@omonkeyz on GitHub · 2026-11-25 13:51 UTC · original
Thanks. Could you add an exec test showing implicit-LOD sampling in a compute shader with a 2D thread group gives the RDNA2 quad results? Without it we cannot check the quad layout.
@SchmashinPrunes on GitHub · 2026-11-25 14:53 UTC · original
@omonkeyz, I was looking through open PRs for things I could test on RDNA2 hardware and saw your request here for the quad layout. So I measured which lanes RDNA2 uses for implicit derivatives in compute. The probe ran on a gfx1036 iGPU (Ryzen 5 9600X) with ROCm/HIP and raw wave32 kernels. That's RDNA2, not the console's gfx1013.
Probe
image_sample(implicit LOD) on a 16x16 R32_FLOAT texture. It has 5 mips, point mip filter, and each texel holdsmip * 1000 + y * 16 + x, so the result shows the mip that was picked.ponly. Any thread whose result moves off mip 0 usedpfor its derivatives.v0,v1and its lane..amdhsa_system_vgpr_workitem_id 1. Every threadpwas perturbed, in u and in v.Result
Identical for all five shapes:
v0= x andv1= y. Threads go into waves in flat order, x fastest.image_sampleuses ddx = lane 1 − lane 0 and ddy = lane 2 − lane 0 for the whole quad.So in an (8,8) group, RDNA2's "vertical" neighbour of (x, y) is (x+2, y), not (x, y+1). In a D3D 2x2 quad, only the horizontal neighbours also share a hardware quad. The vertical and diagonal ones never do: that is 128 of the 192 ordered pairs in (8,8), and 32 of 48 in (4,4). (2,8) is the only shape here where the two layouts coincide.
What this means for this PR
The SM 6.6 derivatives spec (
HLSL_SM_6_6_Derivatives.mdin DirectX-Specs) uses 1D quads only when X is divisible by 4 and Y = Z = 1. For any group where X and Y are divisible by 2, it uses 2x2 quads ofSV_GroupThreadID. In that mode it also says "no relation between the values of SV_GroupIndex and the return value of WaveGetLaneIndex() should be assumed". The translator keeps[numthreads(X, Y, Z)]and setsv0..v2fromSV_GroupThreadID. So with this change, a 2D group:One way to get the RDNA2 layout: when a compute shader has an implicit-derivative sample, declare
[numthreads(X·Y·Z, 1, 1)]and rebuildv0 = i % X,v1 = (i / X) % Y,v2 = i / (X·Y)fromSV_GroupIndex. D3D's 1D quads are then exactly lanes 4k to 4k+3 in flat order. That needs X·Y·Z divisible by 4, which D3D requires too; otherwise the shader would have to be refused. The same applies to mesh and amplification shaders.For the exec test you asked for, a case that separates the two layouts: an (8,8) group sampling at u = 0.53 + 0.25·y, v = 0.53 on a 16x16 texture with 5 mips.
That result doesn't depend on coarse vs fine, which D3D leaves open for implicit samples.
If it helps, I can send a PR on top of this one with the probe (in
tools/rdna2-hwprobe/next tomip_probe.py), a compute exec harness with a bound texture (the current compute harness has none), that test, and the flattening. @lex021, if you'd rather do it in this PR, that's fine too.🤖 Generated with Claude Code
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.