diff options
| author | tedin7 <tommasoderosa94@gmail.com> | 2026-11-23 16:49:34 +0100 |
|---|---|---|
| committer | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 22:14:29 -0600 |
| commit | 81e8a6f2a42e72e49f0338a584cd651d5d3e9db7 (patch) | |
| tree | 4bc69613699f4907bb961a3cf341ff9127d8f507 | |
| parent | 992b19bd44c80eea1ad81bf737b9057d002b9aff (diff) | |
d3d12_xs: device slot 127 creates the committed resource (CreateCommittedResource3 with Xbox descriptors, RT-5 stop 15)
Slot 127 is past the PC device vtable and was refused with E_NOTIMPL. It has the argument list of ID3D12Device10::CreateCommittedResource3; the proxy now calls the PC device's with the Xbox layout word and flag bits cleaned as slot 76 does. Measured in #6982.
(cherry picked from commit 8d622049ae79b7123ae4661ab3feaab27849575e)
| -rw-r--r-- | runtime/shims/d3d12_xs_device.cpp | 71 | ||||
| -rw-r--r-- | runtime/shims/d3d12_xs_device.h | 5 | ||||
| -rw-r--r-- | runtime/test/xs_proxy_mock_test.cpp | 138 |
3 files changed, 211 insertions, 3 deletions
diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 8524df4f0..7f7040fdd 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp | |||
| @@ -153,6 +153,7 @@ const char* slot_name(unsigned slot) { | |||
| 153 | case 73: return "Xbox CreateCommandListX -> PC CreateCommandList"; | 153 | case 73: return "Xbox CreateCommandListX -> PC CreateCommandList"; |
| 154 | case 75: return "CreateCommandQueue1 -> queue proxy"; | 154 | case 75: return "CreateCommandQueue1 -> queue proxy"; |
| 155 | case 76: return "Xbox resource creation"; | 155 | case 76: return "Xbox resource creation"; |
| 156 | case 127: return "Xbox CreateCommittedResource3"; | ||
| 156 | case 78: return "Xbox SetFrameIntervalX"; | 157 | case 78: return "Xbox SetFrameIntervalX"; |
| 157 | case 79: return "Xbox ScheduleFrameEventX"; | 158 | case 79: return "Xbox ScheduleFrameEventX"; |
| 158 | case 80: return "Xbox WaitFrameEventX"; | 159 | case 80: return "Xbox WaitFrameEventX"; |
| @@ -1874,6 +1875,72 @@ D3D12_HEAP_PROPERTIES* proxy_get_custom_heap_properties(D3D12_HEAP_PROPERTIES* o | |||
| 1874 | return out; | 1875 | return out; |
| 1875 | } | 1876 | } |
| 1876 | 1877 | ||
| 1878 | // Xbox device slot 127 (RT-5 stop 15, measured by Pipodi in #6982): the argument list of ID3D12Device10:: | ||
| 1879 | // CreateCommittedResource3, (heap properties, heap flags, desc1, initial layout, clear value, protected session, | ||
| 1880 | // castable format count, castable formats, riid, out), with the Xbox layout word in desc1.Layout and Xbox bits above | ||
| 1881 | // the PC flags in desc1.Flags. The slot is past the PC device's vtable, so the generic thunk could only refuse it. The | ||
| 1882 | // PC device creates the resource through its own CreateCommittedResource3 (PC slot 76) with the layout word replaced | ||
| 1883 | // as slot 76 does and the flags limited to the PC bits. The initial layout, clear value, session and castable list go | ||
| 1884 | // on as the title passed them; 0xFFFFFFFF is D3D12_BARRIER_LAYOUT_UNDEFINED, the value the console passes for the | ||
| 1885 | // state of slot 133 as well. The words take the positions the thunk received them in (see the top of the file). | ||
| 1886 | constexpr unsigned kCreateCommittedResource3X = 127; | ||
| 1887 | constexpr unsigned kPcCreateCommittedResource3 = 76; // ID3D12Device10, the PC device's 77th method | ||
| 1888 | constexpr std::uint32_t kPcResourceFlagsMask = | ||
| 1889 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL | | ||
| 1890 | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE | | ||
| 1891 | D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER | D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS | | ||
| 1892 | D3D12_RESOURCE_FLAG_VIDEO_DECODE_REFERENCE_ONLY | D3D12_RESOURCE_FLAG_VIDEO_ENCODE_REFERENCE_ONLY | | ||
| 1893 | D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE; | ||
| 1894 | |||
| 1895 | HRESULT proxy_create_committed_resource3_x(DeviceProxy* self, std::uint64_t heap_word, std::uint64_t heap_flags, | ||
| 1896 | std::uint64_t desc_word, std::uint64_t layout_word, | ||
| 1897 | std::uint64_t clear_word, std::uint64_t session_word, | ||
| 1898 | std::uint64_t castable_count, std::uint64_t castable_formats, | ||
| 1899 | std::uint64_t riid_word, std::uint64_t out_word) { | ||
| 1900 | note_slot(kCreateCommittedResource3X); | ||
| 1901 | auto* const out = reinterpret_cast<void**>(out_word); | ||
| 1902 | if (out) *out = nullptr; // _COM_Outptr_: NULL on every failure, as slots 14/62/76 | ||
| 1903 | const auto* const xbox_desc = reinterpret_cast<const D3D12_RESOURCE_DESC1*>(desc_word); | ||
| 1904 | const auto* const riid = reinterpret_cast<const IID*>(riid_word); | ||
| 1905 | if (!out || !xbox_desc || !riid) return E_POINTER; | ||
| 1906 | if (self->slot_count <= kPcCreateCommittedResource3) { // the PC device predates ID3D12Device10 | ||
| 1907 | static std::atomic<bool> warned{false}; | ||
| 1908 | if (first_call(warned)) | ||
| 1909 | std::fprintf(stderr, | ||
| 1910 | "[rt] d3d12_xs: device slot %u (%s) needs ID3D12Device10 and the PC device has %u slots; " | ||
| 1911 | "returning E_NOTIMPL\n", | ||
| 1912 | kCreateCommittedResource3X, slot_name(kCreateCommittedResource3X), self->slot_count); | ||
| 1913 | return E_NOTIMPL; | ||
| 1914 | } | ||
| 1915 | |||
| 1916 | D3D12_RESOURCE_DESC1 pc_desc = *xbox_desc; | ||
| 1917 | const auto xbox_layout = static_cast<std::uint32_t>(pc_desc.Layout); | ||
| 1918 | const auto xbox_flags = static_cast<std::uint32_t>(pc_desc.Flags); | ||
| 1919 | pc_desc.Layout = pc_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER ? D3D12_TEXTURE_LAYOUT_ROW_MAJOR | ||
| 1920 | : D3D12_TEXTURE_LAYOUT_UNKNOWN; | ||
| 1921 | pc_desc.Flags = static_cast<D3D12_RESOURCE_FLAGS>(xbox_flags & kPcResourceFlagsMask); | ||
| 1922 | |||
| 1923 | static std::atomic<bool> logged{false}; | ||
| 1924 | if (first_call(logged)) | ||
| 1925 | std::fprintf(stderr, | ||
| 1926 | "[rt] d3d12_xs: slot 127 resource: dimension=%d xbox layout=0x%x -> PC layout=0x%x, xbox flags " | ||
| 1927 | "0x%x -> PC flags 0x%x\n", | ||
| 1928 | static_cast<int>(pc_desc.Dimension), xbox_layout, static_cast<unsigned>(pc_desc.Layout), | ||
| 1929 | xbox_flags, static_cast<unsigned>(pc_desc.Flags)); | ||
| 1930 | |||
| 1931 | using Fn = HRESULT(WINAPI*)(ID3D12Device*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, | ||
| 1932 | const D3D12_RESOURCE_DESC1*, std::uint32_t, const D3D12_CLEAR_VALUE*, | ||
| 1933 | ID3D12ProtectedResourceSession*, std::uint32_t, const DXGI_FORMAT*, const IID*, | ||
| 1934 | void**); | ||
| 1935 | const auto create = reinterpret_cast<Fn>(self->real_vtable[kPcCreateCommittedResource3]); | ||
| 1936 | return create(self->real, reinterpret_cast<const D3D12_HEAP_PROPERTIES*>(heap_word), | ||
| 1937 | static_cast<D3D12_HEAP_FLAGS>(static_cast<std::uint32_t>(heap_flags)), &pc_desc, | ||
| 1938 | static_cast<std::uint32_t>(layout_word), reinterpret_cast<const D3D12_CLEAR_VALUE*>(clear_word), | ||
| 1939 | reinterpret_cast<ID3D12ProtectedResourceSession*>(session_word), | ||
| 1940 | static_cast<std::uint32_t>(castable_count), reinterpret_cast<const DXGI_FORMAT*>(castable_formats), | ||
| 1941 | riid, out); | ||
| 1942 | } | ||
| 1943 | |||
| 1877 | template <unsigned Slot> | 1944 | template <unsigned Slot> |
| 1878 | std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, | 1945 | std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, |
| 1879 | std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7, | 1946 | std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7, |
| @@ -1943,6 +2010,8 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64 | |||
| 1943 | static_cast<D3D12_RESOURCE_STATES>(static_cast<std::uint32_t>(a4)), | 2010 | static_cast<D3D12_RESOURCE_STATES>(static_cast<std::uint32_t>(a4)), |
| 1944 | reinterpret_cast<const D3D12_CLEAR_VALUE*>(a5), reinterpret_cast<const IID*>(a6), | 2011 | reinterpret_cast<const D3D12_CLEAR_VALUE*>(a5), reinterpret_cast<const IID*>(a6), |
| 1945 | reinterpret_cast<void**>(a7))); | 2012 | reinterpret_cast<void**>(a7))); |
| 2013 | } else if constexpr (Slot == kCreateCommittedResource3X) { | ||
| 2014 | return hr_to_u64(proxy_create_committed_resource3_x(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); | ||
| 1946 | } else { | 2015 | } else { |
| 1947 | if constexpr (Slot == 26) { | 2016 | if constexpr (Slot == 26) { |
| 1948 | // The console form has the device in RDX. A PC C++ caller has the proxy in RCX and its return buffer in | 2017 | // The console form has the device in RDX. A PC C++ caller has the proxy in RCX and its return buffer in |
| @@ -2185,7 +2254,7 @@ ID3D12Device* device_proxy_real_device(const void* device) { | |||
| 2185 | bool device_slot_overridden(unsigned slot) { | 2254 | bool device_slot_overridden(unsigned slot) { |
| 2186 | if (slot <= 2 || slot == 8 || slot == 9 || slot == 14 || slot == 25 || slot == 26 || slot == 31 || slot == 32 || slot == 34 || slot == 35 || | 2255 | if (slot <= 2 || slot == 8 || slot == 9 || slot == 14 || slot == 25 || slot == 26 || slot == 31 || slot == 32 || slot == 34 || slot == 35 || |
| 2187 | slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 || slot == 67 || | 2256 | slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 || slot == 67 || |
| 2188 | slot == 70 || slot == 75 || slot == 76 || slot == 133) | 2257 | slot == 70 || slot == 75 || slot == 76 || slot == 133 || slot == kCreateCommittedResource3X) |
| 2189 | return true; | 2258 | return true; |
| 2190 | const XboxDeviceSlotRoutes& routes = xbox_device_slot_routes(); | 2259 | const XboxDeviceSlotRoutes& routes = xbox_device_slot_routes(); |
| 2191 | return slot == routes.frame_interval || slot == routes.schedule_event || slot == routes.wait_event || | 2260 | return slot == routes.frame_interval || slot == routes.schedule_event || slot == routes.wait_event || |
diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 38419358b..7ee880939 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | // The words are not measured, so the destination gets the PC null view (PC CreateShaderResourceView | 16 | // The words are not measured, so the destination gets the PC null view (PC CreateShaderResourceView |
| 17 | // with no resource) and the call returns. | 17 | // with no resource) and the call returns. |
| 18 | // slot 76 resource creation -> PC CreateCommittedResource (PC slot 27), with the Xbox layout word ignored. | 18 | // slot 76 resource creation -> PC CreateCommittedResource (PC slot 27), with the Xbox layout word ignored. |
| 19 | // slot 127 CreateCommittedResource3 (heap, flags, desc1, layout, clear, session, castable count/list, riid, out) -> | ||
| 20 | // PC ID3D12Device10::CreateCommittedResource3 (PC slot 76), with the Xbox layout word replaced and the | ||
| 21 | // Xbox flag bits dropped (RT-5 stop 15, docs/retail_boot_chain.md). E_NOTIMPL when the PC device lacks it. | ||
| 19 | // slot 48 CreateCommandQueueX(desc, riid, out) -> the same queue proxy as slot 8. The Xbox desc's first fields are | 22 | // slot 48 CreateCommandQueueX(desc, riid, out) -> the same queue proxy as slot 8. The Xbox desc's first fields are |
| 20 | // D3D12_COMMAND_QUEUE_DESC's (public HLE). | 23 | // D3D12_COMMAND_QUEUE_DESC's (public HLE). |
| 21 | // slot 73 CreateCommandListX(desc, allocator, initialState, riid, out) -> PC CreateCommandList(0, type, allocator, | 24 | // slot 73 CreateCommandListX(desc, allocator, initialState, riid, out) -> PC CreateCommandList(0, type, allocator, |
| @@ -132,7 +135,7 @@ void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler); | |||
| 132 | // True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue | 135 | // True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue |
| 133 | // proxies), 9 (allocator proxies), 14, 26 (the console's struct-return form), | 136 | // proxies), 9 (allocator proxies), 14, 26 (the console's struct-return form), |
| 134 | // 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 48/73 and | 137 | // 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 48/73 and |
| 135 | // 78/79/80 (the Xbox slots above, at their configured indices), 62, 67, 70 and 76. Slot 10 is intentionally false: the | 138 | // 78/79/80 (the Xbox slots above, at their configured indices), 62, 67, 70, 76 and 127. Slot 10 is intentionally false: the |
| 136 | // measured 9/10 handle conversion is on the heap proxy, and device slot 9 is CreateCommandAllocator, which the proxy | 139 | // measured 9/10 handle conversion is on the heap proxy, and device slot 9 is CreateCommandAllocator, which the proxy |
| 137 | // handles for the allocator proxy. | 140 | // handles for the allocator proxy. |
| 138 | bool device_slot_overridden(unsigned slot); | 141 | bool device_slot_overridden(unsigned slot); |
diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 1ad50a6b8..224030247 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp | |||
| @@ -285,6 +285,35 @@ HRESULT WINAPI mock_create_command_list(Mock* self, std::uint64_t node_mask, std | |||
| 285 | return mock_query(child, riid, out); | 285 | return mock_query(child, riid, out); |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | #ifdef __ID3D12Device10_INTERFACE_DEFINED__ | ||
| 289 | // PC ID3D12Device10::CreateCommittedResource3 takes ten words after `this`, so it has its own entry (PC slot 76) that | ||
| 290 | // keeps all of them: the resource description is copied because the caller's copy is a local of the proxy. | ||
| 291 | struct CommittedResource3Call { | ||
| 292 | unsigned calls; | ||
| 293 | const D3D12_HEAP_PROPERTIES* heap; | ||
| 294 | D3D12_HEAP_FLAGS heap_flags; | ||
| 295 | D3D12_RESOURCE_DESC1 desc; | ||
| 296 | std::uint32_t layout; | ||
| 297 | const D3D12_CLEAR_VALUE* clear; | ||
| 298 | const void* session; | ||
| 299 | std::uint32_t castable_count; | ||
| 300 | const DXGI_FORMAT* castable_formats; | ||
| 301 | const IID* riid; | ||
| 302 | void** out; | ||
| 303 | }; | ||
| 304 | CommittedResource3Call g_committed3; | ||
| 305 | |||
| 306 | HRESULT WINAPI mock_create_committed_resource3(Mock* self, const D3D12_HEAP_PROPERTIES* heap, D3D12_HEAP_FLAGS flags, | ||
| 307 | const D3D12_RESOURCE_DESC1* desc, std::uint32_t layout, | ||
| 308 | const D3D12_CLEAR_VALUE* clear, const void* session, | ||
| 309 | std::uint32_t castable_count, const DXGI_FORMAT* castable_formats, | ||
| 310 | const IID* riid, void** out) { | ||
| 311 | g_committed3 = {g_committed3.calls + 1, heap, flags, *desc, layout, clear, session, castable_count, | ||
| 312 | castable_formats, riid, out}; | ||
| 313 | return mock_create(self, Kind::resource, reinterpret_cast<std::uint64_t>(riid), reinterpret_cast<std::uint64_t>(out)); | ||
| 314 | } | ||
| 315 | #endif | ||
| 316 | |||
| 288 | template <std::size_t... I> | 317 | template <std::size_t... I> |
| 289 | void fill_mock_vtable(void** vtable, std::index_sequence<I...>) { | 318 | void fill_mock_vtable(void** vtable, std::index_sequence<I...>) { |
| 290 | ((vtable[I] = reinterpret_cast<void*>(&mock_slot<static_cast<unsigned>(I)>)), ...); | 319 | ((vtable[I] = reinterpret_cast<void*>(&mock_slot<static_cast<unsigned>(I)>)), ...); |
| @@ -295,6 +324,9 @@ void** mock_vtable() { | |||
| 295 | static const bool filled = [] { | 324 | static const bool filled = [] { |
| 296 | fill_mock_vtable(table, std::make_index_sequence<kMockSlots>{}); | 325 | fill_mock_vtable(table, std::make_index_sequence<kMockSlots>{}); |
| 297 | table[12] = reinterpret_cast<void*>(&mock_create_command_list); | 326 | table[12] = reinterpret_cast<void*>(&mock_create_command_list); |
| 327 | #ifdef __ID3D12Device10_INTERFACE_DEFINED__ | ||
| 328 | table[76] = reinterpret_cast<void*>(&mock_create_committed_resource3); | ||
| 329 | #endif | ||
| 298 | return true; | 330 | return true; |
| 299 | }(); | 331 | }(); |
| 300 | (void)filled; | 332 | (void)filled; |
| @@ -314,6 +346,13 @@ std::uint64_t raw(const void* object, unsigned slot, std::uint64_t a1 = 0, std:: | |||
| 314 | 0, 0, 0); | 346 | 0, 0, 0); |
| 315 | } | 347 | } |
| 316 | 348 | ||
| 349 | // A call with the ten words of device slot 127 (and any other slot that takes up to ten). | ||
| 350 | std::uint64_t raw10(const void* object, unsigned slot, const std::uint64_t (&w)[10]) { | ||
| 351 | void* const* vtable = *reinterpret_cast<void* const* const*>(object); | ||
| 352 | return reinterpret_cast<SlotFn>(vtable[slot])(const_cast<void*>(object), w[0], w[1], w[2], w[3], w[4], w[5], w[6], | ||
| 353 | w[7], w[8], w[9], 0, 0, 0, 0); | ||
| 354 | } | ||
| 355 | |||
| 317 | HRESULT hr_of(std::uint64_t value) { | 356 | HRESULT hr_of(std::uint64_t value) { |
| 318 | return static_cast<HRESULT>(static_cast<std::uint32_t>(value)); | 357 | return static_cast<HRESULT>(static_cast<std::uint32_t>(value)); |
| 319 | } | 358 | } |
| @@ -1206,6 +1245,103 @@ int run_fault_mode(const char* mode) { | |||
| 1206 | return 2; | 1245 | return 2; |
| 1207 | } | 1246 | } |
| 1208 | 1247 | ||
| 1248 | // Device slot 127 is ID3D12Device10::CreateCommittedResource3 with Xbox descriptors (RT-5 stop 15). Past the PC | ||
| 1249 | // vtable it used to be refused with E_NOTIMPL; the PC device must now get the resource with the Xbox layout word and | ||
| 1250 | // flag bits gone and every other word as the title passed it. | ||
| 1251 | int check_committed_resource3_x() { | ||
| 1252 | #ifdef __ID3D12Device10_INTERFACE_DEFINED__ | ||
| 1253 | constexpr std::uint32_t kXboxLayoutTiled = 0x101, kXboxFlagBit = 0x40000, kBarrierLayoutUndefined = 0xFFFFFFFFu; | ||
| 1254 | D3D12_HEAP_PROPERTIES heap{}; | ||
| 1255 | heap.Type = D3D12_HEAP_TYPE_DEFAULT; | ||
| 1256 | D3D12_CLEAR_VALUE clear{}; | ||
| 1257 | clear.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | ||
| 1258 | const DXGI_FORMAT castable[2] = {DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB}; | ||
| 1259 | D3D12_RESOURCE_DESC1 texture{}; | ||
| 1260 | texture.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; | ||
| 1261 | texture.Width = 1920; | ||
| 1262 | texture.Height = 1080; | ||
| 1263 | texture.DepthOrArraySize = 1; | ||
| 1264 | texture.MipLevels = 1; | ||
| 1265 | texture.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; | ||
| 1266 | texture.SampleDesc.Count = 1; | ||
| 1267 | texture.Layout = static_cast<D3D12_TEXTURE_LAYOUT>(kXboxLayoutTiled); | ||
| 1268 | texture.Flags = static_cast<D3D12_RESOURCE_FLAGS>(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | | ||
| 1269 | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | kXboxFlagBit); | ||
| 1270 | |||
| 1271 | // A PC device with ID3D12Device10: the render target comes back, as the console's call returns it. | ||
| 1272 | Mock* mock = nullptr; | ||
| 1273 | void* device = make_device(mock, 10, true); | ||
| 1274 | EXPECT(device && xs::device_proxy_slot_count(device) == 79); | ||
| 1275 | xs::reset_device_proxy_stats(); | ||
| 1276 | g_committed3 = {}; | ||
| 1277 | void* resource = nullptr; | ||
| 1278 | std::uint64_t words[10] = {word(&heap), D3D12_HEAP_FLAG_NONE, word(&texture), kBarrierLayoutUndefined, | ||
| 1279 | word(&clear), 0, 2, word(castable), word(&kResourceIid), word(&resource)}; | ||
| 1280 | EXPECT(hr_of(raw10(device, 127, words)) == S_OK); | ||
| 1281 | EXPECT(resource && reinterpret_cast<Mock*>(resource)->kind == Kind::resource); | ||
| 1282 | EXPECT(g_committed3.calls == 1 && xs::device_slot_hits(127) == 1); | ||
| 1283 | EXPECT(g_committed3.heap == &heap && g_committed3.clear == &clear && !g_committed3.session); | ||
| 1284 | EXPECT(g_committed3.layout == kBarrierLayoutUndefined); | ||
| 1285 | EXPECT(g_committed3.castable_count == 2 && g_committed3.castable_formats == castable); | ||
| 1286 | EXPECT(g_committed3.riid == &kResourceIid); | ||
| 1287 | EXPECT(g_committed3.desc.Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN); | ||
| 1288 | EXPECT(g_committed3.desc.Flags == | ||
| 1289 | (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)); | ||
| 1290 | EXPECT(g_committed3.desc.Width == 1920 && g_committed3.desc.Height == 1080 && | ||
| 1291 | g_committed3.desc.Format == DXGI_FORMAT_R8G8B8A8_TYPELESS && g_committed3.desc.SampleDesc.Count == 1); | ||
| 1292 | EXPECT(texture.Layout == static_cast<D3D12_TEXTURE_LAYOUT>(kXboxLayoutTiled)); // the title's description is read only | ||
| 1293 | static_cast<void>(release(resource)); | ||
| 1294 | |||
| 1295 | // A buffer takes the row-major layout. | ||
| 1296 | D3D12_RESOURCE_DESC1 buffer = texture; | ||
| 1297 | buffer.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; | ||
| 1298 | buffer.Height = 1; | ||
| 1299 | buffer.Format = DXGI_FORMAT_UNKNOWN; | ||
| 1300 | words[2] = word(&buffer); | ||
| 1301 | words[6] = 0; | ||
| 1302 | words[7] = 0; | ||
| 1303 | resource = nullptr; | ||
| 1304 | EXPECT(hr_of(raw10(device, 127, words)) == S_OK && resource); | ||
| 1305 | EXPECT(g_committed3.calls == 2 && g_committed3.desc.Layout == D3D12_TEXTURE_LAYOUT_ROW_MAJOR); | ||
| 1306 | |||
| 1307 | // The PC device's own refusal reaches the title with a null object. | ||
| 1308 | mock->create_result = E_OUTOFMEMORY; | ||
| 1309 | resource = reinterpret_cast<void*>(1); | ||
| 1310 | words[9] = word(&resource); | ||
| 1311 | EXPECT(hr_of(raw10(device, 127, words)) == E_OUTOFMEMORY && !resource); | ||
| 1312 | mock->create_result = S_OK; | ||
| 1313 | |||
| 1314 | // A null description, IID or output is refused before the PC device is called. | ||
| 1315 | const unsigned before = g_committed3.calls; | ||
| 1316 | std::uint64_t bad[10]; | ||
| 1317 | std::memcpy(bad, words, sizeof(bad)); | ||
| 1318 | bad[2] = 0; | ||
| 1319 | EXPECT(hr_of(raw10(device, 127, bad)) == E_POINTER); | ||
| 1320 | std::memcpy(bad, words, sizeof(bad)); | ||
| 1321 | bad[8] = 0; | ||
| 1322 | EXPECT(hr_of(raw10(device, 127, bad)) == E_POINTER); | ||
| 1323 | std::memcpy(bad, words, sizeof(bad)); | ||
| 1324 | bad[9] = 0; | ||
| 1325 | EXPECT(hr_of(raw10(device, 127, bad)) == E_POINTER); | ||
| 1326 | EXPECT(g_committed3.calls == before); | ||
| 1327 | EXPECT(xs::device_slot_overridden(127)); | ||
| 1328 | EXPECT(release(device) == 0); | ||
| 1329 | |||
| 1330 | // A PC device that stops at ID3D12Device9 has no CreateCommittedResource3: E_NOTIMPL, a null object, no PC call. | ||
| 1331 | Mock* old_mock = nullptr; | ||
| 1332 | void* old_device = make_device(old_mock, 9, true); | ||
| 1333 | EXPECT(old_device && xs::device_proxy_slot_count(old_device) == 76); | ||
| 1334 | resource = reinterpret_cast<void*>(1); | ||
| 1335 | words[9] = word(&resource); | ||
| 1336 | const unsigned old_before = g_committed3.calls; | ||
| 1337 | EXPECT(hr_of(raw10(old_device, 127, words)) == E_NOTIMPL && !resource); | ||
| 1338 | EXPECT(g_committed3.calls == old_before && old_mock->calls[76] == 0); | ||
| 1339 | EXPECT(release(old_device) == 0); | ||
| 1340 | std::printf("%s: device slot 127 creates the committed resource with the PC flags and layout\n", g_label); | ||
| 1341 | #endif | ||
| 1342 | return 0; | ||
| 1343 | } | ||
| 1344 | |||
| 1209 | } // namespace | 1345 | } // namespace |
| 1210 | 1346 | ||
| 1211 | // A failure ends the process with a message on stderr, never in a dialog a test run would wait on: abort() (an | 1347 | // A failure ends the process with a message on stderr, never in a dialog a test run would wait on: abort() (an |
| @@ -1410,7 +1546,7 @@ int main(int argc, char** argv) { | |||
| 1410 | if (check_tail(true) || check_levels() || check_slot48() || check_fence1() || check_create_failures() || check_open_shared() || | 1546 | if (check_tail(true) || check_levels() || check_slot48() || check_fence1() || check_create_failures() || check_open_shared() || |
| 1411 | check_alloc_failures() || check_allocators() || check_xbox_slots() || check_console_command_list() || | 1547 | check_alloc_failures() || check_allocators() || check_xbox_slots() || check_console_command_list() || |
| 1412 | check_custom_heap_properties() || | 1548 | check_custom_heap_properties() || |
| 1413 | check_resource_allocation_info() || check_slot70()) | 1549 | check_resource_allocation_info() || check_slot70() || check_committed_resource3_x()) |
| 1414 | return 1; | 1550 | return 1; |
| 1415 | std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); | 1551 | std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); |
| 1416 | return 0; | 1552 | return 0; |