diff --git a/src/core/system.cpp b/src/core/system.cpp index d2c959ce1..472f95bdc 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1954,7 +1954,8 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching) { const RenderAPI api = Settings::GetRenderAPIForRenderer(renderer); - if (!g_gpu_device || (renderer != GPURenderer::Software && g_gpu_device->GetRenderAPI() != api)) + if (!g_gpu_device || + (renderer != GPURenderer::Software && !GPUDevice::IsSameRenderAPI(g_gpu_device->GetRenderAPI(), api))) { if (g_gpu_device) { diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index cf86d132f..dd40cf36a 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -108,10 +108,9 @@ bool GPUPipeline::InputLayout::operator==(const InputLayout& rhs) const bool GPUPipeline::InputLayout::operator!=(const InputLayout& rhs) const { - return (vertex_stride != rhs.vertex_stride || - vertex_attributes.size() != rhs.vertex_attributes.size() || - std::memcmp(vertex_attributes.data(), rhs.vertex_attributes.data(), - sizeof(VertexAttribute) * rhs.vertex_attributes.size()) != 0); + return (vertex_stride != rhs.vertex_stride || vertex_attributes.size() != rhs.vertex_attributes.size() || + std::memcmp(vertex_attributes.data(), rhs.vertex_attributes.data(), + sizeof(VertexAttribute) * rhs.vertex_attributes.size()) != 0); } GPUPipeline::RasterizationState GPUPipeline::RasterizationState::GetNoCullState() @@ -199,7 +198,6 @@ RenderAPI GPUDevice::GetPreferredAPI() const char* GPUDevice::RenderAPIToString(RenderAPI api) { - // TODO: Combine ES switch (api) { // clang-format off @@ -218,6 +216,12 @@ const char* GPUDevice::RenderAPIToString(RenderAPI api) } } +bool GPUDevice::IsSameRenderAPI(RenderAPI lhs, RenderAPI rhs) +{ + return (lhs == rhs || ((lhs == RenderAPI::OpenGL || lhs == RenderAPI::OpenGLES) && + (rhs == RenderAPI::OpenGL || rhs == RenderAPI::OpenGLES))); +} + bool GPUDevice::Create(const std::string_view& adapter, const std::string_view& shader_cache_path, u32 shader_cache_version, bool debug_device, bool vsync, bool threaded_presentation) { diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index e97e8d672..095c94407 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -472,6 +472,9 @@ public: /// Returns a new device for the specified API. static std::unique_ptr CreateDeviceForAPI(RenderAPI api); + /// Returns true if the render API is the same (e.g. GLES and GL). + static bool IsSameRenderAPI(RenderAPI lhs, RenderAPI rhs); + /// Parses a fullscreen mode into its components (width * height @ refresh hz) static bool GetRequestedExclusiveFullscreenMode(u32* width, u32* height, float* refresh_rate);