Repository navigation
d3d12: Detile step for console-tiled layout 0x101 textures (D3D-316) - #2706
Conversation
|
Independent MSVC 19.44 / Windows SDK 10.0.26100 check of The docs currently mark slot-76 I also found a size-validation gap by testing the size helpers without allocating any large buffers. The 32-bit |
|
AI-assisted D3D-316 follow-up to @duudiis’s review. I checked #2706 at
|
8573c6b to
f31fb3a
Compare
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head merged with main f847748, MSVC 14.51):
Only |
|
Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head f31fb3a merged onto AI-assisted (Claude Code); runs on my machine. |
|
Tested
AI-assisted (Claude Code). No game files. |
Implement GFX10 SW_64KB_D 64 KiB detiling and tiling from Mesa addrlib swizzle equations (GFX10_SW_64K_D_RBPLUS_PATINFO) with compile-time LUT coordinate evaluation. Add synthetic round-trip unit tests in resource_detile_test covering 1, 2, 4, 8, 16 BPP, sub-tile and BCn formats. Update docs/d3d12_vulkan.md.
f31fb3a to
7a4e8d7
Compare
|
Tested 7a4e8d7 on RTX 5090, 621.24, Windows 11: pass. Built |
|
Tested 7a4e8d7 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
Flyander
left a comment
There was a problem hiding this comment.
The new span helpers promise bounds checking, but unchecked size multiplication lets very large valid dimensions bypass the span checks and reach out-of-bounds memcpy operations.
| const std::uint32_t tiles_x = (blocks_w + shape.width - 1) / shape.width; | ||
| const std::uint32_t tiles_y = (blocks_h + shape.height - 1) / shape.height; | ||
|
|
||
| const std::size_t expected_linear = static_cast<std::size_t>(blocks_w) * blocks_h * element_bytes; |
There was a problem hiding this comment.
[P2] Check for overflow before accepting the required span sizes. On 64-bit, width = height = 2^31, element_bytes = 4, block_dim = 1 wraps both required byte counts to zero (2^31 * 2^31 * 4 and the corresponding tile count times 64 KiB). Empty spans then pass this check and detile_typed immediately calls memcpy out of bounds. The same unchecked multiplication is in tile_surface_64k and the public size helpers. Use checked multiply/ceil-div arithmetic and reject overflow before touching either span.
|
Tested 7a4e8d7 on Intel Tiger Lake Xe-LP (0x9a78, iGPU, subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass Full runtime ctest on the PR head: 130/138 passed, 5 skipped (shader work folder / driver-feature skips), 2 failed, neither from this PR's code: AI-assisted (GLM, operated by the account owner). |
Item: D3D-316, claimed in #2516 (recommended by @KoertLichtendonk).
Resolves: D3D-316
What was open
In
runtime/shims/d3d12_vulkan_device.cppanddocs/d3d12_vulkan.md(§3.2, lines 1604 and 1708), textures created through Xbox slot 76 carry the non-standard layoutkXboxTiledLayout = 0x101. While the ABI recognizes the flag, the detiling path from console-tiled data into linear/Vulkan layout was listed as Open.The change
runtime/src/resource_detile.h:SW_64KB_Dswizzle coordinate mapping from Mesa addrlib bit equations (GFX10_SW_64K_D_RBPLUS_PATINFO) for elements of 1, 2, 4, 8, and 16 bytes.constexpr SwizzleLut64K), reducing intra-tile swizzle resolution to a singlelut_x[x % tile_w] | lut_y[y % tile_h]) per texel/block with zero heap allocations and zero runtime bit loops.detile_surface_64kandtile_surface_64kfunctions usingstd::span. Supports standard 2D textures, small sub-tiles, arbitrary non-power-of-two dimensions, and block-compressed textures (BC1–BC7 withblock_dim = 4).runtime/test/resource_detile_test.cpp:linear -> tile -> detile == linearand idempotence):runtime/CMakeLists.txt: Registeredresource_detile_testin CTest suite.docs/d3d12_vulkan.md: Updated layout 0x101 status from Open to Implemented.Verification
resource_detile_test.exe: PASSED (all round-trip, bijective, BCn, and error validation tests passed in 0.50s).resource_tiling_test.exe: PASSED.d3d12_state_map_test.exe: PASSED.d3d12_vulkan_device_test.exe: PASSED.19.44.35225), CMake 3.24, Ninja 1.13, NVIDIA GeForce RTX 2070 SUPER (Driver 595.79, Vulkan 1.4).