Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
88c391e
startup: general GFX10 texture tiling and detiling runtime
Holastor Nov 24, 2026
eca1f09
Merge upstream/main and address PR #1469 review feedback
Holastor Nov 25, 2026
5477f0b
Merge upstream/main and pin addrlib swizzle offsets in runtime test
Holastor Nov 25, 2026
088add1
Merge upstream/main and keep console_layout_srv path intact
Holastor Nov 25, 2026
a3cb0e8
Merge upstream/main and align GFX10 slot 9 copy-out with #2257
Holastor Nov 25, 2026
2c835d5
Merge branch 'main' into textures/gfx10-tiling-runtime
tedin7 Nov 25, 2026
32eabd4
Merge branch 'main' into textures/gfx10-tiling-runtime
tedin7 Nov 26, 2026
cbbb8f3
textures: add footprint guard and non-BC upload check with negative c…
Holastor Nov 26, 2026
a450121
Merge upstream/main into textures/gfx10-tiling-runtime
Holastor Nov 26, 2026
fea2a82
Merge remote-tracking branch 'upstream/main' into textures/gfx10-tili…
Holastor Nov 26, 2026
b30d94f
Merge branch 'main' into textures/gfx10-tiling-runtime
Holastor Nov 28, 2026
8903a16
startup: route multi-mip linear uploads via Gfx10Texture and add tests
Holastor Nov 28, 2026
11c7754
Merge branch 'main' into textures/gfx10-tiling-runtime
Holastor Nov 28, 2026
2af2f0f
build: add GFX10 tiling targets to pr build preset
Holastor Nov 28, 2026
00c53f9
startup: align Gfx10Texture layout extents with ShiftCeil and documen…
Holastor Nov 28, 2026
17d4ef6
Merge upstream/main (c3cae611) into textures/gfx10-tiling-runtime
Holastor Nov 29, 2026
389b810
tests: pin non-power-of-two tiled mip extents against addrlib
Holastor Nov 29, 2026
2d1697e
Merge remote-tracking branch 'upstream/main' into textures/gfx10-tili…
Holastor Nov 29, 2026
f50d7d9
Merge remote-tracking branch 'upstream/main' into textures/gfx10-tili…
Holastor Nov 29, 2026
ae9a7e4
docs: point the XG layout sections at the general Gfx10Texture computer
Holastor Nov 29, 2026
d923452
Align 4-byte _D swizzle with gfx10_layout.h and clarify supported modes
Holastor Dec 1, 2026
14fa93f
gfx10: align 4-byte display swizzle row with GFX10.3 RbPlus (x2y2)
Holastor Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3296,6 +3296,8 @@ else()
endif()
add_test(NAME xg_bc64_tiling_reference COMMAND xg_swizzle_select_check --bc64-tiling)
set_tests_properties(xg_bc64_tiling_reference PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77)
add_test(NAME xg_gfx10_tiling_reference COMMAND xg_swizzle_select_check --gfx10-tiling)
set_tests_properties(xg_gfx10_tiling_reference PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77)
if(EXISTS "${INTAKE_PYTHON}")
add_test(NAME tooling_fetch_addrlib_cli_check COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/fetch_addrlib_cli_check.py")
Expand Down Expand Up @@ -4863,6 +4865,9 @@ if(EXISTS "${INTAKE_PYTHON}")
add_test(NAME startup_xg_bc_tiling COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_xg_bc_tiling_check.py" "$<TARGET_FILE:startup_stub_xg_xs>")
set_tests_properties(startup_xg_bc_tiling PROPERTIES TIMEOUT 30 ENVIRONMENT "X2W_D3D12_PERMISSIVE=1")
add_test(NAME startup_xg_gfx10_runtime COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_xg_gfx10_check.py" "$<TARGET_FILE:startup_stub_xg_xs>")
set_tests_properties(startup_xg_gfx10_runtime PROPERTIES TIMEOUT 30 ENVIRONMENT "X2W_D3D12_PERMISSIVE=1")
add_test(NAME startup_xg_tile64_tiling COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_xg_tile64_tiling_check.py" "$<TARGET_FILE:startup_stub_xg_xs>")
set_tests_properties(startup_xg_tile64_tiling PROPERTIES TIMEOUT 30 ENVIRONMENT "X2W_D3D12_PERMISSIVE=1")
Expand Down
5 changes: 3 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check",
"xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check",
"xmem_page_runs_device_check", "linear_buffer_backing_check",
"bcpack_formats_check", "startup_stub_consumer", "startup_inline_retire", "startup_resource_retire_title", "startup_table_lock"
"bcpack_formats_check", "startup_stub_consumer", "startup_inline_retire", "startup_resource_retire_title", "startup_table_lock",
"startup_stub_xg_xs", "xg_swizzle_select_check", "startup_stream_consumer"
]
},
{ "name": "release", "configurePreset": "release" },
Expand All @@ -48,7 +49,7 @@
"displayName": "Windows pull request smoke tests",
"filter": {
"include": {
"name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference)$"
"name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|startup_xg_gfx10_runtime|xg_gfx10_tiling_reference|startup_xg_bc7_draw_warp)$"
}
}
},
Expand Down
18 changes: 18 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -16789,6 +16789,8 @@ ctest --preset release --no-tests=error --output-on-failure -R '^startup_(placem

### Nine-mip BC5/BC7 tile queries

The general GFX10 texture computer described in the next section now answers XG slots 2, 3, 6, 8, 9 and 10 for the explicit layouts `0x100, 0x101, 0x102, 0x105, 0x106, 0x109, 0x10a` (S, D, and linear modes). The pins below stay specific to the earlier nine-mip `0x109` BC5/BC7 shape.

XG texture-computer slot 10 reports a 64 KiB standard tile layout for 1024×512 and 1024×1024 single-sample BC5_UNORM and BC7_UNORM textures with nine mips, one or two array slices, explicit layout `0x109`, default alignment and zero flags. Each slice starts with one packed tile containing six mips. The 1024×512 standard mips start at tiles 4, 2 and 1 in a 12-tile slice. The 1024×1024 standard mips start at tiles 6, 2 and 1 in a 22-tile slice. `ctest --preset dev --no-tests=error -R '^startup_bc64_supports(_layout_control)?$' -V` checks which descriptions `src/startup_stubs/bc64_chain.h` routes to this layout, without a device or AddrLib: the two six-mip and eight nine-mip shapes are accepted, and 16 descriptions that each change one field, among them layout `UNKNOWN`, 64 KiB alignment, a render-target flag, `BC7_UNORM_SRGB` and six mips with two slices, are rejected. The control expects layout `UNKNOWN` to be accepted and must fail.

`startup_xg_bc_tiling` checks 80 subresource queries, including a request spanning the last packed mip in one slice and the first standard mips of the next. The returned count includes only standard mips. Their entries use their original positions in the requested range. Sentinel bytes cover packed entries and the remainder of the caller's array. The field values were compared with XCL's slot 10 implementation on source-built inputs. The optional AMD AddrLib test independently verifies the surface size, slice stride, first packed mip and standard and packed macro-tile offsets for all eight shapes and formats. [XCL implementation](https://github.com/ivall/xcl/blob/64b3f35599bb7102f55d640e1a791e7d6dd3b175/crates/xcl/src/hle/xg.rs#L610-L658) · [AMD AddrLib revision](https://gitlab.freedesktop.org/mesa/mesa/-/tree/5c142e46f3f6e752ed745fd48912ebb8fad67145/src/amd/addrlib)
Expand All @@ -16807,6 +16809,22 @@ cmake --build --preset release --target startup_stream_consumer startup_stub_xg_
ctest --preset release --no-tests=error --output-on-failure -R '^(startup_xg_bc_(array|chain)_(hardware|warp)|startup_xg_bc_tiling|xg_bc64_tiling_reference|startup_xg_bc7_layout)$'
```

### GFX10 texture computer and desktop draw detiling runtime

`Gfx10Texture` (`src/startup_stubs/gfx10_texture.h`) implements the runtime tiling and detiling computer for GFX10 textures across 256 B, 4 KiB, and 64 KiB blocks in standard (`_S`) and display (`_D`) modes (explicit layouts `0x101`, `0x102`, `0x105`, `0x106`, `0x109`, `0x10a`), as well as multi-mip and multi-slice linear layout `0x100` (packed slices, smallest mip first). It supports 1-, 2-, 4-, 8-, and 16-byte elements (including BC1 to BC7 block-compressed formats):

- XG texture-computer stand-in (`src/startup_stubs/xg_xs.cpp`) provides slot 2 (layout query, mip starts, alignment), slot 3 (total allocation size), slot 6 (element coordinate offset query), slot 8 (`CopyIntoSubresource` for linear to tiled upload), and slot 9 (`CopyFromSubresource` for tiled to linear readback).
- 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"`). Both `src/startup_stubs/gfx10_texture.h` and `src/startup_stubs/gfx10_layout.h` use the GFX10.3 RbPlus `----x0x1y0y1x2y2` 4-byte display row (which therefore differs from the 4-byte standard row `y2x2`).
- The desktop draw uploader (`src/startup_stubs/d3d12_draw.inl`) detiles placed CPU textures via `is_gfx10_tiled` for all explicit GFX10 tiled modes and multi-mip or array linear (0x100) textures into desktop D3D12 copyable footprints on upload.
- `xg_gfx10_tiling_reference` independently compares `Gfx10Texture` against Mesa 25.1.0 AMD AddrLib on Navi21 for 23 surface shapes, validating surface sizes, slice strides, base alignments, mip offsets, and coordinate addresses with 0 mismatches.
- `startup_xg_gfx10_runtime` tests layout queries, slot-6 coordinate offsets, slot-8 tiling, slot-9 detiling, pinned AddrLib offsets across all five element sizes, implicit layout routing, and negative controls.
- `startup_xg_bc7_draw_{warp,hardware}` executes end-to-end draw tests with wrapped XG uploads for 4 KiB standard RGBA8 (`rgba8_4k_s`), 3-mip linear RGBA8 (`rgba8_linear_3m`), and their respective negative controls.

```powershell
cmake --build --preset dev --target startup_stub_xg_xs startup_stream_consumer xg_swizzle_select_check
ctest --preset dev --no-tests=error -R '^(startup_xg_gfx10_runtime|xg_gfx10_tiling_reference|startup_xg_bc7_draw_(warp|hardware))$' -V
```

### Slot-10 tile plan for layout `0x10a`

For a two-dimensional texture with layout `0x10a`, one sample and a format with a known 64 KiB tile shape, XG texture-computer slot 10 is answered from `src/startup_stubs/tile64_plan.h` instead of a desktop reserved resource. The plan follows one rule:
Expand Down
9 changes: 5 additions & 4 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -3688,9 +3688,10 @@ In the plan, every row has its exact byte width (a row of texels, or of 4 x 4 bl
follow each other from the top level with no padding. Its size never exceeds the answer:
`startup_small_texture_4k` checks this for every accepted shape. The texels are linear, not the console's
4 KiB swizzle. Data the executable streams in its own 4 KiB layout is therefore read in the wrong order,
as it already was with the desktop layout. A GFX10 4 KiB tiling plan, such as `Gfx10Texture` in #1469,
can replace the compact plan in all three calls at once. At alignment 0 nothing changes: the desktop
answer and the desktop footprint.
as it already was with the desktop layout. `Gfx10Texture` (#1469) tiles the explicit GFX10 layouts, not
this UNKNOWN-and-4096-alignment path; using it here would replace the compact plan in all three calls
at once and is left to a follow-up. At alignment 0 nothing changes: the desktop answer and the desktop
footprint.

Measured on one console executable under the startup debugger: 18 such reads failed during
first-run setup in every run, each with the executable's check firing once. With this answer both
Expand Down Expand Up @@ -3953,7 +3954,7 @@ Limits and choices that are not measured against a console:
are compared with another implementation in the tree (`bc7_4k_s.h`, `bc64_chain.h`);
`tile64_plan.h` checks the `0x10a` mip starts and tail, not the bit order. The display (`_D`)
rows in `gfx10_layout.h` that differ from the standard ones (1-, 8- and 16-byte elements; the 2-
and 4-byte display rows equal the standard rows) and the standard rows for 1-, 2-, 4- and 8-byte
and 2-byte display rows equal the standard rows; the 4-byte display row uses GFX10.3 RbPlus `----x0x1y0y1x2y2` and differs from the 4-byte standard row `y2x2`) and the standard rows for 1-, 2-, 4- and 8-byte
elements are checked only against the addrlib pattern rows restated from the addrlib source text
in `startup_gfx10_layout_check.cpp` (all five element sizes) and in the Python oracle of
`startup_address_console_check.py` (4- and 8-byte elements), both written from the same source.
Expand Down
38 changes: 28 additions & 10 deletions src/startup_stubs/d3d12_draw.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1919,17 +1919,20 @@ bool upload_texture(Wrapper* self, Wrapper* resource, ID3D12Resource* texture)
if (const auto found = written_textures().find(reinterpret_cast<u64>(memory)); found != written_textures().end())
written = found->second;
ReleaseSRWLockShared(&written_lock);
const bool tiled_chain = original && x2w_startup::bc64::supports(original->console);
// Any other texture slot 70 publishes holds its texels in the console layout its description names
// (gfx10_layout.h, address_texture.h).
const bool tiled_bc7 = !tiled_chain && !tiled_address && written.bc7_width != 0;
const bool tiled_chain = !single && original && x2w_startup::bc64::supports(original->console);
// Placed sampled BC7 surfaces can carry the same 64 KiB display layout as an address-only SRV.
// GPU-authored resources have already returned above; only detile the CPU backing on upload.
const bool placed_display_bc7 = !tiled_address && original && desc.MipLevels == 1 &&
desc.DepthOrArraySize == 1 && desc.Format == DXGI_FORMAT_BC7_UNORM &&
x2w_startup::gfx10::swizzle_mode(original->console) == 10 && console_layout_srv(original->console);
const bool detile_console = console || placed_display_bc7;
const bool tiled = tiled_bc7 || tiled_address || tiled_chain || 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) || mips > 1 || slices > 1);
// Any other texture slot 70 publishes holds its texels in the console layout its description names
// (gfx10_layout.h, address_texture.h).
const bool tiled_bc7 = !is_gfx10_tiled && !tiled_chain && !tiled_address && !placed_display_bc7 && written.bc7_width != 0;
const bool tiled = tiled_bc7 || tiled_address || tiled_chain || is_gfx10_tiled || placed_display_bc7;
std::optional<x2w_startup::gfx10::Layout> console_layout;
if (detile_console) console_layout.emplace(original->console);
const auto generation = written.generation;
Expand All @@ -1941,7 +1944,7 @@ bool upload_texture(Wrapper* self, Wrapper* resource, ID3D12Resource* texture)
desc.Format != DXGI_FORMAT_BC7_UNORM || desc.Width != surface.columns * surface.block_texels ||
desc.Height != surface.rows * surface.block_texels) return true;
}
if (tiled && !tiled_chain && !single && !detile_console && (plan.count != 1 || plan.rows[0] != surface.rows ||
if (tiled && !is_gfx10_tiled && !tiled_chain && !single && !detile_console && (plan.count != 1 || plan.rows[0] != surface.rows ||
plan.row_bytes[0] != u64{surface.columns} * surface.block_bytes)) return true;
if (detile_console) {
// The desktop footprints must hold exactly the elements the console layout addresses.
Expand All @@ -1962,7 +1965,17 @@ bool upload_texture(Wrapper* self, Wrapper* resource, ID3D12Resource* texture)
rows_match = compact.level[i].rows == plan.rows[i] && compact.level[i].row_bytes == plan.row_bytes[i];
if (!rows_match) return true;
}
const u64 total = tiled_chain ? x2w_startup::bc64::Chain(original->console).bytes() : detile_console ? console_layout->bytes()
const x2w_startup::Gfx10Texture gfx10_tex = is_gfx10_tiled ? x2w_startup::Gfx10Texture(original->console) : x2w_startup::Gfx10Texture{};
if (is_gfx10_tiled) {
bool rows_match = gfx10_tex.levels == mips && gfx10_tex.slices == slices && plan.count == mips;
for (UINT i = 0; rows_match && i < mips; ++i)
rows_match = plan.bytes(i) && plan.rows[i] == gfx10_tex.rows(i) &&
plan.row_bytes[i] == u64{gfx10_tex.columns(i)} * gfx10_tex.bpe;
if (!rows_match) return true;
}
const u64 total = is_gfx10_tiled ? gfx10_tex.bytes()
: tiled_chain ? x2w_startup::bc64::Chain(original->console).bytes()
: detile_console ? console_layout->bytes()
: tiled && !single ? surface.size() : is_compact ? compact.bytes : stride * (slices - 1) + slice_total;
const bool announced = state.generation != generation;
const UINT elapsed = static_cast<UINT>(frame_number) - static_cast<UINT>(state.checked_frame);
Expand Down Expand Up @@ -2030,8 +2043,9 @@ bool upload_texture(Wrapper* self, Wrapper* resource, ID3D12Resource* texture)
state.pending_list = list;
state.revision = address_upload_revision;
}
} else if (tiled_chain) {
const x2w_startup::bc64::Chain chain(original->console);
} else if (is_gfx10_tiled || tiled_chain) {
std::optional<x2w_startup::bc64::Chain> chain;
if (tiled_chain && !is_gfx10_tiled) chain.emplace(original->console);
for (UINT slice = 0; slice < slices; ++slice) {
for (UINT i = 0; i < mips; ++i) {
const u64 bytes = plan.bytes(i);
Expand All @@ -2043,7 +2057,11 @@ bool upload_texture(Wrapper* self, Wrapper* resource, ID3D12Resource* texture)
return true;
}
std::memset(rows, 0, static_cast<std::size_t>(bytes));
chain.copy<false>(i, slice, rows, memory, plan.placed[i].Footprint.RowPitch);
if (is_gfx10_tiled) {
gfx10_tex.copy_subresource<false>(i, slice, rows, memory, plan.placed[i].Footprint.RowPitch);
} else {
chain->copy<false>(i, slice, rows, memory, plan.placed[i].Footprint.RowPitch);
}
plan.upload(list, texture, chunk, mips, slices, slice, i, offset);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/startup_stubs/d3d12_xs_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "startup_stubs/compute_builder_gate.h"
#include "startup_stubs/bc7_4k_s.h"
#include "startup_stubs/bc64_chain.h"
#include "startup_stubs/gfx10_texture.h"
#include "startup_stubs/address_texture.h"
#include "startup_stubs/list_upload_pages.h"
#include "startup_stubs/resource_budget.h"
Expand Down
2 changes: 1 addition & 1 deletion src/startup_stubs/gfx10_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct Layout {
static constexpr const char* standard[5] = {
"x0x1x2x3y0y1y2y3", "--x0x1x2y0y1y2x3", "----x0x1y0y1y2x2", "------x0y0y1x1x2", "--------y0y1x0x1"};
static constexpr const char* display[5] = {
"x0x1x2y1y0y2x3y3", "--x0x1x2y0y1y2x3", "----x0x1y0y1y2x2", "------x0y0x1x2y1", "--------x0y0x1y1"};
"x0x1x2y1y0y2x3y3", "--x0x1x2y0y1y2x3", "----x0x1y0y1x2y2", "------x0y0x1x2y1", "--------x0y0x1y1"};
static constexpr UINT micro[5][2] = {{16, 16}, {16, 8}, {8, 8}, {8, 4}, {4, 4}};
const bool is_display = mode == 2 || mode == 6 || mode == 10;
const char* pattern = (is_display ? display : standard)[element_log2];
Expand Down
Loading