Shaders: round D16 image reads according to the bound texture format #2030
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2030
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2030"
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?
@AlanQiang0418 on GitHub · 2026-11-25 03:43 UTC · original
AlanQiang0418:codex/d16-normalized-image-read→main· +688 −143 · 10 files · 4 commits · openFixes #2006.
Validation
On RTX 5080 (621.14) and WARP, the translated shader matched all 256 codes of each RGBA8 UNORM/SNORM format and all 65,536 codes of each RGBA16 UNORM/SNORM format. The signed FLOAT controls and filtered RGBA16_UNORM sample also passed on both backends. All six
victory-gpu::drawtests passed on each backend, including the descriptor-slot reuse regression. Clippy passed for both crates with--all-targets --all-features -- -D warnings.The RTX gather failure and two shader stride-test failures also reproduce on upstream
940d32f. The tests here use synthetic textures.AI-assisted with OpenAI Codex.
@jeremygold02 on GitHub · 2026-11-25 03:46 UTC · original
Triage verdict — Keep for #2006, tighten the test signal (
f6058b0)Evidence
Host::newfails. If hardware and WARP both fail to initialize, both tests can report success after zero dispatches. An existing test in the same file already asserts that at least one backend ran. Load test · Sample test · Existing guardChecks and limits
Next step
This verification was AI-assisted.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 03:59 UTC · original
A remaining D16 case on
f6058b0e83: a static MIN_MAG_MIP_POINT sampler selects one texel. The exact normalized-code conversion currently applies to loads and gathers, so a point SampleLevel still takes the interpolated-sample conversion and can double-round.79867f9 is one commit on that exact head. It uses the existing exact conversion for a statically known point sampler. The same WARP dispatch failed before with UNORM16 code 0xffaf returning 0x3bfe instead of 0x3bfd. After, both UNORM edge codes, the two signed SNORM edge codes and the linear interpolation control passed. The regression also requires a backend to dispatch.
Full forced-WARP shader suite: 245 passed / 4 failed / 3 ignored before, 246 / 3 / 3 after. The gather, lane-permute and edge-flagged triangle failures were present in both runs. Strict shader Clippy and asset policy passed.
@astrosteveo on GitHub · 2026-11-25 04:06 UTC · original
On Linux the FLOAT path needs one more step. RTX 5080, driver 620.73.04, Wine 11.22, vkd3d-proton 3.1,
f6058b0:d16_image_load_rounds_normalized_texels_to_nearestfails at the FLOAT control: got[bc023c02, fc007c00], want[bc013c01, fbff7bff], 256 of 256 texels.legacyF32ToF16rounds to nearest here.github.com/astrosteveo/VIctory@980acd1is one commit on your head: it uses the existingf16_toward_zero, which corrects either rounding. With it bothd16_imagetests pass here. Other uses oflegacyF32ToF16for D16 data (d16_channelsand the D16 buffer loads) may round the same way here; I did not test them.The
warpruns are not real WARP under Wine. Not tested: Windows, the title. Take it or leave it. AI-assisted (Claude).@Neins12 on GitHub · 2026-11-25 04:07 UTC · original
Review of
f6058b0(read-only: source and diff, plus a bit-exact model of the new integer path; I did not build or run it).image_norm16is exact for every 16-bit code. I modelled it op for op in Python (Round_neof |x|·max, the 65537 / 131076 +mag >> 13fixed-point expansion,FirstbitHifrom the MSB with −1 for zero, the 13-place subnormal clamp,(doubled + 1) >> 1, sign from bit 31) and compared it with exact round-to-nearest-even ofcode / (2^w − 1)using rationals:The last row matters for the WARP results in #2006, where some returned f32 values were one ULP off: re-rounding
|x|·maxto an integer absorbs that. Endpoints 0 →0x0000and 1 →0x3C00come out right, including the carry from0x7FF + 1into the exponent. As a check on the reference itself, it reproduces the issue's figures: 31,740 / 65,536 for the old toward-zero conversion and 2 / 65,536 for nearest-even of the returned f32 (which is why the 16-bit path needs the exact conversion).Things I checked that hold:
image_d16cannot hit "an image without a heap index": every texture handle comes fromShader::heap_handle, which now records kinds 1–9.heap_handleclamps the index belowHEAP_VIEWSbefore it is stored inview_index, and the table hasmax(count, HEAP_VIEWS)entries.VIEW_STRIDE_MASKkeeps buffer strides out of the three tag bits, sostride_atstill reads 0 for a tagged texture slot (covered by the updated stride test).latergets entry 0 first and its real tag when it is made for the draw, becausemade[index]stays 0.Open points:
VIEW_NORMALIZED. An sRGB read returns the linearized value, notcode / 255. #2006 only measured UNORM and SNORM, so it is unverified whether RDNA2 rounds sRGB D16 reads to nearest or toward zero. Either measure it or leave sRGB on the legacy path until it is measured.a_sampler_chosen_by_a_uniform_branch_samples_as_chosendoes.DXGI_FORMAT_A4B4G4R4_UNORM(191) is missing fromtexture_rounding.R24_UNORM_X8_TYPELESSgoes through nearest-of-f32, which is exact for 8- and 10-bit formats but has not been checked for 24 bits.Model script (
norm16_check.py, standard library only)AI-assisted (Claude Code). No game files used.
@StExpeditus on GitHub · 2026-11-25 04:14 UTC · original
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200
Environment: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 5060 Ti (driver 621.24,
32.0.16.2124) beside an Intel UHD 770 iGPU, Intel Core i5-14600K, 32 GB, Rust 1.98.1 MSVC. Branchcodex/d16-normalized-image-readatf6058b0on main940d32f. No game files; the title was not run.cargo test --workspace --locked --no-fail-fast-> 698 passed, 5 failed, 10 ignored.The PR's D16 tests pass on this hardware (and on WARP):
d16_image_load_rounds_normalized_texels_to_nearest: all 256 codes of RGBA8 UNORM and RGBA8 SNORM and all 65,536 codes of RGBA16 UNORM and RGBA16 SNORM matched on hardware and WARP.d16_image_sample_keeps_fractional_normalized_texels: the linear RGBA16_UNORM sample matched on hardware and WARP.The 5 failures are pre-existing on main (identical panics at
940d32f), all from the NVIDIA 1,000,000-view heap cap (HEAP_VIEWSis 2^21), the same limit behind #1835, #1808, #1760 and test report #1744:victory-gpudescriptor::host::tests::dynamic_slots_are_held_until_releasedheap.NumDescriptors >= HEAP_VIEWSvictory-gpumemory::tests::lists_share_a_table_and_copies_keep_their_viewsvictory-shaderemit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stridehardwarelane mismatchvictory-shaderemit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosE_INVALIDARGvictory-shaderemit::synthetic_tests::gathers_at_a_level_match_the_hardwarehardwarelane mismatchNothing introduced by this PR fails on this machine.
@upipibi on GitHub · 2026-11-25 06:33 UTC · original
Test report for
e87c4f1(the current head, after the static-point and float-truncation commits) on Ampere: NVIDIA RTX 3070, driver 616.56, Windows 11 26100, plus WARP.Tested
d16_image_load_rounds_normalized_texels_to_nearest,d16_point_and_linear_samples_round_correctlyandtexture_rounding_follows_the_view_in_a_reused_heap_slotpass on hardware and WARP. Every RGBA8/RGBA16 UNORM/SNORM code matched.cargo test -p victory-shader --locked: 246 passed, 3 failed.cargo test -p victory-gpu --locked: 141 passed, 3 failed. Five of the failures also fail onmainon this machine: twostride_testsheap-buffer reads,gathers_at_a_level_match_the_hardware, and the two NVIDIA heap-cap tests. The sixth is awatch::test that fails only in the parallel run and passes alone 3 of 3 times.1e-5,-2.9e-6,±0.75·2^-24). It passes on both backends, sof16_toward_zerotruncates subnormals here, with no flush and no round-up to 2^-24.Review points
Source::Constant) take the exact 16-bit path. A point sampler read from the heap, or aSource::Phichoice between two samplers, falls back to nearest-of-f32. That leaves 2 of 65,536 16-bit codes wrong, which may be worth a comment.A4B4G4R4_UNORMis missing fromtexture_rounding.cargo check -p victory-shader --testspasses). Those change onlyd16_channels. #1940'snorm_f16andimage_norm16here do the same exact conversion, so whichever lands second could reuse the other.AI-assisted (Claude Code); runs on the machine above.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 06:55 UTC · original
@upipibi I reproduced the immediate-sampler control-flow case on
e87c4f1f03. A guest shader selects point or linear sampling by workgroup. On WARP the point arm returned 0x3bfe for UNORM16 code 0xffaf, where it should return 0x3bfd.734f7d6 uses the existing sampler choice to select the D16 rounding path in one commit on that exact head. The regression passes with both arm orders. Point reads back 0x3bfd and linear reads back 0x37fe. Forcing the exact texel conversion on both arms changes the linear result to 0x37ff, which the test also catches. Heap-loaded samplers still take the f32 path because their filter is runtime data.
Full forced-WARP shader suite: 246 passed, 4 failed and 3 ignored before, 247 passed, 3 failed and 3 ignored after. The gather, lane-permute and edge-flagged triangle failures were present in both builds. Strict shader Clippy and staged asset policy passed.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 07:17 UTC · original
I also verified the A4B4G4R4_UNORM point from the review. WARP reports texture-load support for this format. On
e87c4f1f03, D16 image_load returned 0x38cc per channel for code 9. The nearest half for 9/15 is 0x38cd.2a474f0 adds the format to the existing normalized tag and extends the native readback. All 16 codes now match across all four channels. The same test still covers the existing FLOAT, RGBA8 and RGBA16 cases. The two follow-ups apply together without a textual conflict. DXGI format reference
Full forced-WARP shader suite: 245 passed, 4 failed, 3 ignored before and 246 passed, 3 failed, 3 ignored after. The three unrelated failures were shared. Strict shader Clippy and staged asset policy passed.
@upipibi on GitHub · 2026-11-25 07:34 UTC · original · edited 2026-11-25 07:47 UTC
@andrewpozdnakov7-jpg Thanks for chasing both points.
734f7d6on hardware: RTX 3070 (Ampere, driver 616.56, Windows 11), plus WARP, since the test runs on both.d16_samples_follow_immediate_sampler_choicepasses 3 of 3 runs on734f7d6.Control: your new test on
e87c4f1'slower.rsfails on hardware the way you saw on WARP. The point arm reads0x3bfewhere0x3bfdis right, and the linear arm0x37ffmatches (left: [15358, 14335],right: [15357, 14335], filters[04000000, 18500000]).victory-shadersuite on734f7d6: 247 passed, 3 failed, 3 ignored. The three (a_heap_buffer_read_by_element_takes_the_views_stride,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,gathers_at_a_level_match_the_hardware) fail onmainon this machine too.734f7d6merged with2a474f0: the five D16 tests pass on hardware and WARP. Ampere does load A4B4G4R4_UNORM (hardware: all A4B4G4R4_UNORM codes matched, and WARP the same), and every RGBA8 / RGBA16 UNORM / SNORM texel still matches.AI-assisted (Claude Code). Synthetic tests only.
@Marvisak on GitHub · 2026-11-25 09:18 UTC · original · edited 2026-11-25 15:54 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/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 currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 09:30 UTC · original
The three review changes are together in 1d1f883, directly on
e87c4f1f03. It includes the A4B4G4R4_UNORM and point/linear Phi changes from 2a474f0 and 734f7d6. sRGB formats keep the pre-PR toward-zero pack path pending console measurements.The new WARP check reads a real RGBA8 sRGB view across all 256 codes. With the original sRGB tag, code 1's green channel rounded to 0x3bee instead of 0x3bed from the same view on the truncating path. With this commit, all 256 sRGB texels match that control. All five D16 tests passed, including RGBA8 and RGBA16 UNORM/SNORM, all 16 packed codes, and point/linear sampler selection. Full forced-WARP shader suite with the same added fixture: 246 passed, 4 failed, 3 ignored before and 247 passed, 3 failed, 3 ignored after. The three remaining failures are the same existing gather, lane-permute and edge-flag tests. Strict Clippy and the staged policy check passed.
For the evidence link in the PR description, the primary gfx1036 measurements cover 8- and 16-bit UNORM/SNORM loads and point samples, with 8-bit code 9 returning 0x2885. The xcl report shows the corresponding truncation difference. These measurements cover linear normalized texels.
Please preserve the Git author if you cherry-pick the commit. If you fold the changes or tests into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted. Synthetic tests only.
@sinan-cmyk on GitHub · 2026-11-25 09:45 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
e87c4f1fontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 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).
@DenRakEiw on GitHub · 2026-11-25 03:57 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib d16— 4 passed, 0 failed on RTX 5090 hardware + WARP (includingd16_image_load_rounds_normalized_texels_to_nearestandd16_image_sample_keeps_fractional_normalized_texels)cargo test -p victory-gpu --lib texture_rounding_follows_the_view_in_a_reused_heap_slot— 1 passed, 0 failed on RTX 5090cargo clippy -p victory-shader -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Awesome sideband
view_tableimplementation solving #2006 cleanly across bothvictory-gpuandvictory-shader, verified end-to-end on RTX 5090 + WARP. Looks good.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 04:17 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed. D16 image reads round according to the bound texture format — format-aware rounding for D16 paths; mixed gpu+shader, gpu half Windows-only. Relates to #1927/#1940 d16 load cluster.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:56 UTC · original
I resolved the current-main conflicts on 190dd03. It keeps
e87c4f1and the existing review fixes in1d1f883, and merges upstream63bcca4. The view table now gives texture rounding tags separate bits from main's integer buffer flags. Both buffer and image paths read the shared table, and view creation computes the tag from the effective view format. The image rounding helpers are in a separate module to keeplower.rswithin policy.On WARP 1.0.22 with Agility 1.620.2, all seven D16 tests and all eight stride tests passed, including integer buffer round trips, UNORM/SNORM image loads, and immediate point/linear sampling. The 64-bit image atomic test also passed.
victory-gpupassed 247 tests with one ignored, including the reused-descriptor-slot case. Strict GPU and shader Clippy and policy passed.The full shader run was 300 passed, 5 failed, 3 ignored. Four of those tests also failed in the full main control. The fifth,
permutes_mask_high_address_bits_and_divergent_branches, failed in the synthetic test group on both main and the integration, and passed three isolated runs on each.The separate runtime sampler-heap case still needs the point/linear choice to reach the shader. The existing fixture and measured
0x3f7fb000collision are linked in the issue. Runtime sampler reportIf you take the integration, please retain the original Git authors, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>for the review/integration changes if folding those into another commit.AI-assisted with Codex.
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.Merge
Merge the changes and update on Forgejo.