mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- implemented OpenGL / Vulkan switch in SDL backend
This commit is contained in:
parent
aa84f7b3e6
commit
7b5eedea32
3 changed files with 23 additions and 22 deletions
|
@ -72,6 +72,7 @@ EXTERN_CVAR (Int, vid_displaybits)
|
||||||
EXTERN_CVAR (Int, vid_maxfps)
|
EXTERN_CVAR (Int, vid_maxfps)
|
||||||
EXTERN_CVAR (Int, vid_defwidth)
|
EXTERN_CVAR (Int, vid_defwidth)
|
||||||
EXTERN_CVAR (Int, vid_defheight)
|
EXTERN_CVAR (Int, vid_defheight)
|
||||||
|
EXTERN_CVAR (Int, vid_backend)
|
||||||
EXTERN_CVAR (Bool, cl_capfps)
|
EXTERN_CVAR (Bool, cl_capfps)
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
@ -111,7 +112,7 @@ namespace Priv
|
||||||
static const int MIN_HEIGHT = 200;
|
static const int MIN_HEIGHT = 200;
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
bool vulkanSupported;
|
bool vulkanEnabled;
|
||||||
bool fullscreenSwitch;
|
bool fullscreenSwitch;
|
||||||
|
|
||||||
void CreateWindow(uint32_t extraFlags)
|
void CreateWindow(uint32_t extraFlags)
|
||||||
|
@ -197,7 +198,7 @@ private:
|
||||||
|
|
||||||
void I_GetVulkanDrawableSize(int *width, int *height)
|
void I_GetVulkanDrawableSize(int *width, int *height)
|
||||||
{
|
{
|
||||||
assert(Priv::vulkanSupported);
|
assert(Priv::vulkanEnabled);
|
||||||
assert(Priv::window != nullptr);
|
assert(Priv::window != nullptr);
|
||||||
assert(Priv::Vulkan_GetDrawableSize);
|
assert(Priv::Vulkan_GetDrawableSize);
|
||||||
Priv::Vulkan_GetDrawableSize(Priv::window, width, height);
|
Priv::Vulkan_GetDrawableSize(Priv::window, width, height);
|
||||||
|
@ -205,17 +206,15 @@ void I_GetVulkanDrawableSize(int *width, int *height)
|
||||||
|
|
||||||
bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
||||||
{
|
{
|
||||||
assert(Priv::vulkanSupported);
|
assert(Priv::vulkanEnabled);
|
||||||
assert(Priv::window != nullptr);
|
assert(Priv::window != nullptr);
|
||||||
assert(Priv::Vulkan_GetInstanceExtensions);
|
|
||||||
return Priv::Vulkan_GetInstanceExtensions(Priv::window, count, names) == SDL_TRUE;
|
return Priv::Vulkan_GetInstanceExtensions(Priv::window, count, names) == SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
||||||
{
|
{
|
||||||
assert(Priv::vulkanSupported);
|
assert(Priv::vulkanEnabled);
|
||||||
assert(Priv::window != nullptr);
|
assert(Priv::window != nullptr);
|
||||||
assert(Priv::Vulkan_CreateSurface);
|
|
||||||
return Priv::Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
|
return Priv::Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,15 +233,16 @@ SDLVideo::SDLVideo ()
|
||||||
Priv::library.Load({ "libSDL2.so", "libSDL2-2.0.so" });
|
Priv::library.Load({ "libSDL2.so", "libSDL2-2.0.so" });
|
||||||
}
|
}
|
||||||
|
|
||||||
Priv::vulkanSupported = Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface;
|
Priv::vulkanEnabled = vid_backend == 0
|
||||||
|
&& Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface;
|
||||||
|
|
||||||
if (Priv::vulkanSupported)
|
if (Priv::vulkanEnabled)
|
||||||
{
|
{
|
||||||
Priv::CreateWindow(Priv::VulkanWindowFlag | SDL_WINDOW_HIDDEN);
|
Priv::CreateWindow(Priv::VulkanWindowFlag | SDL_WINDOW_HIDDEN);
|
||||||
|
|
||||||
if (Priv::window == nullptr)
|
if (Priv::window == nullptr)
|
||||||
{
|
{
|
||||||
Priv::vulkanSupported = false;
|
Priv::vulkanEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
|
||||||
SystemBaseFrameBuffer *fb = nullptr;
|
SystemBaseFrameBuffer *fb = nullptr;
|
||||||
|
|
||||||
// first try Vulkan, if that fails OpenGL
|
// first try Vulkan, if that fails OpenGL
|
||||||
if (Priv::vulkanSupported)
|
if (Priv::vulkanEnabled)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -267,7 +267,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
|
||||||
}
|
}
|
||||||
catch (CRecoverableError const&)
|
catch (CRecoverableError const&)
|
||||||
{
|
{
|
||||||
Priv::vulkanSupported = false;
|
Priv::vulkanEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ int SystemBaseFrameBuffer::GetClientWidth()
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
assert(Priv::vulkanSupported);
|
assert(Priv::vulkanEnabled);
|
||||||
Priv::Vulkan_GetDrawableSize(Priv::window, &width, nullptr);
|
Priv::Vulkan_GetDrawableSize(Priv::window, &width, nullptr);
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
|
@ -312,7 +312,7 @@ int SystemBaseFrameBuffer::GetClientHeight()
|
||||||
{
|
{
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
|
||||||
assert(Priv::vulkanSupported);
|
assert(Priv::vulkanEnabled);
|
||||||
Priv::Vulkan_GetDrawableSize(Priv::window, nullptr, &height);
|
Priv::Vulkan_GetDrawableSize(Priv::window, nullptr, &height);
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
|
|
@ -113,6 +113,15 @@ CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN
|
||||||
// No further checks needed. All this changes now is which scene drawer the render backend calls.
|
// No further checks needed. All this changes now is which scene drawer the render backend calls.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUSTOM_CVAR(Int, vid_backend, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||||
|
{
|
||||||
|
// [SP] This may seem pointless - but I don't want to implement live switching just
|
||||||
|
// yet - I'm pretty sure it's going to require a lot of reinits and destructions to
|
||||||
|
// do it right without memory leaks
|
||||||
|
|
||||||
|
Printf("Changing the video backend requires a restart for " GAMENAME ".\n");
|
||||||
|
}
|
||||||
|
|
||||||
CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window...
|
CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window...
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,15 +50,7 @@
|
||||||
#include "swrenderer/r_swrenderer.h"
|
#include "swrenderer/r_swrenderer.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Int, vid_maxfps)
|
EXTERN_CVAR(Int, vid_maxfps)
|
||||||
|
EXTERN_CVAR(Int, vid_backend)
|
||||||
CUSTOM_CVAR(Int, vid_backend, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
|
||||||
{
|
|
||||||
// [SP] This may seem pointless - but I don't want to implement live switching just
|
|
||||||
// yet - I'm pretty sure it's going to require a lot of reinits and destructions to
|
|
||||||
// do it right without memory leaks
|
|
||||||
|
|
||||||
Printf("Changing the video backend requires a restart for " GAMENAME ".\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
extern HWND Window;
|
extern HWND Window;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue