mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- apply vk_hdr immediately and delay initial swapchain creation until first image needs to be acquired
This commit is contained in:
parent
db4310ca6b
commit
095ea3ce76
4 changed files with 13 additions and 28 deletions
|
@ -549,11 +549,7 @@ uint32_t VulkanFrameBuffer::GetCaps()
|
|||
|
||||
void VulkanFrameBuffer::SetVSync(bool vsync)
|
||||
{
|
||||
if (swapChain->vsync != vsync)
|
||||
{
|
||||
swapChain.reset();
|
||||
swapChain = std::make_unique<VulkanSwapChain>(device);
|
||||
}
|
||||
// This is handled in VulkanSwapChain::AcquireImage.
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::CleanForRestart()
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
TArray<uint8_t> GetScreenshotBuffer(int &pitch, ESSType &color_type, float &gamma) override;
|
||||
|
||||
void SetVSync(bool vsync);
|
||||
void SetVSync(bool vsync) override;
|
||||
|
||||
void Draw2D() override;
|
||||
|
||||
|
|
|
@ -6,29 +6,12 @@
|
|||
|
||||
EXTERN_CVAR(Bool, vid_vsync);
|
||||
|
||||
CUSTOM_CVAR(Bool, vk_hdr, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
Printf("This won't take effect until " GAMENAME " is restarted.\n");
|
||||
}
|
||||
CVAR(Bool, vk_hdr, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
||||
void I_GetVulkanDrawableSize(int *width, int *height);
|
||||
|
||||
VulkanSwapChain::VulkanSwapChain(VulkanDevice *device) : vsync(vid_vsync), device(device)
|
||||
VulkanSwapChain::VulkanSwapChain(VulkanDevice *device) : device(device)
|
||||
{
|
||||
try
|
||||
{
|
||||
SelectFormat();
|
||||
SelectPresentMode();
|
||||
if (!CreateSwapChain())
|
||||
I_Error("Could not create vulkan swapchain");
|
||||
GetImages();
|
||||
CreateViews();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ReleaseResources();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
VulkanSwapChain::~VulkanSwapChain()
|
||||
|
@ -38,11 +21,13 @@ VulkanSwapChain::~VulkanSwapChain()
|
|||
|
||||
uint32_t VulkanSwapChain::AcquireImage(int width, int height, VulkanSemaphore *semaphore, VulkanFence *fence)
|
||||
{
|
||||
if (lastSwapWidth != width || lastSwapHeight != height || !swapChain)
|
||||
if (lastSwapWidth != width || lastSwapHeight != height || lastVsync != vid_vsync || lastHdr != vk_hdr || !swapChain)
|
||||
{
|
||||
Recreate();
|
||||
lastSwapWidth = width;
|
||||
lastSwapHeight = height;
|
||||
lastVsync = vid_vsync;
|
||||
lastHdr = vk_hdr;
|
||||
}
|
||||
|
||||
uint32_t imageIndex;
|
||||
|
@ -132,6 +117,9 @@ void VulkanSwapChain::Recreate()
|
|||
|
||||
bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
|
||||
{
|
||||
SelectFormat();
|
||||
SelectPresentMode();
|
||||
|
||||
int width, height;
|
||||
I_GetVulkanDrawableSize(&width, &height);
|
||||
|
||||
|
@ -266,7 +254,7 @@ void VulkanSwapChain::SelectPresentMode()
|
|||
I_Error("No surface present modes supported");
|
||||
|
||||
swapChainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
if (vsync)
|
||||
if (vid_vsync)
|
||||
{
|
||||
bool supportsFifoRelaxed = std::find(presentModes.begin(), presentModes.end(), VK_PRESENT_MODE_FIFO_RELAXED_KHR) != presentModes.end();
|
||||
if (supportsFifoRelaxed)
|
||||
|
|
|
@ -16,7 +16,6 @@ public:
|
|||
|
||||
void Recreate();
|
||||
|
||||
bool vsync;
|
||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||
VkSurfaceFormatKHR swapChainFormat;
|
||||
VkPresentModeKHR swapChainPresentMode;
|
||||
|
@ -44,6 +43,8 @@ private:
|
|||
|
||||
int lastSwapWidth = 0;
|
||||
int lastSwapHeight = 0;
|
||||
bool lastVsync = false;
|
||||
bool lastHdr = false;
|
||||
|
||||
VulkanSwapChain(const VulkanSwapChain &) = delete;
|
||||
VulkanSwapChain &operator=(const VulkanSwapChain &) = delete;
|
||||
|
|
Loading…
Reference in a new issue