From 9a9f03c9740fdd4e5b4c62e95c78cb304a6b12c7 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 7 Aug 2023 23:25:54 +1000 Subject: [PATCH] Fix interlaced output/sw switching --- src/core/gpu/gpu_device.cpp | 9 +++------ src/core/gpu_hw.cpp | 5 +++-- src/core/system.cpp | 2 +- src/frontend-common/imgui_overlays.cpp | 1 + 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/gpu/gpu_device.cpp b/src/core/gpu/gpu_device.cpp index 250d2fb65..29bbf17b3 100644 --- a/src/core/gpu/gpu_device.cpp +++ b/src/core/gpu/gpu_device.cpp @@ -197,15 +197,11 @@ u32 GPUTextureBuffer::GetElementSize(Format format) return element_size[static_cast(format)]; } -GPUDevice::~GPUDevice() -{ - // TODO: move to Destroy() method - m_shader_cache.Close(); -} +GPUDevice::~GPUDevice() = default; RenderAPI GPUDevice::GetPreferredAPI() { -#ifdef _WIN32___ // TODO remove me +#ifdef _WIN32 return RenderAPI::D3D11; #else return RenderAPI::Metal; @@ -270,6 +266,7 @@ void GPUDevice::Destroy() if (HasSurface()) DestroySurface(); DestroyResources(); + m_shader_cache.Close(); DestroyDevice(); } diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 4b3abbc2a..6f05fd298 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -560,8 +560,8 @@ void GPU_HW::ClearFramebuffer() { g_gpu_device->ClearRenderTarget(m_vram_texture.get(), 0); g_gpu_device->ClearDepth(m_vram_depth_texture.get(), m_pgxp_depth_buffer ? 1.0f : 0.0f); - g_gpu_device->ClearRenderTarget(m_display_texture.get(), 0); ClearVRAMDirtyRectangle(); + g_gpu_device->ClearRenderTarget(m_display_texture.get(), 0); m_last_depth_z = 1.0f; } @@ -2411,9 +2411,10 @@ void GPU_HW::UpdateDisplay() if (interlaced == InterlacedRenderMode::None) g_gpu_device->InvalidateRenderTarget(m_display_texture.get()); + g_gpu_device->SetFramebuffer(m_display_framebuffer.get()); g_gpu_device->SetPipeline( m_display_pipelines[BoolToUInt8(m_GPUSTAT.display_area_color_depth_24)][static_cast(interlaced)].get()); - g_gpu_device->SetFramebuffer(m_display_framebuffer.get()); + g_gpu_device->SetTextureSampler(0, m_vram_texture.get(), g_gpu_device->GetNearestSampler()); const u32 reinterpret_field_offset = (interlaced != InterlacedRenderMode::None) ? GetInterlacedDisplayField() : 0; const u32 reinterpret_start_x = m_crtc_state.regs.X * resolution_scale; diff --git a/src/core/system.cpp b/src/core/system.cpp index 06280260f..65e4c7140 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1635,7 +1635,7 @@ bool System::CreateGPU(GPURenderer renderer) { const RenderAPI api = Settings::GetRenderAPIForRenderer(renderer); - if (!g_gpu_device || g_gpu_device->GetRenderAPI() != api) + if (!g_gpu_device || (renderer != GPURenderer::Software && g_gpu_device->GetRenderAPI() != api)) { if (g_gpu_device) { diff --git a/src/frontend-common/imgui_overlays.cpp b/src/frontend-common/imgui_overlays.cpp index a845993d8..be0b1d7e0 100644 --- a/src/frontend-common/imgui_overlays.cpp +++ b/src/frontend-common/imgui_overlays.cpp @@ -237,6 +237,7 @@ void ImGuiManager::DrawPerformanceOverlay() if (g_settings.display_show_resolution) { + // TODO: this seems wrong? const auto [effective_width, effective_height] = g_gpu->GetEffectiveDisplayResolution(); const bool interlaced = g_gpu->IsInterlacedDisplayEnabled(); const bool pal = g_gpu->IsInPALMode();