Skip to content

startup: read linear (0x100) textures in slot 70 - #2926

Open
pigalot wants to merge 1 commit into
R0Y00:mainfrom
pigalot:slot70/linear-layout
Open

pigalot wants to merge 1 commit into
R0Y00:mainfrom
pigalot:slot70/linear-layout

Conversation

@pigalot

@pigalot pigalot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Device slot 70 refused a texture description whose Layout is 0x100 (the ADDR_SW_LINEAR swizzle
mode word) unless it was a single texel, with reason=unsupported_description. The extent of its
rows was not established. AMD addrlib's Gfx10Lib::HwlComputeSurfaceInfoLinear gives the extent:

  • Each mip's pitch is its width rounded up at each level (GetMipSize), then aligned to 256 bytes.
  • The mips are packed from the smallest to the largest, with no tail.
  • The array slices follow one another.

This change restates that rule in src/startup_stubs/gfx10_layout.h. Two-dimensional linear
textures then go through the existing console-layout path: view checks, XG holds and upload as
desktop footprint rows. One-dimensional and three-dimensional linear textures stay refused.

  • gfx10_layout.h: supports accepts mode 0 for 2D textures. Layout computes the linear pitch and
    mip offsets, and address reads rows.
  • address_texture.h: comment only (linear is now one of the console layouts).
  • tests/startup_gfx10_layout_check.cpp:
    • 4 linear round-trip shapes and one hand-worked linear chain.
    • The "linear mode" refusal becomes a linear volume refusal, and the linear R8 address description is now accepted.
    • A new --addrlib run compares every element address and the surface size of 11 linear textures with addrlib itself.
  • tests/startup_address_console_check.py:
    • The oracle gains the linear rule.
    • Four new draws: RGBA8 100x40 with its rows padded from 400 to 512 bytes; its 4-mip chain viewed at mips 0 and 2; and BC1 200x96, 50 blocks padded to 64.
    • A linear-unpadded negative control.
  • tests/cmake/startup_gfx10_linear.cmake: the order control, the addrlib run (skips with 77 without addrlib) and the unpadded control on WARP and hardware.
  • docs/startup-runtime.md: 0x100 moves from the refused list to the accepted list.
  • docs/experiments/startup-gfx10-linear.md: the note.

This is independent of #1469, which models SW_LINEAR in its own XG texture computer and does not touch the slot-70 path. Its linear rule is the same one.

Tests

Commit 80443a7, rebased on main 3e9542a on 27 Nov to resolve a conflict with #2949 in tests/startup_address_console_check.py (both added test modes to the same list; the list now has both). The results below were measured at ce2d6f5 on main 6ee878d. Regression on the rebased stack (d190f0d): ctest --preset dev --no-tests=error -R 'address|gfx10|memory_srv|xg_|bc64|tile64|small_texture|bc7|slot70|texture|console|1d|draw|translated|sampler|d16' -E '_hardware$|startup_audio' -j 8: 228 of 228 passed, 9 capability skips (spirv_*_warp, bc7_mode6_multiblock_warp). The same filter on _hardware tests at -j 1: 130 of 130 passed, 9 capability skips. The --addrlib comparison was not rerun after the rebase (that build had no addrlib); the layout code it checks did not change in the rebase.

Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 5090 (driver 32.0.16.1088), Microsoft WARP. Debug layer
on (dev preset). addrlib: Mesa 25.1.0 via tools/fetch_addrlib.py.

cmake --preset dev -DXBOX2WINDOWS_ADDRLIB_DIR=<mesa>/src/amd/addrlib
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^startup_gfx10_layout'
ctest --preset dev --no-tests=error -R '^startup_address_console_(warp|hardware|linear_unpadded_(warp|hardware))$' -V
  • startup_gfx10_layout: PASS (13 round trips, 1 linear chain, ...).
  • startup_gfx10_layout_display_control: expected failure (unchanged).
  • startup_gfx10_layout_linear_order_control: expected failure. With the largest mip first, all 6 offset and address checks fail.
  • startup_gfx10_layout_linear_addrlib: PASS, 338763 linear sizes and addresses compared, 0 mismatches (Mesa 25.1.0 addrlib, SW_LINEAR).
  • startup_address_console_warp, _hardware: PASS. The 4 linear draws match all 65,536 pixels exactly; the 7 earlier draws and the 3 held/late cases are unchanged.
  • startup_address_console_linear_unpadded_warp, _hardware: PASS. The texture is published and 63,488 of 65,536 pixels differ.
  • On main without the two header changes, the first linear draw reads the null view: pixel (0,0) is 00000000, and 010300ff was expected.
  • Wider set: ctest --preset dev -R 'address|gfx10|memory_srv|xg_|bc64|tile64|small_texture|bc7|slot70|texture|console'.
    • Software (-j 8, _hardware excluded): 121 tests, 0 failed, 7 skipped. The skips are 6 spirv_address_window_*_warp and bc7_mode6_multiblock_warp, all capability skips (77).
    • Hardware (-j 1): 47 tests, 0 failed, 6 skipped, the same capability skips.

A local 600 s real-world run (release build, same change on top of the slot-70 stack) ended at the
timeout with exit 0. The two 2D 0x100 shapes three earlier runs refused as unsupported_description
(R32_FLOAT with 7 mips, and R16G16B16A16_FLOAT with one mip) were not refused. Two 1D 0x100 shapes
remain refused, as intended.

The addressing rule is addrlib's desktop GFX10 rule. That console memory uses the same 256-byte
pitch for 0x100 is inferred from the layout word, not measured on console hardware.

This change was AI-assisted.

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

PR #2926 by @pigalot — startup: read linear (0x100) textures in slot 70

What works

  • Linear mode derivation from AMD addrlib HwlComputeSurfaceInfoLinear is clearly documented in both experiment notes and gfx10_layout.h comments
  • Mip ordering (smallest to largest) is explicitly coded and tested
  • Array slice handling: slice index * bytes_per_slice, consistent with tiled modes
  • Excellent control test: linear-largest-first order control with WILL_FAIL ensures the ordering is necessary, not coincidental
  • Unpadded control in startup_address_console_check correctly writes rows at native pitch to produce mismatched draws
  • addrlib round-trip comparison (every element address) provides strong correctness guarantee

Issues

  • swizzle_mode() returning 0 for linear mode is correct (0x100 & 0xff == 0), but block_log2/block_width/block_height for mode 0 could trigger division-by-zero or shift-by-zero if any code path assumes mode > 0 in block calculations; verify no switch falls through to block ops without a linear-mode guard
  • The refusal in check_refusals tests linear mode only for 3D (volume). Consider adding linear mode refusal for 1D too to prevent accidental acceptance before #2929 lands
  • For block-compressed linear textures (BC1 in the test suite), the largest-mip-whole-blocks guard applies but is not re-stated in the new layout section of gfx10_layout.h; the tiled-mode docs reference it, linear-mode does not

Recommendations

  • Add an inline guard in the layout path: if (mode == linear_mode) ... skip block dimension calculations; this documents the invariant and prevents future regressions if someone adds a fallback switch case
  • Ensure address_texture.h comments for linear mode mention the 256-byte pitch rule (currently only the comment update references it briefly)
  • Consider adding a linear-mode 2D array test slice to the round-trip shapes in startup_gfx10_layout_check.cpp (currently the linear shapes are single-slice)

Overall

Very solid foundation for linear texture readback. The addrlib-based layout derivation is well-tested with order control, addrlib cross-check, and unpadded mismatch. The 256-byte pitch invariant is clearly enforced. Note that #2929 (1D linear) stacks on this and the PR is safe to merge once the test gap for linear-mode refusals is closed.

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

PR #2926 by @pigalot -- startup: read linear (0x100) textures in slot 70

What works

  • Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
  • The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
  • supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
  • Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
  • Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms

Issues

  • supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
  • The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help

Recommendations

  • Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
  • Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib

Overall

A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.

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

PR #2926 by @pigalot -- startup: read linear (0x100) textures in slot 70

What works

  • Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
  • The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
  • supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
  • Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
  • Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms

Issues

  • supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
  • The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help

Recommendations

  • Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
  • Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib

Overall

A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.

Slot 70 refused a 2D texture whose Layout is the ADDR_SW_LINEAR word 0x100
because the extent of its rows was not established. Restate addrlib's
Gfx10Lib::HwlComputeSurfaceInfoLinear in gfx10_layout.h: each mip's pitch is
its rounded-up width aligned to 256 bytes, and the mips are packed from the
smallest to the largest with no tail. Such textures then take the existing
console-layout path. 1D and 3D linear textures stay refused.

Tests: linear round trips, a hand-worked chain with a mip-order control, an
optional comparison of every element address with addrlib, four exact linear
draws in startup_address_console and an unpadded-pitch control.
@pigalot
pigalot force-pushed the slot70/linear-layout branch from ce2d6f5 to 80443a7 Compare November 27, 2026 09:17
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.

2 participants