mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
- Fix vk_hdr looking for the wrong colorspace
This commit is contained in:
parent
6aed119403
commit
dd2d9f4182
3 changed files with 18 additions and 29 deletions
|
@ -220,7 +220,7 @@ void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool
|
|||
uniforms.Offset = { 0.0f, 1.0f };
|
||||
}
|
||||
|
||||
if (applyGamma && fb->swapChain->swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT && !screenshot)
|
||||
if (applyGamma && fb->swapChain->IsHdrModeActive() && !screenshot)
|
||||
{
|
||||
uniforms.HdrMode = 1;
|
||||
}
|
||||
|
|
|
@ -249,6 +249,11 @@ void VulkanSwapChain::CreateViews()
|
|||
}
|
||||
}
|
||||
|
||||
bool VulkanSwapChain::IsHdrModeActive() const
|
||||
{
|
||||
return swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT || swapChainFormat.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
|
||||
}
|
||||
|
||||
void VulkanSwapChain::SelectFormat()
|
||||
{
|
||||
std::vector<VkSurfaceFormatKHR> surfaceFormats = GetSurfaceFormats();
|
||||
|
@ -264,6 +269,16 @@ void VulkanSwapChain::SelectFormat()
|
|||
|
||||
if (vk_hdr)
|
||||
{
|
||||
for (const auto& format : surfaceFormats)
|
||||
{
|
||||
if (format.format == VK_FORMAT_R16G16B16A16_SFLOAT && format.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT)
|
||||
{
|
||||
swapChainFormat = format;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// For older drivers that reported the wrong colorspace
|
||||
for (const auto &format : surfaceFormats)
|
||||
{
|
||||
if (format.format == VK_FORMAT_R16G16B16A16_SFLOAT && format.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT)
|
||||
|
@ -312,33 +327,6 @@ void VulkanSwapChain::SelectPresentMode()
|
|||
}
|
||||
}
|
||||
|
||||
void VulkanSwapChain::SetHdrMetadata()
|
||||
{
|
||||
if (swapChainFormat.colorSpace != VK_COLOR_SPACE_HDR10_ST2084_EXT)
|
||||
return;
|
||||
|
||||
// Mastering display with HDR10_ST2084 color primaries and D65 white point,
|
||||
// maximum luminance of 1000 nits and minimum luminance of 0.001 nits;
|
||||
// content has maximum luminance of 2000 nits and maximum frame average light level (MaxFALL) of 500 nits.
|
||||
|
||||
VkHdrMetadataEXT metadata = {};
|
||||
metadata.sType = VK_STRUCTURE_TYPE_HDR_METADATA_EXT;
|
||||
metadata.displayPrimaryRed.x = 0.708f;
|
||||
metadata.displayPrimaryRed.y = 0.292f;
|
||||
metadata.displayPrimaryGreen.x = 0.170f;
|
||||
metadata.displayPrimaryGreen.y = 0.797f;
|
||||
metadata.displayPrimaryBlue.x = 0.131f;
|
||||
metadata.displayPrimaryBlue.y = 0.046f;
|
||||
metadata.whitePoint.x = 0.3127f;
|
||||
metadata.whitePoint.y = 0.3290f;
|
||||
metadata.maxLuminance = 1000.0f;
|
||||
metadata.minLuminance = 0.001f;
|
||||
metadata.maxContentLightLevel = 2000.0f;
|
||||
metadata.maxFrameAverageLightLevel = 500.0f;
|
||||
|
||||
vkSetHdrMetadataEXT(device->device, 1, &swapChain, &metadata);
|
||||
}
|
||||
|
||||
void VulkanSwapChain::GetImages()
|
||||
{
|
||||
uint32_t imageCount;
|
||||
|
|
|
@ -17,6 +17,8 @@ public:
|
|||
|
||||
void Recreate();
|
||||
|
||||
bool IsHdrModeActive() const;
|
||||
|
||||
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
||||
VkSurfaceFormatKHR swapChainFormat;
|
||||
VkPresentModeKHR swapChainPresentMode;
|
||||
|
@ -32,7 +34,6 @@ private:
|
|||
void SelectPresentMode();
|
||||
bool CreateSwapChain(VkSwapchainKHR oldSwapChain = VK_NULL_HANDLE);
|
||||
void CreateViews();
|
||||
void SetHdrMetadata();
|
||||
void GetImages();
|
||||
void ReleaseResources();
|
||||
void ReleaseViews();
|
||||
|
|
Loading…
Reference in a new issue