GPU/HW: Don't miss updating read texture for recursive draws

Fixes missing glow in Castlevania SOTN.
pull/3782/head
Stenzek 2 months ago
parent 6f704d405b
commit ee21478ad1
No known key found for this signature in database

@ -2049,6 +2049,13 @@ void GPU_HW::UpdateVRAMReadTexture(bool drawn, bool written)
}
update(m_vram_dirty_draw_rect, dbits);
// Clear the cached draw mode bit, because since we're wiping out the texpage dirty bit, the page that
// we're currently rendering to might still be the texture page (game doesn't need to change it), and
// we need to detect if there is an intersection with the UVs. Same for the palette, those can be
// recursive too, although on real hardware it would require a cache flush to reload so we only
// clear out the texture page bits here.
m_draw_mode.mode_reg.bits = INVALID_DRAW_MODE_TEXTURE_BITS;
}
if (written)
{
@ -3784,17 +3791,13 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd)
texture_mode == BatchTextureMode::Disabled)
{
m_draw_mode.mode_reg.bits = cmd->draw_mode.bits;
m_draw_mode.palette_reg.bits = cmd->palette.bits;
// start by assuming we can use the TC
bool use_texture_cache = m_use_texture_cache;
// check that the palette isn't in a drawn area
if (m_draw_mode.mode_reg.IsUsingPalette())
if (cmd->draw_mode.IsUsingPalette())
{
const GSVector4i palette_rect =
GetPaletteRect(m_draw_mode.palette_reg, m_draw_mode.mode_reg.texture_mode, use_texture_cache);
const GSVector4i palette_rect = GetPaletteRect(cmd->palette, cmd->draw_mode.texture_mode, use_texture_cache);
if (!use_texture_cache || GPUTextureCache::IsRectDrawn(palette_rect))
{
if (use_texture_cache)
@ -3814,6 +3817,9 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd)
}
}
// UpdateVRAMReadTexture() can reset m_draw_mode, needs to be down here.
m_draw_mode.mode_reg.bits = cmd->draw_mode.bits;
m_draw_mode.palette_reg.bits = cmd->palette.bits;
m_compute_uv_range = (m_clamp_uvs || m_texture_dumping);
const GPUTextureMode gpu_texture_mode =

@ -105,7 +105,6 @@ private:
MAX_VERTICES_FOR_RECTANGLE = 6 * (((MAX_PRIMITIVE_WIDTH + (TEXTURE_PAGE_WIDTH - 1)) / TEXTURE_PAGE_WIDTH) + 1u) *
(((MAX_PRIMITIVE_HEIGHT + (TEXTURE_PAGE_HEIGHT - 1)) / TEXTURE_PAGE_HEIGHT) + 1u),
NUM_TEXTURE_MODES = static_cast<u32>(BatchTextureMode::MaxCount),
INVALID_DRAW_MODE_BITS = 0xFFFFFFFFu,
};
enum : u8
{
@ -114,6 +113,8 @@ private:
TEXPAGE_DIRTY_PAGE_RECT = (1 << 2),
TEXPAGE_DIRTY_ONLY_UV_RECT = (1 << 3),
};
static constexpr u32 INVALID_DRAW_MODE_TEXTURE_BITS = 0xFFFFu;
static constexpr u32 INVALID_DRAW_MODE_BITS = 0xFFFFFFFFu;
static_assert(GPUDevice::MIN_TEXEL_BUFFER_ELEMENTS >= (VRAM_WIDTH * VRAM_HEIGHT));

Loading…
Cancel
Save