mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
vulkan: potentially improved highdpi support.
Mostly untested.
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
#include "Shader.h"
|
||||
#include "Vulkan.h"
|
||||
|
||||
#include "SDL_vulkan.h"
|
||||
#include <SDL_vulkan.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@@ -470,7 +470,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)
|
||||
@@ -478,6 +479,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);
|
||||
|
||||
@@ -531,8 +535,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;
|
||||
@@ -1851,15 +1853,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);
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
// SDL
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
#ifdef LOVE_GRAPHICS_VULKAN
|
||||
#include <SDL_vulkan.h>
|
||||
#endif
|
||||
|
||||
#if defined(LOVE_WINDOWS)
|
||||
#include <windows.h>
|
||||
#include <dwmapi.h>
|
||||
@@ -684,11 +688,16 @@ bool Window::onSizeChanged(int width, int height)
|
||||
windowWidth = width;
|
||||
windowHeight = height;
|
||||
|
||||
// TODO: Use SDL_GetWindowSizeInPixels here when supported.
|
||||
if (glcontext != nullptr)
|
||||
SDL_GL_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
else if (metalView != nullptr)
|
||||
SDL_Metal_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#endif
|
||||
#ifdef LOVE_GRAPHICS_VULKAN
|
||||
else if (windowRenderer == graphics::RENDERER_VULKAN)
|
||||
SDL_Vulkan_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
@@ -716,12 +725,17 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
pixelWidth = windowWidth;
|
||||
pixelHeight = windowHeight;
|
||||
|
||||
// TODO: Use SDL_GetWindowSizeInPixels here when supported.
|
||||
if ((wflags & SDL_WINDOW_OPENGL) != 0)
|
||||
SDL_GL_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
else if ((wflags & SDL_WINDOW_METAL) != 0)
|
||||
SDL_Metal_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#endif
|
||||
#ifdef LOVE_GRAPHICS_VULKAN
|
||||
else if ((wflags & SDL_WINDOW_VULKAN) != 0)
|
||||
SDL_Vulkan_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
||||
#endif
|
||||
|
||||
if ((wflags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user