Vulkan fastforward: Check the current presentation mode instead of the Vsync setting.

After 1.15, I'm gonna clean up the presentation mode/vsync management
across the code base. This works around #17308 for now.
This commit is contained in:
Henrik Rydgård 2023-04-26 11:09:33 +02:00
parent 2d2f23bd6c
commit 42ce619705
6 changed files with 37 additions and 1 deletions

View File

@ -75,6 +75,10 @@ public:
return (uint32_t)ShaderLanguage::HLSL_D3D11;
}
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
PresentationMode GetPresentationMode() const override {
// TODO: Fix. Not yet used.
return PresentationMode::FIFO;
}
InputLayout *CreateInputLayout(const InputLayoutDesc &desc) override;
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;

View File

@ -514,6 +514,10 @@ public:
return (uint32_t)ShaderLanguage::HLSL_D3D9;
}
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
PresentationMode GetPresentationMode() const override {
// TODO: Fix. Not yet used.
return PresentationMode::FIFO;
}
ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize, const char *tag) override;
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;

View File

@ -346,6 +346,11 @@ public:
renderManager_.SetErrorCallback(callback, userdata);
}
PresentationMode GetPresentationMode() const override {
// TODO: Fix. Not yet used.
return PresentationMode::FIFO;
}
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
SamplerState *CreateSamplerState(const SamplerStateDesc &desc) override;

View File

@ -398,6 +398,16 @@ public:
}
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
PresentationMode GetPresentationMode() const override {
switch (vulkan_->GetPresentMode()) {
case VK_PRESENT_MODE_FIFO_KHR: return PresentationMode::FIFO;
case VK_PRESENT_MODE_FIFO_RELAXED_KHR: return PresentationMode::FIFO_RELAXED;
case VK_PRESENT_MODE_IMMEDIATE_KHR: return PresentationMode::IMMEDIATE;
case VK_PRESENT_MODE_MAILBOX_KHR: return PresentationMode::MAILBOX;
default: return PresentationMode::FIFO;
}
}
DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) override;
BlendState *CreateBlendState(const BlendStateDesc &desc) override;
InputLayout *CreateInputLayout(const InputLayoutDesc &desc) override;

View File

@ -652,6 +652,13 @@ enum class DebugFlags {
};
ENUM_CLASS_BITOPS(DebugFlags);
enum class PresentationMode {
FIFO,
FIFO_RELAXED,
IMMEDIATE,
MAILBOX,
};
class DrawContext {
public:
virtual ~DrawContext();
@ -666,6 +673,8 @@ public:
virtual std::vector<std::string> GetExtensionList() const { return std::vector<std::string>(); }
virtual std::vector<std::string> GetDeviceList() const { return std::vector<std::string>(); }
virtual PresentationMode GetPresentationMode() const = 0;
// Describes the primary shader language that this implementation prefers.
const ShaderLanguageDesc &GetShaderLanguageDesc() {
return shaderLanguageDesc_;

View File

@ -546,8 +546,12 @@ void __DisplayFlip(int cyclesLate) {
bool duplicateFrames = g_Config.bRenderDuplicateFrames && g_Config.iFrameSkip == 0;
bool fastForwardSkipFlip = g_Config.iFastForwardMode != (int)FastForwardMode::CONTINUOUS;
if (g_Config.bVSync && GetGPUBackend() == GPUBackend::VULKAN) {
bool fifo = gpu && gpu->GetDrawContext() && gpu->GetDrawContext()->GetPresentationMode() == Draw::PresentationMode::FIFO;
if (fifo && GetGPUBackend() == GPUBackend::VULKAN) {
// Vulkan doesn't support the interval setting, so we force skipping the flip.
// TODO: We'll clean this up in a more backend-independent way later.
fastForwardSkipFlip = true;
}