GPU/HW: Download VRAM when enabling sw-for-readbacks

This commit is contained in:
Stenzek 2024-12-23 17:55:47 +10:00
parent 8e254c4baf
commit 9a22ac3c70
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View File

@ -616,6 +616,8 @@ void GPU_HW::UpdateSettings(const GPUSettings& old_settings)
// Need to reload CLUT if we're enabling SW rendering. // Need to reload CLUT if we're enabling SW rendering.
if (g_gpu_settings.gpu_use_software_renderer_for_readbacks && !old_settings.gpu_use_software_renderer_for_readbacks) if (g_gpu_settings.gpu_use_software_renderer_for_readbacks && !old_settings.gpu_use_software_renderer_for_readbacks)
{ {
DownloadVRAMFromGPU(0, 0, VRAM_WIDTH, VRAM_HEIGHT);
if (m_draw_mode.mode_reg.texture_mode <= GPUTextureMode::Palette8Bit) if (m_draw_mode.mode_reg.texture_mode <= GPUTextureMode::Palette8Bit)
{ {
GPU_SW_Rasterizer::UpdateCLUT(m_draw_mode.palette_reg, GPU_SW_Rasterizer::UpdateCLUT(m_draw_mode.palette_reg,
@ -3094,9 +3096,9 @@ ALWAYS_INLINE float GPU_HW::GetCurrentNormalizedVertexDepth() const
void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color, bool interlaced_rendering, u8 active_line_lsb) void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color, bool interlaced_rendering, u8 active_line_lsb)
{ {
FlushRender(); FlushRender();
DeactivateROV();
GL_SCOPE_FMT("FillVRAM({},{} => {},{} ({}x{}) with 0x{:08X}", x, y, x + width, y + height, width, height, color); GL_SCOPE_FMT("FillVRAM({},{} => {},{} ({}x{}) with 0x{:08X}", x, y, x + width, y + height, width, height, color);
DeactivateROV();
GL_INS_FMT("Dirty draw area before: {}", m_vram_dirty_draw_rect); GL_INS_FMT("Dirty draw area before: {}", m_vram_dirty_draw_rect);
@ -3149,17 +3151,21 @@ void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color, bool inter
void GPU_HW::ReadVRAM(u32 x, u32 y, u32 width, u32 height) void GPU_HW::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
{ {
FlushRender(); GL_SCOPE_FMT("ReadVRAM({},{} => {},{} ({}x{})", x, y, x + width, y + height, width, height);
GL_PUSH_FMT("ReadVRAM({},{} => {},{} ({}x{})", x, y, x + width, y + height, width, height);
if (ShouldDrawWithSoftwareRenderer()) if (ShouldDrawWithSoftwareRenderer())
{ {
GL_INS("VRAM is already up to date due to SW draws."); GL_INS("VRAM is already up to date due to SW draws.");
GL_POP();
return; return;
} }
DownloadVRAMFromGPU(x, y, width, height);
}
void GPU_HW::DownloadVRAMFromGPU(u32 x, u32 y, u32 width, u32 height)
{
FlushRender();
// TODO: Only read if it's in the drawn area // TODO: Only read if it's in the drawn area
// Get bounds with wrap-around handled. // Get bounds with wrap-around handled.

View File

@ -239,6 +239,7 @@ private:
/// Returns true if the draw is going to use shader blending/framebuffer fetch. /// Returns true if the draw is going to use shader blending/framebuffer fetch.
bool NeedsShaderBlending(GPUTransparencyMode transparency, BatchTextureMode texture, bool check_mask) const; bool NeedsShaderBlending(GPUTransparencyMode transparency, BatchTextureMode texture, bool check_mask) const;
void DownloadVRAMFromGPU(u32 x, u32 y, u32 width, u32 height);
void UpdateVRAMOnGPU(u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_pitch, bool set_mask, void UpdateVRAMOnGPU(u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_pitch, bool set_mask,
bool check_mask, const GSVector4i bounds); bool check_mask, const GSVector4i bounds);
bool BlitVRAMReplacementTexture(GPUTexture* tex, u32 dst_x, u32 dst_y, u32 width, u32 height); bool BlitVRAMReplacementTexture(GPUTexture* tex, u32 dst_x, u32 dst_y, u32 width, u32 height);