Skip to content

Shaders: load D16 integer textures with their bound component type - #2125

Open
AlanQiang0418 wants to merge 5 commits into
Marvisak:mainfrom
AlanQiang0418:codex/d16-runtime-integer-load
Open

AlanQiang0418 wants to merge 5 commits into
Marvisak:mainfrom
AlanQiang0418:codex/d16-runtime-integer-load

Conversation

@AlanQiang0418

Copy link
Copy Markdown
Contributor

Addresses the D16 integer texture load case in #2087. Thanks to Speartone for the experimental patch and synthetic reproduction.

Depends on #2030 for the view-format table. This draft targets upstream main. The #2087-only diff shows the change on top of that dependency.

Changes

  • Record the effective UINT or SINT texture view format in the existing per-slot table. For D16 image_load and image_load_mip, select a matching typed DXIL load before reading the texture.
  • Pack integer channels into their 16-bit results, saturating 32-bit channels to the signed or unsigned range. Floating-point and normalized loads retain Shaders: round D16 image reads according to the bound texture format #2030's conversion rules.

Validation

  • On RTX 5080 and WARP, one shader switched between six typed RGBA integer textures (8/16/32-bit UINT and SINT) and an FP32 subnormal control. All readbacks matched, including signed and unsigned saturation cases.
  • victory-shader D16 tests passed (5/5), including the existing normalized and sampling regressions. The victory-gpu draw tests passed (6/6 per backend), including descriptor reuse. Clippy passed for both crates with all targets and features.

AI-assisted with OpenAI Codex. All test data is synthetic.

AlanQiang0418 and others added 5 commits November 24, 2026 22:42
legacyF32ToF16 truncates on Windows but rounds to nearest under vkd3d-proton on an RTX 5080, where the FLOAT control of d16_image_load_rounds_normalized_texels_to_nearest failed on all 256 texels. f16_toward_zero gives the same result for either rounding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 980acd1)
@AlanQiang0418
AlanQiang0418 marked this pull request as ready for review November 25, 2026 05:46
@fiestorra

Copy link
Copy Markdown
Contributor

The dependency is not pending: this branch already contains all of #2030, so the two cannot both land

The description says "depends on #2030 for the view-format table" and links a #2087-only diff, which reads like this needs #2030 merged first. It does not: #2125's branch carries #2030's four commits, so the table is already in it.

Checked three ways, because this decides how the pair should be merged:

#2030 head e87c4f1, 4 commits
#2125 head 3fdf5e9, 5 commits
git merge-base --is-ancestor <#2030> <#2125>   →  true

and git log origin/main..<#2125> shows five commits, of which the first four are #2030's, ending at Round D16 image reads according to the bound texture format:

3fdf5e9 Load D16 integer textures with their bound component type
e87c4f1 Require a backend to run the D16 image regressions
04f9cc5 fix(shader): truncate d16 float texels on every host
32ec0d5 Shaders: round static point D16 samples from the texel code
f6058b0 Round D16 image reads according to the bound texture format

What that means for landing them:

I would take the first: the four commits are ready (#2030 is not a draft), and a branch that contains its dependency is easier to review than a queue that has to be merged in order — but the description has to say so, or the maintainer will merge #2030 first and wonder why #2125's diff looks like it contains it.

What I measured on this branch, for the record:

  • it applies to main 940d32f alone and builds;
  • cargo test -p victory-shader --locked --lib 250 passed, 3 ignored (two more tests than main, which is the D16 regression work);
  • the offline census is unchanged: 23,918 validated of 26,084 programs, the same classes as main (23,918 / 871 Flags must match usage / 195 SGPR addresses / …). That is expected for a rounding fix — it changes what the loaded value is, not whether the module validates — and it means this pull request's evidence has to be the pixel or the synthetic reproduction, which the description does provide.

One small thing I could not check: the #2087-only diff they link is against their own tree, and I did not try to construct a #2125-without-#2030 build. If the split matters to them, that build is the thing to test, not this one.

No game data is involved: commit ids, test counts and census counts.

Written with an AI assistant.

@catminou4 catminou4 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.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. D16 integer textures loaded with their bound component type — format-aware D16 integer loads; mixed gpu+shader.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib d16 — 5 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean handling of D16 integer texture loads according to their bound component type via the sideband view table, verified on RTX 5090 + WARP. Looks great.

AI-assisted (Gemini 4 Neon).

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I ran the five existing D16 checks on WARP at 3fdf5e9. All five passed. I also checked an explicit image_load_mip at level 1, with different texels at level 0 so reading the wrong level would fail.

The same two integer fixtures ran against e87c4f1f03ec92794c3008a75c8ef0371b70cf87 and 3fdf5e94d347e3513e7c8abf19704e8128ee65ef. Before, all 32 integer texels were wrong in each of six UINT/SINT formats on both load paths. With this PR, all matched, including signed and unsigned saturation. The FP32 subnormal control passed in both builds. The full shader run went from 246 passed / 5 failed / 3 ignored to 248 passed / 3 failed / 3 ignored, with the same three existing WARP failures in gather, lane permute, and edge-flagged triangles.

The test-only commit is directly on this PR's current HEAD. Strict shader Clippy and the staged asset policy passed. If you include it, please preserve its Git author. If you fold it into your own commit, please add:

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 3fdf5e9 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/descriptor/host.rs, crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/shader.rs, crates/victory-shader/src/emit/stride_tests.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I found a native RDNA2 measurement for the saturation question in the triage comment. The gfx1036 probe and measured results assemble the image instructions into AMD code objects and dispatch them via HIP on a Ryzen 7 7800X3D iGPU. The full-width loads check the staged texels. The D16 cases then compare the same texels against three candidate rules.

For R32 and R32G32 UINT/SINT, every measured out-of-range value followed unsigned or signed saturation, including cases that distinguish it from taking the low 16 bits. The report covers 1D, 2D, 2D array and 3D on both image_load and image_load_mip (mip 0). This is evidence from desktop RDNA2 silicon for the conversion rule. AMD RDNA2 ISA §8.2.1 specifies format-directed D16 conversion and packing.

The WARP test above separately exercises VIctory's explicit nonzero mip path. The branch still depends on #2030.

If you fold in the offered VIctory regression instead of cherry-picking it, please keep its attribution:

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

AI-assisted. Synthetic evidence only.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I resolved the current-main conflicts on top of the published #2030 integration. The branch keeps 3fdf5e9 and 190dd03 as exact parents of 6597d37, with upstream 63bcca4 in the history. Texture format tags use the three texture bits already reserved by #2030, so the integer-buffer flags and stride calculation from main stay intact. Tested branch

I ran the existing integer fixture on 190dd03 with just the test and its format-tag setup added. All 192 integer texels disagreed with the expected result. On 6597d37, all 192 matched across RGBA8, RGBA16, and RGBA32 UINT/SINT. The FP32 subnormal control passed in both runs. These results are from WARP 1.0.22 with Agility 1.620.2.

All eight D16 tests passed, including the normalized reads, point/linear samples, and typed-buffer controls. All 21 draw tests passed, including descriptor slot reuse. The full GPU suite had 247 passed, 0 failed, and 1 ignored. Strict Clippy in both feature configurations and the asset policy passed.

If you use the merge resolution, please retain the original commits and Git authors. If the resolution is folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>. AI-assisted with Codex.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants