diff options
| author | ubiquitarianism <283527159+ubiquitarianism@users.noreply.github.com> | 2026-11-23 19:37:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 19:37:40 -0500 |
| commit | 2e471574666f6d3c4e26bd91c7b54ee91b899fe3 (patch) | |
| tree | d72e59ad7b0a2f977293cb16160a3b9d25ed218c /runtime | |
| parent | 8eee35cfdccc613a1f7a10a5539d5bd3b25038ba (diff) | |
| parent | f9c68577e3c640f2f1dbd4c7b19036eaf3cbd2a4 (diff) | |
Merge pull request #2 from ExCorvus/fix/d3d12-build-breaks-and-texture-va
D3D12: fix the slot-14 and acphal build breaks, report slot-133 texture GPU VAs
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/shims/acphal.cpp | 4 | ||||
| -rw-r--r-- | runtime/shims/d3d12_vulkan_device.cpp | 52 | ||||
| -rw-r--r-- | runtime/shims/d3d12_xs_device.cpp | 18 | ||||
| -rw-r--r-- | runtime/shims/d3d12_xs_device.h | 9 | ||||
| -rw-r--r-- | runtime/test/d3d12_console_descriptor_heap_test.cpp | 18 | ||||
| -rw-r--r-- | runtime/test/d3d12_existing_heap_test.cpp | 10 |
6 files changed, 82 insertions, 29 deletions
diff --git a/runtime/shims/acphal.cpp b/runtime/shims/acphal.cpp index 553f57f20..5ead016d6 100644 --- a/runtime/shims/acphal.cpp +++ b/runtime/shims/acphal.cpp | |||
| @@ -141,7 +141,7 @@ struct SHAPE_XMA_CONTEXT { | |||
| 141 | uint32_t reserved1 : 6; | 141 | uint32_t reserved1 : 6; |
| 142 | uint32_t loopStartOffset : 26; | 142 | uint32_t loopStartOffset : 26; |
| 143 | uint32_t loopEndOffset : 6; | 143 | uint32_t loopEndOffset : 6; |
| 144 | uint32_t reserved[10]; | 144 | uint32_t reserved[11]; // the GDK's 64-byte context: the published field list leaves one trailing word |
| 145 | }; | 145 | }; |
| 146 | static_assert(sizeof(SHAPE_XMA_CONTEXT) == 64, "SHAPE_XMA_CONTEXT is 64 bytes per GDK"); | 146 | static_assert(sizeof(SHAPE_XMA_CONTEXT) == 64, "SHAPE_XMA_CONTEXT is 64 bytes per GDK"); |
| 147 | 147 | ||
| @@ -162,7 +162,7 @@ struct SHAPE_PCM_CONTEXT { | |||
| 162 | uint32_t reserved6 : 15; | 162 | uint32_t reserved6 : 15; |
| 163 | uint32_t format : 2; | 163 | uint32_t format : 2; |
| 164 | uint32_t reserved7 : 14; | 164 | uint32_t reserved7 : 14; |
| 165 | uint32_t reserved[1]; | 165 | uint32_t reserved[2]; // the GDK's 32-byte context: the published field list leaves one trailing word |
| 166 | }; | 166 | }; |
| 167 | static_assert(sizeof(SHAPE_PCM_CONTEXT) == 32, "SHAPE_PCM_CONTEXT is 32 bytes per GDK"); | 167 | static_assert(sizeof(SHAPE_PCM_CONTEXT) == 32, "SHAPE_PCM_CONTEXT is 32 bytes per GDK"); |
| 168 | 168 | ||
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index a6911d0f4..0273f9339 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp | |||
| @@ -2307,10 +2307,15 @@ public: | |||
| 2307 | 2307 | ||
| 2308 | // D3D12 answers only for committed and placed resources (E_INVALIDARG for reserved ones, measured on the PC | 2308 | // D3D12 answers only for committed and placed resources (E_INVALIDARG for reserved ones, measured on the PC |
| 2309 | // runtime). | 2309 | // runtime). |
| 2310 | // Buffers only, as on D3D12; textures have no GPU VA (images are reached through descriptors). An acceleration | 2310 | // Buffers report their console VA into the GPU address arena; an acceleration structure reports its real device |
| 2311 | // structure reports its real device address (instance descriptors and builds hand it to the driver); other | 2311 | // address (instance descriptors and builds hand it to the driver). A texture the title placed at its own address |
| 2312 | // buffers report their console VA into the GPU address arena. | 2312 | // through Xbox slot 133 reports that title address, as the console does: a title uses it as the CPU pointer it |
| 2313 | // clears the texture through (docs/d3d12_vulkan.md 3.3). Any other texture answers 0, as on D3D12. | ||
| 2313 | D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE GetGPUVirtualAddress() override { return accel_ ? gpu_va_ : va_; } | 2314 | D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE GetGPUVirtualAddress() override { return accel_ ? gpu_va_ : va_; } |
| 2315 | // The title's own address for a texture Xbox slot 133 placed. The image is still the committed fallback, so its | ||
| 2316 | // pixels do not alias the title's pages yet; the address is what GetGPUVirtualAddress answers (XCL PR #168's | ||
| 2317 | // behavior, measured on a retail title). | ||
| 2318 | void set_title_address(D3D12_GPU_VIRTUAL_ADDRESS address) { va_ = address; } | ||
| 2314 | 2319 | ||
| 2315 | // | 2320 | // |
| 2316 | // The node masks read back as the one node of a single adapter (0 becomes 1), and the heap flags as the runtime | 2321 | // The node masks read back as the one node of a single adapter (0 becomes 1), and the heap flags as the runtime |
| @@ -2621,7 +2626,7 @@ private: | |||
| 2621 | bool placed_ = false; | 2626 | bool placed_ = false; |
| 2622 | leonida::ResourceBinding binding_{}; // a texture's, as registered with the context | 2627 | leonida::ResourceBinding binding_{}; // a texture's, as registered with the context |
| 2623 | bool host_transfer_ = false; // created with VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT | 2628 | bool host_transfer_ = false; // created with VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT |
| 2624 | D3D12_GPU_VIRTUAL_ADDRESS va_ = 0; | 2629 | D3D12_GPU_VIRTUAL_ADDRESS va_ = 0; // a buffer's console VA, or a slot-133 texture's title address |
| 2625 | VkDeviceSize arena_offset_ = 0; | 2630 | VkDeviceSize arena_offset_ = 0; |
| 2626 | bool in_arena_ = false; | 2631 | bool in_arena_ = false; |
| 2627 | // A placed buffer's heap range, held as a D3D12 placed resource holds its heap: the app may release the heap | 2632 | // A placed buffer's heap range, held as a D3D12 placed resource holds its heap: the app may release the heap |
| @@ -5008,6 +5013,7 @@ public: | |||
| 5008 | // standalone device gta6rt --run uses both come through here (found in review: registering only in | 5013 | // standalone device gta6rt --run uses both come through here (found in review: registering only in |
| 5009 | // create_vulkan_device left the retail path without it). | 5014 | // create_vulkan_device left the retail path without it). |
| 5010 | rt::d3d12_xs::set_placed_at_va_handler(&create_buffer_at_host_address); | 5015 | rt::d3d12_xs::set_placed_at_va_handler(&create_buffer_at_host_address); |
| 5016 | rt::d3d12_xs::set_console_descriptor_heap_handler(&rt::d3d12::create_console_descriptor_heap); | ||
| 5011 | state_.info = info; | 5017 | state_.info = info; |
| 5012 | queue_users_.resize(info.command_queues.size(), 0); | 5018 | queue_users_.resize(info.command_queues.size(), 0); |
| 5013 | compute_users_.resize(info.compute_queues.size(), 0); | 5019 | compute_users_.resize(info.compute_queues.size(), 0); |
| @@ -5500,6 +5506,19 @@ public: | |||
| 5500 | const leonida::BindlessSet* bindless() const { return state_.bindless.get(); } | 5506 | const leonida::BindlessSet* bindless() const { return state_.bindless.get(); } |
| 5501 | const DeviceState& state() const { return state_; } | 5507 | const DeviceState& state() const { return state_; } |
| 5502 | IUnknown* holder() { return identity(); } | 5508 | IUnknown* holder() { return identity(); } |
| 5509 | // Console-extended CreateDescriptorHeap (Xbox slot 14): a heap at the title's console address. The proxy's | ||
| 5510 | // handler (set_console_descriptor_heap_handler) calls this; a normal PC create never does. | ||
| 5511 | HRESULT create_console_descriptor_heap(const D3D12_DESCRIPTOR_HEAP_DESC* desc, | ||
| 5512 | D3D12_GPU_VIRTUAL_ADDRESS console_address, std::uint64_t console_size, | ||
| 5513 | REFIID riid, void** out) { | ||
| 5514 | auto* heap = new DescriptorHeap(state_, *desc, console_address, console_size); | ||
| 5515 | heap->attach_device(identity()); | ||
| 5516 | if (!heap->ok()) { | ||
| 5517 | heap->Release(); | ||
| 5518 | return E_OUTOFMEMORY; | ||
| 5519 | } | ||
| 5520 | return hand_out(heap, riid, out); | ||
| 5521 | } | ||
| 5503 | bool bind_sampler(const leonida::gfx10::SamplerWords& words) { return state_.bind_sampler(words); } | 5522 | bool bind_sampler(const leonida::gfx10::SamplerWords& words) { return state_.bind_sampler(words); } |
| 5504 | void own(const OwnedRuntime& owned) { owned_ = owned; } | 5523 | void own(const OwnedRuntime& owned) { owned_ = owned; } |
| 5505 | void set_outer(IUnknown* outer) { outer_ = outer; } | 5524 | void set_outer(IUnknown* outer) { outer_ = outer; } |
| @@ -7121,9 +7140,12 @@ public: | |||
| 7121 | if (desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) { | 7140 | if (desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) { |
| 7122 | // A texture is not placed on the title's pages yet: it gets an ordinary committed DEFAULT texture of the | 7141 | // A texture is not placed on the title's pages yet: it gets an ordinary committed DEFAULT texture of the |
| 7123 | // same description, as slot 76 gives one, so the title has its resource instead of asserting (found in | 7142 | // same description, as slot 76 gives one, so the title has its resource instead of asserting (found in |
| 7124 | // review). What the title writes at `address` does not reach it. | 7143 | // review). Its GPU VA is still the title's address: the console answers a placed texture's |
| 7125 | log_once("a title-placed texture (device slot 133) is an ordinary committed texture, not the title's pages; " | 7144 | // GetGPUVirtualAddress with the address the title placed it at, and a title turns that into the CPU |
| 7126 | "dimension", | 7145 | // pointer it clears the texture through (docs/d3d12_vulkan.md 3.3). What the title writes at `address` |
| 7146 | // does not reach the image yet. | ||
| 7147 | log_once("a title-placed texture (device slot 133) is a committed texture whose GPU VA is the title " | ||
| 7148 | "address; its pixels do not alias the title's pages yet; dimension", | ||
| 7127 | int(desc.Dimension)); | 7149 | int(desc.Dimension)); |
| 7128 | // The title's barrier layout (slot 133's third argument, measured by @dracbat) is checked against the | 7150 | // The title's barrier layout (slot 133's third argument, measured by @dracbat) is checked against the |
| 7129 | // description as CreateCommittedResource checks a state; one it refuses (or UNDEFINED) gives COMMON, so | 7151 | // description as CreateCommittedResource checks a state; one it refuses (or UNDEFINED) gives COMMON, so |
| @@ -7136,6 +7158,13 @@ public: | |||
| 7136 | if (FAILED(hr) && initial != D3D12_RESOURCE_STATE_COMMON) | 7158 | if (FAILED(hr) && initial != D3D12_RESOURCE_STATE_COMMON) |
| 7137 | hr = create_committed_validated(nullptr, &fallback, D3D12_HEAP_FLAG_NONE, &desc, | 7159 | hr = create_committed_validated(nullptr, &fallback, D3D12_HEAP_FLAG_NONE, &desc, |
| 7138 | D3D12_RESOURCE_STATE_COMMON, nullptr, 0, nullptr, riid, out); | 7160 | D3D12_RESOURCE_STATE_COMMON, nullptr, 0, nullptr, riid, out); |
| 7161 | if (SUCCEEDED(hr) && out && *out) { | ||
| 7162 | // The console answers the texture's GetGPUVirtualAddress with the title's address; without it a | ||
| 7163 | // title that clears the texture through that pointer writes at address 0 (XCL measured this on a | ||
| 7164 | // retail title). The image stays the committed fallback above, so only the address is folded in. | ||
| 7165 | if (auto* texture = Resource::from<Resource>(static_cast<IUnknown*>(*out))) | ||
| 7166 | texture->set_title_address(reinterpret_cast<D3D12_GPU_VIRTUAL_ADDRESS>(address)); | ||
| 7167 | } | ||
| 7139 | return d3d12_trace::result(method, hr); | 7168 | return d3d12_trace::result(method, hr); |
| 7140 | } | 7169 | } |
| 7141 | D3D12_HEAP_PROPERTIES heap{}; | 7170 | D3D12_HEAP_PROPERTIES heap{}; |
| @@ -9997,14 +10026,7 @@ HRESULT create_console_descriptor_heap(ID3D12Device* device, const D3D12_DESCRIP | |||
| 9997 | ID3D12Device* real = rt::d3d12_xs::device_proxy_real_device(device); | 10026 | ID3D12Device* real = rt::d3d12_xs::device_proxy_real_device(device); |
| 9998 | auto* d = Device::from<Device>(real ? real : device); | 10027 | auto* d = Device::from<Device>(real ? real : device); |
| 9999 | if (!d) return E_INVALIDARG; | 10028 | if (!d) return E_INVALIDARG; |
| 10000 | 10029 | return d->create_console_descriptor_heap(desc, console_address, console_size, riid, out); | |
| 10001 | auto* heap = new DescriptorHeap(d->state(), *desc, console_address, console_size); | ||
| 10002 | heap->attach_device(d->identity()); | ||
| 10003 | if (!heap->ok()) { | ||
| 10004 | heap->Release(); | ||
| 10005 | return E_OUTOFMEMORY; | ||
| 10006 | } | ||
| 10007 | return hand_out(heap, riid, out); | ||
| 10008 | } | 10030 | } |
| 10009 | 10031 | ||
| 10010 | std::filesystem::path configured_shader_directory(std::string* error, const std::filesystem::path& config) { | 10032 | std::filesystem::path configured_shader_directory(std::string* error, const std::filesystem::path& config) { |
diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 187406e3d..14a4b38ff 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp | |||
| @@ -48,6 +48,9 @@ namespace { | |||
| 48 | // vtable goes through the generic thunk and is refused with E_NOTIMPL, so the table must outlast the highest one. | 48 | // vtable goes through the generic thunk and is refused with E_NOTIMPL, so the table must outlast the highest one. |
| 49 | constexpr unsigned kMaxSlots = 192; | 49 | constexpr unsigned kMaxSlots = 192; |
| 50 | static_assert(kMaxSlots > 133, "the proxy table must cover the slots the retail title calls (up to 133)"); | 50 | static_assert(kMaxSlots > 133, "the proxy table must cover the slots the retail title calls (up to 133)"); |
| 51 | |||
| 52 | // Set by the Vulkan device behind the proxy; slot 14 uses it for a console-extended CreateDescriptorHeap. | ||
| 53 | std::atomic<ConsoleDescriptorHeapHandler> g_console_descriptor_heap{nullptr}; | ||
| 51 | static_assert(kMaxSlots > 83, "the proxy table must cover ID3D12Device14 (83 slots)"); | 54 | static_assert(kMaxSlots > 83, "the proxy table must cover ID3D12Device14 (83 slots)"); |
| 52 | static_assert(sizeof(void*) == 8, "the Xbox-ABI proxy is x64-only"); | 55 | static_assert(sizeof(void*) == 8, "the Xbox-ABI proxy is x64-only"); |
| 53 | static_assert(sizeof(D3D12_CPU_DESCRIPTOR_HANDLE) == 8, | 56 | static_assert(sizeof(D3D12_CPU_DESCRIPTOR_HANDLE) == 8, |
| @@ -1602,10 +1605,13 @@ HRESULT proxy_create_descriptor_heap(DeviceProxy* self, const D3D12_DESCRIPTOR_H | |||
| 1602 | // Console-extended slot 14 (issue #313): address/size follow the PC desc. Only take this path when a | 1605 | // Console-extended slot 14 (issue #313): address/size follow the PC desc. Only take this path when a |
| 1603 | // non-zero console VA is present; normal PC 16-byte descs never enter it. | 1606 | // non-zero console VA is present; normal PC 16-byte descs never enter it. |
| 1604 | if (address != 0) { | 1607 | if (address != 0) { |
| 1605 | console_extended = true; | 1608 | const ConsoleDescriptorHeapHandler handler = |
| 1606 | hr = rt::d3d12::create_console_descriptor_heap( | 1609 | g_console_descriptor_heap.load(std::memory_order_acquire); |
| 1607 | self->real, desc, static_cast<D3D12_GPU_VIRTUAL_ADDRESS>(address), size, | 1610 | if (handler) { |
| 1608 | __uuidof(ID3D12DescriptorHeap), &created); | 1611 | console_extended = true; |
| 1612 | hr = handler(self->real, desc, static_cast<D3D12_GPU_VIRTUAL_ADDRESS>(address), size, | ||
| 1613 | __uuidof(ID3D12DescriptorHeap), &created); | ||
| 1614 | } | ||
| 1609 | } | 1615 | } |
| 1610 | } | 1616 | } |
| 1611 | } | 1617 | } |
| @@ -2041,6 +2047,10 @@ void set_placed_at_va_pages_hook(PlacedAtVaPagesHook hook) { | |||
| 2041 | g_placed_at_va_pages.store(hook, std::memory_order_release); | 2047 | g_placed_at_va_pages.store(hook, std::memory_order_release); |
| 2042 | } | 2048 | } |
| 2043 | 2049 | ||
| 2050 | void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler) { | ||
| 2051 | g_console_descriptor_heap.store(handler, std::memory_order_release); | ||
| 2052 | } | ||
| 2053 | |||
| 2044 | ID3D12Device* device_proxy_real_device(const void* device) { | 2054 | ID3D12Device* device_proxy_real_device(const void* device) { |
| 2045 | if (!is_device_proxy(device)) return nullptr; | 2055 | if (!is_device_proxy(device)) return nullptr; |
| 2046 | return static_cast<const DeviceProxy*>(device)->real; | 2056 | return static_cast<const DeviceProxy*>(device)->real; |
diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index ac0437215..20ed4afc1 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h | |||
| @@ -108,6 +108,15 @@ void set_placed_at_va_handler(PlacedAtVaHandler handler); | |||
| 108 | using PlacedAtVaPagesHook = bool (*)(const void* va, std::size_t bytes); | 108 | using PlacedAtVaPagesHook = bool (*)(const void* va, std::size_t bytes); |
| 109 | void set_placed_at_va_pages_hook(PlacedAtVaPagesHook hook); | 109 | void set_placed_at_va_pages_hook(PlacedAtVaPagesHook hook); |
| 110 | 110 | ||
| 111 | // Device slot 14's console-extended CreateDescriptorHeap: the description is the PC 16-byte shape followed by a | ||
| 112 | // console VA and a size (issue #313). The proxy does not create the heap itself: the device behind it registers this | ||
| 113 | // handler, which the Vulkan layer implements (rt::d3d12::create_console_descriptor_heap). With none registered, or a | ||
| 114 | // 16-byte PC description (address 0), the slot uses the PC CreateDescriptorHeap. | ||
| 115 | using ConsoleDescriptorHeapHandler = HRESULT (*)(ID3D12Device* real, const D3D12_DESCRIPTOR_HEAP_DESC* desc, | ||
| 116 | D3D12_GPU_VIRTUAL_ADDRESS console_address, std::uint64_t console_size, | ||
| 117 | REFIID riid, void** out); | ||
| 118 | void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler); | ||
| 119 | |||
| 111 | // True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue | 120 | // True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue |
| 112 | // proxies), 9 (allocator proxies), 14, 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 48/73 and | 121 | // proxies), 9 (allocator proxies), 14, 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 48/73 and |
| 113 | // 78/79/80 (the Xbox slots above, at their configured indices), 62, 67 and 76. Slot 10 is intentionally false: the | 122 | // 78/79/80 (the Xbox slots above, at their configured indices), 62, 67 and 76. Slot 10 is intentionally false: the |
diff --git a/runtime/test/d3d12_console_descriptor_heap_test.cpp b/runtime/test/d3d12_console_descriptor_heap_test.cpp index 5f694b5a2..ed2d901f4 100644 --- a/runtime/test/d3d12_console_descriptor_heap_test.cpp +++ b/runtime/test/d3d12_console_descriptor_heap_test.cpp | |||
| @@ -24,6 +24,7 @@ struct Ref { | |||
| 24 | return &p; | 24 | return &p; |
| 25 | } | 25 | } |
| 26 | T* get() const { return p; } | 26 | T* get() const { return p; } |
| 27 | T* operator->() const { return p; } | ||
| 27 | }; | 28 | }; |
| 28 | 29 | ||
| 29 | bool check_console_addressed_heap(ID3D12Device* device) { | 30 | bool check_console_addressed_heap(ID3D12Device* device) { |
| @@ -64,13 +65,13 @@ bool check_console_addressed_heap(ID3D12Device* device) { | |||
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | bool check_xs_proxy_slot14(ID3D12Device* real_device) { | 67 | bool check_xs_proxy_slot14(ID3D12Device* real_device) { |
| 67 | void* proxy_raw = nullptr; | 68 | Ref<ID3D12Device> proxy; |
| 68 | if (FAILED(rt::d3d12_xs::create_device_proxy(real_device, IID_PPV_ARGS(&proxy_raw))) || !proxy_raw) { | 69 | real_device->AddRef(); // create_device_proxy takes ownership of one reference on success |
| 70 | if (FAILED(rt::d3d12_xs::create_device_proxy(real_device, IID_PPV_ARGS(&proxy.p))) || !proxy.p) { | ||
| 71 | real_device->Release(); // the caller keeps its reference on failure | ||
| 69 | std::fprintf(stderr, "create_device_proxy failed\n"); | 72 | std::fprintf(stderr, "create_device_proxy failed\n"); |
| 70 | return false; | 73 | return false; |
| 71 | } | 74 | } |
| 72 | Ref<ID3D12Device> proxy; | ||
| 73 | proxy.p = static_cast<ID3D12Device*>(proxy_raw); | ||
| 74 | 75 | ||
| 75 | struct ConsoleDescriptorHeapDesc { | 76 | struct ConsoleDescriptorHeapDesc { |
| 76 | D3D12_DESCRIPTOR_HEAP_DESC desc{}; | 77 | D3D12_DESCRIPTOR_HEAP_DESC desc{}; |
| @@ -90,7 +91,14 @@ bool check_xs_proxy_slot14(ID3D12Device* real_device) { | |||
| 90 | static_cast<unsigned long>(hr)); | 91 | static_cast<unsigned long>(hr)); |
| 91 | return false; | 92 | return false; |
| 92 | } | 93 | } |
| 93 | const auto cpu = heap->GetCPUDescriptorHandleForHeapStart(); | 94 | // The proxy's own GetCPUDescriptorHandleForHeapStart answers the console (RAX) convention; this test is a PC |
| 95 | // caller, so read the wrapped heap's PC method. The address proves slot 14 passed the console VA through. | ||
| 96 | ID3D12DescriptorHeap* real = rt::d3d12_xs::heap_proxy_real_heap(heap.p); | ||
| 97 | if (!real) { | ||
| 98 | std::fprintf(stderr, "heap proxy has no real heap\n"); | ||
| 99 | return false; | ||
| 100 | } | ||
| 101 | const auto cpu = real->GetCPUDescriptorHandleForHeapStart(); | ||
| 94 | if (cpu.ptr != static_cast<SIZE_T>(console.address)) { | 102 | if (cpu.ptr != static_cast<SIZE_T>(console.address)) { |
| 95 | std::fprintf(stderr, "proxy CPU heap start mismatch: got 0x%llx want 0x%llx\n", | 103 | std::fprintf(stderr, "proxy CPU heap start mismatch: got 0x%llx want 0x%llx\n", |
| 96 | static_cast<unsigned long long>(cpu.ptr), | 104 | static_cast<unsigned long long>(cpu.ptr), |
diff --git a/runtime/test/d3d12_existing_heap_test.cpp b/runtime/test/d3d12_existing_heap_test.cpp index d2af3a1f4..fd827f9a1 100644 --- a/runtime/test/d3d12_existing_heap_test.cpp +++ b/runtime/test/d3d12_existing_heap_test.cpp | |||
| @@ -171,8 +171,9 @@ int check_import(ID3D12Device* device, bool supported) { | |||
| 171 | // Xbox device slot 133's backend (rt::d3d12::create_buffer_at_host_address): a buffer on the caller's own pages. | 171 | // Xbox device slot 133's backend (rt::d3d12::create_buffer_at_host_address): a buffer on the caller's own pages. |
| 172 | // Its GPU VA is the address itself, and what the CPU writes there is what a GPU copy reads, with no upload: the | 172 | // Its GPU VA is the address itself, and what the CPU writes there is what a GPU copy reads, with no upload: the |
| 173 | // pattern is written after the buffer exists and read back through a READBACK buffer. Checked on a VirtualAlloc range | 173 | // pattern is written after the buffer exists and read back through a READBACK buffer. Checked on a VirtualAlloc range |
| 174 | // and on a view of a pagefile-backed section, the form xmem's physical pages are mapped in. A texture is E_NOTIMPL | 174 | // and on a view of a pagefile-backed section, the form xmem's physical pages are mapped in. A texture gets a committed |
| 175 | // and an address off the import alignment E_INVALIDARG. | 175 | // texture whose GPU VA is the same title address (its pixels do not alias the pages yet); an address off the import |
| 176 | // alignment E_INVALIDARG. | ||
| 176 | // `may_refuse`: the driver is allowed to refuse importing these pages, and the layer then answers with its fallback. | 177 | // `may_refuse`: the driver is allowed to refuse importing these pages, and the layer then answers with its fallback. |
| 177 | // RADV imports host memory through amdgpu userptr, which takes anonymous memory only, so it refuses a view of a | 178 | // RADV imports host memory through amdgpu userptr, which takes anonymous memory only, so it refuses a view of a |
| 178 | // pagefile-backed section with EPERM (measured on an RX 9060 XT under Wine, found in review), while NVIDIA and | 179 | // pagefile-backed section with EPERM (measured on an RX 9060 XT under Wine, found in review), while NVIDIA and |
| @@ -231,16 +232,19 @@ int check_title_placed(ID3D12Device* device, const char* kind, void* pages, UINT | |||
| 231 | texture.Width = texture.Height = 64; | 232 | texture.Width = texture.Height = 64; |
| 232 | texture.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | 233 | texture.Format = DXGI_FORMAT_R8G8B8A8_UNORM; |
| 233 | texture.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | 234 | texture.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; |
| 234 | // A texture isn't placed on the pages yet: the title gets an ordinary committed texture instead of a refusal. | 235 | // A texture isn't placed on the pages yet: the title gets an ordinary committed texture instead of a refusal, and |
| 236 | // its GPU VA is the title's address (the console behavior: a title clears a texture through that pointer). | ||
| 235 | Ref<ID3D12Resource> placed_texture; | 237 | Ref<ID3D12Resource> placed_texture; |
| 236 | EXPECT_HR(rt::d3d12::create_buffer_at_host_address(device, pages, texture, 0x6u, IID_PPV_ARGS(&placed_texture.p)), S_OK); | 238 | EXPECT_HR(rt::d3d12::create_buffer_at_host_address(device, pages, texture, 0x6u, IID_PPV_ARGS(&placed_texture.p)), S_OK); |
| 237 | EXPECT(placed_texture.p != nullptr && placed_texture->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D); | 239 | EXPECT(placed_texture.p != nullptr && placed_texture->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D); |
| 240 | EXPECT(placed_texture->GetGPUVirtualAddress() == reinterpret_cast<D3D12_GPU_VIRTUAL_ADDRESS>(pages)); | ||
| 238 | // The layout is validated as a CreateCommittedResource state: RENDER_TARGET (2) on a texture without | 241 | // The layout is validated as a CreateCommittedResource state: RENDER_TARGET (2) on a texture without |
| 239 | // ALLOW_RENDER_TARGET is refused, and the COMMON retry still gives the title its texture. A description the | 242 | // ALLOW_RENDER_TARGET is refused, and the COMMON retry still gives the title its texture. A description the |
| 240 | // checks refuse outright (more mips than the size has) is refused, not created. | 243 | // checks refuse outright (more mips than the size has) is refused, not created. |
| 241 | Ref<ID3D12Resource> target_layout; | 244 | Ref<ID3D12Resource> target_layout; |
| 242 | EXPECT_HR(rt::d3d12::create_buffer_at_host_address(device, pages, texture, 0x2u, IID_PPV_ARGS(&target_layout.p)), S_OK); | 245 | EXPECT_HR(rt::d3d12::create_buffer_at_host_address(device, pages, texture, 0x2u, IID_PPV_ARGS(&target_layout.p)), S_OK); |
| 243 | EXPECT(target_layout.p != nullptr); | 246 | EXPECT(target_layout.p != nullptr); |
| 247 | EXPECT(target_layout->GetGPUVirtualAddress() == reinterpret_cast<D3D12_GPU_VIRTUAL_ADDRESS>(pages)); | ||
| 244 | D3D12_RESOURCE_DESC too_many_mips = texture; | 248 | D3D12_RESOURCE_DESC too_many_mips = texture; |
| 245 | too_many_mips.MipLevels = 12; | 249 | too_many_mips.MipLevels = 12; |
| 246 | Ref<ID3D12Resource> refused_texture; | 250 | Ref<ID3D12Resource> refused_texture; |