GPU: 1D textures are 2D on the host, one texel high (GBV id=940) #1727

Open
github-bot wants to merge 1 commit from github-bot/gh-1727 into main AGit
Owner

@⁠Bullet18x on GitHub · 2026-11-24 21:25 UTC · original
Bullet18x:fix/1d-textures-as-2d → main · +231 −18 · 4 files · 1 commits · open

Fixes #1714 . The SRV case #205 left open: real 1D textures sampled by 2D image instructions.

What changes

  • victory-gpu/src/resource.rs: host_dimension(); host_texture makes a title TEXTURE1D (1D array) a TEXTURE2D (2D array) of height 1. Uploads already take their footprints from the host texture, so they are unchanged.
  • victory-gpu/src/descriptor/host.rs: srv_desc / uav_desc turn the title's 1D and 1D-array views into the 2D forms (the SRV clamp moves past PlaneSlice; UAVs gain PlaneSlice 0); null_uav_desc (#205) makes 1D / 1D-array nulls 2D / 2D array; null_like follows through srv_desc.
  • victory-shader/src/emit/lower.rs: image() declares 1D / 1D-array images as 2D / 2D array and inserts y = 0 into the coordinates (atomics, stores, loads, samples, gradients and offsets get 0 for y); addresses are still read in the console's 1D order, so lod, bias, compare, gradients and offsets are untouched. image_get_resinfo and descriptor_data read a 1D array's layers from the third place.

Tests

  • descriptor::host::tests::one_d_shader_views_become_2d_views, one_d_unordered_views_become_2d_views: field-by-field conversion; 2D and buffer views unchanged.
  • descriptor::host::tests::one_d_texture_is_a_2d_host_texture_its_1d_view_fits: a 16x1 2D texture on the device takes the title's 1D view.
  • emit::waterfall_tests::a_1d_sample_reads_the_one_texel_high_2d_texture: WATERFALL_INDEXED_WAVE32 with its image_sample_lz switched to dim:SQ_RSRC_IMG_1D, validated by dxil.dll and run on hardware and WARP. Without the lower.rs change it fails on the RTX 5090: every lane reads 0.0 (a Texture1D declaration reading a 2D view).
  • null_uavs_keep_the_titles_dimension updated (1D → 2D, 1D array → 2D array).

Tested (RTX 5090, driver 621.40, Ryzen 9 9950X3D, Windows 11 Pro 10.0.28000, Rust 1.98.1, on main ffe310e)

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
  • cargo test --workspace --locked --no-fail-fast: 346 passed, 0 failed, 6 ignored (main: 342)
  • In the title, diag build, VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1, menus, same timeline on both: main 5× id=940 (first ~53 s in); this branch 0× id=940, no GPU-based validation message at all in 76 s.

Not tested: AMD / Intel GPUs; the world (it hangs on NVIDIA either way, #1586); 1D arrays and 1D UAVs in the title (none were seen; covered by the unit tests only); the console-compiler differential tests (no console SDK here).

No game data in the change or tests. AI use: Claude Code (Claude Opus 5.5) traced the bug, wrote the change and tests and ran them; I reviewed the diff and the results.

**@⁠Bullet18x** on GitHub · 2026-11-24 21:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727) `Bullet18x:fix/1d-textures-as-2d` → `main` · +231 −18 · 4 files · 1 commits · open Fixes #1714 . The SRV case #205 left open: real 1D textures sampled by 2D image instructions. **What changes** - `victory-gpu/src/resource.rs`: `host_dimension()`; `host_texture` makes a title TEXTURE1D (1D array) a TEXTURE2D (2D array) of height 1. Uploads already take their footprints from the host texture, so they are unchanged. - `victory-gpu/src/descriptor/host.rs`: `srv_desc` / `uav_desc` turn the title's 1D and 1D-array views into the 2D forms (the SRV clamp moves past `PlaneSlice`; UAVs gain `PlaneSlice` 0); `null_uav_desc` (#205) makes 1D / 1D-array nulls 2D / 2D array; `null_like` follows through `srv_desc`. - `victory-shader/src/emit/lower.rs`: `image()` declares 1D / 1D-array images as 2D / 2D array and inserts y = 0 into the coordinates (atomics, stores, loads, samples, gradients and offsets get 0 for y); addresses are still read in the console's 1D order, so lod, bias, compare, gradients and offsets are untouched. `image_get_resinfo` and `descriptor_data` read a 1D array's layers from the third place. **Tests** - `descriptor::host::tests::one_d_shader_views_become_2d_views`, `one_d_unordered_views_become_2d_views`: field-by-field conversion; 2D and buffer views unchanged. - `descriptor::host::tests::one_d_texture_is_a_2d_host_texture_its_1d_view_fits`: a 16x1 2D texture on the device takes the title's 1D view. - `emit::waterfall_tests::a_1d_sample_reads_the_one_texel_high_2d_texture`: `WATERFALL_INDEXED_WAVE32` with its `image_sample_lz` switched to `dim:SQ_RSRC_IMG_1D`, validated by `dxil.dll` and run on hardware and WARP. **Without the `lower.rs` change it fails on the RTX 5090: every lane reads 0.0** (a Texture1D declaration reading a 2D view). - `null_uavs_keep_the_titles_dimension` updated (1D → 2D, 1D array → 2D array). **Tested** (RTX 5090, driver 621.40, Ryzen 9 9950X3D, Windows 11 Pro 10.0.28000, Rust 1.98.1, on `main` `ffe310e`) - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo test --workspace --locked --no-fail-fast`: 346 passed, 0 failed, 6 ignored (`main`: 342) - In the title, diag build, `VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1`, menus, same timeline on both: `main` 5× id=940 (first ~53 s in); this branch **0× id=940, no GPU-based validation message at all** in 76 s. **Not tested**: AMD / Intel GPUs; the world (it hangs on NVIDIA either way, #1586); 1D arrays and 1D UAVs in the title (none were seen; covered by the unit tests only); the console-compiler differential tests (no console SDK here). No game data in the change or tests. AI use: Claude Code (Claude Opus 5.5) traced the bug, wrote the change and tests and ran them; I reviewed the diff and the results.
The title makes real 1D textures (16x1 R10G10B10A2, 4096x1 R32_FLOAT,
128x1 R16G16_FLOAT in the menus) and samples some of them with 2D image
instructions, as the console hardware allows (it goes by the descriptor
and ignores the extra coordinate). D3D12 wants the shader's resource type
to match the view: GPU-based validation reported id=940 ("SRV Dimension
Expected TEXTURE2D, In Descriptor TEXTURE1D") and NVIDIA reads such a
mismatch as 0.

1D textures and 1D arrays are now 2D textures and 2D arrays on the host
(height 1); the title's 1D views (and the null ones) become 2D views of
the same mips and slices; the translation reads every 1D and 1D-array
image instruction as 2D with y = 0, the slice moving to the third
coordinate, and resinfo and descriptor reads take a 1D array's layers from
the 2D array's third place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:56 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 21:30 UTC · original

Verified head 6cd8375 on an AMD RDNA3 machine, which is a useful second vendor next to the RTX 5090 run in the PR description:

  • Windows 10 x64, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Rust 1.98.1 MSVC.
  • cargo test -p victory-gpu --locked one_d_ -- --test-threads=1 — 3 passed, 0 failed (the view conversions and the 16x1 host texture).
  • With the binary opted into Agility SDK 1.616 locally for SM 6.6: cargo test -p victory-shader --locked a_1d_sample_reads_the_one_texel_high_2d_texture -- --test-threads=1 — 1 passed on the hardware backend, 0 failed. WARP was skipped (SM 6.2 here), so this confirms the 1D-as-2D read on RDNA3 rather than only on Blackwell.

The descriptor mapping and the shader lowering both behave as described; happy to re-run if the branch moves.

**@⁠Calvix2k** on GitHub · 2026-11-24 21:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7145027374) Verified head 6cd8375 on an AMD RDNA3 machine, which is a useful second vendor next to the RTX 5090 run in the PR description: - **Windows 10 x64**, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Rust 1.98.1 MSVC. - `cargo test -p victory-gpu --locked one_d_ -- --test-threads=1` — **3 passed, 0 failed** (the view conversions and the 16x1 host texture). - With the binary opted into Agility SDK 1.616 locally for SM 6.6: `cargo test -p victory-shader --locked a_1d_sample_reads_the_one_texel_high_2d_texture -- --test-threads=1` — **1 passed on the hardware backend**, 0 failed. WARP was skipped (SM 6.2 here), so this confirms the 1D-as-2D read on RDNA3 rather than only on Blackwell. The descriptor mapping and the shader lowering both behave as described; happy to re-run if the branch moves.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 21:52 UTC · original

The new 2D host copy also needs 2D output views. At 6cd8375a23d5e5065c1a277af582f7a15a10ce13, an explicit 1D-array render-target view still described a 1D resource. The DSV path used the same unconverted dimensions.

3d4f1c8 is one commit directly on that SHA. The two new tests failed on the original head at the RTV dimension assertions. With the fix, the descriptor tests preserve mip, layer range and DSV flags. On WARP, the actual clear of layer 1, mip 1 returned four texels of [255, 128, 64, 255]. All five 1D GPU tests passed, and the full GPU suite had 58 passed and one ignored. Strict GPU Clippy and cargo xtask policy passed.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 21:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7145501701) The new 2D host copy also needs 2D output views. At `6cd8375a23d5e5065c1a277af582f7a15a10ce13`, an explicit 1D-array render-target view still described a 1D resource. The DSV path used the same unconverted dimensions. [3d4f1c8](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3d4f1c864f3deb769acbc2cf562ba870178c0a6b) is one commit directly on that SHA. The two new tests failed on the original head at the RTV dimension assertions. With the fix, the descriptor tests preserve mip, layer range and DSV flags. On WARP, the actual clear of layer 1, mip 1 returned four texels of `[255, 128, 64, 255]`. All five 1D GPU tests passed, and the full GPU suite had 58 passed and one ignored. Strict GPU Clippy and `cargo xtask policy` passed.
Author
Owner

@⁠AlanQiang0418 on GitHub · 2026-11-24 23:13 UTC · original

I checked the promoted 1D sampling path at 6cd8375 on an RTX 5080 (621.14) and Microsoft WARP. Setting a linear sampler's V address mode to BORDER exposes a difference that point sampling hides. With a transparent black border, the 32 lanes should read alternating 1.0 and 2.0. Both devices read 0.5 and 1.0 instead. The inserted normalized y = 0 lands on the edge of the single row, so half the filtered value comes from the border.

Sampling at y = 0.5 restored all 32 readbacks on both devices. Integer loads, stores, offsets and gradients keep their zero Y component. The existing 1D shader test now exercises linear filtering with a contrasting border. Cherry-pickable fix and regression

cargo test -p victory-shader --locked --lib -- --test-threads=1 passed 121 tests with one ignored. DXIL validation passed for the targeted readback. This used a synthetic 1D texture on Windows 11. Game rendering and 1D-array readbacks were outside this run. AI-assisted verification and fix.

**@⁠AlanQiang0418** on GitHub · 2026-11-24 23:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7147163544) I checked the promoted 1D sampling path at `6cd8375` on an RTX 5080 (621.14) and Microsoft WARP. Setting a linear sampler's V address mode to BORDER exposes a difference that point sampling hides. With a transparent black border, the 32 lanes should read alternating 1.0 and 2.0. Both devices read 0.5 and 1.0 instead. The inserted normalized y = 0 lands on the edge of the single row, so half the filtered value comes from the border. Sampling at y = 0.5 restored all 32 readbacks on both devices. Integer loads, stores, offsets and gradients keep their zero Y component. The existing 1D shader test now exercises linear filtering with a contrasting border. [Cherry-pickable fix and regression](https://github.com/AlanQiang0418/VIctory/commit/3e1fea71a84819ad2c36c567542dffd035572168) `cargo test -p victory-shader --locked --lib -- --test-threads=1` passed 121 tests with one ignored. DXIL validation passed for the targeted readback. This used a synthetic 1D texture on Windows 11. Game rendering and 1D-array readbacks were outside this run. AI-assisted verification and fix.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:35 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7149717921) <!-- victory-triage v1 head=6cd8375a23d5e5065c1a277af582f7a15a10ce13 verdict=needs-rebase at=2026-11-25T01:35:10Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/lower.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠AlanQiang0418 on GitHub · 2026-11-25 02:27 UTC · original

For the rebase requested above, I replayed 6cd8375 on upstream 940d32f and resolved the conflict in the image-atomic lowering. The merged code keeps the two-register old value and feature flags for 64-bit atomics from main, and uses the promoted host dimension when declaring the UAV handle.

At the second commit the 1D linear-border sampler readback and the existing 64-bit image atomic test passed on RTX 5080 (621.14) and WARP. The three 1D resource/view tests and all-targets Clippy for victory-gpu and victory-shader passed. These two commits are on my fork for you to pick up.

**@⁠AlanQiang0418** on GitHub · 2026-11-25 02:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7150741880) For the rebase requested above, I replayed `6cd8375` on upstream `940d32f` and resolved the conflict in the image-atomic lowering. The merged code keeps the two-register old value and feature flags for 64-bit atomics from main, and uses the promoted host dimension when declaring the UAV handle. - [Rebased original commit, preserving authorship](https://github.com/AlanQiang0418/VIctory/commit/67ebfb683b9cfea3fe15b90d4427de63fca1f769) - [Separate linear/border sampling fix on that base](https://github.com/AlanQiang0418/VIctory/commit/b73d735fbe4055a1e7479a052ca3570f26cfa6ec). The test now uses main's shared requirement for at least one device readback. At the second commit the 1D linear-border sampler readback and the existing 64-bit image atomic test passed on RTX 5080 (621.14) and WARP. The three 1D resource/view tests and all-targets Clippy for `victory-gpu` and `victory-shader` passed. These two commits are on my fork for you to pick up.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 21:41 UTC · original · approved these changes

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows.

1D textures become 2D host textures one texel high (GBV id=940): srv_words_2d/uav_words_2d rewrite view desc words (dimension, mip levels, array slices), with unit tests pinning the word layout and a waterfall test for the sample path. The GPU-side host texture creation is Windows-only; the shader-side view lowering is what macOS compiles. Please confirm the Windows waterfall run covers the 1D sample case.

**@⁠catminou4** on GitHub · 2026-11-24 21:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#pullrequestreview-6047861082) · **approved these changes** Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows. 1D textures become 2D host textures one texel high (GBV id=940): srv_words_2d/uav_words_2d rewrite view desc words (dimension, mip levels, array slices), with unit tests pinning the word layout and a waterfall test for the sample path. The GPU-side host texture creation is Windows-only; the shader-side view lowering is what macOS compiles. Please confirm the Windows waterfall run covers the 1D sample case.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:43 UTC · original

I tested the existing reviewer branch combined with current upstream 63bcca4. Integration 56c00cc retains both the authored 1D promotion commit and the separate center-sample fix.

On the integrated tree, changing only the normalized sample Y back to zero reproduced the linear-border result on WARP across all 32 lanes: [0.5, 1.0, ...]. With the original center-sample fix restored, the exact same test reads [1.0, 2.0, ...].

  • WARP 1.0.22 with app-local Agility 1.620.2: all six waterfall tests and three GPU 1D resource/SRV/UAV tests passed.
  • The 64-bit image atomic test, all 33 lowerer tests, strict GPU and shader Clippy, and policy passed.

The integration is available for the existing PR. If you take it, please retain both contributor commits and their Git authors. If you fold the integration work into a different commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1727#issuecomment-7193756789) I tested the existing [reviewer branch](https://github.com/AlanQiang0418/VIctory/commit/b73d735fbe4055a1e7479a052ca3570f26cfa6ec) combined with current upstream `63bcca4`. [Integration `56c00cc`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/56c00cc32dfc54112e639077b4fbfebe7d8d81aa) retains both the authored 1D promotion commit and the separate center-sample fix. On the integrated tree, changing only the normalized sample Y back to zero reproduced the linear-border result on WARP across all 32 lanes: `[0.5, 1.0, ...]`. With the original center-sample fix restored, the exact same test reads `[1.0, 2.0, ...]`. - WARP 1.0.22 with app-local Agility 1.620.2: all six waterfall tests and three GPU 1D resource/SRV/UAV tests passed. - The 64-bit image atomic test, all 33 lowerer tests, strict GPU and shader Clippy, and policy passed. The integration is available for the existing PR. If you take it, please retain both contributor commits and their Git authors. If you fold the integration work into a different commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1727/head:github-bot/gh-1727'
git switch 'github-bot/gh-1727'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1727'
git switch 'github-bot/gh-1727'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1727'
git switch 'github-bot/gh-1727'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1727'
git switch 'main'
git merge --squash 'github-bot/gh-1727'
git switch 'main'
git merge --ff-only 'github-bot/gh-1727'
git switch 'main'
git merge 'github-bot/gh-1727'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1727
No description provided.