Skip to content

Runtime: bind 3D shader-resource views through set 0 (D3D-72) - #672

Merged
ItsNotRexed merged 4 commits into
ProjectLeonida:mainfrom
Vonsek:codex/volume-texture-srv
Nov 22, 2026
Merged

ItsNotRexed merged 4 commits into
ProjectLeonida:mainfrom
Vonsek:codex/volume-texture-srv

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as D3D-72, single-sampled Texture3D SRVs.

What and why

The bindless set already has a sampled 3D image array at binding 6. The device refused every 3D resource before reaching it. Default and explicit TEXTURE3D SRVs can now bind a typed volume of matching format. The T# encodes the resource's base depth, the Vulkan view has one array layer, and the view's first mip and mip count are preserved.

This covers single-sampled color textures with a zero ResourceMinLODClamp. A nonzero clamp and format casts are rejected on this path. MSAA SRVs remain a separate part of D3D-72. There is no dependency on #643.

Tested

Windows 11, NVIDIA RTX 5080, driver 616.92, Khronos Vulkan validation enabled.

Run Observed result
Parent c432cdc with the new fixture The default volume SRV produced a null descriptor. The T# check failed before dispatch.
d3d12_descriptor_test on this change All 128 RGBA readbacks matched the expected source texels, 64 through the default SRV and 64 through a mip-1 SRV. Zero validation errors.
Reverse only the sampled W coordinate 128 of 128 differed.
Substitute the default SRV's key for the mip-1 SRV's key 64 of 128 differed.
Restore the original shader and keys 0 of 128 differed.

The fixture uploads an 8×8×4 mip and a 4×4×2 mip through CopyTextureRegion. RGB varies independently with X, Y and Z, while alpha identifies the mip. The compute shader looks up both the T# and S# from actual D3D12 heap slots in the device's descriptor hash table. The test owns the Vulkan pipeline and reads the output buffer back on the CPU. Wrong-dimensional, out-of-range, differently typed and nonzero-clamp descriptors were also checked.

Full Windows CTest passed 27/27. d3d12_vulkan_device_test passed; vk_bindless_test returned zero bad pixels across 14 draws using source-built vs_ids and ps_tex.

Checklist

  • No game data, keys or decryption. Tests use synthetic textures and shaders.
  • Runtime-only change. Device behavior and limitations are documented in docs/d3d12_vulkan.md.

AI-assisted with Codex.

Volume depth belongs in the T# depth field, while its Vulkan view has a single array layer. Route matching descriptors through the existing 3D binding so a shader can select W slices and use a view-relative mip.
Keep both packed and volume textures in the bindless readback test. Place the volume upload beyond the UINT texture so the RGB9E5 upload cannot overwrite its first depth slice.
@Vonsek

Vonsek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged 762893f into this branch at 89f19af545ac28a402ed3980e99d408aacedd6be. Both tests initially used upload offset 4096: the incoming RGB9E5 fixture overwrote the first slice of the volume fixture, and exactly 16 of 128 volume samples failed on RTX 5080. The volume footprints now start after the UINT texture, with a bounds check against the upload buffer.

On this head, all 128 volume samples and the RGB9E5 readback matched. Reversing W gave 128 differences; substituting the default view for mip 1 gave 64. The upstream device still rejected the default 3D SRV when tested with the same fixture. The separate 3D RTV test matched WARP for all 648 texels, the bindless test matched all 14 draw readbacks, and Windows CTest passed 28/28. RTX 5080 driver 616.92, Khronos validation enabled. AI-assisted.

Hosted checks on this head finished 8/9. Both Runtime jobs passed. The other CI workflow's check job fails at dotnet build with CS1061: ArchiveEntry.ResourceDrawableOffset is missing at Program.cs lines 124 and 147. The base commit 762893f fails on the same two lines. The PR and base have identical rpf9dump sources, submodule pin (48557ea) and workflows. The coordinator is tracking the submodule update as BUILD-101 in #650. PR failure · base failure · coordination note

@troythedecoyx

Copy link
Copy Markdown
Contributor

Tested 89f19af merged onto main 762893f on NVIDIA GeForce RTX 4060 Ti (Ada), driver 32.0.16.2124 (NVIDIA 621.24), Windows 11 Home 26300, MSVC 2022 / Ninja, Vulkan SDK 1.4.363: pass.

  • d3d12_descriptor_test (changed here): exit 0.
  • ctest: 28/28.

AI-assisted.

@Derpbeat

Copy link
Copy Markdown
Contributor

Tested 89f19af on an NVIDIA GeForce RTX 4090 (driver 617.14, Vulkan 1.4.351), Windows 10 Home 22H2 (19045), MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, Ninja RelWithDebInfo, LEONIDA_VK_VALIDATION=1: pass. (D3D-72 / D3D-80.)

  • Build: no new warnings. ctest: 28/28 with validation.
  • d3d12_descriptor_test: pass, 0 validation messages. The final line reports the RGBA8 and RGB9E5 texels matched.
  • d3d12_vulkan_device_test, d3d12_com_test, vk_command_replay_test: pass. For the device test I made its two host comparisons non-fatal locally, because on Windows 10 they stop the test early (see my finding in Coordinating who works on what (3) (moved to #1006) #634).
  • Negative control: with d3d12_vulkan_device.cpp put back to 762893f and the new test kept, d3d12_descriptor_test fails at line 504: image_at(volume_all, vol) && vol.type == g::ImageType::image_3d ("shader views of 3D and multisampled textures are not supported; dimension 4"). The test catches the missing feature.

Code read: the dimension and view-type check, the one-layer volume view, out.depth, and the refusals (typeless volume, format cast, nonzero ResourceMinLODClamp, DENY_SHADER_RESOURCE) all look right and match the description. Nothing to change from my side.

AI-assisted (Claude Code); repository tests only, no game files.

Preserve the new plane views and packed-format tests alongside volume sampling so they run in the same descriptor fixture.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged 67204bf into this branch at 13cae9c949d625556719b7c93180151d1694b503. The descriptor fixture now runs the incoming depth/stencil-plane and packed-format cases together with the two volume SRVs.

Clean Windows build on RTX 5080 / 616.92 with Vulkan validation enabled. CTest passed 29/29. The two SRVs matched all 128 expected RGBA texels, the separate volume RTV test matched WARP on 648 texels, and the bindless test reported zero bad pixels in 14 draws.

With this head's fixture, the unmodified upstream device failed at the default volume SRV. Reversing W failed 128/128 texels, binding the base view in place of mip 1 failed 64/128, and deliberately overlapping the volume upload with the RGB9E5 upload failed 16/128. Restoring the inputs gave 0/128 differences. AI-assisted verification.

@matheuskshn

Copy link
Copy Markdown
Contributor

Code review at 13cae9c. I checked that the post-merge fixture still places the two volume mips after the last UINT footprint and bounds-checks the last volume slice. It separately checks the base-depth field and the mip-1 view. The runtime also adds a DENY_SHADER_RESOURCE guard for volumes; I would add a matching negative SRV test beside the existing wrong-mip, wrong-type, clamp and typed-format cases. AI-assisted code review.

Exercise the null descriptor when the layer accepts a transfer-only volume and allow a resource-creation rejection consistent with the host runtime.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@matheuskshn added the requested negative case in 94616fef20a9ba5a8f0915007dc07f2e54071ba7. It starts the destination slot with a valid mip-1 SRV, then requests the same view on a volume created with DENY_SHADER_RESOURCE. On RTX 5080 / 616.92, removing only the deny-flag check left a nonzero descriptor, failed the new assertion and produced VUID-VkImageViewCreateInfo-image-04441. Restoring it cleared the slot, gave zero validation errors and preserved all 128 expected volume samples. CTest passed 29/29.

I also tried resource creation directly on native D3D12 and WARP. Both returned S_OK for the ordinary RGBA8 volume and E_INVALIDARG for the same volume with the deny flag alone. The test permits that early rejection too. The current layer returns S_OK and exercises the SRV assertion. Microsoft's resource flag restrictions

AI-assisted verification.

@ItsNotRexed
ItsNotRexed merged commit 28e2991 into ProjectLeonida:main Nov 22, 2026
8 of 9 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