shader: make compile_dxil consume startup requests and publish runtime cache entries #2933
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#2933
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?
@sydney-0o on GitHub · 2026-11-26 21:59 UTC · original
Target branch:
cpp-migrationProblem
The startup runtime and its cache tools use revision 28 keys for graphics and compute requests. The C++ reader in
compile_dxil --requestsstill validates revision 14 keys. Graphics requests with existing ASCII.psinmetadata also differ from the native reader's 12-byte binary pixel-entry record. Updating the revision string alone does not align the input and hash formats.The batch CLI writes
req_<key>.csofor compute andreq_<key>.vs.cso/req_<key>.ps.csofor a graphics pair. The runtime looks for<key>.cs.csoor<key>.vs.cso/<key>.ps.csoand a matching<key>.txtmanifest.This was found by source inspection at
7f951fd3. Runtime key writer and graphics cache loader · C++ request reader · Batch CLIDone when
.psinmetadata and a source-built.c67compute request use the current startup request format and keys. Both compile throughcompile_dxil --requestswith the relevant native profile.A simple VS/PS pair is sufficient for the graphics check. Cross-quad WQM and EXECZ behavior is tracked in #2907.
@consolelogkyo on GitHub · 2026-11-26 22:17 UTC · original
Claiming #2933 on
cpp-migration.10.0.26100), MSVC 19.44, Windows SDK10.0.26100.0DXC, AMD Radeon RX 9070 XT (1002:7550, driver32.0.32029.2010) + Microsoft WARP (1414:008c), D3D12 debug layer enabled.src/shader_compute_request.cpp/direct_compute_cache.cppwith the startup runtime's revision-28 graphics (x2w-startup-shader-28+ optional ASCIIpsin1 <key> ena=0x... addr=0x...inreq_<key>.psin) and compute (x2w-startup-shader-28csover.c67,.data,.root,.desc,.sa,.sb) request formats and keys, rejecting key mismatches or stale/malformed.psinfiles without publishing a loadable entry.compile_dxil --requests(tools/startup/compile_dxil.cpp) to publish<key>.cs.csoor<key>.vs.cso/<key>.ps.csoand atomically publish the matching<key>.txtx2w-manifestlast in the format expected by the startup runtime cache loaders (d3d12_draw.inl/d3d12_compute_dispatch.inl)..psin) and compute (.c67) batch publication, runtime cache acceptance without renaming, and mismatched-key / stale-.psinrefusal controls.AI-assisted.
@Not-Saii on GitHub · 2026-11-26 22:34 UTC · original
@consolelogkyo I had started reading for this before your claim landed, so here is what I found, in case it saves you the same reading. It is all from the source of
cpp-migrationate97c5c7c. Nothing was built or run, so please check each point against a build.The points that would change the plan:
psin1line does not carry (section 1)..psinpair by its key (section 3). @sydney-0o, what should "the runtime accepts the entries" mean for that pair? One reading: the stand-in accepts a pair without a description, and the.psinpair's files are checked against the loader's line forms.1. Request keys
src/startup_stubs/d3d12_draw.inl) andtools/startup/gfx2hlsl.pysrc/shader_compute_request.cpp)x2w-startup-shader-28cs, then code, data, root, desc, sa, sb, each after its length as a u64 (:495-498,compute_key):77-84). Only the string differs (-14cs).x2w-startup-shader-28, then.a,.b,.root, then.iaif there is one (:374-378). With a description,pipeline_keythen hashesb'psin1'and the two masks as little-endian u32 (gfx2hlsl.py:10950-10959).-14, then a, b, root, ia and the raw bytes of.psin(:52-56).So compute needs the revision string and nothing else. Graphics has more:
part(marker, ".psin", 12)(:51) caps the file at 12 bytes. Apsin1line is 39 bytes or more, so today it fails withmissing or oversized .psinbefore anything is hashed.psin1plus<II(ena, addr), not the bytes of the file.read_ps_inputs(gfx2hlsl.py:11355-11374) shows what to accept: the regex, the key in the line equal to the request's key, and both masks present._init_pixel_context(:10197) also refusesena & ~addr."PSI1", the address mask and an interpolant count (src/gfx1013_compute_native.cpp:1779-1786,src/direct_compute_cache.cpp:543-558).addris the mask word.enahas no place in the native stage model, and the count has no source in apsin1line.:1784-1785zeroes the whole record unless it is0x8080with count 0 or passesraw_center_inputs(:1674-1680). Two things follow::1705-1708), and it bounds thev_interpattribute (:1712). Deriving it from the pixel stage, as the highestv_interpattribute plus one, gives 0 for a stage that interpolates nothing, and the mask is then dropped. Three existing fixtures pass count 1 for such a stage:terminal-discard(tests/native_direct_container_check.py:946) and the twocenter-position-zwcases (:960-963). The other way is to treat a key-verified description as the proof that the entry layout is known, and to bound attributes by the table size of 7 (:1689). The pair linker already refuses a pixel input with no vertex output (:1812-1819).0x8003fromtests/startup_packed_position_provenance_check.pyis one such mask. For the third "Done when" item that should be a named refusal.:1780, the!rawtest). For container requests the description can only be compared with the container's ownpixel_input_address. It cannot be passed down.Every revision-14 key in the tests comes from two helpers:
write_request(tests/native_compute_clear_check.py:16) andpublish(tests/native_direct_container_check.py:167). The other native tests import them. Three call sites pass a binarypixel_entry=(:906,:946,:978).To keep this from drifting again, the fixture could take its keys from
gfx2hlsl.pipeline_keyandcompute_key(imported the waytests/startup_stream_check.pydoes), and a pure-Python check could compare the reader's two literals with the runtime's.tests/startup_gfx2hlsl_fract_check.py:166-174already pinsgfx2hlsl.pyto the runtime like that.2. Output names and the manifest
tools/startup/compile_dxil.cpp:192buildsreq_<key>.cso, and:253-256derivereq_<key>.vs.csoandreq_<key>.ps.csofrom it. The loaders read<key>.txt, then<key>.cs.cso(src/startup_stubs/d3d12_compute_dispatch.inl:75,:158) or<key>.vs.csoand<key>.ps.cso(d3d12_draw.inl:266,:353-354).What each loader needs:
d3d12_compute_dispatch.inl:87-150): first linex2w-manifest 2, second linestage cs,ud Nequal to the number ofudsrclines, and only the line forms listed there. Any other line makes the translation unavailable.smpcandsmpheapare refused by name.d3d12_draw.inl:281-347): at least oneudsrcline, because:347rejects an empty list. A pair with no root constants still needs one. Other unknown lines are ignored.create_translated_root(src/startup_stubs/translated_sampler_bindings.h:117): constants at b0, one table with t0.. followed by u0.., static samplers from s0.tests/native_recording_check.cpp:150already creates a native graphics root with it, so the native register allocation should fit.How the native result maps onto lines, as far as I traced it:
constantsblocks in order (src/gfx1013_direct_compute.inl:226-248). For a.c67request a block is a whole root parameter.udsrc n rootconst <root_parameter> <word>GraphicsConstantLayout, in parameter order (src/gfx1013_compute_native.h:77-93)offset(parameter) + wordbuffer_srvat t_isrv i buf table <root_parameter> <byte_offset>raw_buffer_uavat u_i, compute onlyuav i table <root_parameter> <byte_offset>texture_srvwithimage_dimension1 (I only checked the kind)srv i tex2d table <root_parameter> <byte_offset>samplers[i]smp, orsmplforexplicit_lod, orsmpcforcomparison, with the four wordsThe runtime binds table buffers as raw
R32_TYPELESSviews (d3d12_draw.inl:1281-1291,d3d12_compute_dispatch.inl:424,:433-439). That matches the raw native kinds only. I would refuse to publish, and name the binding, wherever no line is exact:indexed_atomic_uav, which needs two more root constants at b(register+1) (src/native_compute_pipeline.cpp:79-84);array_count > 1;pass.constants[a][b]only forb < 8and passes 0 otherwise (d3d12_draw.inl:2663);I did not trace
raw_vector_srv,byte_window_srv,heap_stride_srvorroot_buffer_srvfar enough to say whether abufline is exact for them.For the publication order,
gfx2hlsl.translate_to(gfx2hlsl.py:11186-11218) is the model: compile both stages under a staging name, withdraw the old manifest, move the stage files, then write the manifest through a temporary file. Today the graphics job writes.vs.csounder its final name before the pixel stage compiles (compile_dxil.cpp:253-256), so a pixel failure leaves half a pair, and an older manifest could pair it with an old pixel stage. On a key or description refusal,translate_requestalso removes a manifest published earlier (:11491-11495).3. Three things that shape the end-to-end fixture
.psin.cached_translationhashes a, b, root and the layout (d3d12_draw.inl:369-391). Nothing undersrc/ortools/produces a first description:shader_cache_rekey.pyonly rewrites an existing one under its new key, and the tests write theirs by hand. A key that includes the masks is therefore one the stand-in never looks up, andstartup_stream_consumercan show acceptance only for a pair without a description.startup_stream_check.container()writesXBCHwith a zero version word.read_guest_shader_containerneeds version 3 and the FSSM slot table (src/guest_shader_container.cpp:104-122), so a consumer round trip needs the containers thatnative_direct_container_check.pybuilds (vertex(),patched_pixel()).d3d12_compute_dispatch.inl:163-167), and a direct compute module declares wave size 32 (src/dxil_module.h:202-207). #2935 reports 4-lane waves on WARP, so I expectpipeline creation failedthere. The compute acceptance check then needs a_hardwarevariant with a capability skip. The graphics loader stops at the root signature, so that half can run on WARP.4. Loaded is not the same as drawn
The draw path was written for the
gfx2hlsl.pyvertex model:pipeline_forsets no input layout (d3d12_draw.inl:941-986), so a pair withvertex_fetchcannot create its PSO.basevertexentry value (:2661,:2739,:2745).rectentry value (:2660).:1741-1743), so it is refused for a 6.6 pair.A native vertex stage reads
SV_VertexIDdirectly, and its rectangle expansion is a separate.gs.csothat the loader never reads. A published native pair can therefore load and still draw wrong for a non-zero start vertex or a rectangle list. That reads to me like the "Graphics through the runtime" item of #2935 and not this issue. It may still be worth refusingvertex_fetchpairs here and saying so in the PR.AI-assisted (Claude Code).
@consolelogkyo on GitHub · 2026-11-26 23:12 UTC · original
Opened #2955 for #2933 (verified across all 40
^native_checks on WARP and AMD Radeon RX 9070 XT withX2W_D3D12_DEBUG=1). Thanks @Not-Saii for the detailed notes above — incorporated staged VS/PS bytecode publication and revision-literal pinning in the controls check as well.AI-assisted.
@MasterDomino on GitHub · 2026-11-26 23:23 UTC · original
Closed by #2955 (@consolelogkyo), merged into
cpp-migrationase3670100.compile_dxil --requestsnow reads revision-28 requests, including ASCII.psindescriptions, and publishes<key>.{cs,vs,ps}.csoplus a<key>.txtmanifest that the runtime loaders parse. Follow-ups (silent manifest refusals, buffer-array check, a sampler word-1 difference, and drawing native pairs through the runtime) are listed in the #2955 review. AI-assisted.