mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +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)
|
void VulkanFrameBuffer::SetVSync(bool vsync)
|
||||||
{
|
{
|
||||||
if (swapChain->vsync != vsync)
|
// This is handled in VulkanSwapChain::AcquireImage.
|
||||||
{
|
|
||||||
swapChain.reset();
|
|
||||||
swapChain = std::make_unique<VulkanSwapChain>(device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::CleanForRestart()
|
void VulkanFrameBuffer::CleanForRestart()
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
|
|
||||||
TArray<uint8_t> GetScreenshotBuffer(int &pitch, ESSType &color_type, float &gamma) override;
|
TArray<uint8_t> GetScreenshotBuffer(int &pitch, ESSType &color_type, float &gamma) override;
|
||||||
|
|
||||||
void SetVSync(bool vsync);
|
void SetVSync(bool vsync) override;
|
||||||
|
|
||||||
void Draw2D() override;
|
void Draw2D() override;
|
||||||
|
|
||||||
|
|
|
@ -6,29 +6,12 @@
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vid_vsync);
|
EXTERN_CVAR(Bool, vid_vsync);
|
||||||
|
|
||||||
CUSTOM_CVAR(Bool, vk_hdr, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
CVAR(Bool, vk_hdr, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||||
{
|
|
||||||
Printf("This won't take effect until " GAMENAME " is restarted.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_GetVulkanDrawableSize(int *width, int *height);
|
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()
|
VulkanSwapChain::~VulkanSwapChain()
|
||||||
|
@ -38,11 +21,13 @@ VulkanSwapChain::~VulkanSwapChain()
|
||||||
|
|
||||||
uint32_t VulkanSwapChain::AcquireImage(int width, int height, VulkanSemaphore *semaphore, VulkanFence *fence)
|
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();
|
Recreate();
|
||||||
lastSwapWidth = width;
|
lastSwapWidth = width;
|
||||||
lastSwapHeight = height;
|
lastSwapHeight = height;
|
||||||
|
lastVsync = vid_vsync;
|
||||||
|
lastHdr = vk_hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t imageIndex;
|
uint32_t imageIndex;
|
||||||
|
@ -132,6 +117,9 @@ void VulkanSwapChain::Recreate()
|
||||||
|
|
||||||
bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
|
bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
|
||||||
{
|
{
|
||||||
|
SelectFormat();
|
||||||
|
SelectPresentMode();
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
I_GetVulkanDrawableSize(&width, &height);
|
I_GetVulkanDrawableSize(&width, &height);
|
||||||
|
|
||||||
|
@ -266,7 +254,7 @@ void VulkanSwapChain::SelectPresentMode()
|
||||||
I_Error("No surface present modes supported");
|
I_Error("No surface present modes supported");
|
||||||
|
|
||||||
swapChainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
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();
|
bool supportsFifoRelaxed = std::find(presentModes.begin(), presentModes.end(), VK_PRESENT_MODE_FIFO_RELAXED_KHR) != presentModes.end();
|
||||||
if (supportsFifoRelaxed)
|
if (supportsFifoRelaxed)
|
||||||
|
|
|
@ -16,7 +16,6 @@ public:
|
||||||
|
|
||||||
void Recreate();
|
void Recreate();
|
||||||
|
|
||||||
bool vsync;
|
|
||||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||||
VkSurfaceFormatKHR swapChainFormat;
|
VkSurfaceFormatKHR swapChainFormat;
|
||||||
VkPresentModeKHR swapChainPresentMode;
|
VkPresentModeKHR swapChainPresentMode;
|
||||||
|
@ -44,6 +43,8 @@ private:
|
||||||
|
|
||||||
int lastSwapWidth = 0;
|
int lastSwapWidth = 0;
|
||||||
int lastSwapHeight = 0;
|
int lastSwapHeight = 0;
|
||||||
|
bool lastVsync = false;
|
||||||
|
bool lastHdr = false;
|
||||||
|
|
||||||
VulkanSwapChain(const VulkanSwapChain &) = delete;
|
VulkanSwapChain(const VulkanSwapChain &) = delete;
|
||||||
VulkanSwapChain &operator=(const VulkanSwapChain &) = delete;
|
VulkanSwapChain &operator=(const VulkanSwapChain &) = delete;
|
||||||
|
|
Loading…
Reference in a new issue