GPU/TextureCache: Prevent wrapping for replacement lookup
Fixes replacements for 8 and 16-bit textures placed in the right-most page of VRAM.
This commit is contained in:
parent
635ae5de31
commit
b01c06b412
|
@ -3663,7 +3663,8 @@ void GPUTextureCache::ApplyTextureReplacements(SourceKey key, HashType tex_hash,
|
|||
|
||||
if (HasVRAMWriteTextureReplacements())
|
||||
{
|
||||
const GSVector4i page_rect = GetTextureRect(key.page, key.mode);
|
||||
// Wrapping around the edge for replacement testing breaks 8/16-bit textures in the rightmost page.
|
||||
const GSVector4i page_rect = GetTextureRectWithoutWrap(key.page, key.mode);
|
||||
LoopRectPages(page_rect, [&key, &pal_hash, &subimages, &page_rect](u32 pn) {
|
||||
const PageEntry& page = s_state.pages[pn];
|
||||
ListIterate(page.writes, [&key, &pal_hash, &subimages, &page_rect](const VRAMWrite* vrw) {
|
||||
|
|
|
@ -517,6 +517,15 @@ ALWAYS_INLINE static constexpr GSVector4i GetTextureRect(u32 pn, GPUTextureMode
|
|||
return GSVector4i::cxpr(left, top, right, bottom);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static constexpr GSVector4i GetTextureRectWithoutWrap(u32 pn, GPUTextureMode mode)
|
||||
{
|
||||
const u32 left = VRAMPageStartX(pn);
|
||||
const u32 top = VRAMPageStartY(pn);
|
||||
const u32 right = std::min<u32>(left + TexturePageWidthForMode(mode), VRAM_WIDTH);
|
||||
const u32 bottom = top + VRAM_PAGE_HEIGHT;
|
||||
return GSVector4i::cxpr(left, top, right, bottom);
|
||||
}
|
||||
|
||||
/// Returns the maximum index for a paletted texture.
|
||||
ALWAYS_INLINE static constexpr u32 GetPaletteWidth(GPUTextureMode mode)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue