Skip to content

Commit

Permalink
GPUDevice: Remove BeginPresent() skip parameter
Browse files Browse the repository at this point in the history
It wasn't used - System does its own present skipping.
  • Loading branch information
stenzek committed Sep 7, 2024
1 parent 4b0c1fd commit ac5a2a1
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 55 deletions.
3 changes: 1 addition & 2 deletions src/core/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2063,8 +2063,7 @@ GPUDevice::PresentResult GPU::RenderDisplay(GPUTexture* target, const GSVector4i
{
if (target)
g_gpu_device->SetRenderTarget(target);
else if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(false);
pres != GPUDevice::PresentResult::OK)
else if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(); pres != GPUDevice::PresentResult::OK)
return pres;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/imgui_overlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,

// TODO: Glass effect or something.

if (g_gpu_device->BeginPresent(false) == GPUDevice::PresentResult::OK)
if (g_gpu_device->BeginPresent() == GPUDevice::PresentResult::OK)
{
g_gpu_device->RenderImGui();
g_gpu_device->EndPresent(false);
Expand Down
28 changes: 10 additions & 18 deletions src/core/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@ void System::FrameDone()
const bool explicit_present = (throttle_before_present && g_gpu_device->GetFeatures().explicit_present);
if (explicit_present)
{
const bool do_present = PresentDisplay(false, true);
const bool do_present = PresentDisplay(true);
Throttle(current_time);
if (do_present)
g_gpu_device->SubmitPresent();
Expand All @@ -2176,7 +2176,7 @@ void System::FrameDone()
if (throttle_before_present)
Throttle(current_time);

PresentDisplay(false, false);
PresentDisplay(false);

if (!throttle_before_present && s_throttler_enabled && !IsExecutionInterrupted())
Throttle(current_time);
Expand Down Expand Up @@ -5731,31 +5731,23 @@ void System::HostDisplayResized()
g_gpu->UpdateResolutionScale();
}

bool System::PresentDisplay(bool skip_present, bool explicit_present)
bool System::PresentDisplay(bool explicit_present)
{
// acquire for IO.MousePos.
std::atomic_thread_fence(std::memory_order_acquire);

if (!skip_present)
{
FullscreenUI::Render();
ImGuiManager::RenderTextOverlays();
ImGuiManager::RenderOSDMessages();
FullscreenUI::Render();
ImGuiManager::RenderTextOverlays();
ImGuiManager::RenderOSDMessages();

if (s_state == State::Running)
ImGuiManager::RenderSoftwareCursors();
}
if (s_state == State::Running)
ImGuiManager::RenderSoftwareCursors();

// Debug windows are always rendered, otherwise mouse input breaks on skip.
ImGuiManager::RenderOverlayWindows();
ImGuiManager::RenderDebugWindows();

GPUDevice::PresentResult pres;
if (g_gpu && !skip_present)
pres = g_gpu->PresentDisplay();
else
pres = g_gpu_device->BeginPresent(skip_present);

const GPUDevice::PresentResult pres = g_gpu ? g_gpu->PresentDisplay() : g_gpu_device->BeginPresent();
if (pres == GPUDevice::PresentResult::OK)
{
g_gpu_device->RenderImGui();
Expand Down Expand Up @@ -5783,7 +5775,7 @@ bool System::PresentDisplay(bool skip_present, bool explicit_present)

void System::InvalidateDisplay()
{
PresentDisplay(false, false);
PresentDisplay(false);

if (g_gpu)
g_gpu->RestoreDeviceContext();
Expand Down
2 changes: 1 addition & 1 deletion src/core/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void RequestDisplaySize(float scale = 0.0f);
void HostDisplayResized();

/// Renders the display.
bool PresentDisplay(bool skip_present, bool explicit_present);
bool PresentDisplay(bool explicit_present);
void InvalidateDisplay();

//////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/duckstation-qt/qthost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ void EmuThread::run()
System::Internal::IdlePollUpdate();
if (g_gpu_device)
{
System::PresentDisplay(false, false);
System::PresentDisplay(false);
if (!g_gpu_device->IsVSyncModeBlocking())
g_gpu_device->ThrottlePresentation();
}
Expand Down
5 changes: 1 addition & 4 deletions src/util/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,8 @@ void D3D11Device::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle)
}
}

GPUDevice::PresentResult D3D11Device::BeginPresent(bool skip_present, u32 clear_color)
GPUDevice::PresentResult D3D11Device::BeginPresent(u32 clear_color)
{
if (skip_present)
return PresentResult::SkipPresent;

if (!m_swap_chain)
{
// Note: Really slow on Intel...
Expand Down
2 changes: 1 addition & 1 deletion src/util/d3d11_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class D3D11Device final : public GPUDevice
bool SetGPUTimingEnabled(bool enabled) override;
float GetAndResetAccumulatedGPUTime() override;

PresentResult BeginPresent(bool skip_present, u32 clear_color) override;
PresentResult BeginPresent(u32 clear_color) override;
void EndPresent(bool explicit_present) override;
void SubmitPresent() override;

Expand Down
5 changes: 1 addition & 4 deletions src/util/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,17 +1123,14 @@ void D3D12Device::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle)
}
}

GPUDevice::PresentResult D3D12Device::BeginPresent(bool frame_skip, u32 clear_color)
GPUDevice::PresentResult D3D12Device::BeginPresent(u32 clear_color)
{
if (InRenderPass())
EndRenderPass();

if (m_device_was_lost) [[unlikely]]
return PresentResult::DeviceLost;

if (frame_skip)
return PresentResult::SkipPresent;

// If we're running surfaceless, kick the command buffer so we don't run out of descriptors.
if (!m_swap_chain)
{
Expand Down
2 changes: 1 addition & 1 deletion src/util/d3d12_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class D3D12Device final : public GPUDevice
bool SetGPUTimingEnabled(bool enabled) override;
float GetAndResetAccumulatedGPUTime() override;

PresentResult BeginPresent(bool skip_present, u32 clear_color) override;
PresentResult BeginPresent(u32 clear_color) override;
void EndPresent(bool explicit_present) override;
void SubmitPresent() override;

Expand Down
2 changes: 1 addition & 1 deletion src/util/gpu_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ class GPUDevice
virtual void DrawIndexedWithBarrier(u32 index_count, u32 base_index, u32 base_vertex, DrawBarrier type) = 0;

/// Returns false if the window was completely occluded.
virtual PresentResult BeginPresent(bool skip_present, u32 clear_color = DEFAULT_CLEAR_COLOR) = 0;
virtual PresentResult BeginPresent(u32 clear_color = DEFAULT_CLEAR_COLOR) = 0;
virtual void EndPresent(bool explicit_submit) = 0;
virtual void SubmitPresent() = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/util/metal_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class MetalDevice final : public GPUDevice

void SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle) override;

PresentResult BeginPresent(bool skip_present, u32 clear_color) override;
PresentResult BeginPresent(u32 clear_color) override;
void EndPresent(bool explicit_submit) override;
void SubmitPresent() override;

Expand Down
5 changes: 1 addition & 4 deletions src/util/metal_device.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2312,13 +2312,10 @@ static void DumpShader(u32 n, std::string_view suffix, std::string_view data)
}
}

GPUDevice::PresentResult MetalDevice::BeginPresent(bool skip_present, u32 clear_color)
GPUDevice::PresentResult MetalDevice::BeginPresent(u32 clear_color)
{
@autoreleasepool
{
if (skip_present)
return PresentResult::SkipPresent;

if (m_layer == nil)
{
TrimTexturePool();
Expand Down
12 changes: 4 additions & 8 deletions src/util/opengl_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,16 +740,12 @@ void OpenGLDevice::DestroyBuffers()
m_vertex_buffer.reset();
}

GPUDevice::PresentResult OpenGLDevice::BeginPresent(bool skip_present, u32 clear_color)
GPUDevice::PresentResult OpenGLDevice::BeginPresent(u32 clear_color)
{
if (skip_present || m_window_info.type == WindowInfo::Type::Surfaceless)
if (m_window_info.type == WindowInfo::Type::Surfaceless)
{
if (!skip_present)
{
glFlush();
TrimTexturePool();
}

glFlush();
TrimTexturePool();
return PresentResult::SkipPresent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/opengl_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class OpenGLDevice final : public GPUDevice

void SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle) override;

PresentResult BeginPresent(bool skip_present, u32 clear_color) override;
PresentResult BeginPresent(u32 clear_color) override;
void EndPresent(bool explicit_present) override;
void SubmitPresent() override;

Expand Down
2 changes: 1 addition & 1 deletion src/util/postprocessing_shader_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,7 @@ GPUDevice::PresentResult PostProcessing::ReShadeFXShader::Apply(GPUTexture* inpu
if (pass.render_targets.size() == 1 && pass.render_targets[0] == OUTPUT_COLOR_TEXTURE && !final_target)
{
// Special case: drawing to final buffer.
if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(false); pres != GPUDevice::PresentResult::OK)
if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(); pres != GPUDevice::PresentResult::OK)
{
GL_POP();
return pres;
Expand Down
2 changes: 1 addition & 1 deletion src/util/postprocessing_shader_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ GPUDevice::PresentResult PostProcessing::GLSLShader::Apply(GPUTexture* input_col
// Assumes final stage has been cleared already.
if (!final_target)
{
if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(false); pres != GPUDevice::PresentResult::OK)
if (const GPUDevice::PresentResult pres = g_gpu_device->BeginPresent(); pres != GPUDevice::PresentResult::OK)
return pres;
}
else
Expand Down
5 changes: 1 addition & 4 deletions src/util/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2342,17 +2342,14 @@ void VulkanDevice::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle)
}
}

GPUDevice::PresentResult VulkanDevice::BeginPresent(bool frame_skip, u32 clear_color)
GPUDevice::PresentResult VulkanDevice::BeginPresent(u32 clear_color)
{
if (InRenderPass())
EndRenderPass();

if (m_device_was_lost) [[unlikely]]
return PresentResult::DeviceLost;

if (frame_skip)
return PresentResult::SkipPresent;

// If we're running surfaceless, kick the command buffer so we don't run out of descriptors.
if (!m_swap_chain)
{
Expand Down
2 changes: 1 addition & 1 deletion src/util/vulkan_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class VulkanDevice final : public GPUDevice

void SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle) override;

PresentResult BeginPresent(bool skip_present, u32 clear_color) override;
PresentResult BeginPresent(u32 clear_color) override;
void EndPresent(bool explicit_present) override;
void SubmitPresent() override;

Expand Down

0 comments on commit ac5a2a1

Please sign in to comment.