From 595f1bd4201beafba95da65da103968eab65784d Mon Sep 17 00:00:00 2001 From: QemmHD <290605352+QemmHD@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:18:20 -0500 Subject: [PATCH] d3d12_depth_resolve_test: the host's edge draw takes the standard 4x sample positions The edge cases (TEST-848) compare MIN, MAX and AVERAGE over samples that differ with the PC runtime on the layer's own adapter. On an RTX 4070 SUPER (NVIDIA 621.24, Windows 11) all 34 of them failed against the hardware reference while matching WARP byte for byte. The reference was the one off: with NVIDIA's MFAA ("Enable sample interleaving") on in the driver's global profile, a D3D12 4x target's default sample positions are not the standard pattern. Measured with a D3D12-only program (no Vulkan): until the first Present the four samples of a pixel coincide, so MIN, MAX and AVERAGE agree everywhere, and after each Present two other patterns alternate. Vulkan on the same driver keeps the standard locations, and so does the layer. Where the device has programmable sample positions, the edge cases now set the standard pattern before the clears and keep it through the resolve. The layer and WARP report none and are unchanged. On that machine: 74 of 97 match on the hardware (36 before), 71 of 71 on WARP, exit 0, also under LEONIDA_VK_VALIDATION=1. No game data. AI-assisted. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf --- runtime/test/d3d12_depth_resolve_test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/test/d3d12_depth_resolve_test.cpp b/runtime/test/d3d12_depth_resolve_test.cpp index 35d4259fe7..f247410722 100644 --- a/runtime/test/d3d12_depth_resolve_test.cpp +++ b/runtime/test/d3d12_depth_resolve_test.cpp @@ -104,6 +104,22 @@ bool resolve_and_read(ID3D12Device* device, const Case& c, Planes& out, bool che IID_PPV_ARGS(&list.p)))); CHECK(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p)))); const auto execute = [&](ID3D12CommandList* commands) { queue->ExecuteCommandLists(1, &commands); }; + // The edge draw's samples, pinned to the D3D standard 4x pattern where the device has programmable positions: a + // driver setting can move the default ones. Measured on an RTX 4070 SUPER (621.24) with NVIDIA's MFAA ("sample + // interleaving") on in the global profile: the four samples of a pixel coincide until the first Present and two + // other patterns alternate after each one, so no edge resolve matched WARP or the layer. Set before the clears + // and kept through the resolve, as depth data needs. The layer and WARP have no programmable positions. + const auto pin_samples = [&](ID3D12GraphicsCommandList* commands) { + D3D12_FEATURE_DATA_D3D12_OPTIONS2 options{}; + Ref positions; + if (!c.edge || FAILED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &options, sizeof options)) || + options.ProgrammableSamplePositionsTier == D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED || + FAILED(commands->QueryInterface(IID_PPV_ARGS(&positions.p)))) + return; + D3D12_SAMPLE_POSITION standard[4] = {{-2, -6}, {6, -2}, {-6, 2}, {2, 6}}; // 1/16 pixel from the centre + positions->SetSamplePositions(4, 1, standard); + }; + pin_samples(list.p); D3D12_HEAP_PROPERTIES heap_properties{}; heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT; @@ -203,6 +219,7 @@ bool resolve_and_read(ID3D12Device* device, const Case& c, Planes& out, bool che CHECK(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); CHECK(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr, IID_PPV_ARGS(&list1.p)))); + pin_samples(list1.p); } else { CHECK(SUCCEEDED(list->QueryInterface(IID_PPV_ARGS(&list1.p)))); }