Merge branch 'love2d:12.0-development' into 12.0-development

This commit is contained in:
nikeinikei
2022-12-21 17:20:43 +01:00
committed by GitHub
51 changed files with 1335 additions and 523 deletions
+19 -19
View File
@@ -28,7 +28,7 @@
#include "Shader.h"
#include "Vulkan.h"
#include "SDL_vulkan.h"
#include <SDL_vulkan.h>
#include <algorithm>
#include <vector>
@@ -468,7 +468,8 @@ void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelh
this->pixelWidth = pixelwidth;
this->pixelHeight = pixelheight;
resetProjection();
if (!isRenderTargetActive())
resetProjection();
}
bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa)
@@ -476,6 +477,9 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
requestedMsaa = msaa;
windowHasStencil = windowhasstencil;
// Must be called before the swapchain is created.
setViewportSize(width, height, pixelwidth, pixelheight);
cleanUpFunctions.clear();
cleanUpFunctions.resize(MAX_FRAMES_IN_FLIGHT);
@@ -529,8 +533,6 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
restoreState(states.back());
setViewportSize(width, height, pixelwidth, pixelheight);
Vulkan::resetShaderSwitches();
frameCounter = 0;
@@ -1783,16 +1785,20 @@ VkPresentModeKHR Graphics::chooseSwapPresentMode(const std::vector<VkPresentMode
else
return VK_PRESENT_MODE_FIFO_KHR;
case 0:
if (std::find(begin, end, VK_PRESENT_MODE_MAILBOX_KHR) != end)
// Mailbox mode might be better than immediate mode for a lot of people.
// But on at least some systems it acts as if vsync is enabled
// https://github.com/love2d/love/issues/1852
// TODO: is that a bug in love's code or the graphics driver / compositor?
// Should love expose mailbox mode in an API to users in some manner,
// instead of trying to guess what to do?
if (std::find(begin, end, VK_PRESENT_MODE_IMMEDIATE_KHR) != end)
return VK_PRESENT_MODE_IMMEDIATE_KHR;
else if (std::find(begin, end, VK_PRESENT_MODE_MAILBOX_KHR) != end)
return VK_PRESENT_MODE_MAILBOX_KHR;
else
{
if (std::find(begin, end, VK_PRESENT_MODE_IMMEDIATE_KHR) != end)
return VK_PRESENT_MODE_IMMEDIATE_KHR;
else
return VK_PRESENT_MODE_FIFO_KHR;
}
return VK_PRESENT_MODE_FIFO_KHR;
default:
// TODO: support for swap interval = 2, etc?
return VK_PRESENT_MODE_FIFO_KHR;
}
}
@@ -1814,15 +1820,9 @@ VkExtent2D Graphics::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabiliti
return capabilities.currentExtent;
else
{
auto window = Module::getInstance<love::window::Window>(M_WINDOW);
const void *handle = window->getHandle();
int width, height;
SDL_Vulkan_GetDrawableSize((SDL_Window*)handle, &width, &height);
VkExtent2D actualExtent = {
static_cast<uint32_t>(width),
static_cast<uint32_t>(height)
static_cast<uint32_t>(pixelWidth),
static_cast<uint32_t>(pixelHeight)
};
actualExtent.width = clampuint32_t(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);