Repository navigation
Runtime: milestone M2 — textured quad from translated VS+PS through descriptor heaps, tables and bindless set 0 (error 0) - #1489
Conversation
…ameters Every translated shader declares Int64 (64-bit addresses) and lists shaderInt64 in its index metadata, but neither the standalone device nor the test device enabled it: vkCreateShaderModule was a validation error and the first translated draw lost the queue. The test device also enables shaderDrawParameters, which the translator's zero-based VS ids (PR 436) will need. Two names in the test device no longer shadow each other after the merge with main. The standalone-device change is PR 291's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vs_m15.asm and ps_m15.asm are hand-written RDNA2 (gfx1013), built by test/shaders/build.py through llvm-mc and tools/rdna2spirv.py. build.py now also writes the synthetic FSSM program a shader's header asks for (fssm-at, fssm-data) to fssm/, so the translator records its fssm_sha256 in index.json. d3d12_translated_draw_test creates a graphics PSO from containers carrying those programs; the layer finds both stages by hash in the translator's own index. It covers a descriptor-table root argument and root constants (s0..s5), vertex fetch through a V# the application wrote into a descriptor slot (s_load, then buffer_load_dwordx4 idxen), the PS reading constants through the code base (s_getpc_b64), and compares a float render target bit for bit. All draws use StartVertexLocation 0, so the result is the same with and without PR 436's zero-based ids; verified both ways. docs/d3d12_vulkan.md records the milestone and the measurement that a V# cannot point at an upload buffer (48-bit base, negative console VA). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… log a missing shaderInt64 PR 436's translated vertex shaders read BaseVertex/BaseInstance, so the production device must enable shaderDrawParameters before 436 lands (same lines as 436, so they merge). A GPU without shaderInt64 cannot load any translated shader (all declare Int64): say so once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter edge assert, softer 436 and V# docs make_vsharp used OOB_SELECT raw with stride 32, which on hardware checks the byte offset against num_records; the test only passed because the translator ignores OOB_SELECT. It now encodes a gfx10::Buffer with OobSelect::structured. The 32 diagonal pixels must be the clear colour (a right edge under the top-left rule). Docs: 436 is not in the tree (identical result with its translator change applied); the V# failure follows from the upload buffer lying below the arena, which is allocation order, so the rule stays: anything behind a V# is an arena range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # runtime/CMakeLists.txt # runtime/shims/d3d12_com.h # runtime/shims/d3d12_vulkan_device.cpp
…s in vulkan_replay.h, C4459) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolved along the lines in ItsNotRexed#291 (comment by ItsNotRexed, 2026-11-22 08:27): - Default-heap buffers stay in the GPU address arena: a VA is an arena offset, and every buffer's device address is heap_base + VA (upload and readback buffers: device address minus heap_base, as before). - Acceleration structures: a buffer created in RAYTRACING_ACCELERATION_STRUCTURE state on a ray-tracing device stays out of the arena and keeps main's model, its VA being the VkAccelerationStructureKHR's device address, so BLAS addresses in TLAS instance descriptions are what Vulkan reads. It is registered by that VA. BuildRaytracingAccelerationStructure turns build inputs and scratch into heap_base + VA, and the arena gets the build-input usage on ray-tracing devices. Resource keeps one va_ (gpu_va_/buffer_va_ removed). - buffer_at keeps the size& signature; main's only caller (WriteBufferImmediate) is the branch's version, and ExecuteIndirect resolves its buffers by id. - ~Resource keeps arena_release and main's defer_destroy. - Main's split context locks: pipeline registration and heap_base/zero page take resource_mutex_ (prepare looks pipelines up under its shared lock); VulkanPresenter takes resource_mutex_ shared, plus tracker_mutex_ while it records the back buffer's transition. - Standalone device: main's single instance-extension list and DXGI swapchain enable; info.presentation follows the same swapchain/surface condition, so create_window_presenter keeps working. Main's DeferredDeletionQueue, calibrated timestamps and ray-tracing extensions are kept next to the branch's presentation and feature enables. - Command IR: Dispatch and Draw follow main's DebugMarker, ExecuteIndirect and BuildAccelerationStructure in the variant.
Conflicts (both sides kept): runtime/CMakeLists.txt (stub list), d3d12_com.h, d3d12_vulkan_device.cpp (arena buffers with main's ray-tracing buffers and deferred destruction, calibrated timestamps, instance extensions, sampler registration next to the window presenter), command_list.h, vulkan_backend.h, vulkan_replay.h, vk_test_device.h, d3d12_state_map_test.cpp, docs and README. vulkan_present.h takes main's resource and tracker locks. CI (linux-gpu-tests): ps_m15 and vs_m15 belong to d3d12_translated_draw_test. run_gpu_tests.py still assembles and translates them but reports them as skipped (OTHER_HARNESS) instead of "no checker defined". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main moved (c0ac5fd): vulkan_replay.h takes main's checked buffer copies (predicated copies, overlap and overflow refusals). README's Xbox row is rebuilt from both sides (the previous merge commit had committed a zero-filled README.md; this restores it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On top of the merge candidate 70178d3 (Ryx69#6, which merged main at 426023a): the 219 commits main gained since. Three hunks conflicted, in two files; both follow the notes on ItsNotRexed#291 (ItsNotRexed 08:27 UTC, Vonsek 09:58 UTC on 2026-11-22). runtime/shims/d3d12_vulkan_device.cpp, device setup after the VulkanContext: - the branch's GPU address arena is created first, as before; - main's block that configures predication and the predicated byte copy (ItsNotRexed#1277) follows it; - one load_host_image_copy call and main's lazy D24 converter (enabled only where D24_UNORM_S8_UINT is not usable) replace the branch's unconditional enable_depth24, which was the same code before main changed it. runtime/src/vulkan_replay.h: - CopyBuffer: main's version. It already adds ResourceBinding::buffer_offset to both offsets, as the branch did, and adds the overflow and overlap checks and the predicated copy. With the arena, source and destination are often the same VkBuffer; the overlap check compares the adjusted ranges. - Predication: main's version. prepare() passes buffer_offset + the command's offset to prepare_predicate, so a default-heap buffer inside the arena is read at its own range; emit() captures the word and tests the capture's scratch slot, not the application's buffer. Everything else merged without conflicts. Nothing in main's 219 commits adds a caller that takes a buffer's Vulkan device address for its GPU VA. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main's tests/test_ctest_registration.py (ItsNotRexed#1258) fails on this branch after the merge: d3d12_compute_test, d3d12_draw_test and d3d12_present_test are built but no add_test runs them. They are registered like their neighbours, with SKIP_RETURN_CODE 77, and return 77 when vktest::Device::initialize() finds no Vulkan device, as the other registered D3D12 tests do. Without that, the CPU runtime job, whose runner has no Vulkan driver, would fail on them the way it did on d3d12_predicated_copy before ItsNotRexed#1314. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ExecuteBundle copies the two stencil references back to the calling list only when the bundle set them (stencil_ref_set_). OMSetFrontAndBackStencilRef marks that; the older OMSetStencilRef assigned both faces without it, so a bundle that only calls OMSetStencilRef lost its reference and the next draw tested against the caller's old value. Reported by Vonsek on ItsNotRexed#291 with a fixture compared against native D3D12: 1,050 red pixels expected after the bundle, 0 before this change. d3d12_com_test gets the case next to its other bundle checks; it fails without the change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained 117 commits since f85582e, among them ItsNotRexed#119 itself (through ItsNotRexed#908, which is built on its head and adds PresentX on top), so both sides now carry the presentation path: this branch as ItsNotRexed#119's own commits merged with main at 426023a, main as ItsNotRexed#908's integration of them. Eleven hunks in six files conflicted. runtime/src/vulkan_present.h (2 hunks): - present's blit: main's structure (a blank present, the source rectangle) with both locks of the branch. record() reads and updates the context's layout tracker, which ExecuteCommandLists guards with tracker_mutex_ (it copies the tracker, emits, and commits the copy after the submit); under the resource lock alone a present between that copy and that commit would lose its update. Order as in the context: resource -> tracker -> submit. - presentable(): identical code, main's comment. runtime/shims/d3d12_vulkan_device.cpp (3 hunks): - includes: shader_library.h stays (pipelines read the translator's index); - Resource's fields: the branch's arena fields and main's rgb96_ (D3D-62); - standalone device: info.presentation is set once, where the swapchain extension is pushed (the branch's order); main set the same value later. runtime/shims/d3d12_com.h (2 hunks): the union of the includes; the branch's VulkanDeviceInfo::features and shader_dir stay. runtime/CMakeLists.txt: main now builds and registers d3d12_present_test next to xbox_present_test, so the branch's copy of that block goes; the compute and draw tests keep theirs. d3d12_present_test keeps returning 77 without a Vulkan device, which main's registration (c2967a5) relies on but main's test does not do yet. README.md, docs/d3d12_vulkan.md (3 hunks): the branch's text. main's side is what the branch had already merged at f85582e, unchanged since. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…riptor path (d3d12_m2_textured_test) Pipelines (graphics and compute) whose translated shader declares set-0 bindings were refused. Their layout now holds the device's bindless set 0 and replay binds it at every draw and dispatch. d3d12_m2_textured_test drives heaps, SRVs, a POINT sampler, two root descriptor tables and DrawIndexedInstanced with a translated PS that loads the T#/S# from the tables; 4096 of 4096 pixels match, and the descriptor hash table is checked. d3d12_translated_draw_test is registered with ctest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lines without bind_descriptor_sets, test includes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows 11 run of the published 810acc7 fixture: a fresh MSVC build translated both synthetic shaders, both passed spirv-val, and The stock gradient/reflection distinguishes the SRV switch. With its in-range UVs, registered POINT/CLAMP and the nearest-clamping fallback give identical pixel values. The nonzero sampler-table lookup independently verifies registration. To distinguish the sampler used by the draw, I ran a separate synthetic variant: add 1 to U immediately before image_sample, create POINT/CLAMP and POINT/WRAP in adjacent slots of one sampler heap, and select the sampler through SetGraphicsRootDescriptorTable for each draw. The production runtime was unchanged.
Each variant matched its own CPU prediction in all 4,096 RGBA pixels on both adapters. With U+1 the clamped view reads source x=7; on the right half, only the final eight screen columns already sample that texel. Keeping SRV A on the second draw instead changes every pixel in the right half. These controls separately exercise the texture-table and sampler-table bindings, including a sampler switch between draws in one command list. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 810acc7 on NVIDIA GeForce RTX 3090 (Ampere), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass. This adds a desktop Ampere run next to the RTX 5070 Laptop and 880M results. The PR's diff applied cleanly to
Edit: an earlier version of this comment came from a build configured without |
…5 + M2 on main Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. |
|
Thanks @Vonsek, @Rainmaker33 and @kapitche, that's five more GPUs: RTX 5080, Radeon Graphics, RTX 3090, RTX 4080 SUPER and UHD 770. @Vonsek, good catch. With in-range UVs, the test can't tell the registered sampler from the nearest-clamp fallback. I'm adding your control to AI-assisted (Claude Code). |
…edicted pixels) With U in range, a POINT/CLAMP sampler, a POINT/WRAP one and the fallback sampler give the same pixels, so the first pass cannot tell which sampler a draw used. The control adds 1 to U before image_sample and picks the sampler per half through the sampler table: 4096 of 4096 pixels match the CPU prediction and 1536 differ from the plain pass. Sampler control suggested and measured by @Vonsek in ItsNotRexed#1489. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
AI-assisted independent M2 verification of I ran the stock offscreen On each GPU, the two 8×8 source textures produced these exact results in the 64×64 RGBA8 target:
Fresh MSVC x64 19.38 build with Windows SDK 10.0.26100.0, uv Python 3.12.13, existing WSL LLVM 21.1.8 for AMDGPU assembly only, and Vulkan SDK 1.4.363.0. M2 translated and passed |
|
Tested Setup: Linux 7.3.5, Mesa 26.3.1 (RADV; llvmpipe on LLVM 23.1.5), Vulkan 1.4.363, GCC 16.2.1,
The compute bind
Mutations (llvmpipe only, because an unbound set is invalid GPU work)
How much of the game this covers: 17,528 of 26,503 shaders declare set-0 bindings (ps 10,137 of 12,101; ms 4,511 of 9,282; cs 2,255 of 2,689; vs 625 of 2,236; gs 0 of 195). This is a count over my own copy, from the translator's The set-0 hookup that #313's D3D-3 row still lists as following from me is covered by this PR, so nobody needs to wait for a second one. AI-assisted (Claude Code, Claude Fable 5.2). |
|
Tested
One difference still present after the merge, in case it helps a follow-up. When a translated shader's
Reproduced on the RTX 3080 by hiding The same one-line message in the graphics path would make a stale or partial shader folder easy to diagnose. I'm not opening a PR for it; anyone picking up the area can fold it in. AI-assisted (Claude Code); results run on this machine, no game files. |
…ute_test) Since #1489 the layer binds the device's bindless set at every dispatch as well as at every draw, but only the draw has a test (d3d12_m2_textured_test): d3d12_compute_test takes the binding-free index entry on purpose, and d3d12_descriptor_test samples through set 0 with a Vulkan pipeline of its own. This test covers the compute bind point through D3D12 alone: a compute PSO whose index entry lists set-0 bindings, two SRVs, bytes no view was made for, and a wrapping and a clamping sampler. Four dispatches of test/glsl/cs_set0_sample.comp (GLSL written to the translator's contract) load the T# and the S# from the descriptor tables, find them in the hash table and sample: the two textures texel for texel, the fallback image for the unknown bytes, and the right edge with the clamping sampler. A device without the bindless set refuses the PSO. Registered with ctest like its neighbours (exit 77 is a skip). With the vkCmdBindDescriptorSets call of the compute bind point removed from replay, this test fails (VUID-vkCmdDispatch-None-08600, on llvmpipe). Checked with a mingw-w64 build under Wine on llvmpipe, an RDNA2 integrated GPU and an RX 7900 XTX (RADV), with the validation layer: exact, no validation errors. Not built with MSVC. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
What and why
This is the synthetic part of milestone M2 in
docs/d3d12_vulkan.md§6: a textured quad drawn with a translated RDNA2 VS+PS through the D3D12 descriptor path. Claimed in #1380.Until now, the layer refused any pipeline whose translated shader declares set-0 bindings ("pipelines do not bind set 0 yet"). The pipeline layout now holds the device's bindless set 0, and replay binds it at every draw and dispatch, for graphics and compute.
New test
d3d12_m2_textured_test. It uses the D3D12 API only:Map+CopyTextureRegion;CreateShaderResourceViewand a POINTCreateSampler;SetDescriptorHeaps,SetGraphicsRootDescriptorTableandDrawIndexedInstanced.The pixel shader (
ps_m2.asm, passed through the translator)s_loads the T# and S# from the tables and runsimage_sample.Result: all 4096 pixels match the CPU-computed gradient and its reflection, error 0. The descriptor hash table holds distinct non-zero indices for both T#s and the S#, and none for bytes nothing created. This PR also registers
d3d12_translated_draw_test(#907) with ctest.Sampler control (suggested and measured by @Vonsek): a second pass with
ps_m2_uoff.asmadds 1.0 to U beforeimage_sample. It uses POINT/WRAP on the left (wraps back to the gradient) and POINT/CLAMP on the right (clamps to the edge texel), so the draw provably uses the sampler from the table. 4096 pixels match the CPU prediction, exactly 1536 differ from the plain pass, and the WRAP S# has its own hash-table entry.Not covered: the game's own shaders, direct heap indexing, unbounded tables, static samplers, descriptors the game writes itself, and other formats, mips or arrays through a PSO. There is no host D3D12/WARP byte comparison; the reference is computed on the CPU.
Contains #907 (M1.5, the translated VS+PS draw) and is merged with
mainafter #291 landed.git diff mainshows only M1.5 + M2 (18 files). Merging this lands #907 too; I'll close #907 then.Tested
e4f10932,LEONIDA_VK_VALIDATION=1, 0 validation errors:d3d12_m2_texturedpass (both passes), full ctest 100% of 89.d3d12_m2_texturedpass, full ctest 88/89.d3d12_vulkan_devicefails identically on a cleanmain(99f99890); see the note in D3D12 → Vulkan layer: critical path, who builds what, open methods #313.810acc75: @Vonsek (RTX 5080, Radeon Graphics), @Rainmaker33 (RTX 3090) and @kapitche (RTX 4080 SUPER, UHD 770). All pass; thanks.run_gpu_tests.py --filter _mskips the D3D12-harness fixtures on both GPUs (ps_m15,vs_m15,ps_m2,vs_m2,ps_m2_uoff).tests/test_ctest_registration.pyandtests/test_shader_checks.py: 45 passed.Checklist
mainSKIP_RETURN_CODE 77without a Vulkan device)docs/d3d12_vulkan.md§6 M2 row updated ("Synthetic part met", with what is still open)AI-assisted (Claude Code).
🤖 Generated with Claude Code