Repository navigation
Conversation
… RENDER_TARGET or DEPTH_WRITE
…so the state map is checked with the riid and output in place
|
Independent Windows test of Setup: Windows 11 x64, MSVC 19.44.35220 (
AI-assisted review/test. |
devnull34
left a comment
There was a problem hiding this comment.
Verified: builds and passes all 6 xs_proxy_mock test suites. Initial state 0x6 on committed textures correctly maps to RENDER_TARGET (when ALLOW_RENDER_TARGET) or DEPTH_WRITE (when ALLOW_DEPTH_STENCIL) for slots 27, 53, and 76 while preserving buffers and other states unchanged.
…VC leaves the upper half of the stack slot), and else-branch the generic forwarder (C4702); found by MartinIndra02 on ProjectLeonida#7356
|
@MartinIndra02 thanks, exact. |
|
Independent native Windows check at b3b9bb7 with clang-cl/xwin SDK 10.0.26100. All six xs_proxy_mock CTests passed, including the corrected state-0x6 mapping and unchanged control cases. AI-assisted testing. |
Independent native Windows GPU check of #7356 on RTX 4060 LaptopBase: The same synthetic harness linked the unmodified Xbox device proxy source from each revision. It selected the NVIDIA adapter by PCI IDs, wrapped the native D3D12 device, and created 64x64 RGBA8 render-target and D32 depth textures through slots 27, 53 and 76. For each successful creation it issued an RTV or DSV clear on the native device, submitted the command list and waited for the GPU fence with a 5 s timeout. Standard PC states were controls.
The native harness exited 1 on the base and 0 on the PR head. A second run per revision produced identical stdout. This verifies the compatibility fix at the native D3D12 resource-creation boundary and confirms the resulting resources accepted GPU clear commands. The test does not read back pixel or depth values. D3D12GetDebugInterface returned 0x887A002D on this machine, so the Debug Layer was unavailable. This test used native D3D12, so it provides no Vulkan validation or retail boot coverage. ReproduceUse the same inline cl /nologo /permissive- /utf-8 /EHsc /std:c++20 /O2 /DWIN32_LEAN_AND_MEAN /DNOMINMAX /I. path\to\native.cpp runtime\shims\d3d12_xs_device.cpp dxgi.lib d3d12.lib /Fe:native.exe
native.exe
cl /nologo /W4 /permissive- /utf-8 /EHsc /std:c++20 /O2 /DWIN32_LEAN_AND_MEAN /DNOMINMAX runtime\test\xs_proxy_mock_test.cpp runtime\shims\d3d12_xs_device.cpp /Fe:xs_proxy_mock_test.exeRun the mock executable with no arguments, then separately with native.cpp#include "runtime/shims/d3d12_xs_device.h"
#include <dxgi1_4.h>
#include <d3d12sdklayers.h>
#include <wrl/client.h>
#include <cstdio>
#include <initializer_list>
using Microsoft::WRL::ComPtr;
HRESULT create_texture(void* device, unsigned slot, const D3D12_HEAP_PROPERTIES& heap,
D3D12_RESOURCE_DESC& desc, unsigned state, ID3D12Resource** output) {
using Slot = HRESULT (WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, unsigned,
D3D12_RESOURCE_DESC*, unsigned, const void*, const void*, const void*, void*);
auto call = reinterpret_cast<Slot>((*reinterpret_cast<void***>(device))[slot]);
const IID iid = __uuidof(ID3D12Resource);
return call(device, &heap, 0, &desc, state, nullptr, slot == 53 ? nullptr : &iid,
slot == 53 ? static_cast<const void*>(&iid) : output, output);
}
bool clear_on_gpu(ID3D12Device* device, ID3D12Resource* resource, bool depth) {
const auto type = depth ? D3D12_DESCRIPTOR_HEAP_TYPE_DSV : D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{type, 1};
const D3D12_COMMAND_QUEUE_DESC queue_desc{};
ComPtr<ID3D12DescriptorHeap> heap;
ComPtr<ID3D12CommandQueue> queue;
ComPtr<ID3D12CommandAllocator> allocator;
ComPtr<ID3D12GraphicsCommandList> list;
ComPtr<ID3D12Fence> fence;
if (FAILED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap))) ||
FAILED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue))) ||
FAILED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator))) ||
FAILED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.Get(), nullptr, IID_PPV_ARGS(&list))) ||
FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence)))) return false;
const auto handle = heap->GetCPUDescriptorHandleForHeapStart();
if (depth) {
device->CreateDepthStencilView(resource, nullptr, handle);
list->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_DEPTH, 0.5f, 0, 0, nullptr);
} else {
const float color[4] = {0.25f, 0.5f, 0.75f, 1.0f};
device->CreateRenderTargetView(resource, nullptr, handle);
list->ClearRenderTargetView(handle, color, 0, nullptr);
}
if (FAILED(list->Close())) return false;
ID3D12CommandList* lists[] = {list.Get()};
queue->ExecuteCommandLists(1, lists);
HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
if (!event) return false;
const bool complete = SUCCEEDED(queue->Signal(fence.Get(), 1)) &&
SUCCEEDED(fence->SetEventOnCompletion(1, event)) &&
WaitForSingleObject(event, 5000) == WAIT_OBJECT_0 &&
SUCCEEDED(device->GetDeviceRemovedReason());
CloseHandle(event);
return complete;
}
int main() {
ComPtr<ID3D12Debug> debug;
HRESULT debug_hr = D3D12GetDebugInterface(IID_PPV_ARGS(&debug));
if (debug) debug->EnableDebugLayer();
std::printf("D3D12 Debug Layer: %08lx\n", static_cast<unsigned long>(debug_hr));
ComPtr<IDXGIFactory1> factory;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return 2;
ComPtr<ID3D12Device> device;
for (UINT i = 0; ; ++i) {
ComPtr<IDXGIAdapter1> adapter;
if (factory->EnumAdapters1(i, &adapter) != S_OK) break;
DXGI_ADAPTER_DESC1 desc{};
if (FAILED(adapter->GetDesc1(&desc)) || desc.VendorId != 0x10de || desc.DeviceId != 0x28e0) continue;
if (SUCCEEDED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_12_2, IID_PPV_ARGS(&device)))) {
std::printf("Device: %ls (%04x:%04x)\n", desc.Description, desc.VendorId, desc.DeviceId);
break;
}
}
if (!device) return 3;
ComPtr<IUnknown> proxy;
device->AddRef(); // proxy takes one reference to the native device
if (FAILED(rt::d3d12_xs::create_device_proxy(device.Get(), __uuidof(ID3D12Device),
reinterpret_cast<void**>(proxy.GetAddressOf())))) return 4;
const D3D12_HEAP_PROPERTIES heap{D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN, 1, 1};
unsigned passed = 0, total = 0;
for (unsigned slot : {27u, 53u, 76u}) {
for (bool depth : {false, true}) {
for (bool console : {false, true}) {
D3D12_RESOURCE_DESC desc{};
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
desc.Width = desc.Height = 64;
desc.DepthOrArraySize = desc.MipLevels = desc.SampleDesc.Count = 1;
desc.Format = depth ? DXGI_FORMAT_D32_FLOAT : DXGI_FORMAT_R8G8B8A8_UNORM;
desc.Flags = depth ? D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL : D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
const unsigned state = console ? 6 : depth ? D3D12_RESOURCE_STATE_DEPTH_WRITE : D3D12_RESOURCE_STATE_RENDER_TARGET;
ComPtr<ID3D12Resource> resource;
HRESULT hr = create_texture(proxy.Get(), slot, heap, desc, state, resource.GetAddressOf());
const bool cleared = resource && clear_on_gpu(device.Get(), resource.Get(), depth);
std::printf("slot=%u kind=%s state=0x%x HRESULT=0x%08lx GPU_clear_fence=%s\n",
slot, depth ? "depth" : "color", state, static_cast<unsigned long>(hr), cleared ? "pass" : "no");
++total;
passed += SUCCEEDED(hr) && cleared;
}
}
}
std::printf("Pass %u/%u\n", passed, total);
return passed == total ? 0 : 1;
} |
|
Tested Integration note: on top of #7240 this conflicts in slot 76's |
|
Tested |
|
A data point from a Windows retail boot on an RX 5700 (RDNA1, AMD driver 32.0.21045.29003, own 1.0.2.1 copy). It's a local integration with #7075's slot-133 stand-in, #7052/#7235 and this PR. The state-0x6 textures did not reach this PR's mapping here, because they come through device slot 133 (
So |
|
Second machine for @dracbat's slot-133 result above, and the state that comes next. Windows 11 26300, MSVC 14.44, RTX 2060 SUPER (617.14), Intel i5-9400F (#7111 needed),
AI-assisted (Claude Code). |
Slot 76 keeps ItsNotRexed#7240's lease and maps the initial state as ItsNotRexed#7356 does. The mock's slot 27 entry from ItsNotRexed#7240 also records the words after the fifth for ItsNotRexed#7356's check, and creates a resource only when riid and output are real pointers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @dracbat and @3L1A5-1: the state-0x6 textures coming through slot 133 (#7075, #7218) explains why this PR alone does not clear them. |
|
A correction to my comment above. On slot 133 the |
|
Thanks @dracbat for the correction: slot 133's third argument is a |
Slots 27/53 map the console initial state 0x6 (pc_initial_state_word); slot 76 maps it too and keeps ItsNotRexed#7240's lease. No same-slot clash: 27/53 were plain forwards. The mock keeps one slot-27 entry (creating, with a words-only mode for this PR's checks) and the PR's entry for 53. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claimed in #7231 (comment)
@ItsNotRexed: an exe PR, as you asked.
What
The Xbox device proxy now maps the console initial resource state 0x6 for committed textures. When the description is a texture (not a buffer) and the initial state is exactly 0x6, the PC device gets RENDER_TARGET (flag ALLOW_RENDER_TARGET) or DEPTH_WRITE (flag ALLOW_DEPTH_STENCIL) instead. Slots 27 (CreateCommittedResource), 53 (CreateCommittedResource1) and 76 (the Xbox resource creation, which ends in the PC CreateCommittedResource) share one helper. Every other state and every buffer goes on unchanged. The arguments are copied; the title's memory is never written. Slots 27 and 53 are handled after the Xbox route table, so the LEONIDA_XS_*_SLOT overrides still win.
Why
A retail exe integration run (rafaelpssz) showed the title creating committed render-target and depth textures with state 0x6, which the PC CreateCommittedResource refuses for a texture. Mapping by the resource flags gets past it.
Tested
xs_proxy_mock_test(Wine, p2): PASS. New check: an RT texture with 0x6 reaches the mock PC device as RENDER_TARGET, a DS texture as DEPTH_WRITE (slots 27, 53, 76); a buffer with 0x6, an RT with state 0, a texture without a use flag and an RT with state 0x4 are unchanged.Credit: rafaelpssz for the finding.