startup-runtime: dynamically indexed sampler and resource heap loads #1143
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1143
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?
@denn0x on GitHub · 2026-11-24 01:45 UTC · original
Problem
Shaders that load a sampler descriptor from the sampler heap with a register offset (not a constant) currently get a
default sampler (recorded in
pipe.notes). Dynamic resource heap indexing has the same gap.Done when
The translator emits
SamplerDescriptorHeap[...]/ResourceDescriptorHeap[...]style access (SM 6.6) or anequivalent, with a fixture, and the default-sampler shortcut is removed.
Context:
docs/startup-runtime.md(#1135). Do not attach game files, dumps or logs that contain addresses or names from an executable; describe results in terms of the component tested.AI-assisted (Claude Code).
@mumba17 on GitHub · 2026-11-24 02:12 UTC · original
I'll take this one. No other claim or open PR on it as of 02:30Z.
tools/startup/gfx2hlsl.py, translate a sampler or resource descriptor load whose heap offset is a register (not a constant) into SM 6.6SamplerDescriptorHeap[...]/ResourceDescriptorHeap[...]access. The index comes from the register value and the descriptor stride. The default-sampler shortcut inpipe.notesis removed for the cases this covers.main, or stacked on it if you prefer that.AI-assisted (Claude Code).
@Jess-Doit on GitHub · 2026-11-24 02:23 UTC · original
I’ll take a source-built desktop check for the sampler half of #1143 (Refs #874). From current main, I’ll bind two distinguishable samplers in one shader-visible descriptor table and select between them at runtime in a
cs_6_0shader. I’ll keep the table and texture fixed, compare exact readbacks on the GTX 1060 and Windows 10 in-box WARP, and force index zero as a control that must lose the index-one result.This measures bounded dynamic sampler selection with the existing desktop runtime and can proceed independently of #1135. It complements #1109’s descriptor table fixture and #1121’s sampler field checks. The startup translator and dynamic resource heap indexing remain follow-ups.
AI-assisted (Codex).
@R0Y00 on GitHub · 2026-11-24 02:34 UTC · original
The isolated fixed-table check in #1166 already covers distinguishable ordinary and comparison samplers and independent table swaps. Please compare against it before adding a second fixture. A runtime-supplied shader index with a forced-zero counterexample, or an independent GTX 1060/Windows 10 result, would add evidence. The startup translator change can proceed separately with SM 6.6 heap indexing.
@Jess-Doit on GitHub · 2026-11-24 03:50 UTC · original
I'll take the translator half of #1143, sampler heap only; resource-heap indexing stays open. #1192 (Codex) covers the desktop check: a bounded sampler table indexed at run time from a root constant, at SM 6.0 on a GTX 1060 and in-box WARP. This builds on it.
tools/startup/gfx2hlsl.py, ans_loadfrom the sampler heap with a register offset becomes a boundedSamplerStatearray indexed byoffset / 16, instead of the fixed default sampler. The manifest gets a line naming the heap source and range, so the runtime can bind a matching table. The default-sampler shortcut and itspipe.notesentry go.llvm-mc. Its pixel stage loads its sampler through a register offset into the sampler heap. Translated HLSL compiles with FXC (ps_5_1) and DXC. A desktop readback, with the table filled from two distinguishable sampler words, gives the index-0 and index-1 results on the GTX 1060 and WARP. Controls: a constant offset still produces a static sampler, and a mutation that drops the index must fail.AI-assisted (Claude Code).
@Jess-Doit on GitHub · 2026-11-24 04:17 UTC · original
I'll take the stand-in sampler binding for #1143, stacked on #1217. A
smpheap 2048 1manifest will add a sampler table ats0, space1alongside the static samplers. The draw path will track the bound sampler heap, decode its readable 16-byte entries with the existing sampler decoder, and use a valid fallback descriptor and a named null-sampler count for unreadable entries. Each recorded sampler heap will stay alive through queue completion.I'll reuse #1217's source-built shaders and offscreen readback on the GTX 1060 and Windows 10 in-box WARP. The fixture will use the same manifest, root-signature and sampler-population code as the stand-in, with generated wrap and clamp entries and a guarded unreadable entry. I'll also check a manifest with only static samplers. This keeps sampler-heap translation opt-in.
AI-assisted (Codex).
@Jess-Doit on GitHub · 2026-11-24 04:53 UTC · original
@mumba17, apologies: I missed your 02:12 claim on this issue when I claimed the translator half at 04:17. Since then #1217 (
gfx2hlsl) and #1237 (stand-in binding, stacked on #1217) have gone up and overlap your scope. Here is how they differ, so we can fit them together rather than duplicate:SamplerState qh[2048] : register(s0, space1)table, guarded in the shader (offset / 16, with entry 2047 as the fallback for unaligned or out-of-range offsets). It compiles with FXCps_5_1and DXCps_6_0, so it runs where SM 6.6SamplerDescriptorHeap[...]isn't available. It's opt-in (X2W_SAMPLER_HEAP=1), and the default output is unchanged.Your SM 6.6 path would be the natural default on adapters and runtimes that support it, with this table as the fallback. Or, if you're far along on the sampler side and would rather it go one way, tell me and I'll close #1217/#1237 or rework them around your PR. Either is fine with me; I just don't want us both landing the same thing.
AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-24 05:02 UTC · original
The opt-in sampler table and its stand-in binding are now on main via #1217 and #1237 (
fa414483), including the 16-byte wrapped descriptor stride and the rebind control. The latter was independently retested in Windows Release: 14/14 passed across RTX 4060 Laptop and WARP, including descriptor-paging and stream regressions. Resource-heap indexing and any separate SM 6.6 contribution stay open under the existing claim here.@denn0x on GitHub · 2026-11-24 13:48 UTC · original
Compute data point for this issue. Measured on the 349 gfx1013 compute programs the executable created in one run past start-up, and on the 627 dispatches of one busy frame after loading.
s_load_dwordx4/x8 sD, s[heap], sOff. That is an image or buffer descriptor loaded from the resource heap pointer at a register offset. It is the second-largest compute stop after DPP (#1543).A per-dispatch lowering would cover these without SM 6.6: resolve the offset at record time from the bound root constants or table words, and bind the descriptor it names as an ordinary SRV/UAV.
ResourceDescriptorHeap[]stays the general fallback.Related: #1541 (LDS), #1542 (formatted stores), #1544 (entry layout), #1545 (image stores and atomics), #1546 (small ALU).
AI-assisted (Claude Code).
@triggered02 on GitHub · 2026-11-26 03:21 UTC · original
Splitting this into its two halves, since one is done on main and the other is not:
Sampler-heap indexing � done. main has the opt-in X2W_SAMPLER_HEAP=1 table ( ools/startup/gfx2hlsl.py: pipe.uses_sampler_heap, the SamplerState qh[SAMPLER_HEAP_SIZE] : register(s0, space1) binding, the 16-byte wrapped descriptor stride and the rebind control from #1217/#1237). Without the switch, a dynamic sampler index is still replaced by a default sampler and recorded in pipe.notes ("dynamic sampler index replaced by a default sampler"), which is the documented fallback rather than silent behavior.
Resource-heap indexing � still open, exactly as you measured. main has no ResourceDescriptorHeap[...] (or equivalent) access: grepping the translator for ResourceDescriptorHeap returns nothing. So your 47 compute programs stopping at s_load_dwordx4/x8 sD, s[heap], sOff (49 dispatches in the busy frame) are still stopped, and they are the largest remaining compute stop after DPP.
The part of your data that would move this: whether the offset register is uniform per dispatch (root constant or a dword from a descriptor table) decides between a bounded-table lowering and a genuinely dynamic one. If you can capture the source of that register for even a few of the 47 programs, that is the next concrete step; a bounded table indexed by a uniform offset is the cheaper of the two to land.
@lambirou on GitHub · 2026-11-26 10:49 UTC · original
Resource-heap offset uniformity on the cached compute corpus
I measured the source of the register offset behind
s_load_dwordx4 sD, s[heap], sOffon the 2,689 cached compute requests. The cache was produced at shader revision 17; loading it with the current tree (revision 27) needs the revision-17 key, which is only a name check.0x400)The one clean sample is
003d3bc18a4f7f5b(root0x400, resource heap ins[10:11]). Both heap loads have dispatch-uniform offsets:That first load is already lowered by the Python frontend's
heap_record(the manifest names the table, byte and root constant). The second site (0x284) uses the same shape but loses the('rc', …)mark at the firsts_cbranch_execz, so its index becomes an unnameable('buffer',)and the request stops there.So in this sample the answer to the first-step question is uniform per dispatch, not per lane: a root constant times a literal plus a literal, read as a word from a descriptor table, then shifted by five. Nothing here requires a truly dynamic index.
I am not proposing a Python-translator PR while the frontend is moving to the native C++ path. If the 676-request scalar descriptor-load cohort in #870 is the same class, this trace may be useful as a source-of-offset data point; I can run the same producer trace over the
compile_dxilcohort if you want it.