Skip to content

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

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

Holastor wants to merge 10 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 and mip-tail layout 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 non-tiled_address_srv console-tiled resources (with rows_match footprint guard before copy).
  • Verification suites:
    • tests/startup_xg_gfx10_check.py (startup_xg_gfx10_runtime): 23 synthetic cases across BC1–BC7, R8, RG8, R16, R32, RGBA8, BGRA8, RGBA16, RGBA32, explicit SW_LINEAR (0x100) through SW_64KB_D (0x10a), 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 22 cases (including RGBA8 64x64 3m LINEAR to pin linear mip ordering) against pinned Mesa 25.1.0 addrlib.
    • tests/startup_xg_bc7_draw_check.py (startup_xg_bc7_draw_warp / _hardware): tests BC7 64x64 / 81x69 linear & tiled draws, non-BC64 RGBA8 64x64 0x105 (4KB_S) uploaded draw detiled via is_gfx10_tiled, and negative swizzle control (unswizzled data in 0x105 layout confirms 4064/4096 pixels differ).

Verification

Measured at cbbb8f3a on Windows 11 x64 (MSVC 19.44.35224.0, 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 (Total Test time = 30.15 sec):
    • xg_gfx10_tiling_reference (22/22 including LINEAR 3-mip oracle): PASS
    • startup_xg_bc7_draw_warp (BC7 linear & tiled, RGBA8 0x105 4KB_S draw exact 4096/4096, negative swizzle control 4064/4096 differ): PASS
    • 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

Pure-Python checks:

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

All passed (19 Markdown files and 524 links, 1976 tracked files clean, 6 roundtrip tests OK, 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.

Correction to my previous comment: the head moved from 5477f0b to 088add1 while I was reviewing, so that comment was filed against 088add1 but its text describes 5477f0b.

  • The P3 (merge conflict in src/startup_stubs/d3d12_draw.inl) no longer applies: GitHub now reports the PR as MERGEABLE at 088add1.
  • The Win2025 WARP run in that comment was already executed on 088add1 (startup_xg_gfx10_runtime Passed, including the pinned-offset test).
  • I did not re-read the diff between 5477f0b and 088add1 line by line beyond that run. Verdict stays 0 P1, 0 P2.

AI-assisted; commands listed were executed locally.

@stan495 stan495 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified head 088add19 on Windows x64 (dev preset, MSVC 19.44.35228.0, Python 3.12):

  • cmake --build --preset dev --target xg_swizzle_select_check startup_stub_xg_xs -> succeeded
  • ctest --preset dev --no-tests=error -R '^(xg_gfx10_tiling_reference|startup_xg_gfx10_runtime)$' -V:
    • Passed (1): startup_xg_gfx10_runtime
    • Capability Skipped (1, exit 77): xg_gfx10_tiling_reference (addrlib not configured)

Verdict: Approved at 088add19 (noting xg_gfx10_tiling_reference skipped locally without addrlib).

@RavenCurseBurg

Copy link
Copy Markdown
Contributor

The current explicit-layout branch (088add19) uses the shared BC copy-in prototype for slot 9 in src/startup_stubs/xg_xs.cpp. Microsoft's public Scarlett CopyFromSubresource call has an extra zero-valued UINT after the subresource index. #2257 corrects this for the existing BC mip chains on main. A Windows control restoring the old registration rejected that documented call. When integrating the general layout, the same slot-9 entry point and ctypes prototype apply to your new cases. Focused regression

@Holastor

Copy link
Copy Markdown
Contributor Author

Merged upstream/main (342d3fa9, including #2257 and #2263) into the branch and aligned the general GFX10 path with the Scarlett slot-9 CopyFromSubresource signature at a3cb0e89:

  • Slot 9 & profile dispatch (src/startup_stubs/xg_bc64.inl, src/startup_stubs/xg_xs.cpp):
    • Wired bc64_copy_from on bc_table slot 9 for explicit 0x100–0x10a descriptors (Gfx10Texture::supports), rejecting non-zero scarlett_option with E_NOTIMPL before reading/touching either buffer and forwarding 0 to bc64_copy<false> / gfx10_copy<false>.
    • Kept upstream/main's bc7_4k_table (bc7_4k_s_copy_from from #2263) for the opt-in UNKNOWN 4K BC7 profile and small_texture_4k_plan (#2133) in d3d12_draw.inl / xg_xs.cpp; removed the now-unreachable bc7_4k_s_layout branches from xg_bc64.inl.
  • Tests (tests/startup_xg_gfx10_check.py):
    • Updated slot-9 calls to COPY_FROM (passing 0 for scarlett_option, exercising both slice_pitch = 0 and len(linear_src)).
    • Added negative controls for COPY_FROM(slots[9]): null pointers (E_INVALIDARG), short slice_pitch (E_INVALIDARG), and non-zero scarlett_option (1, 0xFFFFFFFF) on both BC7 and RGBA8 (E_NOTIMPL / 0x80004001, verifying destination sentinel bytes are untouched and option validation runs before argument checks).

Verification at a3cb0e89

  • Debug (MSVC 19.51.36263.0, addrlib from out/deps/mesa/src/amd/addrlib):
    ctest ... --no-tests=error --output-on-failure -R "^(startup_xg_|xg_swizzle_select|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_bc64_supports|startup_small_texture_4k|startup_tile64_plan|startup_gfx10_layout|startup_single_element_srv)"
    -> 33/33 passed (xg_gfx10_tiling_reference, xg_bc64_tiling_reference, startup_xg_gfx10_runtime, startup_xg_bc_tiling, startup_xg_tile64_tiling, startup_xg_bc7_layout, startup_xg_bc7_draw_{warp,hardware}, startup_xg_bc_chain_{warp,hardware}, startup_xg_bc_array_{warp,hardware}, startup_small_texture_4k_*, etc.).
  • Release (/O2, MSVC 19.51.36263.0, addrlib from out/deps/mesa/src/amd/addrlib):
    ctest ... --no-tests=error --output-on-failure -R "^(startup_xg_|xg_swizzle_select|xg_bc64_tiling_reference|xg_gfx10_tiling_reference|startup_bc64_supports|startup_small_texture_4k|startup_tile64_plan|startup_gfx10_layout|startup_single_element_srv|startup_address_)"
    -> 47/47 passed (startup_xg_gfx10_runtime passed all 23 GFX10 cases, 12 pinned addrlib offset surfaces, implicit/depth routing, and negative controls).
  • Pure-Python & diff checks:
    • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: PASS (18 files, 435 links)
    • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: PASS (1586 files)
    • .\out\pe-env\Scripts\python.exe -B tests/gfx10_texture_roundtrip_check.py: PASS (6/6)
    • git diff --check upstream/main: clean

@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 at head a3cb0e896d701f552ed7194e17541e3dbba41650 (previous reviewed head 088add19). The new commit is a merge of main (342d3fa9) plus the slot 9 copy-out alignment with #2257/#2263.

New since the last review:

  • src/startup_stubs/xg_bc64.inl: the bc7_4k_s_layout special cases are removed from gfx10_layout and gfx10_copy. A new bc64_copy_from (slot 9) returns E_NOTIMPL for a non-zero scarlett_option before touching either buffer, then delegates to bc64_copy<false>. This matches xg_xs.cpp:164-166.
  • src/startup_stubs/xg_xs.cpp: table selection now uses Gfx10Texture::supports(desc). The separate bc7_4k_table path still overrides it, so 4 KiB BC7 surfaces keep their own slots.
  • tests/startup_xg_gfx10_check.py: adds a non-zero scarlett_option refusal check on a BC surface and on an RGBA8 64x64 4KB_S surface, plus a mips>16 refusal.

Commands executed locally:

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: pass (18 files, 435 links).
  • python3 tests/bidi_controls_check.py: pass.
  • g++ ... tests/xg_swizzle_select_check.cpp && ./xg_swizzle_select --gfx10-tiling: SKIP (no addrlib on this Linux host).
  • tests/startup_xg_gfx10_check.py needs ctypes.WINFUNCTYPE, so it is Windows-only and cannot run on Linux.
  • x2w_pipe.py win2025 1469 --regex 'xg_gfx10|xg_bc64|startup_xg_bc_tiling|startup_xg_gfx10' on Windows Server 2025 + WARP at this SHA, dev and release: exit 0. startup_xg_gfx10_runtime, startup_xg_bc_tiling and xg_bc64_tiling_reference passed. xg_gfx10_tiling_reference was Skipped (exit 77, addrlib not present).

Findings:

  • P1: none.
  • P2: none.
  • Nit: xg_gfx10_tiling_reference skips on both Linux and the Win2025 runner because addrlib is missing. The new Gfx10Texture tiling is therefore checked against the addrlib reference only where addrlib is configured. The Python runtime test covers exact detile and tile round trips. Consider confirming it once on a host with addrlib before Ready.
  • Nit: I did not run a logic mutation on the new slot 9 option check. The Windows runner tests the pushed head, not my local worktree, so a local mutation would not have been exercised. The test does assert the E_NOTIMPL path explicitly (startup_xg_gfx10_check.py:293-310).

CI on the PR was still pending when I checked (Windows build, Linux Python checks, gfx1013 fixtures). The PR is mergeable and the title is neutral.

AI-assisted; commands listed were executed locally.

@Holastor

Copy link
Copy Markdown
Contributor Author

@tedin7 Thanks for the re-review! The pinned offsets in test_pinned_addrlib_offsets already lock down the exact Mesa addrlib (navi21) byte addresses across 1/2/4/8/16-byte elements so CI guards the swizzle equations even when addrlib is not built on the runner.

@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 Ready for review and merge into main when you have time — all checks are green and verified against Mesa 25.1.0 addrlib (36 passed, 2 skipped in ctest). Let me know if anything needs changes or if it should be closed in favor of another approach.

@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.

@Holastor
Holastor force-pushed the textures/gfx10-tiling-runtime branch from 85e4df3 to fea2a82 Compare November 26, 2026 18:05
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.

7 participants