mirror of
https://github.com/love2d/love.git
synced 2026-08-21 21:15:09 +02:00
support more swapchain image formats
This commit is contained in:
@@ -514,7 +514,7 @@ void Graphics::present(void *screenshotCallbackdata)
|
|||||||
|
|
||||||
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight)
|
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight)
|
||||||
{
|
{
|
||||||
if (swapChain != VK_NULL_HANDLE && (pixelWidth != this->pixelWidth || pixelHeight != this->pixelHeight || width != this->width || height != this->height))
|
if (swapChain != VK_NULL_HANDLE && (pixelwidth != this->pixelWidth || pixelheight != this->pixelHeight || width != this->width || height != this->height))
|
||||||
requestSwapchainRecreation();
|
requestSwapchainRecreation();
|
||||||
|
|
||||||
this->width = width;
|
this->width = width;
|
||||||
@@ -1850,19 +1850,33 @@ void Graphics::createSwapChain()
|
|||||||
|
|
||||||
VkSurfaceFormatKHR Graphics::chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR> &availableFormats)
|
VkSurfaceFormatKHR Graphics::chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR> &availableFormats)
|
||||||
{
|
{
|
||||||
|
std::vector<VkFormat> formatOrder;
|
||||||
|
|
||||||
// TODO: turn off GammaCorrect if a sRGB format can't be found?
|
// TODO: turn off GammaCorrect if a sRGB format can't be found?
|
||||||
|
// TODO: does every platform have these formats?
|
||||||
if (isGammaCorrect())
|
if (isGammaCorrect())
|
||||||
{
|
{
|
||||||
for (const auto &availableFormat : availableFormats)
|
formatOrder = {
|
||||||
// fixme: what if this format and colorspace is not available?
|
VK_FORMAT_B8G8R8A8_SRGB,
|
||||||
if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
|
VK_FORMAT_R8G8B8A8_SRGB,
|
||||||
return availableFormat;
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
formatOrder = {
|
||||||
|
VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
VK_FORMAT_R8G8B8A8_SNORM,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto format : formatOrder)
|
||||||
|
{
|
||||||
for (const auto &availableFormat : availableFormats)
|
for (const auto &availableFormat : availableFormats)
|
||||||
// fixme: what if this format and colorspace is not available?
|
{
|
||||||
if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
|
if (availableFormat.format == format && availableFormat.colorSpace == VK_COLORSPACE_SRGB_NONLINEAR_KHR)
|
||||||
return availableFormat;
|
return availableFormat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return availableFormats[0];
|
return availableFormats[0];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user