GPU: Ensure batches are flushed before presenting frame

Fixes occasional assertion failing when using the debugger.
downsampling
Stenzek 10 months ago
parent dc9cdddd4c
commit cae1ddc971
No known key found for this signature in database

@ -90,6 +90,9 @@ public:
// TODO: replace with "invalidate cached state" // TODO: replace with "invalidate cached state"
virtual void RestoreDeviceContext() = 0; virtual void RestoreDeviceContext() = 0;
/// Ensures all pending draws are flushed to the host GPU.
virtual void FlushRender() = 0;
/// Main command handler for GPU thread. /// Main command handler for GPU thread.
void HandleCommand(const GPUThreadCommand* cmd); void HandleCommand(const GPUThreadCommand* cmd);
@ -140,9 +143,6 @@ protected:
virtual bool AllocateMemorySaveState(System::MemorySaveState& mss, Error* error) = 0; virtual bool AllocateMemorySaveState(System::MemorySaveState& mss, Error* error) = 0;
virtual void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss) = 0; virtual void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss) = 0;
/// Ensures all pending draws are flushed to the host GPU.
virtual void FlushRender() = 0;
/// Helper function for computing the draw rectangle in a larger window. /// Helper function for computing the draw rectangle in a larger window.
void CalculateDrawRect(s32 window_width, s32 window_height, bool apply_rotation, bool apply_aspect_ratio, void CalculateDrawRect(s32 window_width, s32 window_height, bool apply_rotation, bool apply_aspect_ratio,
GSVector4i* display_rect, GSVector4i* draw_rect) const; GSVector4i* display_rect, GSVector4i* draw_rect) const;

@ -71,6 +71,7 @@ public:
u32 GetResolutionScale() const override; u32 GetResolutionScale() const override;
void RestoreDeviceContext() override; void RestoreDeviceContext() override;
void FlushRender() override;
protected: protected:
void UpdateSettings(const GPUSettings& old_settings) override; void UpdateSettings(const GPUSettings& old_settings) override;
@ -91,7 +92,6 @@ protected:
void DrawLine(const GPUBackendDrawLineCommand* cmd) override; void DrawLine(const GPUBackendDrawLineCommand* cmd) override;
void DrawPreciseLine(const GPUBackendDrawPreciseLineCommand* cmd) override; void DrawPreciseLine(const GPUBackendDrawPreciseLineCommand* cmd) override;
void FlushRender() override;
void DrawingAreaChanged() override; void DrawingAreaChanged() override;
void ClearVRAM() override; void ClearVRAM() override;

@ -23,6 +23,7 @@ public:
bool Initialize(bool upload_vram, Error* error) override; bool Initialize(bool upload_vram, Error* error) override;
void RestoreDeviceContext() override; void RestoreDeviceContext() override;
void FlushRender() override;
u32 GetResolutionScale() const override; u32 GetResolutionScale() const override;
@ -46,8 +47,6 @@ protected:
void ClearVRAM() override; void ClearVRAM() override;
void FlushRender() override;
void UpdateResolutionScale() override; void UpdateResolutionScale() override;
void LoadState(const GPUBackendLoadStateCommand* cmd) override; void LoadState(const GPUBackendLoadStateCommand* cmd) override;

@ -1215,6 +1215,9 @@ void GPUThread::SleepUntilPresentTime(Timer::Value present_time)
void GPUThread::Internal::PresentFrame(bool allow_skip_present, u64 present_time) void GPUThread::Internal::PresentFrame(bool allow_skip_present, u64 present_time)
{ {
if (s_state.gpu_backend)
s_state.gpu_backend->FlushRender();
const bool skip_present = (!g_gpu_device->HasMainSwapChain() || const bool skip_present = (!g_gpu_device->HasMainSwapChain() ||
(allow_skip_present && g_gpu_device->GetMainSwapChain()->ShouldSkipPresentingFrame() && (allow_skip_present && g_gpu_device->GetMainSwapChain()->ShouldSkipPresentingFrame() &&
s_state.skipped_present_count < MAX_SKIPPED_PRESENT_COUNT)); s_state.skipped_present_count < MAX_SKIPPED_PRESENT_COUNT));

Loading…
Cancel
Save