Skip to content

Runtime: sample UNORM and sRGB views of typeless RGBA8 volumes - #897

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Vonsek:codex/typeless-rgba8-volume-srv
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Vonsek:codex/typeless-rgba8-volume-srv

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue. Based on main d1211d0. No dependency on an open PR.

What and why

A shader reading an explicit UNORM or sRGB Texture3D view of a committed R8G8B8A8_TYPELESS resource received the null descriptor. The resource already has a mutable Vulkan image. This change lets those two view formats reach the existing T# and 3D image-view binding path. It also tests that the default view, an unspecified view format, a typeless view format and BGRA8 leave a previously populated slot null.

Tested

The synthetic 8×8×4 volume exposes mip 1 as both UNORM and sRGB. The shader reads both depth slices and checks all four channels. The two original typed volume controls run alongside it.

  • Windows 11, RTX 5080 (616.92) and AMD Radeon Graphics (26.10.1), Khronos validation on. With the regression added to main, 128/256 texels differed on each adapter. At this head all 256 matched on both. A trial binding the linear view in place of the sRGB view produced 62 mismatches on each. Alpha and UNORM use exact comparisons; the sRGB RGB check allows one byte of conversion rounding.
  • An independent native D3D12 compute probe on RTX, Radeon and WARP read mip 1 with Texture3D.Load. All three matched the independently computed rounded RGBA values exactly across 64 UNORM and 64 sRGB texels. Substituting UNORM for the second view again failed 62 of its 64 samples.
  • Full Windows build and all 32 enabled CTests passed. GameInput was disabled by the project. The descriptor GPU executable ran directly on both adapters.

Checklist

  • Source-built fixtures only. No game data, keys or decryption.
  • Runtime SRV behavior documented in docs/d3d12_vulkan.md. The shader translator is unchanged.

AI-assisted with Codex.

A committed RGBA8 typeless image already permits mutable Vulkan views. Let explicit UNORM and sRGB Texture3D SRVs select their formats so shaders can read either interpretation of the same voxels.
@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11, NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1714), MSVC 14.51: ctest 32/32 passed, including d3d12_descriptor_test with the new UNORM/sRGB views of a typeless RGBA8 volume.

The pending multisample fixture already owns the next slots on the common heap. Give the two typeless views their own CPU descriptors so both sampling regressions can run in the same command list.

@quackottu quackottu 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 482aa3c on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • d3d12_descriptor_test (changed here): exit=0 validation=0 | [rt] d3d12_xs: device slot 36 (forwarded) first call
  • 33 test programs in the build pass with 0 validation errors
  • Not run (they take an input file, not covered here): vk_binary_occlusion_test
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Tested 482aa3c on an NVIDIA GeForce RTX 3070, driver 610.88, Windows 11 (26300), MSVC 19.44 (VS generator, RelWithDebInfo), Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1: pass

  • Build passes, ctest 26/26. The warnings are main's: C4456 at vulkan_replay.h:1372, and one at d3d12_descriptor_test.cpp:365, which tests: rename the multisample levels in d3d12_descriptor_test (C4456) #909 fixes.
  • d3d12_descriptor_test: exit 0, 0 validation messages, volume SRVs: 0 of 256 sampled RGBA texels differ. The four refusals log as expected: formats 0, 27 and 87 for the new typeless cases (UNKNOWN, R8G8B8A8_TYPELESS, B8G8R8A8_UNORM; the default view's UNKNOWN folds into the first line through log_once), and 30 for the existing R8G8B8A8_UINT view of the typed volume, which is still refused.
  • d3d12_vulkan_device_test, vk_command_replay_test A to F and d3d12_com_test: pass, no validation messages.

Code read: the rule matches D3D12. A typeless resource needs a fully typed view from its own family, so UNKNOWN, TYPELESS and BGRA8 stay null, and typed volumes keep the old same-format rule. I also recomputed the test's sRGB table from the uploaded bytes with the exact transfer function: red 19/38/57 → 1.66/4.94/10.43, green 23/46/69 → 2.19/6.97/15.18 and blue 53 → 9.08, which round to the table's 2/5/10, 2/7/15 and 9. So the ±1 allowance only covers hardware rounding: the linear view would miss by up to 47.

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit ac93fee into ItsNotRexed:main Nov 22, 2026
10 checks passed
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.

5 participants