Placed textures larger on the PC than on the console get memory of their own (Minecraft logo squares) #86

Manually merged
github merged 1 commit from gh-pr/86/head into gh-pr/86/base 2026-11-26 04:09:02 +00:00
Owner

@⁠Foniass on GitHub · 2026-11-23 02:17 UTC · original
Foniass:fix/placed-texture-overlap → main · +39 −0 · 1 files · 1 commits · merged 2026-11-23 10:36 UTC

Minecraft's loading screen showed three small magenta/black squares and a white speck along the bottom edge of the MINECRAFT logo (HANDOFF lists them as open: "small magenta / black 'missing texture' quads on the loading screen's logo"). Nothing is missing. On the PC the logo texture is larger than on the console and covers the textures the game packed after it.

Cause

Titles place textures in their heaps by the console's size: GetResourceAllocationInfo answers with XG's. XCL places the PC texture at the console's offset, but the PC driver's layout can be larger. Minecraft's heap (RTX 5070 Ti):

offset texture console size PC size
0x490000 logo textures/ui/title.png, 1937×333 0x29F000 0x2E0000, up to 0x770000
0x730000 "51%" text, 67×9 0x3000 0x10000
0x740000, 0x750000, 0x760000 16×16 0x1000 0x10000

The logo's last 0x40000 bytes are the memory of the next four textures. The three 16×16s are the game's magenta/black missing-texture image; written into the logo's tail they show as 16×16-texel squares exactly 256 texels apart in its bottom rows. The white speck is the text texture.

How it was found: in a full-size frame dump the squares sit inside the logo's quad (painting that pixel shader green with XCL_DEBUG_MAGENTA hides them), and title.png itself has plain black there. XCL has a fallback for this, "memory of its own", but it only applied when the PC refused the placement (past the heap's end). Here the PC accepts it, and the overlap goes unnoticed. The developer saw the same squares on AMD, so it isn't NVIDIA-only.

Fix

own_memory_if_larger_on_the_pc: a texture placed in a heap whose PC size is larger than its XG size gets a committed resource of the heap's kind, as in the past-the-end case. The console's aliasing of that one placement is lost (the same trade-off as before). Buffers and textures that fit are placed as before. The first 8 such textures are logged with both sizes.

Checked

  • Full-size dumps of every 120th loading-screen frame: 138 magenta pixels in each loading frame before, 0 after; the speck is gone too.
  • Menu and in-game (new survival world, walking around): normal picture, 60 fps, no flicker or blank frames in 1 050 screen captures.
  • cargo build --workspace --release then cargo test --workspace --release on the RTX 5070 Ti: 372 passed, 0 failed. 41 GPU tests print SKIPPED (no wave64 on NVIDIA), as on main.

🤖 Generated with Claude Code

**@⁠Foniass** on GitHub · 2026-11-23 02:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/86) `Foniass:fix/placed-texture-overlap` → `main` · +39 −0 · 1 files · 1 commits · merged 2026-11-23 10:36 UTC Minecraft's loading screen showed three small magenta/black squares and a white speck along the bottom edge of the MINECRAFT logo (HANDOFF lists them as open: "small magenta / black 'missing texture' quads on the loading screen's logo"). Nothing is missing. On the PC the logo texture is larger than on the console and covers the textures the game packed after it. ### Cause Titles place textures in their heaps by the console's size: `GetResourceAllocationInfo` answers with XG's. XCL places the PC texture at the console's offset, but the PC driver's layout can be larger. Minecraft's heap (RTX 5070 Ti): | offset | texture | console size | PC size | |---|---|---|---| | 0x490000 | logo `textures/ui/title.png`, 1937×333 | 0x29F000 | **0x2E0000**, up to 0x770000 | | 0x730000 | "51%" text, 67×9 | 0x3000 | 0x10000 | | 0x740000, 0x750000, 0x760000 | 16×16 | 0x1000 | 0x10000 | The logo's last 0x40000 bytes are the memory of the next four textures. The three 16×16s are the game's magenta/black missing-texture image; written into the logo's tail they show as 16×16-texel squares exactly 256 texels apart in its bottom rows. The white speck is the text texture. How it was found: in a full-size frame dump the squares sit inside the logo's quad (painting that pixel shader green with `XCL_DEBUG_MAGENTA` hides them), and `title.png` itself has plain black there. XCL has a fallback for this, "memory of its own", but it only applied when the PC refused the placement (past the heap's end). Here the PC accepts it, and the overlap goes unnoticed. The developer saw the same squares on AMD, so it isn't NVIDIA-only. ### Fix `own_memory_if_larger_on_the_pc`: a texture placed in a heap whose PC size is larger than its XG size gets a committed resource of the heap's kind, as in the past-the-end case. The console's aliasing of that one placement is lost (the same trade-off as before). Buffers and textures that fit are placed as before. The first 8 such textures are logged with both sizes. ### Checked - Full-size dumps of every 120th loading-screen frame: 138 magenta pixels in each loading frame before, 0 after; the speck is gone too. - Menu and in-game (new survival world, walking around): normal picture, 60 fps, no flicker or blank frames in 1 050 screen captures. - `cargo build --workspace --release` then `cargo test --workspace --release` on the RTX 5070 Ti: 372 passed, 0 failed. 41 GPU tests print SKIPPED (no wave64 on NVIDIA), as on `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A title places textures in its heaps by the console's size (XG's answer from
GetResourceAllocationInfo). When the PC's layout is larger, a texture placed
at the console's offset covers the start of whatever the title placed after
it, and the two write over each other. Until now it only got memory of its
own when the PC refused the placement (past the heap's end).

Minecraft's logo (1937x333: 0x29F000 bytes on the console, 0x2E0000 on the
PC) ran into the "51%" text texture and the 16x16 textures packed after it:
three magenta / black squares and a white speck along the logo's bottom edge
on the loading screen. Now every texture whose PC size exceeds its console
size gets memory of its own of the heap's kind, as the past-the-end case did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:01 +00:00
github manually merged commit 8ad0b447f0 into gh-pr/86/base 2026-11-26 04:09:02 +00:00
Author
Owner

@⁠Lum7nt on GitHub · 2026-11-23 04:44 UTC · original

Tested this branch locally and verified against main and our MSAA work (#43) — all 343 library tests pass and it merges cleanly.

Great catch on the PC padding overflow stomping adjacent textures in the heap! Two small suggestions for robustness:

  1. Retry with COMMON state on creation failure:
    In the existing past-the-end fallback (real.rs:2011), if committed resource creation fails with the requested state, it retries with D3D12_RESOURCE_STATE_COMMON (state 0) to handle driver quirks (e.g. UAV state requested without UAV bind flag). In own_memory_if_larger_on_the_pc, if dev_create_committed_resource fails, it currently returns None, falling through to dev_create_placed_resource and re-introducing the overlap. Adding the state 0 retry prevents that:

    let mut hr = dev_create_committed_resource(this, &h.Properties as *const _ as usize, 0, d.as_ptr() as usize, st as usize, clear, riid, ppv);
    if hr < 0 && st != 0 {
        hr = dev_create_committed_resource(this, &h.Properties as *const _ as usize, 0, d.as_ptr() as usize, 0, clear, riid, ppv);
    }
    
  2. Resource Tracking:
    dev_create_committed_resource_x registers newly created committed resources with register_resource(ptr, false). Calling register_resource(unsafe { *ppv }, false) when hr >= 0 ensures XCL's texture/aliasing tracker knows the resource is committed rather than placed.

**@⁠Lum7nt** on GitHub · 2026-11-23 04:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/86#issuecomment-7091831623) Tested this branch locally and verified against `main` and our MSAA work (#43) — all 343 library tests pass and it merges cleanly. Great catch on the PC padding overflow stomping adjacent textures in the heap! Two small suggestions for robustness: 1. **Retry with `COMMON` state on creation failure**: In the existing past-the-end fallback (`real.rs:2011`), if committed resource creation fails with the requested state, it retries with `D3D12_RESOURCE_STATE_COMMON` (state 0) to handle driver quirks (e.g. UAV state requested without UAV bind flag). In `own_memory_if_larger_on_the_pc`, if `dev_create_committed_resource` fails, it currently returns `None`, falling through to `dev_create_placed_resource` and re-introducing the overlap. Adding the state 0 retry prevents that: ```rust let mut hr = dev_create_committed_resource(this, &h.Properties as *const _ as usize, 0, d.as_ptr() as usize, st as usize, clear, riid, ppv); if hr < 0 && st != 0 { hr = dev_create_committed_resource(this, &h.Properties as *const _ as usize, 0, d.as_ptr() as usize, 0, clear, riid, ppv); } ``` 2. **Resource Tracking**: `dev_create_committed_resource_x` registers newly created committed resources with `register_resource(ptr, false)`. Calling `register_resource(unsafe { *ppv }, false)` when `hr >= 0` ensures XCL's texture/aliasing tracker knows the resource is committed rather than placed.
Author
Owner

@⁠certified-retart on GitHub · 2026-11-23 05:56 UTC · original

Tested head \8ad0b447\ on a dual-GPU Windows 10 setup (NVIDIA RTX 5070 + AMD Radeon 9800X3D iGPU) with D3D12 Agility SDK 1.619.1 (#75):

  • NVIDIA RTX 5070 (\XCL_ADAPTER=0, wave32-only): \xcl\ lib suite 351 passed, 0 failed (41 wave64-only GPU tests \SKIPPED\ as expected on NVIDIA).
  • AMD Radeon(TM) Graphics (9800X3D iGPU, \XCL_ADAPTER=1, wave32..64): \xcl\ lib suite 351 passed, 0 failed, 0 skipped (all wave64 GPU + mesh dispatch tests pass).

No regressions on either adapter, and the \creator!\ macro for \dev_create_committed_resource\ already calls \dopt(*ppv, Kind::Resource)\ on success.

**@⁠certified-retart** on GitHub · 2026-11-23 05:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/86#issuecomment-7092865192) Tested head \8ad0b447\ on a dual-GPU Windows 10 setup (NVIDIA RTX 5070 + AMD Radeon 9800X3D iGPU) with D3D12 Agility SDK 1.619.1 (\#75\): - **NVIDIA RTX 5070 (\XCL_ADAPTER=0\, wave32-only):** \xcl\ lib suite **351 passed, 0 failed** (41 wave64-only GPU tests \SKIPPED\ as expected on NVIDIA). - **AMD Radeon(TM) Graphics (9800X3D iGPU, \XCL_ADAPTER=1\, wave32..64):** \xcl\ lib suite **351 passed, 0 failed, 0 skipped** (all wave64 GPU + mesh dispatch tests pass). No regressions on either adapter, and the \creator!\ macro for \dev_create_committed_resource\ already calls \dopt(*ppv, Kind::Resource)\ on success.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:36 UTC · original

Merged – great find. On the RX 9070 Minecraft logs the logo and the 16×16 textures after it getting memory of their own, as you describe. I also took @⁠Lum7nt's suggestion (9284dcd): when the PC refuses the title's state for the committed resource, it retries with COMMON instead of falling back to the overlapping placement. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 10:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/86#issuecomment-7098218469) Merged – great find. On the RX 9070 Minecraft logs the logo and the 16×16 textures after it getting memory of their own, as you describe. I also took @⁠Lum7nt's suggestion (9284dcd): when the PC refuses the title's state for the committed resource, it retries with COMMON instead of falling back to the overlapping placement. Tested on Windows 11 with an RX 9070 (RDNA4): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!
Author
Owner

@⁠Foniass on GitHub · 2026-11-23 10:47 UTC · original

Thanks @⁠Lum7nt and @⁠certified-retart for testing it.

On the two suggestions:

  1. Retry in COMMON. The past-the-end fallback on main (dev_create_placed_resource_x) has no such retry: it creates the committed resource once, in the title's state masked to the PC's (PC_RESOURCE_STATES). The new path does the same. If that creation fails, own_memory_if_larger_on_the_pc returns None and the texture is placed as the title asked, which is what main does today, so a failure costs no more than before. A retry in COMMON would hand the title a texture in a state other than the one its barriers start from (its first transition names the state it asked for). The debug layer reports that, and drivers are free to mishandle it, so I'd keep the title's state.
  2. Tracking. There is no register_resource in the tree. As @⁠certified-retart says, the creator! wrapper of dev_create_committed_resource adopts the new resource (adopt(*ppv, Kind::Resource)), the same path the past-the-end fallback goes through.

Also re-checked today on current main (d70f8e9, RTX 5070 Ti): the workspace suite passes, and Minecraft's menu renders at 60 fps.

**@⁠Foniass** on GitHub · 2026-11-23 10:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/86#issuecomment-7098499231) Thanks @⁠Lum7nt and @⁠certified-retart for testing it. On the two suggestions: 1. **Retry in `COMMON`.** The past-the-end fallback on `main` (`dev_create_placed_resource_x`) has no such retry: it creates the committed resource once, in the title's state masked to the PC's (`PC_RESOURCE_STATES`). The new path does the same. If that creation fails, `own_memory_if_larger_on_the_pc` returns `None` and the texture is placed as the title asked, which is what `main` does today, so a failure costs no more than before. A retry in `COMMON` would hand the title a texture in a state other than the one its barriers start from (its first transition names the state it asked for). The debug layer reports that, and drivers are free to mishandle it, so I'd keep the title's state. 2. **Tracking.** There is no `register_resource` in the tree. As @⁠certified-retart says, the `creator!` wrapper of `dev_create_committed_resource` adopts the new resource (`adopt(*ppv, Kind::Resource)`), the same path the past-the-end fallback goes through. Also re-checked today on current `main` (d70f8e9, RTX 5070 Ti): the workspace suite passes, and Minecraft's menu renders at 60 fps.
This discussion has been locked. Commenting is limited to contributors.
No description provided.