From 13cfd9c3d6dfc902e903a0e18bcffb0b4abecfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 17 Aug 2023 22:05:48 +0200 Subject: [PATCH 1/2] Add Mesa as a known GPU driver "vendor". --- Common/GPU/OpenGL/GLFeatures.h | 1 + Common/GPU/OpenGL/thin3d_gl.cpp | 2 ++ Common/GPU/Vulkan/VulkanContext.cpp | 1 + Common/GPU/Vulkan/VulkanContext.h | 1 + Common/GPU/Vulkan/thin3d_vulkan.cpp | 1 + Common/GPU/thin3d.h | 1 + GPU/Common/PostShader.cpp | 2 ++ 7 files changed, 9 insertions(+) diff --git a/Common/GPU/OpenGL/GLFeatures.h b/Common/GPU/OpenGL/GLFeatures.h index f2aa3380568d..e8849f681d33 100644 --- a/Common/GPU/OpenGL/GLFeatures.h +++ b/Common/GPU/OpenGL/GLFeatures.h @@ -18,6 +18,7 @@ enum { GPU_VENDOR_BROADCOM = 7, // Raspberry PI etc GPU_VENDOR_VIVANTE = 8, GPU_VENDOR_APPLE = 9, + GPU_VENDOR_MESA = 10, GPU_VENDOR_UNKNOWN = 0, }; diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index efa48acdf597..66c408f95375 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -463,6 +463,7 @@ class OpenGLContext : public DrawContext { case GPUVendor::VENDOR_BROADCOM: return "VENDOR_BROADCOM"; case GPUVendor::VENDOR_VIVANTE: return "VENDOR_VIVANTE"; case GPUVendor::VENDOR_APPLE: return "VENDOR_APPLE"; + case GPUVendor::VENDOR_MESA: return "VENDOR_MESA"; case GPUVendor::VENDOR_UNKNOWN: default: return "VENDOR_UNKNOWN"; @@ -615,6 +616,7 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT case GPU_VENDOR_IMGTEC: caps_.vendor = GPUVendor::VENDOR_IMGTEC; break; case GPU_VENDOR_VIVANTE: caps_.vendor = GPUVendor::VENDOR_VIVANTE; break; case GPU_VENDOR_APPLE: caps_.vendor = GPUVendor::VENDOR_APPLE; break; + case GPU_VENDOR_MESA: caps_.vendor = GPUVendor::VENDOR_MESA; break; case GPU_VENDOR_UNKNOWN: default: caps_.vendor = GPUVendor::VENDOR_UNKNOWN; diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index d11010d3c46e..14278be23694 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -57,6 +57,7 @@ std::string VulkanVendorString(uint32_t vendorId) { case VULKAN_VENDOR_QUALCOMM: return "Qualcomm"; case VULKAN_VENDOR_IMGTEC: return "Imagination"; case VULKAN_VENDOR_APPLE: return "Apple"; + case VULKAN_VENDOR_MESA: return "Mesa"; default: return StringFromFormat("%08x", vendorId); } diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index 83c05e461e83..4dea4ed380b0 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -36,6 +36,7 @@ enum { VULKAN_VENDOR_QUALCOMM = 0x00005143, VULKAN_VENDOR_IMGTEC = 0x00001010, // PowerVR VULKAN_VENDOR_APPLE = 0x0000106b, // Apple through MoltenVK + VULKAN_VENDOR_MESA = 0x00010005, // lavapipe }; VK_DEFINE_HANDLE(VmaAllocator); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 2c2d5a109e96..7d7a3ea7609e 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -920,6 +920,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread) case VULKAN_VENDOR_QUALCOMM: caps_.vendor = GPUVendor::VENDOR_QUALCOMM; break; case VULKAN_VENDOR_INTEL: caps_.vendor = GPUVendor::VENDOR_INTEL; break; case VULKAN_VENDOR_APPLE: caps_.vendor = GPUVendor::VENDOR_APPLE; break; + case VULKAN_VENDOR_MESA: caps_.vendor = GPUVendor::VENDOR_MESA; break; default: WARN_LOG(G3D, "Unknown vendor ID %08x", deviceProps.vendorID); caps_.vendor = GPUVendor::VENDOR_UNKNOWN; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 551964b3964f..e40918cd927b 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -231,6 +231,7 @@ enum class GPUVendor { VENDOR_BROADCOM, // Raspberry VENDOR_VIVANTE, VENDOR_APPLE, + VENDOR_MESA, }; enum class NativeObject { diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index c8321e9315de..37066703e5a3 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -126,6 +126,8 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct blacklistedVendor = Draw::GPUVendor::VENDOR_APPLE; } else if (item == "Intel") { blacklistedVendor = Draw::GPUVendor::VENDOR_INTEL; + } else if (item == "Mesa") { + blacklistedVendor = Draw::GPUVendor::VENDOR_MESA; } if (blacklistedVendor == gpuVendor && blacklistedVendor != Draw::GPUVendor::VENDOR_UNKNOWN) { skipped = true; From 5cc85d1df7f98e54d99997f2e0078d7a2f731cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 17 Aug 2023 22:06:17 +0200 Subject: [PATCH 2/2] SDL: Actually pick the Vulkan device specified in the config. --- SDL/SDLVulkanGraphicsContext.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index f58ae422dd44..11d749526587 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -69,7 +69,15 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, in vulkan_ = nullptr; return false; } - vulkan_->ChooseDevice(vulkan_->GetBestPhysicalDevice()); + + int deviceNum = vulkan_->GetPhysicalDeviceByName(g_Config.sVulkanDevice); + if (deviceNum < 0) { + deviceNum = vulkan_->GetBestPhysicalDevice(); + if (!g_Config.sVulkanDevice.empty()) + g_Config.sVulkanDevice = vulkan_->GetPhysicalDeviceProperties(deviceNum).properties.deviceName; + } + + vulkan_->ChooseDevice(deviceNum); if (vulkan_->CreateDevice() != VK_SUCCESS) { *error_message = vulkan_->InitError(); delete vulkan_;