gpu/vulkan renderer: Reconfigure the window on renderer creation if it has the OpenGL flag

In some cases, conflicts can occur at the platform or driver level if a window initially configured for OpenGL is then used with a Vulkan-based renderer. Try to reconfigure or recreate the window in the unlikely event that it has the OpenGL flag set when initializing the Vulkan or GPU renderer to remove any platform or driver-specific OpenGL objects and properties.
This commit is contained in:
Frank Praznik
2026-06-19 13:29:13 -04:00
parent a45ef5dc64
commit e26370810b
2 changed files with 15 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
#include "../../events/SDL_windowevents_c.h"
#include "../../video/SDL_pixels_c.h"
#include "../../video/SDL_sysvideo.h"
#include "../SDL_d3dmath.h"
#include "../SDL_sysrender.h"
#include "SDL_gpu_util.h"
@@ -1745,6 +1746,13 @@ static bool GPU_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
{
GPU_RenderData *data = NULL;
// Clear any OpenGL properties on the window to avoid potential driver conflicts.
SDL_WindowFlags flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_OPENGL) {
flags &= ~SDL_WINDOW_OPENGL;
SDL_ReconfigureWindow(window, flags);
}
SDL_SetupRendererColorspace(renderer, create_props);
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB &&

View File

@@ -4549,6 +4549,13 @@ static bool VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SD
{
VULKAN_RenderData *rendererData;
// Clear any OpenGL properties on the window to avoid potential driver conflicts.
SDL_WindowFlags flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_OPENGL) {
flags &= ~SDL_WINDOW_OPENGL;
SDL_ReconfigureWindow(window, flags);
}
SDL_SetupRendererColorspace(renderer, create_props);
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB &&