[PR #3700] [MERGED] image_info: Fix guest size calculation for linear render targets #3665

Closed
opened 2026-02-27 22:04:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3700
Author: @raphaelthegreat
Created: 10/3/2025
Status: Merged
Merged: 10/4/2025
Merged by: @georgemoralis

Base: mainHead: linear-align


📝 Commits (1)

  • bb11184 image_info: Fix guest size calculation for linear render targets

📊 Changes

2 files changed (+21 additions, -7 deletions)

View changed files

📝 src/video_core/texture_cache/image_info.cpp (+18 -7)
📝 src/video_core/texture_cache/texture_cache.cpp (+3 -0)

📄 Description

The linear aligned tile mode doesn't require image height to be tile aligned only the pitch per addrlib

This is an issue with render targets because the registers that hold size information store it in units of tiles, so using these makes the guest size appear larger than it actually is. For example a 16128x1 RGBA32 render target should have a size of 258048 bytes (16128 * 16), but the color buffer registers will report 2064384 bytes (16128 * 8 * 16) which would be correct if the height were to be padded to tile dimension (8). The fix is manually computing the size if the render target is not tiled. Also removed handling of ArrayLinearGeneral because this doesn't align at all, so the current code is wrong for it anyway and seems entirely unused.

This should resolve some "Encountered unresolvable image overlap with equal memory address." asserts like this and might also fix random crashes when readback linear images is enabled, because with previous code it could overwrite additional memory, especially if the image size was 1x1 which isn't uncommon

This issue was reported to me by @Xcedf who also provided needed debugging information


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/3700 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 10/3/2025 **Status:** ✅ Merged **Merged:** 10/4/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `linear-align` --- ### 📝 Commits (1) - [`bb11184`](https://github.com/shadps4-emu/shadPS4/commit/bb11184395324b183f45f35b428a2b8bd1952adb) image_info: Fix guest size calculation for linear render targets ### 📊 Changes **2 files changed** (+21 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/video_core/texture_cache/image_info.cpp` (+18 -7) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+3 -0) </details> ### 📄 Description The linear aligned tile mode doesn't require image height to be tile aligned only the pitch [per addrlib](https://github.com/chaotic-cx/mesa-mirror/blob/52c7b0d20c88620fd55d21a62468211674559978/src/amd/addrlib/src/r800/egbaddrlib.cpp#L666) This is an issue with render targets because the registers that hold size information store it in units of tiles, so using these makes the guest size appear larger than it actually is. For example a 16128x1 RGBA32 render target should have a size of 258048 bytes (16128 * 16), but the color buffer registers will report 2064384 bytes (16128 * 8 * 16) which would be correct if the height were to be padded to tile dimension (8). The fix is manually computing the size if the render target is not tiled. Also removed handling of ArrayLinearGeneral because this doesn't align at all, so the current code is wrong for it anyway and seems entirely unused. This should resolve some "Encountered unresolvable image overlap with equal memory address." asserts like [this](https://github.com/shadps4-compatibility/shadps4-game-compatibility/issues/1701) and might also fix random crashes when readback linear images is enabled, because with previous code it could overwrite additional memory, especially if the image size was 1x1 which isn't uncommon This issue was reported to me by @Xcedf who also provided needed debugging information --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:04:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3665
No description provided.