Skip to content

runtime: bind 3D and 1D texture UAVs and write them in the C++ compute manifest - #2975

Open
Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:tex3d-runtime
Open

Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:tex3d-runtime

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of #2974 (steps 1 and 2). Part of #2935. Target branch main. Step 3, binding these views on the in-process native route, will be a separate pull request.

Change:

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on cpp-migration 2b678fd3 plus this commit.

  • startup_compute_dispatch_texture_hardware passed.
    • The first Dispatch publishes the request and is refused with no translation.
    • compile_dxil then writes <key>.txt with uav 0 tex3d or tex1d float table 1 64 channels 4, and <key>.cs.cso.
    • The next Dispatch matches the CPU expectation on mip one: 6,144 words for 3D and for 3D NSA, 128 for 1D.
    • The mismatched view, 3D W range and 1D mip controls are refused with the sentinels intact.
  • startup_compute_dispatch_texture_warp passed. WARP refused the PSO, so for the 3D/1D cases only the manifest was checked there.

Mutation checks, run by hand; each fails the hardware test:

  • writing a 3D UAV as tex2d in the formatter fails the manifest assertion;
  • dropping the W range check fails the texture-volume-bad-w control.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.

AI-assisted.

…e manifest (R0Y00#2974)

The stand-in's manifest reader and Dispatch path took only 2D and 2D
array output textures, so a compute program storing to a 3D or 1D image
could not run on cpp-migration. The runtime half of R0Y00#2902 (open on main)
is taken here unchanged: `uav N tex3d|tex1d float table P OFF channels
C` lines, TEXTURE3D/TEXTURE1D UAV views from the title's view record,
and the mip and W range checks, also for slot 19. For the offline route,
format_compute_runtime_manifest now writes those lines for 3D and 1D
texture UAVs, so compile_dxil publishes a manifest the runtime accepts.

AI-assisted.
@Jess-Doit

Copy link
Copy Markdown
Contributor

The view checks are scoped clearly. Please distinguish unsupported native wave-size capability from unexpected PSO failure, so a passing WARP job tells us whether the new cases actually ran. A portable shader fixture could cover the binding path independently. Ready for more review

…1D UAV fixture

After a published compute translation fails PSO creation, the stand-in
checks the adapter's wave capabilities (the same OPTIONS1 test the
native route uses) and logs "pipeline creation failed: the adapter has
no 32-lane waves" when they rule out a WaveSize(32) module. The texture
check skips the native 3D/1D dispatch cases on WARP only for that
reason; any other PSO failure fails it. Portable 3D and 1D cases
compile a cs_6_0 store with dxc and a hand-written manifest, so the
binding path is checked on WARP and hardware independently of the C++
compiler.

AI-assisted.
@Leyukaka

Copy link
Copy Markdown
Contributor Author

Thanks. Both done in the new commit.

Wave size versus PSO failure.

  • After a published compute translation fails PSO creation, the stand-in now checks the adapter's wave capabilities, with the same OPTIONS1 test the native route uses. It logs pipeline creation failed: the adapter has no 32-lane waves when they rule out a WaveSize(32) module.
  • The texture check skips the native 3D/1D dispatch cases on WARP only for that reason, and says so. A PSO failure without that label fails the check, on WARP too.
  • The manifest records no wave size, so on an adapter without 32-lane waves any PSO failure of a published translation gets that label.

Portable fixture. The 3D and 1D cases now also run with a cs_6_0 store compiled by dxc (no WaveSize) and a hand-written manifest. It uses the same uav 0 tex3d|tex1d float table 1 64 channels 4 line and the same request key. So the binding path, the mip-one readback and the mismatched-view, bad-W and bad-mip refusals run on WARP independently of the C++ compiler.

Results on an RTX 5080 and on WARP (Windows 11, DXC from the Windows SDK 10.0.26100):

Adapter Portable 3D Portable 1D Native 3D, 3D NSA, 1D
Hardware 6,144 words 128 words match, refusals as before
WARP 6,144 words 128 words skipped: "the adapter has no 32-lane waves"

A manual mutant that never names the wave reason makes the WARP check fail.

AI-assisted.

@Jess-Doit

Copy link
Copy Markdown
Contributor

The two portable shader and manifest checks passed locally. The new portable fixture covers the binding path independently of native wave size. One diagnostic issue remains. A published shader with no wave-size requirement can still get a missing-32-lane-waves label if its PSO fails on that adapter, and a failed capability query gets the same label. Please keep the generic PSO failure as the primary reason and report the observed capability separately, or limit the specific reason to shaders known to require that wave size. Ready for more review

…ility beside it

A failed published compute PSO stays "pipeline creation failed". The
stand-in adds the adapter's 32-lane wave capability as observed:
"(adapter has no 32-lane waves)" or "(adapter wave capability query
failed)". The manifest records no wave size, so the runtime does not
claim the shader needed one. Only the texture check, whose native
modules declare WaveSize(32), skips its native cases on WARP for the
no-waves observation.

AI-assisted.
@Leyukaka

Copy link
Copy Markdown
Contributor Author

Thanks, done in the new commit. I took the first option; the wave-size-specific reading now lives only in the test, which knows its modules declare WaveSize(32).

  • A failed published compute PSO keeps pipeline creation failed as the reason. The stand-in only adds the adapter's 32-lane wave capability next to it, as observed: pipeline creation failed (adapter has no 32-lane waves), or pipeline creation failed (adapter wave capability query failed) when CheckFeatureSupport fails. The manifest records no wave size, so the runtime no longer suggests that the shader needed one.
  • The texture check knows its native modules declare WaveSize(32), so it alone treats the no-waves observation as the explanation: it skips the native 3D, 3D NSA and 1D cases on WARP only for that line. A bare PSO failure or the query-failed form fails it.
  • The in-process native route is unchanged: it still refuses when the query fails or the capability is missing.

On the RTX 5080 and on WARP, the results are the same as in my last comment. With a mutant that drops the observation, the WARP check fails on the bare pipeline creation failed. I could not make CheckFeatureSupport fail on either adapter, so the query-failed form is not exercised by a test.

AI-assisted.

@Jess-Doit

Copy link
Copy Markdown
Contributor

The diagnostic finding is resolved. Five scripted checks passed, including the separate capability-query failure note. The Release dispatch checks passed on both adapters, and both portable UAV cases passed on the GTX 1060. The WARP texture failure reproduced on clean main, and the native GTX 1060 pipeline failure reproduced on the prior PR head. The isolated WARP run stalled, so it adds no coverage. Ready to merge from our side

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed e18549cafe7f9412b896fd43cf261fdc6750498a. The published PSO failure remains the primary diagnostic; the independent adapter-capability result no longer claims a wave requirement on the shader. I rebuilt startup_stream_consumer d3d12_xs_shim compile_dxil with the Release preset and ran ctest --preset release --no-tests=error --output-on-failure -R '^startup_compute_dispatch_texture_(warp|hardware)$' on Windows 11 build 26200.9974. Both CTest entries passed. WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656) each matched 6,144 portable volume words and 128 portable line words; the incompatible views left sentinels intact. RTX also matched 6,144 words each for native volume and volume NSA and 128 for native line. WARP capability-skipped those three native subcases. The texture-input check reports the D3D12 debug layer enabled with no errors on both adapters. The merge trial with cpp-migration at e0d83759 was clean, and #2993 contains this head as an ancestor.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2975 adds 3D and 1D texture UAV support to the C++ compute manifest. Good incremental work.

What works

  • Minimal diff: the direct_compute_cache.cpp switch expands the old two-case if/else to a full switch on image_dimension with default: nullopt.
  • Runtime dispatch: volume_uav_range_error() extracts 3D W-range validation into a reusable inline function.
  • ComputeTranslation struct replaces bool array with D3D12_UAV_DIMENSION uav_dimension, giving a typed discriminator.
  • Test fixture gains texture-volume, texture-line, texture-volume-bad-w, texture-line-bad-mip modes.
  • CMakeLists.txt conditionally passes compile_dxil and DXC SDK paths to the texture test when the tools exist.

Issues

  1. std::min type deduction: (std::min)(view.MipSlice, 15u) mixes UINT and unsigned int. Consider static_cast(15u) for portability.
  2. adapter_32_lane_waves() caching: ensure the static local returns a cached value rather than re-querying on every Dispatch.
  3. Stale manifest compatibility: uav_dimension defaults to UNKNOWN (zero-initialized). The dispatch path must check this field rather than array for 3D/1D dispatches.
  4. Test 3D resource: MipLevels=2, view on mip 1 where depth=3. FirstWSlice=1, WSize=~0u covers slices 1 and 2. The bad-w case uses WSize=6 which correctly triggers refusal (6 > 3-1=2).

Recommendations

  • Add comment near uav_dimension noting it replaces array.
  • Ensure adapter_32_lane_waves() caches its result.
  • Consider a one-time runtime log when tex3d/tex1d manifests are accepted.

Overall: clean, correct change. The dimension switch is easier to maintain than the previous binary condition.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2975 adds 3D and 1D texture UAV support to the C++ compute manifest.

What works

  • Minimal diff: direct_compute_cache.cpp switch replaces binary if/else with a full dimension switch, default: nullopt keeps unmapped dims refused.
  • runtime: volume_uav_range_error() extracts 3D W-range validation into a reusable inline function.
  • struct ComputeTranslation: replaces bool array with D3D12_UAV_DIMENSION uav_dimension, typed discriminator.
  • test fixture gains texture-volume, texture-line, texture-volume-bad-w, texture-line-bad-mip modes.
  • CMakeLists.txt conditionally passes compile_dxil and DXC SDK paths to texture test when tools exist.

Issues

  1. std::min type deduction: (std::min)(view.MipSlice, 15u) mixes UINT and unsigned int. Consider static_cast(15u) for portability.
  2. adapter_32_lane_waves() caching: ensure the static local returns cached value rather than re-querying each Dispatch.
  3. Stale manifest compatibility: uav_dimension defaults to UNKNOWN (zero-init). The dispatch path must check this field, not array, for tex3d/tex1d dispatches.
  4. Test resource: MipLevels=2, view on mip 1 where depth=3. FirstWSlice=1, WSize=~0u covers slices 1-2 (correct). bad-w uses WSize=6, 6 > 2 triggers refusal (correct).

Recommendations

  • Add comment near uav_dimension noting it replaces array.
  • Ensure adapter_32_lane_waves() caches its result.
  • One-time runtime log when tex3d/tex1d manifests are accepted.

Overall: clean, correct change. The dimension switch is easier to maintain.

@Leyukaka

Copy link
Copy Markdown
Contributor Author

Thanks. Answers to the three points:

  1. UINT is unsigned int in the Windows headers, so both arguments of (std::min)(view.MipSlice, 15u) have the same type.
  2. adapter_32_lane_waves() is not queried per Dispatch. It runs only after a published translation's PSO creation fails, and at most once per key on the in-process route, which tries each key once.
  3. Among output slots, uav_dimension stays UNKNOWN only for raw buffer UAVs. Both the manifest reader and the in-process route (runtime: bind table buffers, 2D texture inputs and texture outputs on the in-process compute route #2993) set a known dimension for every texture UAV slot, and the dispatch path picks the view from that field.

AI-assisted.

@MasterDomino

Copy link
Copy Markdown
Collaborator

Title-run results for e18549ca, before merging. This is not a code review; R0Y00's approval and my test results above stand. I am holding the merge on one start-up result that needs your eyes.

Setup: Windows 11 26300.9974, RX 9070 XT (driver 32.0.32029.2010), release. Each run lasts 300 s with the same scripted inputs. The shader cache is the same local rev-28 cache, copied fresh for each run.

Start-up progress is measured as file opens by the title over time. The .txt count includes requests published during the run.

Run Build Injected manifests (with tex3d/tex1d) File opens at 120 / 180 / 240 / 290 s Compute keys dispatched at the end
base e0d83759 none 5,509 / 5,568 / 5,640 / 6,371 9
default PR none 5,497 / 5,557 / 5,629 / 6,371 10
base-inject e0d83759 64 (0) 5,508 / 5,567 / 5,639 / 6,380 10
inject2 PR 64 (0) 5,500 / 5,559 / 5,631 / 6,361 9
inject-no3d PR 65 (0) 5,515 / 5,575 / 5,647 / 6,378 564
inject PR 81 (16) 5,425 / 5,425 / 5,444 / 5,444 3
inject3 PR 81 (16) 5,430 / 5,430 / 5,442 / 6,108 10
  • Default runs: this PR changes nothing in the default configuration (base vs default), and natively published manifests without 3D/1D outputs are fine on both builds.
  • The two stalled runs: both are the runs that also loaded the 16 manifests with a tex3d/tex1d output. In both, the title stops opening files at about 110 s. One run never recovers within 300 s, and the other resumes at about 250 s. Frames keep being presented at about 28 fps in every run.

What the stand-in does in the stalled runs: three pipelines now load as translated. They are the per-frame compute pipeline you described on #2974 (srv 0/1 buf, srv 2 tex2d, uav 0 tex3d float table 1 32 channels 4) and two pipelines dispatched next to it (srv 0/1 buf, uav 0 tex1d float table 1 32 channels 4). On this branch gfx2hlsl.py refuses all three with image_store on SQ_RSRC_IMG_3D/1D: only 2D images are lowered. Every one of their Dispatches is then refused: an input is in a placed buffer that does not alias title memory. So the native program never runs. On e0d83759 the same three keys are refused earlier with no translation. Both paths leave the outputs untouched as far as I can see, yet only the first one coincides with the stall.

I have not found the cause. It could be:

  • something the translated-but-refused path does that the untranslated path does not, such as resource or view creation for the 3D UAV, or state left behind;
  • timing in that refusal path;
  • something specific to these manifests.

Why I'm holding it: without this PR, compile_dxil cannot publish these manifests, so the stall cannot happen. With it, compile_dxil --requests/--watch publishing into the runtime cache reaches it. That is the workflow this PR and #2993 build on. Could you check whether the refused-after-translation path for a 3D UAV binding has a side effect the no translation path does not? With your capture, the same injection should reproduce it.

AI-assisted; the runs above were done locally, counts only.

@Leyukaka

Copy link
Copy Markdown
Contributor Author

Thanks for the runs. I compared the two paths in the stand-in at e18549ca: a key whose manifest loads and whose every Dispatch is then refused, against a key with no manifest. I found no side effect of the refusal that the title could wait on, so I cannot explain the stall yet.

The refusal path.

  • In record_translated_dispatch, the binding loop stops at the first reason. For this layout that is input 0 or 1: srv 0/1 buf table, refused by indirect_table_buffer with "an input is in a placed buffer that does not alias title memory".
  • The helpers it calls before that only read: the table record, list_upload_range, placed_buffer_range and list_copied_gpu_range.
  • The 2D input, the 3D/1D output, upload_texture, require_state, the descriptor heap writes and the Dispatch are never reached. The function returns the reason with nothing recorded on the list.
  • The stand-in keeps first_refusal, a counter, one "first refused input" log line per key and up to 16 shared "refused" lines.
  • list_dispatch discards the reason. The ExecuteIndirect caller only counts and logs it, as it does for no translation.
  • Nothing else in src/startup_stubs reads a compute key's translation state.
  • Once per key, the loaded path creates a root signature and a PSO under draw_lock.

One difference: manifest polling.

  • A key with no manifest keeps retry_manifest_at set, so it reopens <key>.txt on a Dispatch at most once per second.
  • A key whose manifest was read, usable or not, never retries. So loading manifests for those three keys removes up to one open per key per second.
  • files.txt from run.ps1 records the stand-in's own opens as well. In one of my runs, 199,667 of its 208,352 lines are NtCreateFile opens of <key>.txt in the shader cache, spread over 1,650 keys (draw and compute).

If your count includes those paths, this could account for the missing ~1 open per second between 120 and 240 s, at most. It does not explain the missing step of about 730 opens after 240 s, nor the 3 keys dispatched at the end of inject. Could you check whether your count excludes the shader cache directory? Either way, the stall needs a closer look at what the title waits for after 110 s in those runs. I will try to reproduce it with my capture.

AI-assisted.

Copy link
Copy Markdown
Contributor

I opened draft #3049 on main to combine this work with #2993, preserving your commit authorship. #2902 is already in the base, so the draft adds the C++ tex1d/tex3d manifest support and reuses the existing runtime view checks. Offline readback passed on a GTX 1080 Ti with app-local Agility SDK 1.620.2, including the bad mip, W range and mismatched-view controls. The startup stall reported here still needs a separate before/after run.

@R0Y00

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Retargeted to main. My local integration on e04217f preserves #2902, compute root SRVs and the Python-published 1D/3D fixtures while adding separate compile_dxil publication coverage. I also saw #3049, which integrates both original PRs and preserves Leyukaka's commits. I am checking it as the combined integration candidate. The original-program startup observation with injected manifests is still open. For a comparable run on current main, please report title file opens separately from shader-cache paths, and record translated/refused dispatch counts for the three keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants