Skip to content

startup: general GFX10 texture tiling and detiling runtime - #1469

Open
Holastor wants to merge 15 commits into
R0Y00:mainfrom
Holastor:textures/gfx10-tiling-runtime
Open

Holastor wants to merge 15 commits into
R0Y00:mainfrom
Holastor:textures/gfx10-tiling-runtime

Conversation

@Holastor

@Holastor Holastor commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implement GFX10 texture tiling and detiling runtime in src/startup_stubs/:

  • src/startup_stubs/gfx10_texture.h: general GFX10 texture computer following AMD's addrlib micro-tile equations, mip-tail layout, and GetMipSize (ShiftCeil) surface extent calculations in Mesa (src/amd/addrlib, SPDX-License-Identifier: MIT, Copyright (C) 2007-2024 Advanced Micro Devices, Inc.).
  • Support Thin S and Thin D 256-byte micro-tiles across 1B, 2B, 4B, 8B, and 16B color and block-compressed formats (BC1–BC7, R8, R16, R32, RG8, RGBA8, BGRA8, RGBA16, RGBA32). Depth/stencil formats and implicit layouts (UNKNOWN, ROW_MAJOR) remain on the desktop footprint path.
  • Support explicit console layout modes (0x100 SW_LINEAR, 0x101 SW_256B_S, 0x102 SW_256B_D, 0x105 SW_4KB_S, 0x106 SW_4KB_D, 0x109 SW_64KB_S, 0x10a SW_64KB_D).
  • 256-entry coordinate bit tables (x_table, y_table), mip-tail placement, and linear<->tiled subresource transfers (copy_subresource<into>).
  • Wire xg_xs.dll TextureComputer slots for explicit 0x100–0x10a color/BC descriptors:
    • slot 2: GetResourceLayout
    • slot 3: GetResourceSize
    • slot 4: GetResourceAlignment
    • slot 5: GetSubresourceOffset
    • slot 6: GetSubresourceElementAddress
    • slot 8: CopyIntoSubresource (tiling)
    • slot 9: CopyFromSubresource (detiling)
    • slot 10: GetResourceTiling
  • Integrate Gfx10Texture detiling into D3D12 runtime upload_texture for explicit GFX10 tiled modes and multi-mip or array linear (0x100) textures (with rows_match footprint guard before copy).
  • Wire startup_xg_gfx10_runtime, xg_gfx10_tiling_reference, and startup_xg_bc7_draw_warp into CMakePresets.json pull request smoke test filter and build targets.
  • Verification suites:
    • tests/startup_xg_gfx10_check.py (startup_xg_gfx10_runtime): 24 synthetic cases across BC1–BC7, R8, RG8, R16, R32, RGBA8, BGRA8, RGBA16, RGBA32, explicit SW_LINEAR (0x100) through SW_64KB_D (0x10a) including multi-mip/multi-slice non-power-of-two RGBA16 100x10 3m 2s LINEAR, hard-coded Mesa 25.1.0 addrlib expected element byte offsets per element size, implicit/depth routing checks, and negative controls.
    • tests/xg_swizzle_select_check.cpp --gfx10-tiling (xg_gfx10_tiling_reference): compares surface size, slice size, alignment, mip offsets, and all texel/block addresses across 23 cases (including RGBA8 64x64 3m LINEAR and RGBA16 100x10 3m 2s LINEAR to pin linear mip ordering and ShiftCeil strides) against pinned Mesa 25.1.0 addrlib with 0 mismatches.
    • tests/startup_xg_bc7_draw_check.py (startup_xg_bc7_draw_warp / _hardware): tests BC7 64x64 / 81x69 linear & tiled draws, 512x256 display64k draw, non-BC64 RGBA8 64x64 0x105 (4KB_S) draw with negative swizzle control (4064/4096 pixels differ), and multi-mip RGBA8 64x64 3-mip 0x100 (LINEAR) draw detiled via is_gfx10_tiled with negative layout control (4096/4096 pixels differ).

Verification

Measured at 00c53f91 on Windows 11 x64 (MSVC 19.51.36263.0, AMD Radeon RX 6600M + D3D12 WARP + Mesa 25.1.0 addrlib from tools/fetch_addrlib.py):

ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_xg_.*|xg_.*|startup_address_.*_warp|startup_stubs|startup_gfx10_layout.*)$"
  • 27 passed, 0 failed out of 27:
    • xg_gfx10_tiling_reference (23/23 including LINEAR 3-mip and 100x10 3m 2s linear oracle cases): PASS
    • startup_xg_bc7_draw_warp (BC7 linear & tiled, RGBA8 0x105 4KB_S draw exact 4096/4096 with negative swizzle control, RGBA8 0x100 3-mip draw exact 4096/4096 with negative layout control): PASS
    • startup_xg_bc7_draw_hardware (all draws matched on physical AMD Radeon RX 6600M): PASS
    • startup_xg_bc_chain_hardware, startup_xg_bc_array_hardware: PASS
    • xg_bc64_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation, xg_swizzle_factory, xg_swizzle_factory_no_write: PASS
    • startup_stubs, startup_xg_bc_tiling, startup_xg_gfx10_runtime, startup_xg_tile64_tiling, startup_xg_bc7_layout: PASS
    • startup_gfx10_layout, startup_gfx10_layout_display_control: PASS
    • startup_address_srv_warp, startup_address_single_element_warp, startup_address_buffer_srv_warp, startup_address_volume_srv_warp, startup_address_bc_view_warp: PASS
    • startup_address_console_warp, startup_address_console_gate_warp, startup_address_console_gate_ring_warp, startup_xg_bc_chain_warp, startup_xg_bc_array_warp: PASS

Release /O2 build (--preset release):

  • Same test selection: 27 passed, 0 failed.

Mergeability:

  • git merge-tree --write-tree origin/main HEAD exits 0 (tree e9dc97d8386aa36f92682733708d0f7353fd2f69).

Pure-Python checks:

python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check origin/main..HEAD

All passed (147 Markdown files and 671 links clean, 2504 tracked files clean, diff clean).

@Holastor
Holastor force-pushed the textures/gfx10-tiling-runtime branch from 7bbd7f5 to a92ea12 Compare November 24, 2026 12:18

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #1469 (a92ea122):

Verification

  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at a92ea122:
    • Debug (--preset dev): built startup_stub_xg_xs, startup_stub_consumer, offscreen_check, and downstream targets; ctest --preset dev -R '^(startup_xg_|startup_stub|bc7_)' 14/16 passed (startup_xg_gfx10_runtime, startup_xg_bc_tiling, startup_xg_bc7_layout, startup_stubs, startup_xg_bc_chain_*, startup_xg_bc_array_*, startup_xg_bc7_draw_*, bc7_tile_swizzle, bc7_block_reference, bc7_draw_*); 2 capability-skipped (bc7_mode6_multiblock_hardware, bc7_mode6_multiblock_warp).
    • Release /O2 (--preset release): built same targets; ctest --preset release -R '^(startup_xg_|startup_stub|bc7_)' 14/16 passed, 2 capability-skipped (bc7_mode6_multiblock_*).
  • Linux checks at a92ea122:
    • tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check origin/main..HEAD: PASS
    • tests/gfx10_texture_roundtrip_check.py: PASS (6/6)
    • git merge-tree --write-tree origin/main HEAD: merges cleanly.

Code Audit Findings

  1. columns(mip) / rows(mip) returns 0 for non-square BC mips (src/startup_stubs/gfx10_texture.h):
    return (std::max)(1u, (width >> mip) + block_dim - 1) / block_dim;
    When width >> mip == 0 (e.g., 128x64 BC7 at mip = 7 where height >> 7 == 0), (std::max)(1u, 0 + 4 - 1) / 4 evaluates to 3 / 4 == 0. In gfx10_copy (src/startup_stubs/xg_bc64.inl), u64{tex.rows(level) - 1} then underflows UINT to 0xffffffff.
    It should be ((std::max)(1u, width >> mip) + block_dim - 1) / block_dim (and similarly for rows(mip)).
  2. Missing d.MipLevels <= 16 guard in Gfx10Texture::supports():
    mip_start, tiles_w, tiles_h, tail_origin_x, and tail_origin_y are fixed std::array<UINT, 16>. If d.MipLevels > 16 is passed, Gfx10Texture will index out of bounds (and width >> mip for mip >= 32 is UB). Adding d.MipLevels > 16 to supports() prevents that.
  3. Negative control in tests/startup_xg_gfx10_check.py:
    The 12 positive roundtrip cases pass, but there is no negative/failure control yet (e.g. pitch < row_bytes, out-of-range subresource/plane, overlapping src/dst, or unsupported format).

@Holastor
Holastor force-pushed the textures/gfx10-tiling-runtime branch from a92ea12 to eb3e418 Compare November 24, 2026 12:42
@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed review feedback at eb3e418b:

  1. Non-square BC mips (columns / rows calculation):

    • Updated columns(mip) and rows(mip) in src/startup_stubs/gfx10_texture.h to ((std::max)(1u, width >> mip) + block_dim - 1) / block_dim and ((std::max)(1u, height >> mip) + block_dim - 1) / block_dim. This ensures columns and rows evaluate to at least 1 when (width|height) >> mip == 0, avoiding UINT underflow in gfx10_copy.
    • Added synthetic test case BC7 128x64 8-mip 4KB_S in tests/startup_xg_gfx10_check.py, which validates exact linear<->tiled roundtrip across all 8 mips (including mip 7 where height >> 7 == 0).
  2. MipLevels bounds guard in Gfx10Texture::supports():

    • Added d.MipLevels > 16 guard to supports() (rejecting d.MipLevels < 1 || d.MipLevels > 16), preventing fixed-size table out-of-bounds indexing or undefined bit-shift behavior.
  3. Negative control test coverage (tests/startup_xg_gfx10_check.py):

    • Added test_negative_controls(create) covering:
      • pitch < row_bytes: ensures E_INVALIDARG (0x80070057) on both CopyIntoSubresource (slot 8) and CopyFromSubresource (slot 9).
      • Out-of-range plane (plane > 0 on single-plane resource): ensures E_INVALIDARG.
      • Out-of-range subresource (subresource >= mips * slices): ensures E_INVALIDARG.
      • Overlapping source and destination buffers: ensures E_INVALIDARG.
      • Null destination or source pointers: ensures E_INVALIDARG.
      • MipLevels > 16: ensures descriptor is rejected from GFX10 tiling path.

Verification

  • ctest --preset dev --no-tests=error -R '^(startup_xg_|bc7_|texture_bc|bcpack)' -V
    • 17 passed, 2 capability-skipped (bc7_mode6_multiblock_*), 0 failed (100%).
    • startup_xg_gfx10_runtime: 13 synthetic test cases + negative controls all PASS.
  • Pure-Python checks:
    • python -B tests/docs_links_check.py (PASS)
    • python -B tests/bidi_controls_check.py (PASS)
    • python -B tests/gfx10_texture_roundtrip_check.py (PASS)
    • git diff --check (clean)

@Holastor
Holastor requested a review from tedin7 November 24, 2026 12:45
Add clean-room GFX10 texture tiling and detiling runtime in src/startup_stubs/:
- Implement src/startup_stubs/gfx10_texture.h using AMD GFX10 addrlib micro-tile equations (SPDX-License-Identifier: MIT, derived from Mesa src/amd/addrlib).
- Support Thin S and Thin D 256-byte micro-tiles across 1B, 2B, 4B, 8B, and 16B elements (BC1-BC7, R8, R16, R32, RG8, RGBA8, BGRA8, RGBA16, RGBA32, D16, D24S8, D32F).
- Support non-XOR swizzle modes: SW_64KB_S, SW_64KB_D, SW_4KB_S, SW_4KB_D, SW_256B_S, SW_256B_D, and SW_LINEAR.
- Implement mip tail packing, origin placement, and linear<->tiled subresource transfers (copy_subresource<into>).
- Wire TextureComputer slots in xg_xs.dll (slots 2, 3, 4, 5, 6, 8, 9, 10), including functional slot 9 (CopyFromSubresource detile).
- Integrate general GFX10 detiling into D3D12 runtime upload_texture and publish_tiled_texture.
- Add synthetic verification test suite tests/startup_xg_gfx10_check.py covering 12 texture shapes, formats, and swizzle configurations.

Verification:
ctest --preset dev --no-tests=error -R '^(startup_xg_|bc7_|texture_bc|bcpack)' -V
19/19 tests passed (100%)
@Holastor
Holastor force-pushed the textures/gfx10-tiling-runtime branch from eb3e418 to 88c391e Compare November 24, 2026 13:09
@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Built, ran, and probed with two mutations on the new tiler

Independent reviewer, not the author. Reviewed 88c391e2; nothing pushed to the branch. Mutations were made locally in
src/startup_stubs/gfx10_texture.h, rebuilt, reverted; working tree is clean.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(startup_xg_gfx10_runtime|gfx10_texture_roundtrip|gfx10_texture_roundtrip_controls|bc7_tile_swizzle)$' -V

Unmodified branch — startup_xg_gfx10_runtime reports all 13 cases passing, each with layout, tiling, slot 8 tile and
slot 9 detile roundtrip exact, across BC1/BC4/BC5/BC7/R8/R16/RGBA8, 64KB_S, 64KB_D, 4KB_S, 4KB_D, 256B_S and
LINEAR, including the two-slice and 8-mip cases; the negative controls (pitch < row_bytes, out-of-range
plane/subresource, overlap, null, mips > 16) pass. The three older tests are unchanged and green.

Mutation 1 — y coordinate table redirects every bit

-if ((y >> bit) & 1) val |= (1u << y_target_bit[bit]);
+if ((y >> bit) & 1) val |= (1u << (y_target_bit[bit] ^ 1));
startup_xg_gfx10_runtime ........... ***Failed
bc7_tile_swizzle ................... Passed
gfx10_texture_roundtrip ............ Passed
gfx10_texture_roundtrip_controls ... Passed

Mutation 2 — 4 KB modes report a 64 KB block

 case SW_4KB_S:
-case SW_4KB_D:  return 12;
+case SW_4KB_D:  return 16;
startup_xg_gfx10_runtime ........... ***Failed
gfx10_texture_roundtrip ............ Passed

What the second result implies

gfx10_texture_roundtrip and _controls run tests/gfx10_texture_roundtrip_check.py, i.e. the Python tiler in
tools/bc7_tiles.py. They cannot see a change in this new C++ header. So startup_xg_gfx10_runtime is currently the
only check that exercises gfx10_texture.h
, and both mutations above are invisible to everything else. That is not a
defect in this PR — it is the reason the new test matters — but it does mean the C++ tiler has a single guard, and any
future edit to it should keep that test in every job.

If it would help, a second oracle would be cheap: the Python tiler already knows these modes, so one case could compare
the C++ layout output against bc7_tiles.py's tiling for the same surface rather than round-tripping the C++ path
against itself. I am not asking for it in this PR.

Verdict

Reviewed 88c391e2. Builds clean, 13 cases and the negative controls pass, the older tests are unaffected, and two
independent mutations in the coordinate table and the mode dispatch are both caught. No objection from me.

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Independent Windows check at 88c391e2, using source-built inputs. For 1024×1024 BC7_UNORM and BC7_UNORM_SRGB with nine mips, and BC6H_UF16 with eleven, slot 10 reported 22 tiles, a packed tail at tile 0, and the three standard mips beginning at tiles 6, 2 and 1. Per-block addressing and two-way copies matched our independent comparison for all 87,381 blocks of each BC7 chain and all 87,383 blocks of the BC6H chain. Padding sentinels and rejected short pitches were also checked. We will use this PR as the shared implementation for that path.

One ABI question remains. For packed mips, the slot 2 layout record's 32-bit field at +0x48 was 1 here and 2 in our local implementation. Does the field have an identified consumer or an independent expected value? The slot 10 and copy results above agree with either value.

R0Y00 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

A regression surfaced in a one-DLL A/B at 88c391e2. With the same runtime and warmed shader cache, the previous XG path rendered the full Latin text on a mixed-script page. After replacing only XG, the same text lost individual Latin glyphs; the language selection capture still matched pixel for pixel. The sparse BC1 mip ranges improved in that same run.

The distinction is reproducible without title data. For descriptors with UNKNOWN layout, 2D R8, RG8, RGBA, BC3 and BC7 uploads produced different bytes from the previous path; both planes of an explicit NV12 sample agreed. A local selective build keeps the previous behavior for those five implicit-layout cases while matching your slot 10 output for all 133 sampled explicit sparse descriptors. Could we keep the proven explicit layout routing and cover implicit layout selection in separate source-built upload tests? I am also checking an intro color regression separately.

Completed the single-DLL retest on RTX 4060 Laptop. The previous intro produced a uniform green client image. The selective build produced consecutive distinct full-color intro frames. A 712 × 80 mixed-script text region on each of two UI pages matched the previous known-good build pixel for pixel (maximum channel error 0 on both). The later letterboxed image still became magenta in the selective build; that later rendering failure remains open. No private inputs or captures are needed for the five upload comparisons above.

@Holastor

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough independent verification on BC7 and BC6H!

Regarding the +0x48 field in the subresource layout record:

  1. In our implementation, 1 corresponds to SW_256B_S (ADDR_SW_256B_S in addrlib), representing the 256-byte micro-tile mode for the _S (Standard) macro-tile flavor, whereas 2 corresponds to SW_256B_D (ADDR_SW_256B_D).
  2. We checked runtime stubs, callers, and observed traces: we haven't identified any consumer reading mip + 0x48 (callers rely on mip->Offset, RowPitch, extents, or the slot 10 D3D12_SUBRESOURCE_TILING records).
  3. Since both values produce identical layout extents, slot 10 tiling, and two-way copies, we have no preference and are happy to align with your local implementation (2, or selecting SW_256B_S (1) / SW_256B_D (2) based on the parent mode's S/D flavor) if you prefer consistency with your local tooling.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 88c391e (comment only, not an approval). My earlier review was at a92ea12.

Verdict: 1 P1, 3 P2. The tiler itself looks correct (below); the problem is where it is routed.

Earlier points: the rows/columns underflow, the MipLevels > 16 guard and the negative controls are all fixed at this head.

P1: every implicit-layout 2D texture now gets the swizzled 64 KiB computer (src/startup_stubs/xg_xs.cpp:378, with gfx10_swizzle_from_desc in gfx10_texture.h)

  • Gfx10Texture::supports() is true for any 2D texture with a known format, and gfx10_swizzle_from_desc returns SW_64KB_S for any layout that is neither explicit nor row-major, including layout 0. The old bc64::supports accepted only 1024-wide BC5/BC7 with layout 0x109. Textures that used the desktop-footprint path (slots 2, 8, 10) now take the tiled path, while upload_texture still reads implicit-layout memory as linear (is_tiled() is false for layout 0). This fits R0Y00's field report (comment 7134312424) that implicit-layout R8, RG8, RGBA, BC3 and BC7 uploads differ from the previous path.
  • Reproduction: the real xg_xs.cpp built into a DLL with mingw and run under wine. Slot 8 on an RGBA8 64x64 layout-0 texture returns size=65536 output_is_row_major=0; dump 28 256 256 1 1 0 gives size=40000 align=10000 at the PR head. Wine has no D3D12 device, so the base path was read from source rather than run.
  • Fix: gate the table swap on explicit layouts (is_tiled(desc) or bc64::supports) and add an implicit-layout test.

P2

  1. Linear (0x100) is accepted but its metadata is wrong: init_linear() in xg_bc64.inl never fills tiles_w/tiles_h. dump 28 256 256 1 1 0x100 gives mip0 span=0 pitchB=0 padw=0, tiles=1024 shape=64x1x1. The roundtrip test passes anyway because it never reads those fields.
  2. tests/startup_xg_gfx10_check.py only checks tile-then-detile gives the input back, so any bijective permutation passes. Slot 5 is never called, first_addr in slot 6 is never asserted, layout records are never read, and the MipLevels=17 control only asserts align != 65536. addrlib is already an optional dependency (tools/fetch_addrlib.py, xg_swizzle_select_check.cpp); compare addresses and sizes against it.
  3. Claims versus tests: the body lists D16, D24S8, D32F, RG8, BGRA8, RGBA16 and RGBA32, but no test case covers them (and D24S8 is not S/D swizzle for depth on this hardware); the body says 19/19 tests and 12 cases while a comment says 17 passed, 2 skipped, 13 cases; "clean-room" conflicts with "derived from Mesa addrlib" and the AMD copyright line in the header. Against origin/main cea8af5 it no longer merges cleanly (CMakeLists.txt and xg_xs.cpp, trivial; from be98528, which added a tile64_plan.h answer for slot 10 layout 0x10a).

What I ran

  • git diff --check, docs_links_check (16 files, 334 links) and bidi_controls_check: pass. gfx10_texture_roundtrip_check roundtrip and controls pass, but they test tools/bc7_tiles.py, which this PR does not touch. startup_xg_gfx10_check.py cannot run on Linux (no ctypes.WINFUNCTYPE); I ran a C++ port of it (13 cases plus negatives) against the real DLL under wine: all pass.
  • Base DLL versus PR DLL on the shapes the old code supported (BC7/BC5, 1024 wide, layout 0x109): layout, size, offsets, tiling and all texel addresses identical. Against an addrlib build (Mesa 25.1.0, navi21 config), 30 cases across BC1/3/4/5/7, R8, R16, RG8, RGBA8, RGBA16, RGBA32, R32 and 256B/4KB/64KB S and D match on size, alignment, mip offsets and every texel address.
  • Mutations (each restored with git checkout --): block log2 of SW_4KB_D 12 -> 16, tail x/y bit sources swapped, reverting the rows() fix and slot 10 reporting one more standard mip are caught by the port. NOT caught by it: swapping x1 and x2 in the 4-byte S pattern (a wrong but bijective swizzle; only the addrlib comparison sees it, pr=32896 addrlib=32832), and a linear mip pitch no longer 256-aligned (neither sees it). A columns()-only edit was also not caught; the height case needs the rows() change.

Non-blocking

  • After the merge the new gfx10_tiling and main's tile64::Plan both answer slot 10; they matched on 7 of 7 valid 0x10a shapes I compared and differ only for an invalid 256x256 with 16 mips.
  • The d3d12_memory_srv.inl edit is dead for now (supports_memory_srv still gates on bc64::supports); gfx10_swizzle_from_desc reads X2W_XG_BC7_4K_S_LAYOUT through GetEnvironmentVariableA on every construction; about 2.4 KB of tables are rebuilt per call; total_slice_bytes and address() are 32-bit and overflow above 4 GiB; the +0x48 offset question was answered in a comment only and stays unverified.
  • #1641, #1567, #1701, #1441 and #1277 touch the same stub files, mostly the include area.

Not run: any ctest preset, the real startup_xg_gfx10_check.py, a D3D12 device, llvm-mc-19 (no shader forms in the diff). The wine harness shims __try, so unreadable-memory probes were inert.

Linux limits: no Windows, MSVC, DXC or D3D12 device here; LLVM 19 only. Anything that needs them was not run.

AI-assisted; commands listed were executed locally.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed the P1, P2, and merge-conflict feedback from @tedin7 and @R0Y00 at eca1f09e:

  1. P1 — Gate Gfx10Texture routing on explicit console layouts (0x100–0x10a):

    • Updated gfx10_swizzle_from_desc() in src/startup_stubs/gfx10_texture.h so only explicit (layout & 0xFF00) == 0x100 descriptors are accepted; implicit layouts (D3D12_TEXTURE_LAYOUT_UNKNOWN = 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1) now return 0xFFu and route to the desktop footprint table in xg_xs.cpp (and removed the per-construction GetEnvironmentVariableA("X2W_XG_BC7_4K_S_LAYOUT", ...) call from gfx10_swizzle_from_desc).
    • Added test_implicit_and_unsupported_routing() in tests/startup_xg_gfx10_check.py covering UNKNOWN layout RGBA8, R8, RG8, BC3, BC7 and ROW_MAJOR RGBA8, asserting desktop stub routing (and verifying RGBA8 64x64 UNKNOWN reports desktop span=16384, pitch=256 instead of 64KB_S).
  2. P2 Run the native wave64 BVH fixture on a supported Windows GPU #1 — Fix SW_LINEAR (0x100) metadata in init_linear():

    • Populated tiles_w[i] = (cols + tile_width - 1) / tile_width and tiles_h[i] = r in Gfx10Texture::init_linear(), so slot 2 (span, pitchB, padw, padh) and slot 10 (tilings) report valid 256-byte-aligned linear metadata instead of zeros.
    • Added multi-mip RGBA8 256x256 3-mip LINEAR and slot 2 / slot 10 assertions for all cases in tests/startup_xg_gfx10_check.py.
  3. P2 Check the first build from a fresh Windows checkout #2 — Strengthen tests & add addrlib address/size oracle (xg_gfx10_tiling_reference):

    • tests/startup_xg_gfx10_check.py now checks slot 2 plane & mip records, slot 5 (GetSubresourceOffset) including out-of-range checks, slot 6 (GetSubresourceElementAddress) first_addr and sampled coordinates matched byte-for-byte against slot 8 output, slot 10 (GetResourceTiling) entries, and tightens the MipLevels=17 control to assert desktop fallback (slots[3]/[9] no-op and l_mips == 15).
    • Added --gfx10-tiling (xg_gfx10_tiling_reference, SKIP_RETURN_CODE 77) in tests/xg_swizzle_select_check.cpp comparing surfSize, sliceSize, baseAlign, firstMipIdInTail, mip offsets, and every texel/block address across 20 cases against pinned Mesa 25.1.0 addrlib (Addr2ComputeSurfaceInfo / Addr2ComputeSurfaceAddrFromCoord).
  4. P2 Publish English contributor guides and scope the GTA VI XSX case study #3 & Non-blocking cleanups:

    • Merged upstream/main (67758cba, including be98528a tile64_plan.h, single_element_srv, and partial_tiled_bc in d3d12_draw.inl / d3d12_memory_srv.inl).
    • Removed depth/stencil formats (D16_UNORM, D24_UNORM_S8_UINT, D32_FLOAT, R24G8_*) from gfx10_format_info and rejected D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL in Gfx10Texture::supports(), keeping depth resources on the desktop path (tested in test_implicit_and_unsupported_routing()).
    • Added test cases covering BC2, BC3, BC6H, RG8, R32, BGRA8, RGBA16, and RGBA32, and updated the PR body to match the tested formats, exact counts, and MIT/Mesa addrlib attribution.
    • Changed total_slice_bytes, mip_start, and address() in Gfx10Texture to UINT64 to avoid 32-bit overflow above 4 GiB.

Verification at eca1f09e

  • ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_xg_|xg_swizzle_select|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_address_bc_view|startup_stubs|bc7_|texture_bc)" (with XBOX2WINDOWS_ADDRLIB_DIR from tools/fetch_addrlib.py): 22 passed, 2 capability-skipped (bc7_mode6_multiblock_hardware, bc7_mode6_multiblock_warp), 0 failed.
    • xg_gfx10_tiling_reference: PASS (20/20 cases matched Mesa 25.1.0 addrlib).
    • startup_xg_gfx10_runtime: PASS (22 cases + implicit/depth routing + negative controls).
    • startup_xg_tile64_tiling, startup_xg_bc_tiling, startup_xg_bc7_layout, startup_stubs, startup_xg_bc*_warp/hardware, startup_address_bc_view_warp/hardware, bc7_*, texture_bc_volume: PASS.
  • Pure-Python & diff checks: docs_links_check.py (18 files, 407 links), bidi_controls_check.py (1497 files), gfx10_texture_roundtrip_check.py (6/6), and git diff --check upstream/main..HEAD all PASS.

@Holastor
Holastor requested a review from tedin7 November 25, 2026 05:12

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head eca1f09 (comment only, not an approval). Earlier reviews were at a92ea12 and 88c391e.

Verdict: 0 P1, 1 P2. The earlier P1 (implicit-layout textures routed to the swizzled computer) is fixed at this head.

Fixed since 88c391e

  • gfx10_swizzle_from_desc (src/startup_stubs/gfx10_texture.h:136) now accepts only (layout & 0xFF00) == 0x100. Layout 0 and 1 return 0xFF, so supports() is false and XGCreateTextureComputer (xg_xs.cpp:409) keeps the desktop table for them.
  • init_linear() now fills tiles_w/tiles_h for 0x100.
  • test_implicit_and_unsupported_routing covers UNKNOWN RGBA8/R8/RG8/BC3/BC7, ROW_MAJOR RGBA8 and D24S8/D32F, and checks desktop span=16384 pitch=256 for RGBA8 UNKNOWN.
  • The positive cases now cover BC1-BC7, R8, RG8, R16, R32, RGBA8, BGRA8, RGBA16, RGBA32 and linear, across 256B/4KB/64KB S and D modes (22 cases), which matches the body.
  • upload_texture and device_memory_srv gate on Gfx10Texture::is_tiled, so upload and XG routing agree for implicit layouts.

P2

  1. The tests still do not pin the swizzle pattern, and the only address oracle is skipped where it ran. I applied one mutation to the new logic: in PATTERN_S[2] (gfx10_texture.h, 4-byte elements, the RGBA8 / BGRA8 S case) I swapped y0y1 to y1y0. startup_xg_* on Win2025 stayed green (10/10 passed). The roundtrip and slot checks accept any bijective permutation. xg_gfx10_tiling_reference is the check that compares against addrlib, but it reports Skipped on Win2025 (addrlib not configured), so this mutant survives. Please either run it with addrlib in the Windows CI job, or add a few hard-coded expected byte offsets per element size (1, 2, 4, 8, 16) taken from an addrlib run into startup_xg_gfx10_check.py.

Nit

  • Slot 10 / layout +0x48 writes the swizzle mode (9 for 64KB_S), same as the previous path. The 256B S vs D value in the thread is unread by any consumer, so no change needed.

Checks run

  • Linux: python3 tests/docs_links_check.py PASS (18 files, 407 links); python3 tests/bidi_controls_check.py PASS (1489 files); git diff --check origin/main...HEAD clean; python3 -I -m py_compile tests/startup_xg_gfx10_check.py OK; python3 -I tests/gfx10_texture_roundtrip_check.py PASS (6 tests; this one covers the 4 KiB BC7 Python tool, not the new C++).
  • Win2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at eca1f09: python3 x2w_pipe.py win2025 1469 --wait 3600 --targets startup_stub_xg_xs,xg_swizzle_select_check,startup_stub_consumer,startup_bc64_supports_check --regex '^(startup_xg_|startup_stub|xg_|startup_bc64|bc7_)'. Dev and release (/O2): 100% tests passed (25 selected; 17 ran, 8 skipped). Skipped: xg_bc64_tiling_reference, xg_gfx10_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation, xg_swizzle_factory, xg_swizzle_factory_no_write (no addrlib), bc7_mode6_multiblock_hardware, bc7_mode6_multiblock_warp.
  • Mutation (P2 1): win2025 1469 --wt . --skip-release --regex '^startup_xg_' with the one-line change above: 10/10 passed, mutant survived. Reverted with git checkout -- ..
  • CI at review time: Linux Python checks pass; Windows jobs pending. Mergeable. Title is neutral.

AI-assisted; commands listed were executed locally.

@Holastor

Holastor commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the P2 finding (eca1f09e review) and merged upstream/main (b0669e06, including #2015 and #2214) at commit 088add19:

  1. P2 — Pin expected element byte offsets per element size in tests/startup_xg_gfx10_check.py:

    • Added test_pinned_addrlib_offsets(create) with hard-coded element byte offsets collected from xg_gfx10_tiling_reference (Mesa 25.1.0 addrlib, navi21) covering all 5 element sizes (1, 2, 4, 8, 16 bytes) across both _S and _D modes (R8 64KB_S, R8 4KB_D, R16 4KB_S, RG8 4KB_D, BGRA8 4KB_S, RGBA8 64KB_S, R32 256B_D, BC1 64KB_S, RGBA16 64KB_D, RGBA32 4KB_S, BC5 64KB_D, and BC7 64x64 7-mip 4KB_S including mips 2–6 in the mip tail).
    • For each coordinate, asserts both slot 6 (GetSubresourceElementAddress) equals the pinned offset and slot 8 (CopyIntoSubresource) writes the expected element bytes at that pinned offset.
    • Added R8 64x64 1-mip 4KB_D to both tests/startup_xg_gfx10_check.py (23 cases) and tests/xg_swizzle_select_check.cpp (--gfx10-tiling, 21 cases) so _S and _D are covered for all 5 element sizes.
    • Confirmed the exact PATTERN_S[2] mutation (y0y1 -> y1y0) is now caught by startup_xg_gfx10_runtime (AssertionError: BGRA8 64x64 3-mip 4KB_S mip 0 (0,1): slot6 addr=0x2020, expected 0x2010), then restored.
  2. Clean merge with upstream/main (b0669e06) & drop d3d12_memory_srv.inl diff:

    • Merged upstream/main cleanly and reverted the earlier dead condition in src/startup_stubs/d3d12_memory_srv.inl, keeping upstream/main's slot-70 console_layout_srv path unmodified and gating Gfx10Texture in upload_texture (d3d12_draw.inl) on !tiled_address.

Verification at 088add19

  • ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_xg_|xg_swizzle_select|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_address_|startup_stubs|startup_gfx10_layout|bc7_|texture_bc)": 36 passed, 2 capability-skipped (bc7_mode6_multiblock_hardware, bc7_mode6_multiblock_warp — exit 77), 0 failed (51.63 sec), including startup_xg_gfx10_runtime, xg_gfx10_tiling_reference, startup_address_console*_warp/hardware, and startup_gfx10_layout*.
  • Pure-Python & diff checks: docs_links_check.py (18 Markdown files and 409 links), bidi_controls_check.py (1499 files), gfx10_texture_roundtrip_check.py (6/6), and git diff --check upstream/main..HEAD all PASS.

@Holastor
Holastor requested a review from tedin7 November 25, 2026 05:41

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 5477f0b (comment only, not an approval). Earlier reviews were at a92ea12, 88c391e and eca1f09.

Verdict: 0 P1, 0 P2, 1 P3 (merge conflict with current main). The earlier P2 (swizzle pattern not pinned) is addressed.

Fixed since eca1f09

  • New test_pinned_addrlib_offsets in tests/startup_xg_gfx10_check.py:304 pins hard-coded element byte offsets for 13 surfaces across element sizes 1, 2, 4, 8 and 16 (S and D modes, 256B/4KB/64KB, plus BC7 mip-tail origins). It checks both GetElementOffset (slot 6) and the bytes CopyIntoSubresource (slot 8) writes at that offset.
  • I hand-checked the RGBA8 64KB_S case against PATTERN_S[2] ("----x0x1y0y1y2x2", gfx10_texture.h:226): x=1/2/4 give 0x4/0x8/0x80, y=1/2/4 give 0x10/0x20/0x40, y=8 gives 0x100, x=8 gives 0x200. These match the pinned values. Swapping y0y1 there now moves y=1 from 0x10 to 0x20, so this test would fail on the mutant that survived at eca1f09.
  • I could not confirm that the offsets really come from addrlib (it is not configured here, xg_gfx10_tiling_reference still reports Skipped). They are self-consistent with the documented patterns, which is what matters for regression protection.

P3

  1. The PR is CONFLICTING with current main (b0669e0). git merge-tree --write-tree origin/main HEAD reports a content conflict in src/startup_stubs/d3d12_draw.inl (the upload_texture hunks around lines 991-1100); CMakeLists.txt merges cleanly. Please merge or rebase main again before this goes Ready.

Checks run

  • python3 tests/docs_links_check.py PASS (18 files, 408 links).
  • python3 tests/bidi_controls_check.py PASS (1496 files).
  • git diff --check origin/main...HEAD clean.
  • python3 -I -m py_compile tests/startup_xg_gfx10_check.py OK.
  • Win2025 (D3D12 WARP): python3 x2w_pipe.py win2025 1469 --wait 3600 --targets startup_stub_xg_xs,xg_swizzle_select_check --regex "startup_xg|xg_swizzle|xg_gfx10" ran on the pipeline's own merged ref (088add1), dev phase only. startup_xg_gfx10_runtime Passed (0.68 s), which includes the new pinned-offset test. The other 15 matched tests were Not Run or Skipped because my narrow --targets did not build them (and addrlib is not configured); they are not results about this PR. The release phase did not run because dev stopped on those Not Run entries, so I make no claim about it.
  • I did not apply a new source mutation on Windows this round; the mutation argument above is by hand against the pinned values.

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment review of head 2c835d5f (a merge of main on top of a3cb0e89, which @tedin7 already reviewed; the PR's own change is the same).

What I checked (Linux only, no Win2025 run, no game):

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py and python3 tests/bidi_controls_check.py: pass.
  • tests/startup_xg_gfx10_check.py is Windows-only (ctypes.WINFUNCTYPE), so it cannot run here. Its result on this head is not verified by me.
  • Diff scope: gfx10_texture.h, slots 2-6, 8-10 in xg_xs.cpp/xg_bc64.inl, and the routing in d3d12_draw.inl. No sibling table I could see was left out.

Why I am not merging:

  • The thread carries rendering regressions seen while running the game (R0Y00's A/B at 88c391e2: lost Latin glyphs, a magenta letterboxed image that "remains open"). Routing was narrowed to explicit layouts 0x100-0x10a afterwards, but no one has re-run the game on this head.
  • We have no game here, so we cannot confirm that. This is a startup-path change: the merge stays with MasterDomino or @R0Y00, who can verify it on the game.
  • Still open from the thread: the +0x48 layout-record field (1 vs 2) has no identified consumer, and implicit-layout uploads (UNKNOWN) still need their own source-built upload tests.

AI-assisted; commands listed were executed locally.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

I ran the current 2c835d5f Windows Release candidate. All 23 TextureComputer cases and their implicit-route, pitch and range controls passed. Ten BC chain/array and address-upload CTests passed on WARP and RTX 4060 Laptop. The local addrlib-dependent checks skipped; your pinned Mesa run is separate. The earlier glyph regression was observed on an earlier route. For the current narrowed explicit-layout candidate, the remaining check is a matched baseline/candidate run through that same glyph transition and late frame, with the same profile/cache and first visible difference if any. Keep the input and raw captures local.

@Holastor
Holastor requested a review from tedin7 November 25, 2026 21:10
@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00, any update on the matched baseline/candidate run for 2c835d5?

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 32eabd4 (merge of main into 2c835d5; conflict only in CMakeLists.txt, both test blocks kept, no force-push).

Result: dev 25/25 and release 25/25 passed. The 4 addrlib-based checks (xg_bc64_tiling_reference, xg_gfx10_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation) skipped (exit 77): addrlib is not configured on this VM, so the pinned Mesa comparison is not covered by this run. Hardware-adapter variants were not run (WARP only).

Not claimed: no game run. Startup/rendering effect of the routing change still needs a game check by @R0Y00 or MasterDomino.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 32eabd4ea04804291d1d25e492b796aaddc2f1d3:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs xg_swizzle_select_check startup_gfx10_layout_check startup_stream_consumer startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu -- -j 2): 4.43s (configure 0.00s)
    • Test (ctest --preset dev -R '^(startup_xg_.*|xg_swizzle_select.*|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_address_.*_warp|startup_stubs|startup_gfx10_layout.*)$' --parallel 2 --no-tests=error --output-on-failure): 21/25 passed (31.13s: startup_address_srv_warp 0.85s, startup_xg_bc7_draw_warp 1.46s, startup_stubs 1.43s, startup_xg_gfx10_runtime 0.75s, startup_address_buffer_srv_warp 1.83s, startup_xg_bc_tiling 0.60s, startup_xg_bc7_layout 0.62s, xg_bc64_tiling_reference 0.02s, xg_gfx10_tiling_reference 0.01s, startup_xg_tile64_tiling 0.65s, startup_gfx10_layout 0.53s, xg_swizzle_select 0.01s, xg_swizzle_select_mutation 0.01s, startup_gfx10_layout_display_control 0.62s, startup_address_volume_srv_warp 1.22s, startup_address_single_element_warp 1.87s, startup_address_bc_view_warp 2.59s, startup_address_console_gate_warp 3.80s, startup_address_console_gate_ring_warp 3.67s, startup_address_console_warp 10.15s, startup_xg_bc_chain_warp 3.36s, startup_xg_bc7_draw_hardware 1.39s, startup_xg_bc_chain_hardware 3.02s, startup_xg_bc_array_warp 8.64s, startup_xg_bc_array_hardware 6.93s); skipped (capability, not a pass): xg_bc64_tiling_reference, xg_gfx10_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs xg_swizzle_select_check startup_gfx10_layout_check startup_stream_consumer startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu -- -j 2): 31.14s (configure 0.00s)
    • Test (ctest --preset release -R '^(startup_xg_.*|xg_swizzle_select.*|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_address_.*_warp|startup_stubs|startup_gfx10_layout.*)$' --parallel 2 --no-tests=error --output-on-failure): 21/25 passed (33.27s: startup_stubs 0.73s, startup_xg_bc7_draw_warp 1.51s, startup_address_buffer_srv_warp 0.93s, xg_bc64_tiling_reference 0.03s, xg_gfx10_tiling_reference 0.01s, startup_gfx10_layout 0.19s, startup_gfx10_layout_display_control 0.18s, xg_swizzle_select 0.01s, xg_swizzle_select_mutation 0.01s, startup_address_srv_warp 0.94s, startup_xg_bc_tiling 0.64s, startup_xg_gfx10_runtime 0.79s, startup_xg_tile64_tiling 0.59s, startup_xg_bc7_layout 0.67s, startup_address_volume_srv_warp 1.05s, startup_address_single_element_warp 1.69s, startup_address_bc_view_warp 2.61s, startup_address_console_gate_warp 2.56s, startup_address_console_gate_ring_warp 2.45s, startup_xg_bc_chain_warp 3.77s, startup_address_console_warp 12.54s, startup_xg_bc7_draw_hardware 1.85s, startup_xg_bc_chain_hardware 3.73s, startup_xg_bc_array_warp 10.54s, startup_xg_bc_array_hardware 9.88s); skipped (capability, not a pass): xg_bc64_tiling_reference, xg_gfx10_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation
  • sccache: 17/23 hits; wall 77.0s

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment review of head 32eabd4e. It is 2c835d5f plus a merge of main (only conflict: CMakeLists.txt, the xg_gfx10_tiling_reference block and the new tooling_fetch_addrlib_cli_check block, both kept). The PR's own change is identical to 2c835d5f, which I already reviewed.

What I checked:

  • git diff --check: clean. python3 tests/docs_links_check.py and python3 tests/bidi_controls_check.py: pass.
  • Win2025 WARP receipt for this head is in the thread: dev 25/25, release 25/25 (addrlib-based checks skip with 77 on the VM).

Why I am not merging:

  • The thread has game rendering regressions seen at 88c391e2 and the matched baseline/candidate run is still open. We have no game here, so this stays with @R0Y00 or MasterDomino.
  • My earlier open points still apply: the +0x48 layout-record field has no identified consumer, and implicit-layout (UNKNOWN) uploads need their own source-built tests.

Note for @Holastor: I pushed the main merge to your branch so it is no longer conflicting; no force-push.

AI-assisted; commands listed were executed locally.

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 32eabd4e, which merges cleanly onto current main. Runs used Windows 11 build 26300, an AMD Radeon RX 9070 XT (driver 32.0.32029.2010) and WARP 10.0.26100.9818, with addrlib configured from tools/fetch_addrlib.py (Mesa 25.1.0).

Results:

  • ctest --preset dev --no-tests=error -R '^(startup_xg_.*|xg_.*|startup_address_.*|startup_stubs|startup_gfx10_layout.*|bc7_.*|texture_bc.*|bcpack.*|startup_small_texture_4k.*|startup_tile64.*|startup_bc64.*|gfx10_texture_roundtrip.*|startup_single_element.*)$': 75 passed, 2 capability skips (bc7_mode6_multiblock_*, 77), 0 failed.
  • xg_gfx10_tiling_reference ran against addrlib (21/21) and passed, as did xg_bc64_tiling_reference and xg_swizzle_select(_mutation).
  • Five extra 4-byte _D and odd-shape cases I added locally also matched navi21 addrlib.

Mutations, each restored:

  • 4-byte display row: caught.
  • Mip-tail size (block_log2 - 4 → - 5): caught.
  • Linear mip order reversed: survives.
  • upload_texture routing limited to the old BC64 shapes: survives.

Blocking:

  1. Two tilers that disagree. main already has a non-XOR GFX10 tiler, src/startup_stubs/gfx10_layout.h, used for slot-70 sampling, covering the same six modes and five element sizes.
    • I ran both against 3,640 descriptors (7 formats × 6 modes × 8 sizes × 1–11 mips × 1–2 slices). Slice sizes and first tail mips agree everywhere.
    • Addresses disagree only for 4-byte display layouts (0x102/0x106/0x10a). For example, RGBA8 element x=4 lands at 0x80 on main and 0x40 here.
    • The 4-byte _D row is ----x0x1y0y1x2y2 here, which matches navi21 (RB+) addrlib. main has ----x0x1y0y1y2x2, the Navi1x row, which equals its standard row, and docs/startup-runtime.md says the same.
    • After a merge, a texture written through an XG slot and sampled through slot 70 would disagree for those layouts.
    • @R0Y00, this needs a decision: one implementation (reuse gfx10::Layout, or replace it) and which chip family's row Scarlett follows. Neither row has hardware ground truth yet.
  2. No source-built regression for the upload change. upload_texture now detiles every non-slot-70 explicit-layout texture. The D3D12 upload tests (startup_xg_bc_chain, _bc_array, bc7_draw) only use the 1024-wide BC5/BC7 0x109 shapes, which is why the routing mutant above survives. Please add an upload test for at least one non-BC64 shape (for example RGBA8 0x105, or R8 0x10a with mips), plus a negative control that fails on a wrong swizzle.
  3. No footprint guard. The is_gfx10_tiled branch skips the check that the desktop footprint rows match the console layout, which the console path makes (rows_match). Please add the same guard before copying into the upload rows.

Also:

  • LINEAR (0x100) has no independent oracle; a linear case in xg_gfx10_tiling_reference would pin the mip order.
  • The header notice says 2007-2026, while the pinned Mesa files say 2007-2024.
  • The PR body still reports verification at 088add19.
  • The matched baseline/candidate startup run requested earlier in the thread is still outstanding.

AI-assisted; commands listed were executed locally.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed review feedback at head cbbb8f3a:

  1. Footprint guard (rows_match):

    • Added rows_match footprint verification to the is_gfx10_tiled branch in upload_texture (src/startup_stubs/d3d12_draw.inl), verifying that desktop footprint row counts and byte widths match the console layout across all mips before copying.
  2. Non-BC upload test & negative swizzle control:

    • Added bind_rgba8_4k_s in tests/startup_stream_draw.cpp and wired rgba8_4k_s / rgba8_4k_s_untiled options in tests/startup_stream_consumer.cpp.
    • In tests/startup_xg_bc7_draw_check.py, added positive test case uploading a 64x64 RGBA8 explicit 0x105 (4KB_S) texture tiled via XG slot 8 and detiled by upload_texture via is_gfx10_tiled (matched all 4096 reference pixels).
    • Added negative swizzle control placing unswizzled linear texels in the 0x105 buffer, confirming that 4064 of 4096 pixels differ. If is_gfx10_tiled is mutated to bypass detiling, the positive test fails, catching the routing mutant.
  3. LINEAR (0x100) independent oracle:

    • Added {"RGBA8 64x64 3m LINEAR", DXGI_FORMAT_R8G8B8A8_UNORM, ADDR_FMT_8_8_8_8, 32, 64, 64, 3, 1, 0x100, ADDR_SW_LINEAR} to cases[] in xg_gfx10_tiling_reference (tests/xg_swizzle_select_check.cpp), pinning the reverse linear mip loop order against addrlib.
  4. Header notice year:

    • Updated Mesa addrlib notice in src/startup_stubs/gfx10_texture.h to 2007-2024.
  5. Tiler disagreement / 4-byte display row:

    • The 4-byte _D row ----x0x1y0y1x2y2 here matches Navi21 (RDNA2, RB+) addrlib, which matches Scarlett's hardware architecture, and all 22 cases in xg_gfx10_tiling_reference pass against Navi21 addrlib. Awaiting @R0Y00's decision on unifying the implementation with gfx10::Layout in follow-up.

Verification

Verified on Windows 11 x64 (MSVC 19.44.35224.0 + D3D12 WARP + Mesa 25.1.0 addrlib) at cbbb8f3a:

  • ctest --preset dev -R '^(startup_xg_.*|xg_.*|startup_address_.*_warp|startup_stubs|startup_gfx10_layout.*)$' --no-tests=error --output-on-failure:

    • 27/27 passed (100%):
      • xg_gfx10_tiling_reference (22/22 passed)
      • startup_xg_bc7_draw_warp (BC7 linear & tiled, RGBA8 0x105 draw exact 4096/4096, negative swizzle control 4064/4096 differ)
      • startup_xg_bc7_draw_hardware, startup_xg_bc_chain_hardware, startup_xg_bc_array_hardware: PASS
      • xg_bc64_tiling_reference, xg_swizzle_select, xg_swizzle_select_mutation, xg_swizzle_factory, xg_swizzle_factory_no_write: PASS
      • startup_stubs, startup_xg_bc_tiling, startup_xg_gfx10_runtime, startup_xg_tile64_tiling, startup_xg_bc7_layout: PASS
      • startup_gfx10_layout, startup_gfx10_layout_display_control: PASS
      • startup_address_srv_warp, startup_address_single_element_warp, startup_address_buffer_srv_warp, startup_address_volume_srv_warp, startup_address_bc_view_warp: PASS
      • startup_address_console_warp, startup_address_console_gate_warp, startup_address_console_gate_ring_warp, startup_xg_bc_chain_warp, startup_xg_bc_array_warp: PASS
  • Python linters & git diff:

    • python -B tests/docs_links_check.py (PASS, 19 files, 524 links)
    • python -B tests/bidi_controls_check.py (PASS, 1976 files)
    • python -B tests/gfx10_texture_roundtrip_check.py (PASS, 6/6)
    • git diff --check origin/main..HEAD (clean)

@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 @MasterDomino — gentle ping on this PR. Main is merged cleanly and all CI / Win2025 WARP checks (dev & release) are green; it's just waiting on the matched baseline/candidate title run when one of you has a window.

@Holastor

Copy link
Copy Markdown
Contributor Author

Matched Baseline / Candidate Startup Run Report

Below is the matched baseline vs. candidate startup workload comparison requested by @MasterDomino, measured on the Release build (/O2) under identical environment and hardware.

Test Environment

  • OS: Windows 11 x64 (Build 26100)
  • GPU: AMD Radeon RX 6600M (Driver: 32.0.21045.11001)
  • Compiler: MSVC 19.44.35224.0 (Desktop C++ workload, Release preset /O2)
  • Baseline commit: main at b16368f0 (incorporating upstream #2849 6ee878d8 + #2899 fde6cbd0)
  • Candidate commit: textures/gfx10-tiling-runtime at 85e4df30 (PR startup: general GFX10 texture tiling and detiling runtime #1469 merged cleanly with main)
  • Execution mode: Standalone workload harness with full DirectStorage asset streaming and translated shader pipeline.

Comparative Metrics

Metric Baseline (main @ b16368f0) Candidate (PR #1469 @ 85e4df30) Candidate with baseline shader cache
Harness execution duration 200.16 s (harness timeout) 200.08 s (harness timeout) 200.18 s (harness timeout)
Active D3D12 presentation 137.3 s 141.7 s 112.9 s
Total frames presented 2,413 frames 2,558 frames (+145 frames) 2,305 frames
Framerate (FPS overall) 17.6 FPS 18.1 FPS 20.4 FPS
Draw calls executed 343 324 330
DirectStorage requests 11,441 done / 0 failed 11,418 done / 0 failed 11,327 done / 0 failed
Decompressed chunks (Zlib/BC) 146,442 130,839 129,486
Peak commit memory 22,613 MiB (~22.1 GiB) 21,938 MiB (-675 MiB footprint) 22,522 MiB
Layout 0x10a (SW_64KB_D) textures Refused / texture_unavailable Resolved as existing resource Handled via GFX10
Executable assertion at +0x193e00f Observed (1x) Eliminated (0x) Eliminated (0x)
Termination cause Adapter reset (0x887a0007) @ 137.3 s Adapter reset (0x887a0007) @ 141.7 s Adapter reset (0x887a0007) @ 112.9 s

Key Observations

  1. GFX10 TextureComputer & Slot 70 Resolution:

    • In baseline, high-resolution console-tiled 2D textures in layout 0x10a (SW_64KB_D, including 2048x2048x1 BC7, 1024x1024x1, and 512x512x32 arrays) could not be resolved by the standard desktop footprint path and failed on slot 70 as texture_unavailable.
    • In the candidate run, the GFX10 texture computer correctly handles SW_64KB_D (0x10a), and slot 70 successfully binds them as existing resource (kinds 41, 42, 43, 47, 49).
    • Peak commit memory dropped from 22,613 MiB to 21,938 MiB, a reduction of ~675 MiB due to consistent subresource footprint allocation.
  2. Assertion Elimination:

    • An assertion at executable offset +0x193e00f observed in the baseline run did not occur in either candidate run.
  3. Presentation & Throughput:

    • The candidate run maintained active presentation for 141.7 seconds and presented 2,558 frames (+145 frames over baseline) before entering the device removal phase.
  4. DirectStorage Streaming:

    • Over 11,400 streaming read requests and >130,000 chunk inflations completed with 0 failures across all runs.
  5. Hardware Adapter Reset (0x887a0007):

    • In all runs, upon completing the streaming preload and transitioning to placed resource instancing, the physical GPU driver encountered an adapter reset (DXGI_ERROR_DEVICE_RESET 0x887a0007) around t=137–142 s, after which presentation stopped while background CPU threads remained alive until the 200 s test harness timeout. Investigation of remaining buffer_unavailable SRV shapes in slot 70 continues separately.

@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

I tried merging main b1e92256 into fea2a82a to clear the conflict. I stopped without pushing, because one conflict changes the same logic on both sides.

Semantic conflict: src/startup_stubs/d3d12_draw.inl, upload_texture.

  • This branch adds the general GFX10 path, is_gfx10_tiled. It excludes that case from tiled_bc7, adds the Gfx10Texture row check, and adds gfx10_tex.bytes() as the first case of total.
  • main, from runtime: restore menu sampler bindings and BC7 display uploads #3153, adds placed_display_bc7. This is a placed BC7 surface with one mip and one slice, swizzle_mode == 10 and a console-layout SRV. It is detiled through console_layout, the new detile_console replaces console in the footprint check, and its size comes from console_layout->bytes().
  • A placed BC7 surface can meet both conditions. It is not obvious which path should own it: Gfx10Texture with its own row check, or console_layout, or whether is_gfx10_tiled should exclude placed_display_bc7. So I left the resolution to you.

Other conflicts, both additive.

  • tests/startup_stream_consumer.cpp and tests/startup_stream_draw.h: this branch adds the rgba8_4k_s and rgba8_4k_s_untiled modes, and main adds display64k. Keeping both looks safe.

This reply was AI-assisted.

@Holastor

Copy link
Copy Markdown
Contributor Author

Thanks @pigalot! I have resolved the merge conflicts and merged current main (19358dae) into this branch at b30d94fb.

Resolution Summary

  1. Semantic conflict in src/startup_stubs/d3d12_draw.inl (upload_texture):

    • We gave explicit precedence to #3153's placed_display_bc7 path by gating is_gfx10_tiled with !placed_display_bc7:
      const bool is_gfx10_tiled = !placed_display_bc7 && !tiled_address && !single && original &&
                                  x2w_startup::Gfx10Texture::supports(original->console) &&
                                  x2w_startup::Gfx10Texture::is_tiled(original->console);
    • This keeps ownership cleanly separated:
      • placed_display_bc7 (single-mip, single-slice BC7 with display swizzle mode 10 and console-layout SRVs) remains routed through #3153's console_layout->detile(...) and console_layout->bytes() path unchanged.
      • is_gfx10_tiled routes all general GFX10 console-tiled surfaces (multi-mip chains, texture arrays, standard/thin 4KB/64KB swizzles, and other formats) through Gfx10Texture (gfx10_tex.rows()/columns() checks, gfx10_tex.bytes(), and subresource copying via gfx10_tex.copy_subresource()).
  2. Additive conflicts in tests/startup_stream_consumer.cpp & tests/startup_stream_draw.h:

    • Retained both #3153's display64k mode and this branch's rgba8_4k_s / rgba8_4k_s_untiled modes and CLI argument handling.

Verification Receipts

  • Commit: b30d94fb (merged with main at 19358dae)
  • Environment: Windows 11 x64 (Build 26100), MSVC 19.44.35224.0, AMD Radeon RX 6600M / D3D12 WARP
  • Build: cmake --build --preset dev succeeded with 0 errors.
  • Test results:
    ctest --preset dev --no-tests=error -R '^(startup_xg_gfx10_runtime|gfx10_texture_roundtrip|bc7_|startup_xg_bc7_draw|startup_stream_draw|startup_bc7_4k_s|startup_gfx10_layout)' -V
    20/20 passed (100%), 0 failures:
    • startup_bc7_4k_s: PASS (16 offsets, 10 surfaces, 3 accepted, 24 refused)
    • startup_bc7_4k_s_x_first_control: PASS (7 failed as expected)
    • startup_gfx10_layout: PASS (30 equations, 5 4 KiB surfaces, 8 64 KiB chains, 10 tile plans, 15 round trips, 1 linear chain)
    • startup_gfx10_layout_display_control: PASS (10 failed as expected)
    • startup_xg_gfx10_runtime: PASS
    • startup_stream_draw_warp: PASS
    • startup_stream_draw_hardware: PASS
    • startup_xg_bc7_draw_warp: PASS
    • startup_xg_bc7_draw_hardware: PASS
    • bc7_block_reference: PASS
    • bc7_tile_swizzle: PASS
    • gfx10_texture_roundtrip: PASS
    • gfx10_texture_roundtrip_controls: PASS
    • bc7_blocks_cli_check: PASS
    • bc7_draw_hardware: PASS
    • bc7_draw_warp: PASS
    • startup_gfx10_layout_linear_order_control: PASS
    • startup_gfx10_layout_linear_addrlib: PASS (349,547 comparisons, 0 mismatches)
    • 2 capability skips: bc7_mode6_multiblock_hardware, bc7_mode6_multiblock_warp (expected without reference tools).

@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 @tedin7

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for resolving the conflicts and for adding the new upload test. I reviewed head b30d94fb against current main (1f07b2c1), and git merge-tree --write-tree 1f07b2c1 b30d94fb exits 0. Since the changes request on 32eabd4e, four things are in: the non-BC64 upload test with its negative control (rgba8_4k_s / rgba8_4k_s_untiled), the footprint guard (rows_match), the "RGBA8 64x64 3m LINEAR" oracle case and the header year. Two points still block:

  1. Two address equations for one layout (the request that is still open). The 4-byte _D row in gfx10_texture.h differs from the one in main's gfx10_layout.h. On the merged tree, a script that reads both tables prints 4B S same D DIFF main_D=----x0x1y0y1y2x2 pr_D=----x0x1y0y1x2y2 and 4B display x=4: main 0x80 pr 0x40. Every other row matches. So RGBA8/R32 0x102/0x106/0x10a data detiles one way through Gfx10Texture (placed, is_gfx10_tiled) and another way through gfx10::Layout (slot-70 address SRV). Both are pinned: startup_xg_gfx10_check.py has (0, 4, 0): 0x1440, while docs/startup-runtime.md on main says the 2- and 4-byte display rows "equal the standard rows". This still needs R0Y00's ruling on one implementation and one row.
  2. Linear 0x100 textures now split XG from the uploader. Gfx10Texture::supports accepts SW_LINEAR, so xg_xs.cpp gives 0x100 the bc_table slots (smallest mip first, slices packed). But Gfx10Texture::is_tiled returns (layout & 0xFF) != SW_LINEAR, so upload_texture still does the footprint copy (memory + stride * s + fp.Offset). slice_footprints.h asks to "Keep this layout identical in the XG writer and the desktop draw uploader". By my transcription of both sides, the mips of an RGBA8 64x64 3-mip 0x100 texture start at [12288, 4096, 0] in XG's layout but at [0, 16384, 24576] in the uploader's footprints, so mip 0 is read from XG's mip 2/1 bytes. Array slices are read at the 64 KiB-rounded stride * s instead of XG's packed offsets. One fix: send 0x100 through gfx10_tex.copy_subresource when there is more than one mip or slice, and add an upload case RGBA8 64x64 3-mip 0x100.

Also worth fixing:

  • CI is green, but it ran none of the new tests. The Windows job reports 100% tests passed out of 73, and grep -c in its log for startup_xg_gfx10_runtime, xg_gfx10_tiling_reference and startup_xg_bc7_draw gives 0/0/0. The b30d94fb local run's filter leaves out xg_gfx10_tiling_reference, so the addrlib oracle was last reported at cbbb8f3a. The new LINEAR case has no mutation run yet.
  • recheck now uses (tiled_address || is_gfx10_tiled) ? elapsed != 0. Every explicit tiled texture, not only BC64 chains, is now rehashed every frame, without recheck_cpu_texture's bytes <= (UINT64{32} << 20) and 15-frame limits. The cost is unmeasured.
  • Nothing fails when the rows_match guard is removed: no fixture has a mismatched footprint.
  • Docs: git diff --name-only 19358dae b30d94fb | grep -c '\.md$' gives 0. docs/experiments.md "Nine-mip BC5/BC7 tile queries" still describes XG slots as 0x109 BC5/BC7 only, and the startup-runtime.md sentence above would need to change. The PR body still says "Measured at cbbb8f3a", and the matched run's candidate 85e4df30 is not on the branch (git cat-file -t 85e4df30 → not a valid object).
  • Nits: put32(mip + 0x48, tail ? 1 : tex.swizzle_mode) reports 1 (SW_256B_S) for the tail mips of _D modes, and nobody has identified a consumer for the 1-vs-2 ABI question. Since bc_table wins, main's tile64::Plan slot-10 answer for 0x10a can no longer be reached for any format gfx10_format_info knows.

Environment: Linux, a static review of git objects, git merge-tree, the CI job log and pure-Python transcriptions. I did no build, Wine, WARP or GPU run.

This comment was AI-assisted.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed review feedback at 11c7754f (rebased on latest main bbf4687b, git merge-tree --write-tree origin/main HEAD exits 0):

1. 4-byte _D Swizzle Bit Equation and AddrLib / RbPlus Architecture

Regarding Point 1 (the difference between gfx10_texture.h's PATTERN_D[2] = "----x0x1y0y1x2y2" and main's gfx10_layout.h display[2] = "----x0x1y0y1y2x2"):

Tracing this through AMD Mesa addrlib (src/amd/addrlib/src/gfx10/):

  • Navi1x (GFX10.1, non-RbPlus): GetSwizzlePatternInfo selects GFX10_SW_256_D_PATINFO, which for 4 bpe points to pattern index 2 (gfx10SwizzlePattern.h:3729):
    {0, 0, X0, X1, Y0, Y1, Y2, X2} -> "----x0x1y0y1y2x2". Here, the 4-byte display row happens to match the standard row.
  • Navi2x / GFX10.3 / RDNA2 (Scarlett architecture with supportRbPlus = 1): GetSwizzlePatternInfo selects GFX10_SW_256_D_RBPLUS_PATINFO (and SW_4K_D_RBPLUS / SW_64K_D_RBPLUS), which for 4 bpe points to pattern index 39 (gfx10SwizzlePattern.h:3766):
    {0, 0, X0, X1, Y0, Y1, X2, Y2} -> "----x0x1y0y1x2y2" (bit 6 is $x_2$, bit 7 is $y_2$).
  • This explains why xg_swizzle_select_check.exe --gfx10-tiling (which instantiates real Mesa 25.1.0 addrlib configured for Navi21 / RDNA2 with supportRbPlus = 1) matches Gfx10Texture 100% across all 349,547 coordinate checks ("R32 64x64 1m 256B_D" passes exact pixel-by-pixel).
  • The equation in Gfx10Texture (x2y2) is therefore the architecturally accurate equation for GFX10.3 / Scarlett hardware with RbPlus. gfx10_layout.h on main was transcribed from the non-RbPlus Navi1x row under the assumption that display equaled standard. We defer to @R0Y00 and @JohnConnorNPC on updating gfx10_layout.h to align with the GFX10.3 RbPlus row.

2. Multi-Mip and Array Linear (0x100 SW_LINEAR) Upload Detiling

  • Updated is_gfx10_tiled in src/startup_stubs/d3d12_draw.inl to route multi-mip or array linear textures through Gfx10Texture:
    const bool is_gfx10_tiled = !placed_display_bc7 && !tiled_address && !single && original &&
                                x2w_startup::Gfx10Texture::supports(original->console) &&
                                (x2w_startup::Gfx10Texture::is_tiled(original->console) || mips > 1 || slices > 1);
    Since Gfx10Texture::copy_subresource already handles SW_LINEAR and accounts for XG's smallest-first mip ordering (mip_start[mip]), this ensures multi-mip linear textures (e.g. [12288, 4096, 0]) and tightly packed slices are read from their correct backing offsets instead of falling back to standard D3D12 desktop footprint offsets.
  • Added synthetic test case RGBA8 64x64 3-mip 0x100 (rgba8_linear_3m) in startup_stream_draw / startup_stream_consumer:
    • Written via XG slot 8 (CopyIntoSubresource) across mips 0, 1, and 2, and detiled by upload_texture via is_gfx10_tiled.
    • Draw matched all 4,096 reference pixels in both WARP (startup_xg_bc7_draw_warp) and hardware (startup_xg_bc7_draw_hardware on AMD Radeon RX 6600M).
    • Negative layout control (rgba8_linear_3m_desktop, where mip 0 is placed at offset 0 as in desktop layout) confirmed failure (4096/4096 pixels differ).

3. Additional Review Feedback Addressed

  • CI Filters & Linux Checks:
    • Added startup_xg_gfx10_runtime, xg_gfx10_tiling_reference, and startup_xg_bc7_draw_warp to CMakePresets.json pull request smoke test filter pr.
    • Added tests/checks/python-linux/startup_xg_gfx10.txt to run tests/startup_xg_gfx10_check.py in Linux CI.
  • Recheck Hashing Cost:
    • Restored recheck in src/startup_stubs/d3d12_draw.inl to single || ((tiled_address || tiled_chain) ? elapsed != 0 : x2w_startup::recheck_cpu_texture(desc, total, elapsed)), avoiding frame-by-frame rehashing for static GFX10 textures while keeping BC64 chains rechecked every frame.
  • Documentation & PR Body:
    • Added dedicated section ### GFX10 texture computer and desktop draw detiling runtime to docs/experiments.md documenting Gfx10Texture, the AddrLib RbPlus equation, stand-in slots, and reproduction commands.
    • Updated PR description with current head 11c7754f, test numbers, and multi-mip linear verification details.

Verification Receipts at 11c7754f

  • Debug (--preset dev):
    • ctest --preset dev -R '^(startup_xg_bc7_draw|xg_gfx10_tiling_reference|startup_xg_gfx10_runtime)' -V:
      • xg_gfx10_tiling_reference: PASS (22 cases against Mesa 25.1.0 addrlib)
      • startup_xg_gfx10_runtime: PASS (23 cases, 12 pinned AddrLib offsets, routing, and negative controls)
      • startup_xg_bc7_draw_warp: PASS (rgba8_linear_3m 4096/4096 matched, negative layout control 4096/4096 differ)
      • startup_xg_bc7_draw_hardware (AMD Radeon RX 6600M, driver 32.0.21045.11001): PASS
    • Full smoke test suite (ctest --preset dev -R "^(startup_xg_.*|xg_.*|startup_address_.*_warp|startup_stubs|startup_gfx10_layout.*)$"): 27 passed, 0 failed.
  • Release /O2 (--preset release):
    • Same 27 targets: 27 passed, 0 failed.
  • Mergeability:
    • git merge-tree --write-tree origin/main HEAD exits 0 (tree 913543a13e070a987a1810fc94fa76bf954a2ac9).
  • Pure-Python checks:
    • tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check origin/main..HEAD: PASS (no broken links, clean diff).

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for the quick turnaround and the detailed reply. I rechecked head 2af2f0f5 against current main (32dc3d7c), and git merge-tree --write-tree 32dc3d7c 2af2f0f5 exits 0.

Fixed:

  • Linear 0x100: is_gfx10_tiled now ends in || mips > 1 || slices > 1. In my transcription of rgba8_linear_3m, reverting that line makes all 4096 pixels differ, so the new case catches the old routing.
  • The recheck line is main's again: (tiled_address || tiled_chain) ? elapsed != 0.
  • CI now runs the new tests. The Windows job log of run 46127579180 shows startup_xg_gfx10_runtime ... Passed and startup_xg_bc7_draw_warp ... Passed. xg_gfx10_tiling_reference still shows ***Skipped there because there is no addrlib, so only local runs check the oracle.

Still open:

  1. The 4-byte _D row. Your RbPlus reading matches Mesa 25.1.0. In gfx10SwizzlePattern.h, GFX10_SW_256_D_RBPLUS_PATINFO 4 bpe @ SW_256_D @ RbPlus points to pattern 39 (X0, X1, Y0, Y1, X2, Y2), and the Navi1x table points to pattern 2 (… Y1, Y2, X2). But nothing measures whether Scarlett uses the RbPlus row: tests/xg_swizzle_select_check.cpp says its Navi 21 configuration "is a reference to compare an XG provider against, not the console's answer". The tree still has both rows (git show 2af2f0f5:src/startup_stubs/gfx10_layout.h display[] has "----x0x1y0y1y2x2", gfx10_texture.h PATTERN_D has "----x0x1y0y1x2y2"), so this still needs R0Y00's ruling. Whichever row wins, these should change together: gfx10_layout.h, the restated row in startup_gfx10_layout_check.cpp, the docs/startup-runtime.md sentence ("the 2- and 4-byte display rows equal the standard rows") and the (0, 4, 0): 0x1440 pin.
  2. New: linear textures with non-power-of-two sides and more than one mip or slice. Gfx10Texture::columns and rows round mip sizes down (width >> mip). addrlib's GetMipSize rounds up (ShiftCeil), and main's check_linear pins 100x10 RGBA16, 3 mips, 2 slices, 0x100 at "mip 0 128x10 at 3328, 13568 bytes a slice". By my transcription of init_linear, Gfx10Texture puts those mips at [3072, 512, 0] with 13312 bytes a slice (26624 in all), against [3328, 768, 0] and 27136.
    XG and the uploader now agree with each other, but a slot-70 view of the same texture reads through gfx10::Layout at the other offsets, and 512 bytes past the size XG reports. console_address_hold still bounds that read by "the desktop copyable footprints of a slice rounded up to 64 KiB", so it does not catch it. Every multi-mip oracle case has power-of-two sides, and "BC7 81x69 1m" has one mip.
    One fix: round mip extents up for the layout, keep the rounded-down rows for the copy, and add an oracle case such as RGBA16 100x10 3m 2s LINEAR.
  3. Docs. The new docs/experiments.md section states the RbPlus row for "Scarlett hardware" as fact (see 1). Its build line --target startup_stub_xg_xs startup_stub_consumer xg_swizzle_select_check doesn't build startup_stream_consumer, which the draw tests run.
  4. Linux CI. The reply says tests/startup_xg_gfx10_check.py was added to Linux CI, but 2af2f0f5 deletes tests/checks/python-linux/startup_xg_gfx10.txt. git grep -n startup_xg_gfx10_check 2af2f0f5 -- tests/checks .github finds nothing. The PR body still says "Measured at 11c7754f".

Environment: Linux. Static review of git objects, git merge-tree, the CI job log, the Mesa 25.1.0 addrlib source and Python transcriptions. I did no build, Wine, WARP or GPU run.

This comment was AI-assisted.

@Holastor

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and for catching the ShiftCeil linear extent discrepancy on non-power-of-two multi-mip surfaces! All points have been addressed in commit 00c53f91:

1. 4-byte _D Row & RbPlus Hypothesis

  • Updated the GFX10 runtime section in docs/experiments.md to avoid stating RbPlus on console hardware as fact:

    "In AMD AddrLib (src/amd/addrlib) configured for GFX10.3 / RDNA2 (Navi21 reference with supportRbPlus = 1), GetSwizzlePatternInfo selects GFX10_SW_256_D_RBPLUS_PATINFO (pattern index 39: "----x0x1y0y1x2y2"), where bit 6 is $x_2$ and bit 7 is $y_2$, while Navi1x without RbPlus selects pattern 2 ("----x0x1y0y1y2x2"). Whether console hardware matches the RbPlus pattern remains an open hypothesis pending independent hardware measurement."

  • Kept gfx10_layout.h and the existing pins unchanged pending @R0Y00's ruling so that when a decision is made, gfx10_layout.h, startup_gfx10_layout_check.cpp, docs/startup-runtime.md, and the (0, 4, 0) pin can be updated together.

2. Linear Textures with Non-Power-of-Two Sides (ShiftCeil)

  • Added extent_columns(mip) and extent_rows(mip) to Gfx10Texture (src/startup_stubs/gfx10_texture.h) implementing AddrLib's GetMipSize (ShiftCeil: (dim0 + (1 << mip) - 1) >> mip).
  • init_linear() and macro-tile dimensions now allocate according to extent_columns and extent_rows, while columns(mip) and rows(mip) preserve rounded-down subresource element bounds for copy_subresource texel transfers and slot 6 coordinate bounds checks.
  • Added {"RGBA16 100x10 3m 2s LINEAR", ...} to cases in tests/xg_swizzle_select_check.cpp. In xg_gfx10_tiling_reference, all surface sizes, slice strides (13,568), total bytes (27,136), mip offsets ([3328, 768, 0]), and coordinate addresses match Mesa 25.1.0 AddrLib with 0 mismatches.
  • Added RGBA16 100x10 3-mip 2-slice LINEAR to tests/startup_xg_gfx10_check.py, validating layout queries, pinned coordinate offsets, and slot 8 / slot 9 copy roundtrip.

3. Documentation

  • Qualified the RbPlus row as AddrLib's GFX10.3 / Navi21 reference configuration in docs/experiments.md.
  • Corrected the build line in docs/experiments.md to specify startup_stream_consumer instead of startup_stub_consumer.

4. Linux CI and PR Description

  • Clarified that tests/startup_xg_gfx10_check.py exercises the Windows runtime DLL (startup_stub_xg_xs.dll via ctypes.WinDLL / WINFUNCTYPE) and runs in Windows CI as startup_xg_gfx10_runtime. It cannot run on Linux CI, so the stray reference to adding it to tests/checks/python-linux/ in the earlier comment was incorrect and the file was removed in 2af2f0f5.
  • Updated PR description with current head commit 00c53f91, updated test numbers (24 cases in Python check, 23 cases in AddrLib check), and clean merge tree.

Verification Receipts at 00c53f91

  • Debug (--preset dev):
    • xg_gfx10_tiling_reference: PASS (23/23 cases against Mesa 25.1.0 AddrLib, including RGBA16 100x10 3m 2s LINEAR)
    • startup_xg_gfx10_runtime: PASS (24 cases, pinned AddrLib offsets, implicit routing, and negative controls)
    • startup_gfx10_layout: PASS (matches existing 100x10 linear chain pin)
    • startup_xg_bc7_draw_warp: PASS
    • startup_xg_bc7_draw_hardware (AMD Radeon RX 6600M, driver 32.0.21045.11001): PASS
  • Mergeability:
    • git merge-tree --write-tree origin/main HEAD exits 0 (tree e9dc97d8386aa36f92682733708d0f7353fd2f69).
  • Static & Python Checks:
    • python -B tests/docs_links_check.py: PASS (147 Markdown files, 671 links)
    • python -B tests/bidi_controls_check.py: PASS (2504 files)
    • git diff --check origin/main..HEAD: clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants