Repository navigation
startup: answer 4 KiB allocation-info requests for small 2D textures - #2133
Conversation
A console executable asks slots 25 and 108 with Alignment 0x1000 for a texture that is not a render or depth target and whose top level, padded to 4 KiB blocks, holds at most 0x80007 bits, and keeps the answer only when its alignment is 0x1000. sanitized() dropped the request and the desktop answer, 64 KiB, made the executable size such a texture at 16 pages and stream 64 KiB of archive data into it, ending inside a following compressed chunk. For a single 2D texture with layout UNKNOWN, one sample, one slice, power-of-two dimensions, a format of 4 to 128 bits a texel and the executable's bound, both slots now answer 4 KiB alignment and the GFX10 4 KiB thin-block size as addrlib computes it. Anything else keeps the desktop answer. Tests: literal sizes and refused descriptions, a whole-width-tail mutation that must fail, every accepted shape against Mesa 25.1.0 addrlib SW_4KB_S (skips without it), and the wrapper's two slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A texture given the 4 KiB answer has only that many bytes of executable memory, while its desktop linear footprint can be larger (32x32 R8G8B8A8: 0x1f80). Texture upload now reads no further than the answer and zero-fills the rest of the footprint, XG slot 8 writes no rows past it, and XG slot 2 reports the answer's size and 4 KiB alignment. small_texture_4k_extent() applies the same shape test at alignment 0 or 0x1000. The helper also leaves depth with stencil (R32G8X24, R24G8: two planes) and widths or heights over 16384 alone, and keeps a desktop failure, as console_plane_size does. Tests: every format value's bits per texel against a literal DXGI table, the new refusals, the extent and span limits, and an XG slot 8 copy into exactly the answered size before a no-access guard page, with an explicit 64 KiB alignment as the negative control. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
small_texture_4k_extent() also took Alignment 0, which the allocation-info entries answer with the desktop size: a 32x32 R8G8B8A8 texture at alignment 0 then got a 0x1000 size from XG slot 2, half its rows from slot 8 and a zero-filled bottom half on upload. The limit now applies only where the 4 KiB answer was given. The XG check covers both: a copy before a guard page at 0x1000, and alignment 0 unchanged (slot 2 0x10000, all 32 rows written). Slot 2's mip records still describing the linear footprint is stated as a limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00
left a comment
There was a problem hiding this comment.
The 4 KiB size calculation is useful and the arithmetic fixture passes locally. I also reproduced the acceptance gap with the real XG shim: a 32x32 RGBA8 texture is advertised as 4 KiB, its mip footprint extends past that allocation, and slot 8 returns S_OK after writing only 16 of 32 rows. The translated upload then fills missing rows with zeros. Please keep the public layout, full copy and upload consistent for every shape that gets the new allocation answer. Use one shared compact or tiled plan across the relevant calls, or restrict the production answer to a proven complete subset and report unsupported copies without writing or announcing a new generation. A separate arithmetic-only PR can move first. Verify distinct rows in both halves, two mips with different sentinels, a guard at the returned allocation end, and actual rendered/read-back pixels. Coordinate the shared tiling code with #1469. Keep the observed application count improvement as author evidence, separate from the byte-correctness requirement.
tedin7
left a comment
There was a problem hiding this comment.
Review of head 75287587ae0e0bc0f9075fd7f2fb2bd98a28ad9f (comment only, no approval).
Summary: The size rule matches the GFX10 4 KiB thin-block layout. I checked the block table by hand: 128x64 at 4 bits, 64x64 at 8, 64x32 at 16, 32x32 at 32, 32x16 at 64 and 16x16 at 128 all give 4096 bytes. Scope checks, the failure passthrough (~0ull), slots 25 and 108, the XG layout and the upload and copy limits read correctly. CI is green on the Windows build and the Linux Python checks. The /O2 job and the chart job were skipped. Mergeable state was UNKNOWN when I looked. No P1 found. Two P2 items and one nit are below.
Commands executed locally (PR worktree, origin/main...HEAD):
git diff --stat origin/main...HEAD: 9 files, +714/-17.python3 tests/docs_links_check.py: pass (18 files, 391 links).python3 tests/bidi_controls_check.py: pass.git diff --check origin/main...HEAD: FAILS, see P2-1.- Built
tests/startup_small_texture_4k_check.cppwithx86_64-w64-mingw32-g++ -std=c++17 -Isrcand ran it under wine. The file as committed does not compile, see P2-1. With only the CR bytes removed, the run printsPASS (14 sizes, 19 refused descriptions, 256 format values, extent and span limits).
P2-1: tests/startup_small_texture_4k_check.cpp has CRLF line endings, plus a raw CR inside a string literal.
- All 255 lines end in CRLF. Sibling tests such as
tests/startup_tile64_plan_check.cppare LF. - This is why
git diff --checkreports trailing whitespace on every line. - Line 116 is
std::printf("FAIL 2x2 BC1: a desktop failure was replaced<CR>\n");. The raw CR sits inside the string. - MSVC accepts it, which is why the Windows CI job passes. GCC and clang reject it with
missing terminating " character. - Fix: convert the file to LF and put
\non that line normally.
P2-2: the 8-level tail limit is not covered by the device-free literal run.
- Mutation: in
small_texture_4k_bytes, changemips - m <= 8tomips - m <= 7. - Result: the literal test still passes (
rc=0). - Only the
--addrlibrun, which skips with 77 when addrlib is absent, would compare these shapes. Please add one literal case whose tail level is chosen by the 8-level limit rather than by the half-block width, for example a case with more than 8 mips remaining where the width and height test is already true.
Mutations run (each reverted with git checkout -- .):
h <= b.heightchanged toh <= b.height * 2: killed (FAIL 64x128 BC1 5 mips).mips - m <= 8changed to<= 7: survived (P2-2).offset >= extentchanged tooffset > extentinsmall_texture_4k_within: survived. This one is an equivalent mutant, because the clamp returns 0 either way.0x80007changed to0x80008: survived. Also equivalent, because padded bit counts are multiples of 4096.
Nit: the doc and header say that XG mip records still describe the desktop footprint beyond the answer. That limit is documented in the code comment and handled by clamping in slot 8.
Windows proof: I did not run python3 $P win2025. The Windows CI build and test job passed on this head (I did not inspect which tests it ran). A Win2025 run on the final head after the P2 fixes is still worth doing before this goes to Ready.
AI-assisted; commands listed were executed locally.
…4 KiB-answer textures The desktop linear footprint of a texture given the 4 KiB allocation answer can exceed it (32x32 R8G8B8A8: 0x1f80 bytes at a 256-byte pitch), so slot 8 wrote only part of the rows and upload filled the rest with zeros. All three calls now use one compact linear plan for such a description: every row at its exact byte width (texels or 4x4 blocks), levels back to back from the top level. Slot 2 reports the answer at 4 KiB alignment with the plan's level records, slot 8 writes every row of a level or nothing (short pitch, level past the last), and upload reads the same rows. The plan ends inside the answer for all 4,943 accepted shapes, checked in the device-free test. addrlib's 8-level tail cap is dropped from the size rule: a 4 KiB thin tail never holds more than 7 levels (checked over every accepted shape), so it never applied. Tests: the XG check writes two mips with distinct rows and per-mip sentinels into exactly the answered size before a guard page and compares bytes; refused copies leave memory unchanged; alignment 0 is unchanged. A new draw check places that texture, draws both mips on WARP and hardware and compares all 1,536 read-back pixels. The test file is LF again with no stray CR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tight source pitch let slot 8 place rows at the caller's pitch unnoticed; 160-byte source rows must still land as 128-byte plan rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, agreed. Fixed in For every shape that gets the 4 KiB answer, XG slot 2, XG slot 8 and texture upload now use one compact
New checks:
The plan's texels are linear, not the 4 KiB swizzle, so bytes streamed in the console's tiled order are still not displayed correctly, as on AI-assisted (Claude Code). |
|
Thanks, both fixed in
AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
Review of head d340e4645b1d8e62df08910560aa878b6b99fe2c (comment only, no approval).
Summary: This head is reworked since the earlier review (13 files, +1085/-10). The 4 KiB size rule and the new compact linear plan for XG slots 2 and 8 read correctly. The earlier CRLF problem is gone. No P1 and no P2 found. CI is green on the Windows build and test job, the gfx1013 job and the Linux Python checks. The /O2 and chart jobs were skipped. The PR is mergeable and the title is neutral.
Commands executed locally (PR worktree, origin/main...HEAD):
git diff --stat origin/main...HEAD: 13 files, +1085/-10.python3 tests/docs_links_check.py: pass (18 files, 401 links).python3 tests/bidi_controls_check.py: pass (1461 files).git diff --check origin/main...HEAD: clean.git ls-files --eolshows LF on all four new test files.- Built
tests/startup_small_texture_4k_check.cppwithx86_64-w64-mingw32-g++ -std=c++17 -Isrcand ran it under wine:PASS (15 sizes, 19 refused descriptions, 256 format values, extents, compact plans), 4943 accepted shapes, 0 past the answer.
Mutations run (each reverted with git checkout -- .):
- Tail test
w <= b.width / 2changed tow <= b.width: killed (7 failures). - Compressed row bytes
bits * 2changed tobitsin the plan: killed (2 failures). - Bound
0x80007doubled: killed (4 failures). - Dropping
mips > 1 &&insmall_texture_4k_bytes: survived. This is an equivalent mutant: with one level the tail branch returns one block, the same as the loop.
Notes (nit, no action needed):
small_texture_4k.hstates that the XG mip records beyond the answer are compact. The device and XG tests (guard page,no-limitcontrol) cover this, but they need Windows, so I did not run them.- The texels are linear, not the console swizzle. The header says so and points to a later tiling plan.
Windows proof: I did not run python3 $P win2025. The Windows CI job passed on this head. A Win2025 run is still worth doing before Ready, because the change touches the device wrapper, XG stubs and the draw path.
AI-assisted; commands listed were executed locally.
|
Ran the draw on hardware, since it needs RX 9070 XT, driver 32.0.32029.2010. The exact-size allocation, the no-access guard page and the two mips all read back as the reference, so the 4 KiB answer is not just accepted by the console path but actually writes where the draw reads. Limits: AMD only, no NVIDIA here; and this tells nothing about the allocation answers other consoles ask for. AI-assisted. |
|
Merged current I checked that the fence-safe sampling path from #2214 cannot bypass the plan: it requires a console swizzle mode in Behaviour is unchanged. Re-run on the merged head, WARP and RTX 5090: AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
Review of head c0db8308334d4a6331511aa6670558c6f05036b2 (comment only, no approval).
Summary: This head is the previous reviewed head (d340e464) plus a merge of origin/main. The PR's own files (small_texture_4k.h, xg_xs.cpp, the device and draw hooks, the four new tests) are unchanged by the merge, so the earlier read of the 4 KiB size rule and the compact plan still applies. No P1 and no P2 found. CI: Windows build and test, gfx1013 and Linux Python checks pass; the /O2 and chart jobs are skipped. The PR is mergeable and the title is neutral.
Commands executed locally (PR worktree, origin/main...HEAD):
git diff --stat origin/main...HEAD: 13 files, +1084/-10.python3 tests/docs_links_check.py: pass (18 files, 409 links).python3 tests/bidi_controls_check.py: pass (1501 files).git diff --check origin/main...HEAD: clean.- Built
tests/startup_small_texture_4k_check.cppwithx86_64-w64-mingw32-g++ -std=c++17 -Isrcand ran it under wine:PASS (15 sizes, 19 refused descriptions, 256 format values, extents, compact plans), 4943 accepted shapes, 0 past the answer.
Mutations run (each reverted with git checkout -- .):
- 32x16 block for 64-bit texels changed to 32x32: killed (82 shapes past the answer, 1 failure).
- Dropping the
Alignment != 0x1000guard insmall_texture_4k: killed (2 failures). - Bound
0x80007changed to0x8000F: survived. This is an equivalent mutant: the padded bit count is always a multiple of 0x8000, so no value lies between the two bounds.
Not run: the Win2025 WARP job. The merge changed no shader or C++ code of this PR, and the previous head's review already covered the logic. The startup_small_texture_4k_device, _xg and _draw CTest targets need Windows; I only ran the Linux-reachable size test.
P1: none. P2: none.
Nit: none new.
AI-assisted; commands listed were executed locally.
R0Y00
left a comment
There was a problem hiding this comment.
The previous partial-row finding is resolved by the shared compact plan in allocation info, the XG layout and copy, and the upload reader. Independent Windows Release startup_small_texture_4k coverage: 8 pass, 1 AddrLib capability skip. Both WARP and RTX 4060 Laptop matched 1,536 pixels across two mips with a guard after the reported allocation. The XG no-limit negative also behaved as expected.
|
Small correction on wording: "the no-access guard page" is not something the log shows, and the fixture does not mention a guard page either. Strike it. What the run does show, verbatim: So the claim worth keeping is the exact-size allocation (0x2000, aligned 0x1000, a 4 KiB answer) and the two mips, not a guard page I cannot point to. AI-assisted. |
Change
A console executable asks the device's allocation-info entries (slots 25 and 108) with
Alignment0x1000 for a texture that is not a render or depth target and whose top level, padded to 4 KiB blocks,
holds at most 0x80007 bits. It keeps the answer only when the returned alignment is 0x1000.
sanitized()dropped that request, so the stand-in forwarded the desktop answer: 64 KiB at 64 KiB alignment.
With that answer the executable records 16 pages for a texture the console sizes at one. Its streaming
read for that texture then runs 64 KiB through the following resources' compressed chunks and ends
inside one of them. The executable's own check rejects that read before submitting it, and the storage
stand-in refuses the request. This change corrects the size answer, so storage receives whole-chunk
requests and publishes the range it actually wrote (#1914).
What changes:
4 KiB thin-block size as AMD addrlib computes it (
src/startup_stubs/small_texture_4k.h). Each levelis padded to whole blocks until the first level no wider than half a block and no taller than a block;
that level and every smaller one share one block.
Alignment0x1000, one sample, one array slice,power-of-two sides up to 16384,
MipLevels0 up to the full chain, and no render-target or depth flag.The format must be single-plane at 4/8/16/32/64/128 bits a texel. The texture must be within the
executable's bound, and the desktop answer must not be a failure. Anything else, alignment 0 included,
keeps the desktop answer.
answer (32x32 R8G8B8A8: 0x1f80 bytes). For such a description, XG slot 2 (layout records), XG slot 8
(copy) and texture upload all use one compact linear plan: rows at their exact byte width (texels or
4x4 blocks), levels back to back. The plan ends inside the answer for every accepted shape.
last one, fails without writing or announcing a write.
the console's 4 KiB tiled order are therefore still not displayed correctly, as on
main. Thedifference is that the upload now reads strictly inside the allocation;
mainread the 256-byte-pitchfootprint, which ran past it.
any answer.
Overlap with #1469: its
Gfx10Textureuses the same tail rule, and itsgfx10_swizzle_from_descpicksSW_64KB_Sfor layout UNKNOWN. For descriptions this change answers atAlignment0x1000, that sideshould choose
SW_4KB_S. Its 4 KiB tiling plan can then replace the compact plan: the plan is used inexactly three places (slot 2, slot 8, upload). This PR does not depend on #1469.
Refs #1914. AI-assisted (Claude Code).
Verification
Release build at
d340e464, Windows 11 build 26300, debug layer off. Adapters:addrlib from
python tools/fetch_addrlib.py(Mesa 25.1.0, 5c142e46).Result: 20 of 20 passed, 0 failed, 0 skipped. Every device test ran on both WARP and the hardware
adapter.
The other draw tests that use the edited stream consumer
(
^startup_(packed_target_draw|stream_|mrt_|logical_view|slot57_blend_draw|placed_vertex|address_srv|address_buffer_srv))also pass: 26 of 27, with 1 capability skip.
startup_logical_view_warpskips because the adapteraccepts the descriptor count directly.
The tests:
startup_small_texture_4k, device-free:startup_small_texture_4k_whole_width_tail_controlexpects a tail one block wide and must fail.startup_small_texture_4k_addrlib: 4,943 shapes against addrlibADDR_SW_4KB_S, 0 mismatches. Itskips (77) without addrlib.
startup_small_texture_4k_device_warpand_hardware: slots 25 and 108 give the 4 KiB answer for 3descriptions and the desktop answer for 3 controls.
startup_small_texture_4k_xguses a 32x32 R8G8B8A8 texture with 2 mips at 0x1000:rows in both halves and per-mip sentinels;
startup_small_texture_4k_xg_no_limit_control: at an explicit 64 KiB alignment the desktop footprintdoes not fit before the guard page, so the run must fail.
startup_small_texture_4k_draw_warpand_hardware: the same texture is written through slot 8 infront of a guard page, placed (slot 133), sampled at both mips by a translated draw, and all 1,536
read-back pixels are compared.
startup_xg_*tests pass unchanged.Mutants, each run against the tests above: 8 of 8 killed. "Slot 8 rows at the caller's pitch" survived at
first, because every copy used a tight pitch. The XG check now copies mip 0 from a source with padded
160-byte rows, which kills it.
Evidence and follow-up
Byte correctness rests on the fixtures above, which are synthetic. The addrlib oracle is optional,
MIT-licensed and not vendored.
Author evidence, separate from byte correctness, from one console executable under the startup debugger:
executable's own check firing once. With this answer both counts were 0 to the same screen.
(272 shape groups) are spaced exactly at the answered size. These are counts only.
takes 0x4000.
Follow-up:
Checklist
🤖 Generated with Claude Code