From 98e9db7fbbbed4a5d9e4c7abc984b6625d42de2d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 13 Mar 2026 17:48:26 +1000 Subject: [PATCH] GPUDevice: Drop SDL window type Never worked properly anyway. Couldn't change modes, since releasing the window destroyed the context, didn't support multi-window, etc. --- src/util/CMakeLists.txt | 7 - src/util/gpu_device.cpp | 7 - src/util/opengl_context.cpp | 18 -- src/util/opengl_context.h | 2 - src/util/opengl_context_sdl.cpp | 281 -------------------------------- src/util/opengl_context_sdl.h | 47 ------ src/util/sdl_video_helpers.h | 54 ------ src/util/util.vcxproj | 6 - src/util/util.vcxproj.filters | 2 - src/util/vulkan_loader.cpp | 160 +----------------- src/util/vulkan_swap_chain.cpp | 18 -- src/util/window_info.h | 1 - 12 files changed, 7 insertions(+), 596 deletions(-) delete mode 100644 src/util/opengl_context_sdl.cpp delete mode 100644 src/util/opengl_context_sdl.h delete mode 100644 src/util/sdl_video_helpers.h diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 36832cc15..0eead48d9 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -201,14 +201,7 @@ if(NOT ANDROID) sdl_audio_stream.cpp sdl_input_source.cpp sdl_input_source.h - sdl_video_helpers.h ) - if(ENABLE_OPENGL) - target_sources(util PRIVATE - opengl_context_sdl.cpp - opengl_context_sdl.h - ) - endif() target_compile_definitions(util PUBLIC ENABLE_SDL ) diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index 2627b3ea9..d8454b828 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -395,13 +395,6 @@ std::optional GPUDevice::GetAdapterListForAPI(Render break; #endif -#ifdef ENABLE_OPENGL - case RenderAPI::OpenGL: - case RenderAPI::OpenGLES: - ret = OpenGLContext::GetAdapterList(window_type, error); - break; -#endif - #ifdef _WIN32 case RenderAPI::D3D11: case RenderAPI::D3D12: diff --git a/src/util/opengl_context.cpp b/src/util/opengl_context.cpp index 838400575..cb4b4fe8e 100644 --- a/src/util/opengl_context.cpp +++ b/src/util/opengl_context.cpp @@ -33,10 +33,6 @@ #endif #endif -#ifdef ENABLE_SDL -#include "opengl_context_sdl.h" -#endif - LOG_CHANNEL(GPUDevice); static void DisableBrokenExtensions(const char* gl_vendor, const char* gl_renderer, const char* gl_version) @@ -165,10 +161,6 @@ std::unique_ptr OpenGLContext::Create(WindowInfo& wi, SurfaceHand if (wi.type == WindowInfoType::Surfaceless) context = OpenGLContextEGL::Create(wi, surface, versions_to_try, error); #endif -#ifdef ENABLE_SDL - if (wi.type == WindowInfoType::SDL) - context = OpenGLContextSDL::Create(wi, surface, versions_to_try, error); -#endif if (!context) return nullptr; @@ -210,13 +202,3 @@ std::unique_ptr OpenGLContext::Create(WindowInfo& wi, SurfaceHand return context; } - -GPUDevice::AdapterInfoList OpenGLContext::GetAdapterList(WindowInfoType window_type, Error* error) -{ -#ifdef ENABLE_SDL - if (window_type == WindowInfoType::SDL) - return OpenGLContextSDL::GetAdapterList(window_type, error); -#endif - - return {}; -} diff --git a/src/util/opengl_context.h b/src/util/opengl_context.h index c48b7aa02..7cf20548f 100644 --- a/src/util/opengl_context.h +++ b/src/util/opengl_context.h @@ -53,8 +53,6 @@ public: static std::unique_ptr Create(WindowInfo& wi, SurfaceHandle* surface, bool prefer_gles_context, Error* error); - static GPUDevice::AdapterInfoList GetAdapterList(WindowInfoType window_type, Error* error); - protected: Version m_version = {}; }; diff --git a/src/util/opengl_context_sdl.cpp b/src/util/opengl_context_sdl.cpp deleted file mode 100644 index cac4c6ddd..000000000 --- a/src/util/opengl_context_sdl.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin -// SPDX-License-Identifier: CC-BY-NC-ND-4.0 - -#include "opengl_context_sdl.h" -#include "gpu_texture.h" -#include "opengl_loader.h" -#include "sdl_video_helpers.h" - -#include "common/assert.h" -#include "common/error.h" -#include "common/log.h" -#include "common/scoped_guard.h" - -#include - -LOG_CHANNEL(GPUDevice); - -OpenGLContextSDL::OpenGLContextSDL() = default; - -OpenGLContextSDL::~OpenGLContextSDL() -{ - if (SDL_GL_GetCurrentContext() == m_context) - SDL_GL_MakeCurrent(nullptr, nullptr); - - if (m_context) - SDL_GL_DestroyContext(m_context); -} - -std::unique_ptr OpenGLContextSDL::Create(WindowInfo& wi, SurfaceHandle* surface, - std::span versions_to_try, Error* error) -{ - std::unique_ptr context = std::make_unique(); - if (!context->Initialize(wi, surface, versions_to_try, false, error)) - context.reset(); - - return context; -} - -GPUDevice::AdapterInfoList OpenGLContextSDL::GetAdapterList(WindowInfoType window_type, Error* error) -{ - std::vector fullscreen_modes = SDLVideoHelpers::GetFullscreenModeList(); - if (fullscreen_modes.empty()) - { - // no point adding anything if no modes - return {}; - } - - // Set some reasonable defaults, since we don't know this until we actually create the context. - GPUDevice::AdapterInfoList ret; - GPUDevice::AdapterInfo& ai = ret.emplace_back(); - ai.driver_type = GPUDriverType::Unknown; - ai.max_multisamples = 8; - ai.supports_sample_shading = true; - ai.max_texture_size = 16384; - ai.fullscreen_modes = std::move(fullscreen_modes); - return ret; -} - -bool OpenGLContextSDL::Initialize(WindowInfo& wi, SurfaceHandle* surface, std::span versions_to_try, - bool share_context, Error* error) -{ - static bool opengl_loaded = false; - if (!opengl_loaded) - { - if (!SDL_GL_LoadLibrary(nullptr)) - { - Error::SetStringFmt(error, "SDL_GL_LoadLibrary() failed: {}", SDL_GetError()); - return false; - } - - opengl_loaded = true; - } - - if (wi.IsSurfaceless()) - { - Error::SetStringView(error, "Surfaceless is not supported with OpenGLContextSDL."); - return false; - } - else if (wi.type != WindowInfoType::SDL) - { - Error::SetStringView(error, "Incompatible window type."); - return false; - } - - if (wi.surface_format == GPUTextureFormat::Unknown) - wi.surface_format = GPUTextureFormat::RGBA8; - - SDL_Window* const window = static_cast(wi.window_handle); - for (const Version& cv : versions_to_try) - { - if (CreateVersionContext(cv, window, wi.surface_format, share_context, !share_context)) - { - m_version = cv; - *surface = window; - UpdateWindowInfoSize(wi, window); - return true; - } - } - - Error::SetStringView(error, "Failed to create any contexts."); - return false; -} - -void* OpenGLContextSDL::GetProcAddress(const char* name) -{ - return (void*)SDL_GL_GetProcAddress(name); -} - -OpenGLContext::SurfaceHandle OpenGLContextSDL::CreateSurface(WindowInfo& wi, Error* error /*= nullptr*/) -{ - if (wi.IsSurfaceless()) [[unlikely]] - { - Error::SetStringView(error, "Trying to create a surfaceless surface."); - return nullptr; - } - else if (wi.type != WindowInfoType::SDL) - { - Error::SetStringView(error, "Incompatible window type."); - return nullptr; - } - - return static_cast(wi.window_handle); -} - -void OpenGLContextSDL::DestroySurface(SurfaceHandle handle) -{ - // cleaned up on window destruction? but we still need to clear current - SDL_Window* const window = static_cast(handle); - if (m_current_window == window) - DoneCurrent(); -} - -void OpenGLContextSDL::ResizeSurface(WindowInfo& wi, SurfaceHandle handle) -{ - UpdateWindowInfoSize(wi, static_cast(handle)); -} - -void OpenGLContextSDL::UpdateWindowInfoSize(WindowInfo& wi, SDL_Window* window) const -{ - int drawable_width, drawable_height; - SDL_GetWindowSizeInPixels(window, &drawable_width, &drawable_height); - wi.surface_width = static_cast(drawable_width); - wi.surface_height = static_cast(drawable_height); - if (WindowInfo::ShouldSwapDimensionsForPreRotation(wi.surface_prerotation)) - std::swap(wi.surface_width, wi.surface_height); -} - -bool OpenGLContextSDL::SwapBuffers() -{ - SDL_GL_SwapWindow(m_current_window); - return true; -} - -bool OpenGLContextSDL::IsCurrent() const -{ - return (m_context && SDL_GL_GetCurrentContext() == m_context); -} - -bool OpenGLContextSDL::MakeCurrent(SurfaceHandle surface, Error* error /* = nullptr */) -{ - SDL_Window* const window = static_cast(surface); - if (m_current_window == window) - return true; - - if (!SDL_GL_MakeCurrent(window, m_context)) - { - ERROR_LOG("SDL_GL_MakeCurrent() failed: {}", SDL_GetError()); - return false; - } - - m_current_window = window; - return true; -} - -bool OpenGLContextSDL::DoneCurrent() -{ - if (!SDL_GL_MakeCurrent(nullptr, nullptr)) - return false; - - m_current_window = nullptr; - return true; -} - -bool OpenGLContextSDL::SupportsNegativeSwapInterval() const -{ - int current_interval = 0; - if (!SDL_GL_GetSwapInterval(¤t_interval)) - { - ERROR_LOG("SDL_GL_GetSwapInterval() failed: {}", SDL_GetError()); - return false; - } - - const bool supported = SDL_GL_SetSwapInterval(-1); - SDL_GL_SetSwapInterval(current_interval); - return supported; -} - -bool OpenGLContextSDL::SetSwapInterval(s32 interval, Error* error) -{ - if (SDL_GL_SetSwapInterval(interval) != 0) - { - Error::SetStringFmt(error, "SDL_GL_SetSwapInterval() failed: ", SDL_GetError()); - return false; - } - - return true; -} - -std::unique_ptr OpenGLContextSDL::CreateSharedContext(WindowInfo& wi, SurfaceHandle* surface, - Error* error) -{ - std::unique_ptr context = std::make_unique(); - if (!context->Initialize(wi, surface, std::span(&m_version, 1), true, error)) - context.reset(); - return {}; -} - -bool OpenGLContextSDL::CreateVersionContext(const Version& version, SDL_Window* window, GPUTextureFormat surface_format, - bool share_context, bool make_current) -{ - SDL_GL_ResetAttributes(); - - switch (surface_format) - { - case GPUTextureFormat::RGBA8: - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - break; - - case GPUTextureFormat::RGB565: - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - break; - - default: - ERROR_LOG("Unsupported texture format {}", GPUTexture::GetFormatName(surface_format)); - break; - } - - if (share_context) - SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true); - - if (version.profile != Profile::NoProfile) - { - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, - (version.profile == Profile::ES) ? SDL_GL_CONTEXT_PROFILE_ES : SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, version.major_version); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, version.minor_version); - if (version.profile == Profile::Core) - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); - } - - SDL_GLContext context = SDL_GL_CreateContext(window); - if (!context) - { - DEV_LOG("SDL_GL_CreateContext({}.{}{}) failed: {}", version.major_version, version.minor_version, - ((version.profile == Profile::ES) ? " ES" : ((version.profile == Profile::Core) ? " Core" : "")), - SDL_GetError()); - return false; - } - - if (make_current) - { - if (!SDL_GL_MakeCurrent(window, context)) - { - DEV_LOG("SDL_GL_MakeCurrent({}.{}{}) failed: {}", version.major_version, version.minor_version, - ((version.profile == Profile::ES) ? " ES" : ((version.profile == Profile::Core) ? " Core" : "")), - SDL_GetError()); - SDL_GL_DestroyContext(context); - return false; - } - - m_current_window = window; - } - - m_context = context; - return true; -} diff --git a/src/util/opengl_context_sdl.h b/src/util/opengl_context_sdl.h deleted file mode 100644 index 66458a37f..000000000 --- a/src/util/opengl_context_sdl.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin -// SPDX-License-Identifier: CC-BY-NC-ND-4.0 - -#pragma once - -#include "opengl_context.h" -#include "opengl_loader.h" - -#include - -typedef struct SDL_GLContextState* SDL_GLContext; -struct SDL_Window; - -class OpenGLContextSDL final : public OpenGLContext -{ -public: - OpenGLContextSDL(); - ~OpenGLContextSDL() override; - - static std::unique_ptr Create(WindowInfo& wi, SurfaceHandle* surface, - std::span versions_to_try, Error* error); - static GPUDevice::AdapterInfoList GetAdapterList(WindowInfoType window_type, Error* error); - - void* GetProcAddress(const char* name) override; - SurfaceHandle CreateSurface(WindowInfo& wi, Error* error = nullptr) override; - void DestroySurface(SurfaceHandle handle) override; - void ResizeSurface(WindowInfo& wi, SurfaceHandle handle) override; - bool SwapBuffers() override; - bool IsCurrent() const override; - bool MakeCurrent(SurfaceHandle surface, Error* error = nullptr) override; - bool DoneCurrent() override; - bool SupportsNegativeSwapInterval() const override; - bool SetSwapInterval(s32 interval, Error* error = nullptr) override; - std::unique_ptr CreateSharedContext(WindowInfo& wi, SurfaceHandle* surface, Error* error) override; - -private: - bool Initialize(WindowInfo& wi, SurfaceHandle* surface, std::span versions_to_try, bool share_context, - Error* error); - - bool CreateVersionContext(const Version& version, SDL_Window* window, GPUTextureFormat surface_format, - bool share_context, bool make_current); - - void UpdateWindowInfoSize(WindowInfo& wi, SDL_Window* window) const; - - SDL_GLContext m_context = nullptr; - SDL_Window* m_current_window = nullptr; -}; diff --git a/src/util/sdl_video_helpers.h b/src/util/sdl_video_helpers.h deleted file mode 100644 index 389fc2034..000000000 --- a/src/util/sdl_video_helpers.h +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin -// SPDX-License-Identifier: CC-BY-NC-ND-4.0 - -#pragma once - -#include "gpu_device.h" - -#include "common/error.h" -#include "common/log.h" - -#include - -#include - -namespace SDLVideoHelpers { - -inline std::vector GetFullscreenModeList() -{ - int display_count = 0; - const SDL_DisplayID* const displays = SDL_GetDisplays(&display_count); - if (display_count <= 0) - { - GENERIC_LOG(Log::Channel::SDL, Log::Level::Error, Log::Color::Default, "SDL_GetDisplays() returned no displays: {}", - SDL_GetError()); - return {}; - } - - std::vector modes; - for (int i = 0; i < display_count; i++) - { - int dm_count = 0; - const SDL_DisplayMode* const* const dms = SDL_GetFullscreenDisplayModes(displays[i], &dm_count); - if (dm_count <= 0) - { - GENERIC_LOG(Log::Channel::SDL, Log::Level::Error, Log::Color::Default, - "SDL_GetFullscreenDisplayModes() returned no modes for display {}: {}", displays[i], SDL_GetError()); - continue; - } - - modes.reserve(modes.size() + static_cast(dm_count)); - - for (int j = 0; j < dm_count; j++) - { - const SDL_DisplayMode* const dm = dms[j]; - const GPUDevice::ExclusiveFullscreenMode mode{static_cast(dm->w), static_cast(dm->h), dm->refresh_rate}; - if (std::ranges::find(modes, mode) == modes.end()) - modes.push_back(mode); - } - } - - return modes; -} - -} // namespace SDLVideoHelpers diff --git a/src/util/util.vcxproj b/src/util/util.vcxproj index 17b3e61ca..8fd734b9d 100644 --- a/src/util/util.vcxproj +++ b/src/util/util.vcxproj @@ -63,9 +63,6 @@ true - - true - true @@ -178,9 +175,6 @@ true - - true - true diff --git a/src/util/util.vcxproj.filters b/src/util/util.vcxproj.filters index 8a8d16769..53f201433 100644 --- a/src/util/util.vcxproj.filters +++ b/src/util/util.vcxproj.filters @@ -71,7 +71,6 @@ - @@ -162,7 +161,6 @@ - diff --git a/src/util/vulkan_loader.cpp b/src/util/vulkan_loader.cpp index 0f5bd52c6..2c556be8a 100644 --- a/src/util/vulkan_loader.cpp +++ b/src/util/vulkan_loader.cpp @@ -15,11 +15,6 @@ #include "common/error.h" #include "common/log.h" -#ifdef ENABLE_SDL -#include "sdl_video_helpers.h" -#include -#endif - #include #include #include @@ -47,11 +42,6 @@ static bool LoadInstanceFunctions(VkInstance instance, Error* error); static void ResetInstanceFunctions(); static void UnloadVulkanLibrary(); -#ifdef ENABLE_SDL -static bool LoadVulkanLibraryFromSDL(Error* error); -static void UnloadVulkanLibraryFromSDL(); -#endif - static bool LockedCreateVulkanInstance(WindowInfoType wtype, bool* request_debug_instance, Error* error); static void LockedReleaseVulkanInstance(); static void LockedDestroyVulkanInstance(); @@ -59,8 +49,6 @@ static void LockedDestroyVulkanInstance(); static bool SelectInstanceExtensions(VulkanDevice::ExtensionList* extension_list, WindowInfoType wtype, bool debug_instance, Error* error); -static std::vector EnumerateFullscreenModes(WindowInfoType wtype); - VKAPI_ATTR static VkBool32 VKAPI_CALL DebugMessengerCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, @@ -76,9 +64,6 @@ struct Locals OptionalExtensions optional_extensions{}; WindowInfoType window_type = WindowInfoType::Surfaceless; bool is_debug_instance = false; -#ifdef ENABLE_SDL - bool library_loaded_from_sdl = false; -#endif std::mutex mutex; }; @@ -91,25 +76,6 @@ ALIGN_TO_CACHE_LINE static Locals s_locals; bool VulkanLoader::LoadVulkanLibrary(WindowInfoType wtype, Error* error) { -#ifdef ENABLE_SDL - // Switching to/from SDL? - if (wtype == WindowInfoType::SDL) - { - if (s_locals.library_loaded_from_sdl) - return true; - - UnloadVulkanLibrary(); - if (!LoadVulkanLibraryFromSDL(error)) - return false; - } - else - { - // Unload from SDL if we were previously using it.. unlikely. - if (s_locals.library_loaded_from_sdl) - UnloadVulkanLibraryFromSDL(); - } -#endif - if (s_locals.library.IsOpen()) return true; @@ -159,14 +125,6 @@ bool VulkanLoader::LoadVulkanLibrary(WindowInfoType wtype, Error* error) void VulkanLoader::UnloadVulkanLibrary() { -#ifdef ENABLE_SDL - if (s_locals.library_loaded_from_sdl) - { - UnloadVulkanLibraryFromSDL(); - return; - } -#endif - ResetModuleFunctions(); s_locals.library.Close(); } @@ -178,64 +136,6 @@ void VulkanLoader::ResetModuleFunctions() #undef VULKAN_MODULE_ENTRY_POINT } -#ifdef ENABLE_SDL - -bool VulkanLoader::LoadVulkanLibraryFromSDL(Error* error) -{ - if (!SDL_Vulkan_LoadLibrary(nullptr)) - { - Error::SetStringFmt(error, "SDL_Vulkan_LoadLibrary() failed: {}", SDL_GetError()); - return false; - } - - vkGetInstanceProcAddr = reinterpret_cast(SDL_Vulkan_GetVkGetInstanceProcAddr()); - if (!vkGetInstanceProcAddr) - { - Error::SetStringFmt(error, "SDL_Vulkan_GetVkGetInstanceProcAddr() failed: {}", SDL_GetError()); - SDL_Vulkan_UnloadLibrary(); - return false; - } - - bool required_functions_missing = false; - const auto load_function = [&error, &required_functions_missing](PFN_vkVoidFunction* func_ptr, const char* name, - bool is_required) { - // vkGetInstanceProcAddr() can't resolve itself until Vulkan 1.2. - if (func_ptr == reinterpret_cast(&vkGetInstanceProcAddr)) - return; - - *func_ptr = vkGetInstanceProcAddr(nullptr, name); - if (!(*func_ptr) && is_required && !required_functions_missing) - { - Error::SetStringFmt(error, "Failed to load required module function {}", name); - required_functions_missing = true; - } - }; - -#define VULKAN_MODULE_ENTRY_POINT(name, required) \ - load_function(reinterpret_cast(&name), #name, required); -#include "vulkan_entry_points.inl" -#undef VULKAN_MODULE_ENTRY_POINT - - if (required_functions_missing) - { - ResetModuleFunctions(); - SDL_Vulkan_UnloadLibrary(); - return false; - } - - s_locals.library_loaded_from_sdl = true; - return true; -} - -void VulkanLoader::UnloadVulkanLibraryFromSDL() -{ - ResetModuleFunctions(); - s_locals.library_loaded_from_sdl = false; - SDL_Vulkan_UnloadLibrary(); -} - -#endif // ENABLE_SDL - bool VulkanLoader::LoadInstanceFunctions(VkInstance instance, Error* error) { bool required_functions_missing = false; @@ -543,25 +443,6 @@ bool VulkanLoader::SelectInstanceExtensions(VulkanDevice::ExtensionList* extensi } #endif -#if defined(ENABLE_SDL) - if (wtype == WindowInfoType::SDL) - { - Uint32 sdl_extension_count = 0; - const char* const* sdl_extensions = SDL_Vulkan_GetInstanceExtensions(&sdl_extension_count); - if (!sdl_extensions) - { - ERROR_LOG("SDL_Vulkan_GetInstanceExtensions() failed: {}", SDL_GetError()); - return false; - } - - for (unsigned int i = 0; i < sdl_extension_count; i++) - { - if (!SupportsExtension(sdl_extensions[i], true)) - return false; - } - } -#endif - // VK_EXT_debug_utils if (debug_instance && !SupportsExtension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, false)) WARNING_LOG("Vulkan: Debug report requested, but extension is not available."); @@ -600,12 +481,6 @@ void VulkanLoader::LockedReleaseVulkanInstance() // We specifically keep the instance around even after releasing it. // Both AMD on Windows and Mesa leak a few tens of megabytes for every instance... DEV_LOG("Released Vulkan instance, reference count {}", s_locals.reference_count); - -#ifdef ENABLE_SDL - // SDL Vulkan kinda breaks OpenGL contexts if the instance isn't destroyed... - if (s_locals.window_type == WindowInfoType::SDL && s_locals.reference_count == 0) - LockedDestroyVulkanInstance(); -#endif } void VulkanLoader::LockedDestroyVulkanInstance() @@ -744,16 +619,6 @@ VulkanLoader::GPUList VulkanLoader::EnumerateGPUs(Error* error) return gpus; } -std::vector VulkanLoader::EnumerateFullscreenModes(WindowInfoType wtype) -{ -#ifdef ENABLE_SDL - if (wtype == WindowInfoType::SDL) - return SDLVideoHelpers::GetFullscreenModeList(); -#endif - - return {}; -} - bool VulkanLoader::IsSuitableDefaultRenderer(WindowInfoType window_type) { #ifdef __ANDROID__ @@ -852,8 +717,6 @@ GPUDriverType VulkanLoader::GuessDriverType(const VkPhysicalDeviceProperties& de std::optional VulkanLoader::GetAdapterList(WindowInfoType window_type, Error* error) { - std::optional ret; - std::vector fullscreen_modes; GPUList gpus; { const std::lock_guard lock(s_locals.mutex); @@ -862,36 +725,27 @@ std::optional VulkanLoader::GetAdapterList(WindowInf if (s_locals.instance != VK_NULL_HANDLE) { gpus = EnumerateGPUs(error); - fullscreen_modes = EnumerateFullscreenModes(window_type); } else { // Otherwise we need to create a temporary instance. // Hold the lock for both creation and querying, otherwise the UI thread could race creation. if (!LockedCreateVulkanInstance(window_type, nullptr, error)) - return ret; + return std::nullopt; gpus = EnumerateGPUs(error); - fullscreen_modes = EnumerateFullscreenModes(window_type); LockedReleaseVulkanInstance(); } } - ret.emplace(); - ret->reserve(gpus.size()); - for (size_t i = 0; i < gpus.size(); i++) - { - GPUDevice::AdapterInfo& ai = gpus[i].second; - - // splat fullscreen modes across gpus - if (i == (gpus.size() - 1)) - ai.fullscreen_modes = std::move(fullscreen_modes); - else - ai.fullscreen_modes = fullscreen_modes; + if (gpus.empty()) + return std::nullopt; - ret->push_back(std::move(ai)); - } + GPUDevice::AdapterInfoList ret; + ret.reserve(gpus.size()); + for (size_t i = 0; i < gpus.size(); i++) + ret.push_back(std::move(gpus[i].second)); return ret; } diff --git a/src/util/vulkan_swap_chain.cpp b/src/util/vulkan_swap_chain.cpp index eba225dfc..690cf4f50 100644 --- a/src/util/vulkan_swap_chain.cpp +++ b/src/util/vulkan_swap_chain.cpp @@ -18,10 +18,6 @@ #include #include -#ifdef ENABLE_SDL -#include -#endif - LOG_CHANNEL(GPUDevice); static VkFormat GetLinearFormat(VkFormat format) @@ -190,20 +186,6 @@ bool VulkanSwapChain::CreateSurface(VkPhysicalDevice physical_device, Error* err } #endif -#if defined(ENABLE_SDL) - if (m_window_info.type == WindowInfoType::SDL) - { - if (!SDL_Vulkan_CreateSurface(static_cast(m_window_info.window_handle), - VulkanLoader::GetVulkanInstance(), nullptr, &m_surface)) - { - Error::SetStringFmt(error, "SDL_Vulkan_CreateSurface() failed: {}", SDL_GetError()); - return false; - } - - return true; - } -#endif - Error::SetStringFmt(error, "Unhandled window type: {}", static_cast(m_window_info.type)); return false; } diff --git a/src/util/window_info.h b/src/util/window_info.h index 817482d7d..dd996df39 100644 --- a/src/util/window_info.h +++ b/src/util/window_info.h @@ -20,7 +20,6 @@ enum class WindowInfoType : u8 Wayland, MacOS, Android, - SDL, }; enum class WindowInfoPrerotation : u8