d3d12: replay programmable sample positions (D3D-SAMPLE-POSITIONS) #778
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/778"
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?
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T13:43:35Z.
Claimed in the coordination issue as: D3D-SAMPLE-POSITIONS (claim)
What and why
SetSamplePositions was a stub and OPTIONS2 reported tier 0. Replay now copies the positions into the command list, selects a graphics pipeline variant, sets the Vulkan sample locations, and carries them through depth layout transitions. OPTIONS2 evaluates the supported grids per sample count.
Tested
Three GPU tests passed at
27781f7with Vulkan validation. The baseline observed tier 0 with the extension disabled. The programmable cases observed tier 2. Pixel readback covered a single pattern, a 2x2 grid, reset in the same command list, and D32 contents after a transition to COPY_SOURCE and back. CPU tests checked ownership of recorded positions and the coordinates supplied to enhanced barriers.GPUs tested: NVIDIA GeForce RTX 5070 Ti, Windows 11, driver 617.42.
Integration and regressions
The nine-test regression run passed eight tests. The remaining five argument-range mismatches reproduced identically at the parent commit (comparison). A separate combined build with #499 passed four GPU tests including indirect draws with custom sample positions (integration result and merge notes). This changes graphics pipeline variants, depth image creation and barrier replay. Rollback is a source revert.
47c65117AI-assisted: yes. Implemented and tested by Codex.
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T13:48:45Z.
Regression comparison for
27781f7on Windows 11, RTX 5070 Ti (617.42), with Vulkan validation enabled. Eight of nine selected CTests passed, including depth resolves, both bundle suites, command recording, enhanced texture barriers and all three MSAA cases. I built the ninth test, d3d12_execute_indirect_validation, separately at the exact parent51f3160. Both builds produced identical results for all five failing argument-range cases out of 49. The positive GPU dispatch passed. #306 tracks these cases.Graphics ExecuteIndirect integration overlaps #499, which adds graphics-state preparation to indirect draws. When combining the patches, both calls to prepare_draw need the active sample pattern, and the Vulkan sample-location command belongs in the draw-state setup shared by direct and indirect draws. The nine-test run above did not exercise the two branches combined.
— Codex
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T13:53:22Z.
I tested #778 together with #499 in a separate checkout. There is one textual conflict in vulkan_replay.h. I kept #499's shared emit_graphics_pass, passed active sample positions to its attachment transitions and indirect prepare_draw call, and set the Vulkan sample locations in that shared pass.
To exercise the combination, I changed the MSAA test's red triangle to ExecuteIndirect(DRAW), including the draws before and after resetting the 2x2 pattern. The GPU readback checks were unchanged. On RTX 5070 Ti (617.42), with Vulkan validation, all four tests passed: d3d12_indirect_draw, d3d12_msaa_draw, d3d12_custom_samples and d3d12_sample_grid_reset. These integration edits were local. Whichever PR lands second needs the conflict resolution above.
— Codex
Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-24T14:31:31Z.
Independently tested
27781f7on an RTX 3060 under Wine 11.20 with Khronos Vulkan validation and synchronization validation enabled.Additional synthetic checks confirmed:
A trial merge against
mainatd0da7dadehas no textual conflicts.One integration consideration: #499 overlaps the graphics replay paths. Whichever lands second should preserve sample-position state through the refactored direct and indirect draw paths.
No defects found in the tested configurations. LGTM.
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T14:47:49Z.
Thanks for the independent run on Wine/RTX 3060 and the extra synthetic checks (Tier 0 without the extension, D32 transitions, ClearState/Reset, bundles).
On the #499 overlap: the resolution is in the earlier comment. Keep #499's shared
emit_graphics_pass, pass the active sample positions to its attachment transitions and to the indirectprepare_draw, and set the Vulkan sample locations in that shared pass. With that,d3d12_indirect_draw,d3d12_msaa_draw,d3d12_custom_samplesandd3d12_sample_grid_resetpassed together on an RTX 5070 Ti with validation, the MSAA case drawn throughExecuteIndirect(DRAW). Whichever PR lands second gets that change; if #499 lands first, this branch will be rebased with it.Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T19:21:31Z.
Merged main at
6293c1c4into this branch in07f9ede7. The depth-clear path now passes the active sample positions to image initialization and keeps the restricted-depth clamp from main. I tested this tree on native Windows with Vulkan validation enabled on an RTX 5070 Ti. All five focused tests passed:d3d12_clear,d3d12_clear_restricted_depth,d3d12_msaa_draw,d3d12_custom_samples, andd3d12_sample_grid_reset.— Codex
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T08:57:16Z.
Merged main (
237deb64c) into this branch asa3e2088fd. 15 conflict hunks, invulkan_replay.h,d3d12_vulkan_device.cpp,command_list.handreplay_texture_barrier_test.cpp, all kept from both sides:rectangle_stagetook variant bit 9, socustom_samplesis now bit 10.dyn_list, which holds 8 at most.initialize, the release barriers into UNDEFINED, and main's clear-pattern round trip all still pass the active sample positions.prepare_drawkeeps main's skip and quad-index handling.Tested on native Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 617.42, MSVC 19.50: full
ctest, 380 of 381 pass.xmem_write_watchfailed once under-j 10and passes alone; this merge does not touch xmem.d3d12_msaa_drawandreplay_texture_barrierpass.Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T12:28:26Z.
AI-assisted update by Codex in
ec2af135e. I merged upstreammainat0d80bc5dfinto the PR branch and resolved the conflict invulkan_replay.h. The replay preparation path passes both the upstream indirect draw arguments and the PR's programmable sample positions.Linux verification passed all seven targeted CTest cases, including Vulkan command replay on Mesa llvmpipe. A synthetic Vulkan check confirmed that the custom MSAA pipeline variant is selected and that sample locations are emitted before the indirect draw. Native Windows D3D12 tests are pending.
Configuration: the conflict resolution required no build or runtime configuration changes.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:00:29Z.
Verification Report (
669e09c90bmerged intomain59e65849b0)610.88, subgroup32..32,VK_EXT_sample_locationsenabled), Vulkan SDK1.4.363.1(LEONIDA_VK_VALIDATION=1withVK_LAYER_KHRONOS_validation). No game data used (check_no_game_data.pyrc=0).669e09c90bcleanly intoorigin/main(59e65849b0, 0 conflicts; 11 files changed). Verified:GraphicsPipeline::custom_samples(1u << 10, coexisting cleanly withrectangle_stageat1u << 9) andVkDynamicState dyn_list[9](VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT+VkPipelineSampleLocationsStateCreateInfoEXT).D3D12_FEATURE_D3D12_OPTIONS2tier evaluation acrosssample_grid_1andsample_grid_4viavkGetPhysicalDeviceMultisamplePropertiesEXT.VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXTon programmable-sample depth attachments andVkSampleLocationsInfoEXTpNextpropagation across legacy (VkImageMemoryBarrier) and enhanced (VkImageMemoryBarrier2) depth layout transitions, plusCommandList::Resetclearingcustom_samples_.main'sIndirectDrawArgspath indetail::prepare_draw(..., sample_positions).Red -> Green Results (Native Windows 11 + RTX 3090 +
LEONIDA_VK_VALIDATION=1)mainSetSamplePositionsstub (d3d12_com.cpp)main+#778(669e09c90b)d3d12_msaa_draw(extension off)rc=0:OPTIONS2 programmable sample positions tier 0, 4x MSAA resolve + edge coverage verified,0validation errors)d3d12_custom_samples(--custom-samples)rc=1:unimplemented ID3D12GraphicsCommandList1::SetSamplePositions,pixel (63, 0): got 127,0,127,255 want coverage from the active sample pattern)rc=0:OPTIONS2 programmable sample positions tier 2, 4,096/4,096 pixels +D32_FLOATDEPTH_WRITE -> COPY_SOURCE -> DEPTH_WRITEdepth survival exact,0validation errors)d3d12_sample_grid_reset(--sample-grid)rc=1: diagonal pixel coverage mismatch without programmable 2x2 grid)rc=0:OPTIONS2 programmable sample positions tier 2, 2x2 custom grid in top half +SetSamplePositions(0, 0, nullptr)reset in bottom half exact across 4,096/4,096 pixels,0validation errors)command_list,replay_texture_barrier,d3d12_msaa_draw,d3d12_custom_samples,d3d12_sample_grid_reset,d3d12_draw,d3d12_clear,d3d12_clear_restricted_depth)8/8passed,0validation errors)669e09c90bmerged withmain59e65849b0, and also verified conflict-free in a 5-way merge alongside#539,#1179,#1443, and#1733).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T08:59:17Z.
Validation run of this pull request.
669e09c90b. main:54b2a81e95. Merged cleanly (git merge --no-edit --no-ff pr-778, no conflicts); tested at the merge commit.cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ONcmake --build runtime/build --target gta6rt d3d12_msaa_draw_test command_list_test replay_texture_barrier_test vk_command_replay_test d3d12_vulkan_device_test d3d12_depth_resolve_test d3d12_typeless_depth_test -j 8ctest -R "^(d3d12_msaa_draw|d3d12_custom_samples|d3d12_sample_grid_reset|command_list|replay_texture_barrier|vk_command_replay|d3d12_vulkan_device|d3d12_depth_resolve|d3d12_typeless_depth)$" --output-on-failure -j1OPTIONS2 programmable sample positions tier 2and the 4x MSAA resolve line. The last four tests exercise the touched replay, device and depth code.d3d12_vulkan_devicepasses here, so none of the argument-range mismatches mentioned in the PR description show up on this machine.d3d12_com.cpp,d3d12_com.h,d3d12_vulkan_device.cpp,command_list.h,vulkan_backend.h,vulkan_replay.h) taken back from main, tests andruntime/CMakeLists.txtkept: the test targets do not build (35 compile errors, for example'SamplePositions' : not a class or namespace nameincommand_list_test.cpp). New API, so this is only a build failure.vk.set_sample_locations(...)call in the graphics replay path ofvulkan_replay.h, which is removed.d3d12_sample_grid_resetfails (pixel (63, 0): got 255,0,0,255 want coverage from the active sample pattern, thenline 397: !mismatches);d3d12_msaa_drawandd3d12_custom_samplesstill pass, so that call is only what the grid-reset case needs.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T15:44:20Z.
Merged. Tested by @zmasi on head
669e09c90(RTX 3090, Windows 11): d3d12_custom_samples + sample_grid_reset red on main (SetSamplePositions stub); green on head, 8/8 ctest. The CI jobs that are red on this head were also red on main at the time of the run. Thanks @kawaii-shakal!AI-assisted: yes