From 3cf0a41bc542f4f2172f9a0703da0b14d67063bc Mon Sep 17 00:00:00 2001 From: QemmHD <290605352+QemmHD@users.noreply.github.com> Date: Tue, 24 Nov 2026 23:32:49 -0500 Subject: [PATCH] d3d12_xs: make a D16S8 depth texture without UAV when the depth provider refuses it Since #939, slots 76 and 133 hand a depth-stencil texture with unordered access to the depth provider. On a GPU with D24S8 attachments (every NVIDIA card) the Vulkan layer's pc_format() makes D16_UNORM_S8_UINT (format 118) as D24_UNORM_S8_UINT, and Resource::enable_depth_stencil_uav accepts only R16_TYPELESS, 118 and R32G8X24_TYPELESS, so it answers E_INVALIDARG. Slot 133 passed that on for a 1280x720 format 118 texture with ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS (all-ones layout), and the boot stopped on an int3. When the provider refuses (E_INVALIDARG or E_NOTIMPL from the provider call itself), slot 76 now makes the committed texture without unordered access and slot 133 goes on to its stand-in (the title-placed texture, else the committed one), as both did before the provider. The first refusal per slot is logged. Any other failure is passed on as before: the provider out of memory, the backing's own CreateCommittedResource, a refused placement or description. The refused backing is released and no placement range is registered. On a real boot (Windows 11, RTX 4070 SUPER, driver 621.24), on 0bc810504 with an earlier form of this change that fell back on any failure of the depth path (the only one that occurred was the provider's): the fallback fires once (slot 133, format 118, hr=0x80070057), no int3, 6,187 PresentX ok and 0 failed, 69/69 captures non-black, and the boot reaches the first-run pages. Without it, 3 of 3 boots stopped on the int3 after 182-362 PresentX. Tests: - xs_proxy_mock: a mock provider refusing a format 118 texture (E_INVALIDARG, E_NOTIMPL) through slots 76 and 133 gets S_OK and the stand-in, with the refused backing released; E_OUTOFMEMORY from the provider, a failing backing and a refused placement are passed on with no stand-in. - xbox_d16s8_refused_uav (Vulkan, LEONIDA_CONSOLE_D16S8=d24): slots 76 and 133 return a depth-stencil texture without unordered access. Both fail without the change (slot 76 and slot 133 each checked on its own). Follow-up: teach enable_depth_stencil_uav the D24S8-made form of format 118, so these textures keep their UAVs on NVIDIA too. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf --- docs/d3d12_vulkan.md | 11 ++ runtime/CMakeLists.txt | 5 + runtime/shims/d3d12_xs_device.cpp | 56 ++++++++--- runtime/test/xbox_depth_storage_test.cpp | 49 +++++++++ runtime/test/xs_proxy_mock_test.cpp | 122 ++++++++++++++++++++++- 5 files changed, 230 insertions(+), 13 deletions(-) diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index e23985ecb3..bc4362e205 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -2861,6 +2861,17 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv image when both layouts are opaque, since D3D12 leaves an alias's contents undefined until reinitialized, and is refused only for a non-opaque layout. Before this, the retail boot stopped on the title's assert while it created its D16 depth targets on an RDNA2 iGPU under RADV. A refused depth placement is logged (no trace line covers it). + Where the provider (`Resource::enable_depth_stencil_uav`) has no unordered-access form of a texture it answers + `E_INVALIDARG` or `E_NOTIMPL`, and slots 76 and 133 then make the texture without unordered access, as before the + provider: slot 76 as a committed depth-stencil texture, slot 133 through its stand-in (the title-placed texture, or + the committed one). The first such refusal per slot is logged. That is the console D16S8 format (118) on a GPU with + D24S8 attachments (every NVIDIA card): `pc_format()` makes it as `D24_UNORM_S8_UINT`, which the provider does not + take; a real boot stopped on an int3 after slot 133 returned that refusal. Its UAVs then write no + descriptor, as for the slot 25 stand-in. Any other failure (out of memory, the backing itself, a refused placement) + is passed on as before. Follow-up: teach `enable_depth_stencil_uav` the D24S8-made form of format 118 (its widened + path already serves a D16S8 target stored as `D32_SFLOAT_S8_UINT`), so these textures keep their UAVs on NVIDIA + too. `xs_proxy_mock` checks the refusal against a mock provider, and `xbox_d16s8_refused_uav` on a GPU with + `LEONIDA_CONSOLE_D16S8=d24`. - Legacy and enhanced texture transitions copy the selected planes and layers to or from their storage images. Fence-ordered graphics and compute queues can share UAV access. A dedicated compute family can perform the plane transfer itself when `VK_KHR_maintenance10` and the format's depth/stencil copy flags allow it. diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 48c8af3602..7e5c0a8df4 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -2895,6 +2895,11 @@ if(TARGET Vulkan::Headers) set_tests_properties(xbox_d16s8_storage PROPERTIES ENVIRONMENT "LEONIDA_TEST_D16S8_UAV=1;LEONIDA_CONSOLE_D16S8=native" SKIP_RETURN_CODE 77 TIMEOUT 30) set_tests_properties(xbox_depth_storage PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 30) + # Made as D24S8, a D16S8 depth-stencil texture with unordered access is refused by the depth provider; slots 76 + # and 133 make it without unordered access instead (d24 forces what a GPU with D24S8 attachments chooses). + add_test(NAME xbox_d16s8_refused_uav COMMAND xbox_depth_storage_test) + set_tests_properties(xbox_d16s8_refused_uav PROPERTIES + ENVIRONMENT "LEONIDA_TEST_D16S8_REFUSED_UAV=1;LEONIDA_CONSOLE_D16S8=d24" SKIP_RETURN_CODE 77 TIMEOUT 30) add_executable(xbox_d16s8_surface_test test/xbox_d16s8_surface_test.cpp) target_link_libraries(xbox_d16s8_surface_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(xbox_d16s8_surface_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 60d7c62f30..415ea6cca5 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -4253,9 +4253,26 @@ D3D12_RESOURCE_STATES depth_image_state(D3D12_RESOURCE_STATES requested) { return requested == D3D12_RESOURCE_STATE_UNORDERED_ACCESS ? D3D12_RESOURCE_STATE_COMMON : requested; } +// The depth provider answers E_INVALIDARG or E_NOTIMPL for a texture it has no unordered-access form of +// (Resource::enable_depth_stencil_uav). A console D16S8 target is one on a GPU with D24S8 attachments (every NVIDIA +// card): pc_format() makes it as D24_UNORM_S8_UINT, and the provider takes only R16_TYPELESS, 118 and +// R32G8X24_TYPELESS. Slots 76 and 133 then make the texture without unordered access, as they did before the provider +// (#939), and the title gets its texture instead of asserting. Any other failure is passed on as it is. +bool depth_provider_refusal(HRESULT hr) { return hr == E_INVALIDARG || hr == E_NOTIMPL; } + +void note_depth_provider_refusal(std::atomic& seen, unsigned slot, DXGI_FORMAT format, HRESULT hr) { + if (first_call(seen)) + std::fprintf(stderr, + "[rt] d3d12_xs: slot %u: the depth provider refused a depth-stencil texture with unordered access " + "(format %d, hr=0x%08x); it is made without unordered access\n", + slot, static_cast(format), static_cast(hr)); +} + +// `refused` (optional) is set when the provider refused the texture (depth_provider_refusal), not when the backing +// itself failed. HRESULT create_depth_uav_backing(DeviceProxy* self, const D3D12_HEAP_PROPERTIES* props, D3D12_HEAP_FLAGS flags, const D3D12_RESOURCE_DESC& native, D3D12_RESOURCE_STATES initial, - const D3D12_CLEAR_VALUE* clear, ID3D12Resource** out) { + const D3D12_CLEAR_VALUE* clear, ID3D12Resource** out, bool* refused = nullptr) { // The logical Xbox texture has a UAV. Its writable planes take ALLOW_SHADER_ATOMICS, which the PC // rejects on the depth-only attachment. Upload/readback heaps cannot hold a UAV on either API. if (props && (props->Type == D3D12_HEAP_TYPE_UPLOAD || props->Type == D3D12_HEAP_TYPE_READBACK)) @@ -4268,12 +4285,14 @@ HRESULT create_depth_uav_backing(DeviceProxy* self, const D3D12_HEAP_PROPERTIES* if (FAILED(hr)) { (*out)->Release(); *out = nullptr; + if (refused) *refused = depth_provider_refusal(hr); } return hr; } HRESULT proxy_create_placed_depth(DeviceProxy* self, UINT64 address, const D3D12_RESOURCE_DESC& desc, - std::uint32_t layout, const D3D12_CLEAR_VALUE* clear, REFIID riid, void** out) { + std::uint32_t layout, const D3D12_CLEAR_VALUE* clear, REFIID riid, void** out, + bool* provider_refused) { const auto native = depth_image_desc(desc); const bool valid = self->validate_depth_placement(native, layout, clear); D3D12_RESOURCE_ALLOCATION_INFO alloc{}; @@ -4283,12 +4302,13 @@ HRESULT proxy_create_placed_depth(DeviceProxy* self, UINT64 address, const D3D12 const D3D12_HEAP_PROPERTIES heap{D3D12_HEAP_TYPE_DEFAULT}; hr = self->placed_depth_textures.create(address, native, alloc, clear, desc.Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN, riid, out, [&](ID3D12Resource** backing) { return create_depth_uav_backing(self, &heap, D3D12_HEAP_FLAG_NONE, native, D3D12_RESOURCE_STATE_COMMON, - clear, backing); + clear, backing, provider_refused); }); } - // A refusal here reaches no trace line, and the title stops on an int3 right after it: log the first few. + // A refusal here reaches no trace line, and the title stops on an int3 right after it: log the first few. The + // provider's own refusal is not one of them: slot 133 makes that texture without unordered access and says so. static std::atomic refusals{0}; - if (FAILED(hr) && refusals.fetch_add(1, std::memory_order_relaxed) < 8) + if (FAILED(hr) && !*provider_refused && refusals.fetch_add(1, std::memory_order_relaxed) < 8) std::fprintf(stderr, "[rt] d3d12_xs: slot 133 depth texture refused (hr=0x%08x, %s): format %d %llux%ux%u, Xbox layout " "0x%x, layout word 0x%x, PC size %llu\n", @@ -4329,13 +4349,19 @@ HRESULT proxy_create_resource(DeviceProxy* self, const D3D12_HEAP_PROPERTIES* he // With a provider for the unordered-access planes the texture keeps them (two resources behind one). if (supports_depth_uav(self, *xbox_desc)) { ID3D12Resource* resource = nullptr; + bool refused = false; HRESULT hr = create_depth_uav_backing(self, heap_properties, heap_flags, depth_image_desc(pc_desc), - depth_image_state(initial_state), clear_value, &resource); - if (FAILED(hr)) return hr; - hr = resource->QueryInterface(*riid, out); - if (SUCCEEDED(hr)) lease_title_resource_memory(self, *out, pc_desc, unsigned(xbox_desc->Layout)); - resource->Release(); - return hr; + depth_image_state(initial_state), clear_value, &resource, &refused); + if (SUCCEEDED(hr)) { + hr = resource->QueryInterface(*riid, out); + if (SUCCEEDED(hr)) lease_title_resource_memory(self, *out, pc_desc, unsigned(xbox_desc->Layout)); + resource->Release(); + return hr; + } + if (!refused) return hr; + // pc_desc has no unordered access already (without_depth_stencil_uav): the committed texture below is it. + static std::atomic refusal_seen{false}; + note_depth_provider_refusal(refusal_seen, 76, xbox_desc->Format, hr); } const HRESULT hr = self->real->CreateCommittedResource(heap_properties, heap_flags, &pc_desc, pc_initial_state(&pc_desc, initial_state), clear_value, @@ -4663,7 +4689,13 @@ HRESULT proxy_create_placed_resource_slot133(DeviceProxy* self, std::uint64_t va depth_uav_description(*xbox_desc)) { note_slot(133); *out = nullptr; - return proxy_create_placed_depth(self, va, *xbox_desc, state, clear_value, *riid, out); + bool refused = false; + const HRESULT hr = proxy_create_placed_depth(self, va, *xbox_desc, state, clear_value, *riid, out, &refused); + if (!refused) return hr; + // The paths below make it without unordered access, as before the provider (depth_provider_refusal). + *out = nullptr; + static std::atomic refusal_seen{false}; + note_depth_provider_refusal(refusal_seen, 133, xbox_desc->Format, hr); } if (out && xbox_desc && riid) { const HRESULT hr = proxy_create_buffer_at_va(self, reinterpret_cast(va), xbox_desc, state, clear_value, diff --git a/runtime/test/xbox_depth_storage_test.cpp b/runtime/test/xbox_depth_storage_test.cpp index 9f33db608b..4ae4a40a3d 100644 --- a/runtime/test/xbox_depth_storage_test.cpp +++ b/runtime/test/xbox_depth_storage_test.cpp @@ -54,6 +54,50 @@ int check_lease(ID3D12Device* dev, ID3D12Device* xbox) { rt::d3d12_xs::set_descriptor_heap_allocator(nullptr, nullptr); return 0; } + +// With the console D16S8 family made as D24S8 (LEONIDA_CONSOLE_D16S8=d24; the default on a GPU with D24S8 +// attachments, every NVIDIA card), the depth provider has no unordered-access form of a format 118 depth-stencil +// texture and refuses it (Resource::enable_depth_stencil_uav). Slots 76 and 133 then make it without unordered +// access, as before the provider, so the title gets its texture instead of asserting. The description is the one +// measured where a real boot stopped: 1280x720, one mip, the all-ones layout through slot 133. +int check_d16s8_refused_uav(ID3D12Device* xbox) { + D3D12_RESOURCE_DESC tex{}; + tex.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + tex.Width = 1280; + tex.Height = 720; + tex.DepthOrArraySize = tex.MipLevels = 1; + tex.SampleDesc.Count = 1; + tex.Format = static_cast(118); + tex.Layout = static_cast(0x101); + tex.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + D3D12_HEAP_PROPERTIES heap{D3D12_HEAP_TYPE_DEFAULT}; + D3D12_CLEAR_VALUE clear{}; + clear.Format = tex.Format; + clear.DepthStencil.Depth = 1; + using Create = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, UINT, const D3D12_RESOURCE_DESC*, UINT, + const D3D12_CLEAR_VALUE*, const IID*, void**); + Ref committed; + VERIFY(SUCCEEDED(reinterpret_cast(slot(xbox, 76))(xbox, &heap, 0, &tex, D3D12_RESOURCE_STATE_DEPTH_WRITE, + &clear, &__uuidof(ID3D12Resource), + reinterpret_cast(&committed.p)))); + VERIFY(committed.p && committed->GetDesc().Flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); + + using Place = HRESULT(WINAPI*)(void*, UINT64, const D3D12_RESOURCE_DESC*, UINT, const D3D12_CLEAR_VALUE*, + const IID*, void**); + constexpr SIZE_T pages = 16u << 20; // past the texture's size on any GPU; VirtualAlloc aligns it to 64 KiB + void* va = VirtualAlloc(nullptr, pages, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + VERIFY(va); + Ref placed; + const HRESULT hr = reinterpret_cast(slot(xbox, 133))(xbox, reinterpret_cast(va), &tex, 0xFFFFFFFFu, + &clear, &__uuidof(ID3D12Resource), + reinterpret_cast(&placed.p)); + const bool made = SUCCEEDED(hr) && placed.p && placed->GetDesc().Flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; + placed = {}; + VirtualFree(va, 0, MEM_RELEASE); + VERIFY(made); + std::printf("Xbox D16S8 made as D24S8: slots 76 and 133 make the depth-stencil texture without unordered access\n"); + return 0; +} } int main() { @@ -96,6 +140,11 @@ int main() { VERIFY(SUCCEEDED(rt::d3d12_xs::create_device_proxy(dev, __uuidof(ID3D12Device), reinterpret_cast(&proxy.p), true))); rt::d3d12::set_device_outer(dev, proxy.p); + if (std::getenv("LEONIDA_TEST_D16S8_REFUSED_UAV")) { + VERIFY(check_d16s8_refused_uav(proxy.p) == 0); + VERIFY(gpu.validation_errors() == 0); + return 0; + } VERIFY(check_lease(dev, proxy.p) == 0); const auto allocation = dev->GetResourceAllocationInfo(0, 1, &tex); VERIFY(allocation.SizeInBytes >= 768u * 768 * layers * 2 && allocation.SizeInBytes != UINT64_MAX); diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index d1dd93461c..d4c3e192bf 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -1547,6 +1547,126 @@ int check_placed_resource_x() { return 0; } +// ---- 6c. Slots 76 and 133 when the depth provider refuses a depth-stencil texture with unordered access ---- +// +// The provider answers E_INVALIDARG or E_NOTIMPL for a texture it has no unordered-access form of: a console D16S8 +// (format 118) target that the Vulkan layer makes as D24S8 on a GPU with D24S8 attachments (NVIDIA). The slots then +// make the texture as they did before the provider: slot 76 a committed texture without unordered access, slot 133 +// its stand-in (the title-pages handler, else the committed one). The backing the provider refused is released. Any +// other failure (the provider out of memory, the backing itself, a placement the backend refuses) is passed on as it +// is, with no stand-in. +HRESULT g_provider_result = S_OK; +unsigned g_provider_calls = 0; +Mock* g_provider_backing = nullptr; // the resource the provider was last given +bool g_placement_valid = true; + +HRESULT mock_depth_provider(ID3D12Resource* resource, D3D12_HEAP_FLAGS) { + ++g_provider_calls; + g_provider_backing = reinterpret_cast(resource); + return g_provider_result; +} + +bool mock_validate_placement(const D3D12_RESOURCE_DESC&, std::uint32_t, const D3D12_CLEAR_VALUE*) { + return g_placement_valid; +} + +int check_depth_provider_refusal() { + Mock* mock = nullptr; + void* device = make_device(mock, 9, true); + EXPECT(device && xs::set_depth_stencil_uav_provider(device, mock_depth_provider, mock_validate_placement)); + constexpr std::uint64_t kVa = 0x7f0000000000ull; // 64 KiB aligned, as the placement is checked to be + constexpr auto kDepthStencilUav = static_cast(D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL | + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); + // The description measured where a real boot stopped: 1280x720, one mip, format 118, depth-stencil with UAV. + D3D12_RESOURCE_DESC d16s8{}; + d16s8.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + d16s8.Width = 1280; + d16s8.Height = 720; + d16s8.DepthOrArraySize = 1; + d16s8.MipLevels = 1; + d16s8.Format = static_cast(118); + d16s8.SampleDesc.Count = 1; + d16s8.Layout = static_cast(0x101); + d16s8.Flags = kDepthStencilUav; + const D3D12_HEAP_PROPERTIES heap{D3D12_HEAP_TYPE_DEFAULT}; + void* resource = nullptr; + const std::uint64_t words76[10] = {word(&heap), 0, word(&d16s8), D3D12_RESOURCE_STATE_DEPTH_WRITE, 0, + word(&kResourceIid), word(&resource), 0, 0, 0}; + const auto place = [&] { + return hr_of(raw6(device, 133, kVa, word(&d16s8), 0xFFFFFFFFu, 0, word(&kResourceIid), word(&resource))); + }; + const auto arm = [&](HRESULT result) { + g_provider_result = result; + g_provider_calls = 0; + g_provider_backing = nullptr; + resource = reinterpret_cast(1); + return mock->calls[27]; + }; + + // The provider accepts: one backing, handed out as the texture (slot 76) or behind its placement (slot 133). + unsigned before = arm(S_OK); + EXPECT(hr_of(raw10(device, 76, words76)) == S_OK && resource == g_provider_backing && g_provider_calls == 1); + EXPECT(mock->calls[27] == before + 1 && !(g_committed.desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)); + EXPECT(release(resource) == 0); + before = arm(S_OK); + EXPECT(place() == S_OK && resource && g_provider_calls == 1 && mock->calls[27] == before + 1); + EXPECT(release(resource) == 0 && g_provider_backing->refs == 0); + + // The provider refuses: the texture is made without it, and the refused backing is not kept. + for (const HRESULT refusal : {E_INVALIDARG, E_NOTIMPL}) { + before = arm(refusal); + EXPECT(hr_of(raw10(device, 76, words76)) == S_OK && resource && g_provider_calls == 1); + EXPECT(g_provider_backing && g_provider_backing->refs == 0 && resource != g_provider_backing); + EXPECT(mock->calls[27] == before + 2 && reinterpret_cast(resource)->kind == Kind::resource); + EXPECT(g_committed.desc.Flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL && + g_committed.desc.Format == d16s8.Format && g_committed.desc.Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN); + EXPECT(g_committed.state == D3D12_RESOURCE_STATE_DEPTH_WRITE); + EXPECT(release(resource) == 0); + + // Slot 133 reaches its stand-in with the title's description, as before the provider; without the + // title-pages handler that is the committed DEFAULT one, in COMMON for the all-ones layout. + before = arm(refusal); + EXPECT(place() == S_OK && resource && g_provider_calls == 1); + EXPECT(g_provider_backing && g_provider_backing->refs == 0 && resource != g_provider_backing); + EXPECT(mock->calls[27] == before + 2 && reinterpret_cast(resource)->kind == Kind::resource); + EXPECT(g_committed.heap.Type == D3D12_HEAP_TYPE_DEFAULT && g_committed.state == D3D12_RESOURCE_STATE_COMMON); + EXPECT(g_committed.desc.Format == d16s8.Format && g_committed.desc.Width == d16s8.Width && + g_committed.desc.Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN); + EXPECT(release(resource) == 0); + } + + // Any other failure of the provider is passed on, with no texture and no stand-in. + before = arm(E_OUTOFMEMORY); + EXPECT(hr_of(raw10(device, 76, words76)) == E_OUTOFMEMORY && !resource && g_provider_calls == 1); + EXPECT(g_provider_backing->refs == 0 && mock->calls[27] == before + 1); + before = arm(E_OUTOFMEMORY); + EXPECT(place() == E_OUTOFMEMORY && !resource && g_provider_calls == 1); + EXPECT(g_provider_backing->refs == 0 && mock->calls[27] == before + 1); + + // So is a failure of the backing itself, which the provider never sees. + mock->create_result = E_INVALIDARG; + before = arm(S_OK); + EXPECT(hr_of(raw10(device, 76, words76)) == E_INVALIDARG && !resource && g_provider_calls == 0); + EXPECT(mock->calls[27] == before + 1); + before = arm(S_OK); + EXPECT(place() == E_INVALIDARG && !resource && g_provider_calls == 0 && mock->calls[27] == before + 1); + mock->create_result = S_OK; + + // And a placement the backend refuses (E_INVALIDARG too), before any backing is made. + g_placement_valid = false; + before = arm(E_INVALIDARG); + EXPECT(place() == E_INVALIDARG && !resource && g_provider_calls == 0 && mock->calls[27] == before); + g_placement_valid = true; + + EXPECT(xs::set_depth_stencil_uav_provider(device, nullptr)); + g_provider_result = S_OK; + EXPECT(release(device) == 0 && mock->refs == 0); + std::printf("%s: a format 118 depth-stencil texture the depth provider refuses (E_INVALIDARG, E_NOTIMPL) is made " + "without it by slots 76 and 133; its other failures, the backing's and the placement's are passed " + "on\n", g_label); + return 0; +} + // The same stand-in with LEONIDA_SLOT133_LAYOUT_WORD=1 (its own process: the switch is read once): the fourth word is // a D3D12_BARRIER_LAYOUT. A device without ID3D12Device10 gets the legacy state of that layout through // CreateCommittedResource; one with it gets CreateCommittedResource3 and the layout as given. @@ -4101,7 +4221,7 @@ int main(int argc, char** argv) { check_list_cpu_handles() || check_presentation_wiring() || check_queue_copy_page_mappings()) return 1; - if (check_placed_resource_x()) return 1; + if (check_placed_resource_x() || check_depth_provider_refusal()) return 1; std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); return 0; }