mirror of https://github.com/snes9xgit/snes9x.git
Win32: Allow the Vulkan driver to fail at the loader stage.
This commit is contained in:
parent
929a213b71
commit
3c50e995ee
|
@ -12,17 +12,6 @@ static std::unique_ptr<vk::DynamicLoader> dl;
|
||||||
|
|
||||||
Context::Context()
|
Context::Context()
|
||||||
{
|
{
|
||||||
if (!dl)
|
|
||||||
{
|
|
||||||
dl = std::make_unique<vk::DynamicLoader>();
|
|
||||||
if (!dl->success())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto vkGetInstanceProcAddr =
|
|
||||||
dl->getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
|
||||||
|
|
||||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context()
|
Context::~Context()
|
||||||
|
@ -44,8 +33,28 @@ Context::~Context()
|
||||||
device.destroy();
|
device.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool load_loader()
|
||||||
|
{
|
||||||
|
if (dl)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
dl = std::make_unique<vk::DynamicLoader>();
|
||||||
|
if (!dl->success())
|
||||||
|
{
|
||||||
|
dl.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto vkGetInstanceProcAddr =
|
||||||
|
dl->getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
||||||
|
|
||||||
|
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static vk::UniqueInstance create_instance_preamble(const char *wsi_extension)
|
static vk::UniqueInstance create_instance_preamble(const char *wsi_extension)
|
||||||
{
|
{
|
||||||
|
load_loader();
|
||||||
if (!dl || !dl->success())
|
if (!dl || !dl->success())
|
||||||
return vk::UniqueInstance();
|
return vk::UniqueInstance();
|
||||||
|
|
||||||
|
|
|
@ -98,15 +98,6 @@ void WinChangeWindowSize(unsigned int newWidth, unsigned int newHeight)
|
||||||
S9xDisplayOutput->ChangeRenderSize(newWidth,newHeight);
|
S9xDisplayOutput->ChangeRenderSize(newWidth,newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FlushMessageQueue()
|
|
||||||
{
|
|
||||||
for (MSG msg; PeekMessage(&msg, GUI.hWnd, 0, 0, PM_NOREMOVE);)
|
|
||||||
{
|
|
||||||
GetMessage(&msg, GUI.hWnd, 0, 0);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* WinDisplayReset
|
/* WinDisplayReset
|
||||||
initializes the currently selected display output and
|
initializes the currently selected display output and
|
||||||
reinitializes the core graphics rendering
|
reinitializes the core graphics rendering
|
||||||
|
@ -115,10 +106,10 @@ returns true if successful, false otherwise
|
||||||
*/
|
*/
|
||||||
bool WinDisplayReset(void)
|
bool WinDisplayReset(void)
|
||||||
{
|
{
|
||||||
|
const TCHAR* driverNames[] = { TEXT("DirectDraw"), TEXT("Direct3D"), TEXT("OpenGL"), TEXT("Vulkan") };
|
||||||
static bool VulkanUsed = false;
|
static bool VulkanUsed = false;
|
||||||
static bool OpenGLUsed = false;
|
static bool OpenGLUsed = false;
|
||||||
S9xDisplayOutput->DeInitialize();
|
S9xDisplayOutput->DeInitialize();
|
||||||
FlushMessageQueue();
|
|
||||||
|
|
||||||
switch(GUI.outputMethod) {
|
switch(GUI.outputMethod) {
|
||||||
default:
|
default:
|
||||||
|
@ -137,7 +128,6 @@ bool WinDisplayReset(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
S9xDisplayOutput = &OpenGL;
|
S9xDisplayOutput = &OpenGL;
|
||||||
OpenGLUsed = true;
|
|
||||||
break;
|
break;
|
||||||
case VULKAN:
|
case VULKAN:
|
||||||
if (OpenGLUsed)
|
if (OpenGLUsed)
|
||||||
|
@ -146,7 +136,6 @@ bool WinDisplayReset(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
S9xDisplayOutput = &VulkanDriver;
|
S9xDisplayOutput = &VulkanDriver;
|
||||||
VulkanUsed = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +144,33 @@ bool WinDisplayReset(void)
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
S9xDisplayOutput->DeInitialize();
|
S9xDisplayOutput->DeInitialize();
|
||||||
Sleep(500);
|
Sleep(500);
|
||||||
|
|
||||||
|
auto oldDriverName = driverNames[GUI.outputMethod];
|
||||||
|
|
||||||
|
if (GUI.outputMethod == VULKAN)
|
||||||
|
{
|
||||||
|
GUI.outputMethod = OPENGL;
|
||||||
|
S9xDisplayOutput = &OpenGL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUI.outputMethod = DIRECT3D;
|
||||||
|
S9xDisplayOutput = &Direct3D;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto newDriverName = driverNames[GUI.outputMethod];
|
||||||
|
TCHAR msg[512];
|
||||||
|
_stprintf(msg, TEXT("Couldn't load selected driver: %s. Trying %s."), oldDriverName, newDriverName);
|
||||||
|
MessageBox(GUI.hWnd, msg, TEXT("Snes9x Display Driver"), MB_OK | MB_ICONERROR);
|
||||||
|
|
||||||
initialized = S9xDisplayOutput->Initialize(GUI.hWnd);
|
initialized = S9xDisplayOutput->Initialize(GUI.hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
|
if (S9xDisplayOutput == &VulkanDriver)
|
||||||
|
VulkanUsed = true;
|
||||||
|
if (S9xDisplayOutput == &OpenGL)
|
||||||
|
OpenGLUsed = true;
|
||||||
S9xGraphicsDeinit();
|
S9xGraphicsDeinit();
|
||||||
S9xSetWinPixelFormat();
|
S9xSetWinPixelFormat();
|
||||||
S9xGraphicsInit();
|
S9xGraphicsInit();
|
||||||
|
|
Loading…
Reference in New Issue