Repository navigation
D3D-54: test upload-backed vertex, index, root CBV and descriptor-table bindings - #653
VictorJulianiR wants to merge 12 commits into
Conversation
- vulkan_present.h: VulkanPresenter blits a back buffer (an ordinary texture in D3D12's PRESENT state, layout tracked like any other) to an acquired swapchain image and presents it on the same VkQueue, after the application's work. Two frames in flight, a present semaphore per image, FIFO for vsync else MAILBOX/IMMEDIATE, swapchain recreated on resize or out-of-date/suboptimal, minimised windows skip presents. - rt::d3d12::create_window_presenter / WindowPresenter: Win32 surface for a Vulkan device created with presentation; holds the device. This is the back end a DXGI shim or PresentX would call; the game's own front end is still open (docs question 6), so neither is invented here. - Standalone device enables VK_KHR_surface/win32_surface and VK_KHR_swapchain when present; the test helper can too. Test: d3d12_present_test opens a window and presents 60 frames through the Xbox-ABI proxy (reset, PRESENT->RENDER_TARGET, clear, ->PRESENT, execute, present, fence), resizes the window (swapchain recreated, scaled blit), switches to unsynchronised presents, and reads the screen with GDI: 51,153,229 for a 51,153,230 clear. Clean under the Khronos validation layer, as are the other GPU tests; 6/6 ctest.
The debug messenger in test/vk_test_device.h counted every error-severity message, so a broken third-party implicit layer (ReShade's, reported on an RTX 5090) failed every GPU test. Only VALIDATION-type errors are counted now; general loader and layer messages are still printed, marked "not counted". A real validation error still fails the test (checked by replaying part B of vk_command_replay_test without the layout tracker). runtime/README.md says so and mentions VK_LOADER_LAYERS_DISABLE.
First pieces of D3D-3 (compute path), no pipelines wired up yet: - shader_library.h: FSSM extraction from the DXBC container (DXIL, XDAT 0x0D, XBCH, zlib), SHA-256, a minimal JSON reader and the spirv/index.json lookup by fssm_sha256. Self-contained inflate, no dependencies. - IR Dispatch with user data captured at record time; replay binds the pipeline, pushes the 144-byte block (s0..s31, heap base, code base) and dispatches. Arena buffers get a buffer_offset that copies honour. - Root signatures use main's model (runtime/src/root_signature.h); the docs say so. Tests: shader_library_test (FIPS 180-4 vectors; stored, fixed and dynamic deflate blocks; corrupt and truncated streams; FSSM from a synthetic container) joins ctest; command_list_test covers dispatch recording.
… compute PSOs, Dispatch) - GPU address arena (docs 3.3), when the device has bufferDeviceAddress: one host-visible, device-addressable buffer (LEONIDA_ARENA_MB, default 256, max 4095 so VAs fit 32-bit table pointers). Default-heap buffers are 64 KiB-aligned ranges with VA = offset, zeroed through the mapping; shader-visible descriptor heaps live there (CPU handle = mapping, GPU handle = VA); upload/readback buffers get VA = device address - heap base; GetGPUVirtualAddress returns these. - CreateRootSignature on main's model (rt::rootsig): parse_rts0, then pack() for each parameter's place in the 32 user-data dwords; what pack() refuses is refused with its reason. CreateComputePipelineState (PC slot 11, Xbox slot 62 via the proxy) finds the shader by the SHA-256 of its FSSM program in the translator's index (VulkanDeviceInfo::shader_dir or LEONIDA_SHADERS); its FSSM blob is copied into the arena as the code base. Shaders that declare set-0 bindings are refused with a log until the bindless set exists (M2). - Command list: root signatures (arguments cleared on change), pipeline state, constant / root view / descriptor-table setters for compute and graphics, SetDescriptorHeaps, Dispatch recording the user data as it is, ClearState (which also resets ItsNotRexed#164's stencil references); misuse makes Close return E_INVALIDARG. - Test helper and standalone device enable bufferDeviceAddress. Test: d3d12_compute_test (through the proxy) creates the root signature from the PC serializer's blob and the PSO through slot 62 in the measured (desc, 0, 0, riid, out) shape (28cf235) from a container shaped like the game's, sets root constants, a root UAV and a table whose application-written entry points at an upload buffer, runs two dispatches that each keep their own arguments, and reads the results back: 64/64 twice. Its shader is GLSL written to the translator's push-constant and address contract, compiled with glslangValidator. Clean under the Khronos validation layer, as are the other GPU tests; 13/13 ctest.
- CreateGraphicsPipelineState (PC slot 10): VS and PS found by the SHA-256 of their FSSM programs in the translator's index. Input-layout elements are matched to the VS input signature by semantic name and index; location = the element's register (the translator's vertex-fetch rule); a layout that leaves an input unfed is refused, as D3D12 does. Rasterizer, blend and depth-stencil state map one to one; viewport, scissor, topology, vertex strides, stencil references and blend factor are dynamic; dynamic rendering takes the RTV/DSV formats. Hull/domain/geometry, stream output, MSAA, set-0 bindings and two code-base stages (question 14) are refused with a log. - Command list: IASetPrimitiveTopology / VertexBuffers / IndexBuffer, RSSetViewports / ScissorRects (first of each), OMSetRenderTargets (views read at the call, single-range handles too), OMSetBlendFactor, OMSetStencilRef and CommandList8's front/back references (now applied), DrawInstanced / DrawIndexedInstanced recording a copy of that state. CreateCommandList's initial pipeline state is applied. Reset and ClearState share one state reset. - Replay: vertex/index views resolve to buffers by VA (arena or upload), attachments move to attachment layouts through the tracker (first use zero-fills), the draw runs in a dynamic-rendering scope with a flipped viewport (translated VS write D3D clip coordinates), stencil references per face, then vkCmdDraw / vkCmdDrawIndexed. Render-target views take the pipeline's formats (the view cache keys on format). - shader_library.h reads the index's input_signature and PS outputs. Test: d3d12_draw_test (through the proxy) builds a VS+PS PSO whose input layout order differs from the VS registers, uploads a vertex buffer into the arena, reads indices from an upload heap, and draws two indexed quads with different root constants and root CBVs plus a back-facing triangle: all 4096 read-back pixels match (which also checks the viewport flip and winding). Shaders are GLSL written to the translator's contract. d3d12_com_test now uses SetMarker as its unimplemented-method example, since DrawInstanced is implemented. 13/13 ctest; all six GPU tests clean under the Khronos validation layer.
…n (arena without Resizable BAR) Without Resizable BAR the only DEVICE_LOCAL | HOST_VISIBLE memory type sits in a heap of 256 MiB or less (214 MiB on an RTX 3090, driver 616.56). The 256 MiB default arena preferred that type, so vkAllocateMemory was asked for more than the heap holds (VUID-vkAllocateMemory-pAllocateInfo-01713). The NVIDIA driver still returned VK_SUCCESS, so the fallback to plain host-visible memory never ran, and d3d12_compute_test and d3d12_draw_test failed under validation. Reported by CharlyRien. memory_type_order (vulkan_backend.h) now leaves out every type whose heap is smaller than the allocation, so the preference falls through to system memory there. DeviceState::allocate uses it for every allocation. d3d12_state_map_test checks the order on that card's heap layout and with Resizable BAR on.
… stages from the stage table Review feedback from IAmNotSiob: - Both PSO paths declared a 144-byte push-constant range without consulting ItsNotRexed#224's limit. On a device with maxPushConstantsSize 128 (the Vulkan minimum) that breaks VUID-VkPushConstantRange-size-00298 and returns a bare E_FAIL. Both paths now refuse with E_NOTIMPL and log the limit until the uniform-buffer tail exists. d3d12_compute_test checks this with a device that reports 128 bytes. - The graphics range's stage flags are now the whole stage table create_graphics accepts, kept in GraphicsPipeline::push_stages, and the replay pushes with the same flags. A geometry or mesh stage added to the table is covered without another change. docs/d3d12_vulkan.md section 5.2 now counts code-base readers per stage with the current translator: of the 662 shaders with s_getpc_b64, 53 VS, 92 PS, 246 MS and 263 CS read the code base. VS+PS pairs are only known at PSO creation.
|
Tested 80fc786 on an NVIDIA GeForce RTX 3060 (driver 610.88), Windows 11, MSVC (VS 18 Build Tools), Ninja, RelWithDebInfo: pass. #653 was claimed first, so I'd keep it as D3D-54. The one case #648 has that this doesn't is a descriptor-table entry holding an upload-heap VA, read by the pixel shader (the 64-bit entry read as words, since a biased upload VA's high dword is usually |
Adapt the graphics descriptor-table fixture from woreksami's ItsNotRexed#648 (f2dc190 and 1591fdd). Vonsek's review identified the need for an observable difference when an earlier binding is reused. Keep the existing vertex, index and root tint offsets and place both filters in separate aligned regions of the same upload allocation. Co-authored-by: woreksami <249861314+woreksami@users.noreply.github.com>
|
This complements your test, and it's relevant to open question 17. In M1.5 (#699), a translated VS fetches its vertices through a V# ( The cause is the V# base address:
Root CBVs, root views and table pointers are 64-bit, so the paths you test are unaffected. The safe rule seems to be that anything a V# can address (any buffer a game may describe with a V#) must be an arena range. #699 draws from a DEFAULT buffer for now and records this in AI-assisted (Claude Code). |
|
@woreksami, I incorporated your #648 descriptor-table case in co-authored commit @AlxcBTW, the vertex buffer in this test goes through the input assembler. The update changes only the test and its pixel shader. I linked #699 in the PR description so the translated vertex fetch and its allocation requirement stay visible. |
|
Rebase status against |
…ending bundle fence fix Preserve the upstream readbacks, run the D3D-54 pixel filter on its own graphics pipeline and read its output separately. The upstream parent includes the existing ItsNotRexed#1995 fence fix by carlcdx.
|
Tested Commands run: cmake --build runtime/build --config RelWithDebInfo --target d3d12_draw_test d3d12_compute_test --parallel
ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_draw|d3d12_compute)$" --output-on-failure -VResults:
Synthetic tests only; no game files. AI-assisted. |
Resolve the two conflicts as unions: runtime/CMakeLists.txt builds and defines both main's vs_draw_int/gs_double shaders and this branch's ps_draw_filter, and d3d12_draw_test copies ps_draw_filter.spv through main's vktest::shader_fixture_path like the other fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current
I haven't built it locally. Upstream CI is running on this head. AI-assisted (Claude). |
|
Tested the current head
AI-assisted (Claude Code). |
Depends on: #1995
D3D-54, claimed on the coordination board. The original dependencies #119 and #291 have merged. This branch includes @carlcdx's #1995 to wait for the bundle's GPU work before reading its image. Both current main and D3D-54 reproduced the stale readback without the fence fix. #1807 proposes the same fence correction. If that lands first, this branch can follow it. Paired reproduction · Three-file D3D-54 diff over #1995.
The added indexed draw binds vertices, indices and a root CBV at byte offsets 2048, 2176 and 2304 within one 4 KiB upload allocation. Its pixel-shader descriptor table selects between filters at offsets 2560 and 2816. A separate pixel shader and pipeline state keep the existing draw passes intact. The test checks the original capture and a second image for the upload draw.
@woreksami contributed the descriptor-table case from #648. @Vonsek identified why the filter needed a visibly different result when an old binding was reused. Both source commits are recorded in the co-authored commit. Original contribution · Offer and hardware results.
Verification on
93a5094. On a GitHub-hosted Windows runner using MSVC and Mesa llvmpipe, the original and upload-backed draws each matched all 4096 expected pixels. The MSAA readback also matched all 4096 pixels. Five independent controls exercised the vertex, index, root tint and descriptor-table bindings, including one vertex-color change that kept the geometry. In each case the original capture stayed correct, the upload assertion failed as intended, and the resulting image differed from the normal upload image at exactly the 1024 predicted pixels. The Vulkan validation layer reported zero errors. Both compute dispatches matched all 64 elements. The unmodified draw and compute executables also passed on the dependency alone. Candidate and five controls · Dependency control.Earlier independent checks. A native D3D12 WARP reference on Windows Server 2022 (Microsoft Basic Render Driver 10.0.20348.5756) produced all six predicted images. @woreksami ran revision
80fc786on a physical RTX 3060 (driver 610.88, Windows 11), where all 15 CTest tests passed. The current revision was tested on software Vulkan. WARP reference · Earlier RTX 3060 run.AI-assisted. All inputs are synthetic. This covers input-assembler vertex fetch and full-width bindings. The translated vertex-shader buffer descriptor path is tracked separately in #699.