From 1d948a4a49d813ba5653945b5882ed7eb7601a8f Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:08:57 +0700 Subject: [PATCH] GSDevice: Add GetName() Function This function allows you to retrieve the currently used GPU string name. --- pcsx2/GS/Renderers/Common/GSDevice.h | 4 ++++ pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 2 ++ pcsx2/GS/Renderers/DX12/GSDevice12.cpp | 2 ++ pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm | 2 ++ pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 3 +++ pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 3 +++ 6 files changed, 16 insertions(+) diff --git a/pcsx2/GS/Renderers/Common/GSDevice.h b/pcsx2/GS/Renderers/Common/GSDevice.h index 186c83b80d99a4..103e4d9a531b73 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.h +++ b/pcsx2/GS/Renderers/Common/GSDevice.h @@ -805,6 +805,7 @@ class GSDevice : public GSAlignedClass<32> // clang-format on protected: + std::string m_name; FeatureSupport m_features; u32 m_max_texture_size = 0; @@ -870,6 +871,9 @@ class GSDevice : public GSAlignedClass<32> GSDevice(); virtual ~GSDevice(); + /// Returns a string containing current adapter in use. + const std::string& GetName() const { return m_name; } + /// Returns a string representing the specified API. static const char* RenderAPIToString(RenderAPI api); diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index ba8a109ee6ea79..ee496a9fd800d1 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -122,6 +122,8 @@ bool GSDevice11::Create(GSVSyncMode vsync_mode, bool allow_present_throttle) temp_dev.reset(); temp_ctx.reset(); + m_name = D3D::GetAdapterName(dxgi_adapter.get()); + if (GSConfig.UseDebugDevice && IsDebuggerPresent()) { wil::com_ptr_nothrow info; diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index e576bf6af60a21..529a94f3e1f046 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -690,6 +690,8 @@ bool GSDevice12::Create(GSVSyncMode vsync_mode, bool allow_present_throttle) return false; } + m_name = D3D::GetAdapterName(m_adapter.get()); + if (!CreateDescriptorHeaps() || !CreateCommandLists() || !CreateTimestampQuery()) return false; diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index fd3428578f9ade..f8a249f0c5eb64 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -857,6 +857,8 @@ static void OnMainThread(Fn&& fn) if (!m_dev.dev) Host::ReportErrorAsync("No Metal Devices Available", "No Metal-supporting GPUs were found. PCSX2 requires a Metal GPU (available on all macs from 2012 onwards)."); } + + m_name = [[m_dev.dev name] UTF8String]; m_queue = MRCTransfer([m_dev.dev newCommandQueue]); m_pass_desc = MRCTransfer([MTLRenderPassDescriptor new]); diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 5daccd7b373d37..a1e17a87d1e8e1 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -184,6 +184,9 @@ bool GSDeviceOGL::Create(GSVSyncMode vsync_mode, bool allow_present_throttle) if (!CheckFeatures(buggy_pbo)) return false; + // Store adapter name currently in use + m_name = reinterpret_cast(glGetString(GL_RENDERER)); + SetSwapInterval(); // Render a frame as soon as possible to clear out whatever was previously being displayed. diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 4e5617b5e131b9..31f56457f2a67f 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -2539,6 +2539,9 @@ bool GSDeviceVK::CreateDeviceAndSwapChain() // Read device physical memory properties, we need it for allocating buffers vkGetPhysicalDeviceProperties(m_physical_device, &m_device_properties); + // Stores the GPU name + m_name = m_device_properties.deviceName; + // We need this to be at least 32 byte aligned for AVX2 stores. m_device_properties.limits.minUniformBufferOffsetAlignment = std::max(m_device_properties.limits.minUniformBufferOffsetAlignment, static_cast(32));