Video: Show Video Info for all backends

Also removes duplication of the message on OpenGL.
This commit is contained in:
Dentomologist 2024-08-18 13:14:53 -07:00
parent 5af0ae25e6
commit 88ed9374eb
13 changed files with 118 additions and 7 deletions

View File

@ -580,6 +580,11 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot
PanicAlertFmt("Failed to initialize video backend!");
return;
}
const std::string video_info = fmt::format("Video Info: {}", g_video_backend->GetVideoInfo());
OSD::AddMessage(video_info, 5000);
INFO_LOG_FMT(VIDEO, "{}", video_info);
Common::ScopeGuard video_guard{[] {
// Clear on screen messages that haven't expired
OSD::ClearMessages();

View File

@ -6,6 +6,8 @@
#include <memory>
#include <string>
#include <dxgi.h>
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
@ -38,6 +40,40 @@ std::string VideoBackend::GetDisplayName() const
return _trans("Direct3D 11");
}
std::string VideoBackend::GetVideoInfo() const
{
ComPtr<IDXGIAdapter> adapter;
HRESULT hr = D3D::dxgi_factory->EnumAdapters(g_ActiveConfig.iAdapter, adapter.GetAddressOf());
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to enumerate {} adapter: {}", GetDisplayName(), DX11HRWrap(hr));
return GetDisplayName();
}
DXGI_ADAPTER_DESC description;
hr = adapter->GetDesc(&description);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to retrieve {} adapter description: {}", GetDisplayName(),
DX11HRWrap(hr));
return GetDisplayName();
}
LARGE_INTEGER driver_version;
hr = adapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &driver_version);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to retrieve {} adapter driver version: {}", GetDisplayName(),
DX11HRWrap(hr));
return fmt::format("{}, {}", GetDisplayName(), WStringToUTF8(description.Description));
}
const LONGLONG& version = driver_version.QuadPart;
return fmt::format("{}, {}, {}.{}.{} Build {}", GetDisplayName(),
WStringToUTF8(description.Description), version >> 48,
(version >> 32) & 0xffff, (version >> 16) & 0xffff, version & 0xffff);
}
std::optional<std::string> VideoBackend::GetWarningMessage() const
{
std::optional<std::string> result;

View File

@ -16,6 +16,7 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
std::string GetVideoInfo() const override;
std::optional<std::string> GetWarningMessage() const override;
void InitBackendInfo(const WindowSystemInfo& wsi) override;

View File

@ -36,6 +36,48 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 12";
}
std::string VideoBackend::GetVideoInfo() const
{
if (g_dx_context == nullptr)
{
WARN_LOG_FMT(VIDEO, "Unable to retrieve adapter info because no {} context established",
GetDisplayName());
return GetDisplayName();
}
ComPtr<IDXGIAdapter> adapter;
HRESULT hr =
g_dx_context->GetDXGIFactory()->EnumAdapters(g_ActiveConfig.iAdapter, adapter.GetAddressOf());
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to enumerate {} adapter: {}", GetDisplayName(), DX12HRWrap(hr));
return GetDisplayName();
}
DXGI_ADAPTER_DESC description;
hr = adapter->GetDesc(&description);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to retrieve {} adapter description: {}", GetDisplayName(),
DX12HRWrap(hr));
return GetDisplayName();
}
LARGE_INTEGER driver_version;
hr = adapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &driver_version);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Unable to retrieve {} adapter driver version: {}", GetDisplayName(),
DX12HRWrap(hr));
return fmt::format("{}, {}", GetDisplayName(), WStringToUTF8(description.Description));
}
const LONGLONG& version = driver_version.QuadPart;
return fmt::format("{}, {}, {}.{}.{} Build {}", GetDisplayName(),
WStringToUTF8(description.Description), version >> 48,
(version >> 32) & 0xffff, (version >> 16) & 0xffff, version & 0xffff);
}
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
if (!D3DCommon::LoadLibraries())

View File

@ -16,6 +16,7 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
std::string GetVideoInfo() const override;
void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "D3D12";

View File

@ -40,6 +40,20 @@ std::string Metal::VideoBackend::GetDisplayName() const
return _trans("Metal");
}
std::string Metal::VideoBackend::GetVideoInfo() const
{
const std::vector<MRCOwned<id<MTLDevice>>> devs = Util::GetAdapterList();
size_t selected_adapter_index = static_cast<size_t>(g_Config.iAdapter);
if (selected_adapter_index >= devs.size())
{
return GetDisplayName();
}
const id<MTLDevice> device = devs[selected_adapter_index];
const std::string device_name = [[device name] UTF8String];
return fmt::format("{}, {}", GetDisplayName(), device_name);
}
std::optional<std::string> Metal::VideoBackend::GetWarningMessage() const
{
if (Util::GetAdapterList().empty())

View File

@ -16,6 +16,7 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
std::string GetVideoInfo() const override;
std::optional<std::string> GetWarningMessage() const override;
void InitBackendInfo(const WindowSystemInfo& wsi) override;

View File

@ -726,10 +726,6 @@ bool PopulateConfig(GLContext* m_main_gl_context)
g_Config.VerifyValidity();
UpdateActiveConfig();
OSD::AddMessage(fmt::format("Video Info: {}, {}, {}", g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_version),
5000);
if (!g_ogl_config.bSupportsGLBufferStorage && !g_ogl_config.bSupportsGLPinnedMemory)
{
OSD::AddMessage(fmt::format("Your OpenGL driver does not support {}_buffer_storage.",
@ -738,9 +734,6 @@ bool PopulateConfig(GLContext* m_main_gl_context)
OSD::AddMessage("This device's performance may be poor.", 60000);
}
INFO_LOG_FMT(VIDEO, "Video Info: {}, {}, {}", g_ogl_config.gl_vendor, g_ogl_config.gl_renderer,
g_ogl_config.gl_version);
const std::string missing_extensions = fmt::format(
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ",

View File

@ -74,6 +74,12 @@ std::string VideoBackend::GetDisplayName() const
return _trans("OpenGL");
}
std::string VideoBackend::GetVideoInfo() const
{
return fmt::format("{}, {}, {}", GetDisplayName(), g_ogl_config.gl_renderer,
g_ogl_config.gl_version);
}
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
std::unique_ptr<GLContext> temp_gl_context =

View File

@ -18,6 +18,7 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
std::string GetVideoInfo() const override;
void InitBackendInfo(const WindowSystemInfo& wsi) override;

View File

@ -303,4 +303,13 @@ void VideoBackend::PrepareWindow(WindowSystemInfo& wsi)
wsi.render_surface = layer;
#endif
}
std::string VideoBackend::GetVideoInfo() const
{
const VkPhysicalDevice device = g_vulkan_context->GetPhysicalDevice();
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(device, &properties);
return fmt::format("{}, {}, {}, {:x}", GetDisplayName(), properties.deviceName,
properties.driverVersion, properties.driverVersion);
}
} // namespace Vulkan

View File

@ -16,6 +16,7 @@ public:
std::string GetName() const override { return NAME; }
std::string GetDisplayName() const override { return _trans("Vulkan"); }
std::string GetVideoInfo() const override;
void InitBackendInfo(const WindowSystemInfo& wsi) override;
void PrepareWindow(WindowSystemInfo& wsi) override;

View File

@ -47,6 +47,7 @@ public:
virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const { return GetName(); }
virtual std::string GetVideoInfo() const { return GetDisplayName(); }
virtual void InitBackendInfo(const WindowSystemInfo& wsi) = 0;
virtual std::optional<std::string> GetWarningMessage() const { return {}; }