upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authortedin7 <tommasoderosa94@gmail.com>2026-11-23 19:18:17 +0100
committerTreXito <81475944+TreXito@users.noreply.github.com>2026-11-23 21:08:55 +0000
commit136efd5b59fe866898fcfe02c0e98d2c8c966f8a (patch)
tree19acee619aec25781b3a49ce96858f6d059be45d /runtime
parent6ad9db8e99f0040bb2f46fa32ab8ef729434de15 (diff)
d3d12: normalize additional console layouts in slot 25
(cherry picked from commit b8cbab6ab0b37920addfc5a362449f49a8220637)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/shims/d3d12_xs_desc_clean.h13
-rw-r--r--runtime/test/xs_proxy_mock_test.cpp30
2 files changed, 37 insertions, 6 deletions
diff --git a/runtime/shims/d3d12_xs_desc_clean.h b/runtime/shims/d3d12_xs_desc_clean.h
index 77f7e3281..23c54de5d 100644
--- a/runtime/shims/d3d12_xs_desc_clean.h
+++ b/runtime/shims/d3d12_xs_desc_clean.h
@@ -1,9 +1,7 @@
1// The PC form of a resource description the retail title builds for the console, for the Xbox-ABI device proxy. 1// The PC form of a resource description the retail title builds for the console, for the Xbox-ABI device proxy.
2// 2//
3// The title's D3D12_RESOURCE_DESC carries console values the PC device cannot take: the layout word is 0x101 (tiled) 3// The title's D3D12_RESOURCE_DESC carries console layout words and flag bits the PC device cannot take
4// or 0x1 (row-major buffer), and the flags have bits above the PC ones set (docs/retail_boot_chain.md, #6982). Slot 76 4// (docs/retail_boot_chain.md, #6982). The slot 25 cleaner returns a copy of the title's description.
5// replaces the layout word the same way before it forwards to CreateCommittedResource; slot 25 and the slot 127
6// stand-in need the same cleaning. The title's own description is never written: a caller gets a copy.
7#pragma once 5#pragma once
8 6
9#include <windows.h> 7#include <windows.h>
@@ -41,10 +39,13 @@ inline std::uint32_t pc_resource_flags(D3D12_RESOURCE_DIMENSION dimension, std::
41 return without_depth_stencil_uav(dimension, xbox_flags & kPcResourceFlagsMask); 39 return without_depth_stencil_uav(dimension, xbox_flags & kPcResourceFlagsMask);
42} 40}
43 41
44// Strip Xbox-only flags and translate the Xbox tiled layout. Preserve all other layouts so the host can validate them. 42// Strip Xbox-only flags and preserve the three supported PC layouts. In addition to 0x101, zebraso measured
43// layout words 0x102 and 0x105 reaching slot 25 during a retail boot.
45inline D3D12_RESOURCE_DESC pc_resource_desc(const D3D12_RESOURCE_DESC& xbox) { 44inline D3D12_RESOURCE_DESC pc_resource_desc(const D3D12_RESOURCE_DESC& xbox) {
46 D3D12_RESOURCE_DESC pc = xbox; 45 D3D12_RESOURCE_DESC pc = xbox;
47 if (pc.Layout == kXboxTiledResourceLayout) { 46 if (pc.Layout != D3D12_TEXTURE_LAYOUT_UNKNOWN &&
47 pc.Layout != D3D12_TEXTURE_LAYOUT_ROW_MAJOR &&
48 pc.Layout != D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE) {
48 pc.Layout = pc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER ? D3D12_TEXTURE_LAYOUT_ROW_MAJOR 49 pc.Layout = pc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER ? D3D12_TEXTURE_LAYOUT_ROW_MAJOR
49 : D3D12_TEXTURE_LAYOUT_UNKNOWN; 50 : D3D12_TEXTURE_LAYOUT_UNKNOWN;
50 } 51 }
diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp
index 1c63895ca..e299d320f 100644
--- a/runtime/test/xs_proxy_mock_test.cpp
+++ b/runtime/test/xs_proxy_mock_test.cpp
@@ -2171,6 +2171,36 @@ int check_allocation_descriptions_cleaned() {
2171 EXPECT(std::memcmp(kept, titles, sizeof(kept)) == 0); 2171 EXPECT(std::memcmp(kept, titles, sizeof(kept)) == 0);
2172 EXPECT(info.SizeInBytes == 8847360 + 131072); 2172 EXPECT(info.SizeInBytes == 8847360 + 131072);
2173 2173
2174 const D3D12_TEXTURE_LAYOUT normalized_layouts[] = {
2175 static_cast<D3D12_TEXTURE_LAYOUT>(kXboxTiledLayout),
2176 static_cast<D3D12_TEXTURE_LAYOUT>(0x102),
2177 static_cast<D3D12_TEXTURE_LAYOUT>(0x105),
2178 D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE,
2179 };
2180 for (const auto layout : normalized_layouts) {
2181 D3D12_RESOURCE_DESC descs[] = {titles[0], titles[1]};
2182 descs[0].Layout = descs[1].Layout = layout;
2183 g_seen_calls = 0;
2184 EXPECT(get_info(&info, device, 0, 2, descs) == &info);
2185 EXPECT(g_seen_desc_count == 2);
2186 EXPECT(g_seen_descs[0].Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN);
2187 EXPECT(g_seen_descs[1].Layout == D3D12_TEXTURE_LAYOUT_ROW_MAJOR);
2188 }
2189
2190 const D3D12_TEXTURE_LAYOUT preserved_layouts[] = {
2191 D3D12_TEXTURE_LAYOUT_UNKNOWN,
2192 D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
2193 D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE,
2194 };
2195 for (const auto layout : preserved_layouts) {
2196 D3D12_RESOURCE_DESC descs[] = {titles[0], titles[1]};
2197 descs[0].Layout = descs[1].Layout = layout;
2198 g_seen_calls = 0;
2199 EXPECT(get_info(&info, device, 0, 2, descs) == &info);
2200 EXPECT(g_seen_desc_count == 2);
2201 EXPECT(g_seen_descs[0].Layout == layout && g_seen_descs[1].Layout == layout);
2202 }
2203
2174 // A null array with a zero count reaches the PC device as it came. 2204 // A null array with a zero count reaches the PC device as it came.
2175 g_seen_desc_count = 99; 2205 g_seen_desc_count = 99;
2176 g_seen_calls = 0; 2206 g_seen_calls = 0;