1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-07 16:54:14 +01:00

[d3d9] Make adapter code use new wsi abstraction

This commit is contained in:
Joshua Ashton 2022-08-14 17:39:48 +00:00 committed by Philip Rebohle
parent dac7e38f4b
commit 9690b2a9e4

View File

@ -8,6 +8,9 @@
#include "../util/util_bit.h" #include "../util/util_bit.h"
#include "../util/util_luid.h" #include "../util/util_luid.h"
#include "../util/util_ratio.h" #include "../util/util_ratio.h"
#include "../util/util_string.h"
#include "../wsi/wsi_monitor.h"
#include <cfloat> #include <cfloat>
@ -59,14 +62,14 @@ namespace dxvk {
const auto& props = m_adapter->deviceProperties(); const auto& props = m_adapter->deviceProperties();
DISPLAY_DEVICEA device = { }; WCHAR wideDisplayName[32] = { };
device.cb = sizeof(device); if (!wsi::getDisplayName(wsi::getDefaultMonitor(), wideDisplayName)) {
Logger::err("D3D9Adapter::GetAdapterIdentifier: Failed to query monitor info");
if (!::EnumDisplayDevicesA(nullptr, m_displayIndex, &device, 0)) {
Logger::err("D3D9Adapter::GetAdapterIdentifier: Failed to query display info");
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
std::string displayName = str::fromws(wideDisplayName);
GUID guid = bit::cast<GUID>(m_adapter->devicePropertiesExt().vk11.deviceUUID); GUID guid = bit::cast<GUID>(m_adapter->devicePropertiesExt().vk11.deviceUUID);
uint32_t vendorId = options.customVendorId == -1 ? props.vendorID : uint32_t(options.customVendorId); uint32_t vendorId = options.customVendorId == -1 ? props.vendorID : uint32_t(options.customVendorId);
@ -75,7 +78,7 @@ namespace dxvk {
const char* driver = GetDriverDLL(DxvkGpuVendor(vendorId)); const char* driver = GetDriverDLL(DxvkGpuVendor(vendorId));
copyToStringArray(pIdentifier->Description, desc); copyToStringArray(pIdentifier->Description, desc);
copyToStringArray(pIdentifier->DeviceName, device.DeviceName); // The GDI device name. Not the actual device name. copyToStringArray(pIdentifier->DeviceName, displayName.c_str()); // The GDI device name. Not the actual device name.
copyToStringArray(pIdentifier->Driver, driver); // This is the driver's dll. copyToStringArray(pIdentifier->Driver, driver); // This is the driver's dll.
pIdentifier->DeviceIdentifier = guid; pIdentifier->DeviceIdentifier = guid;
@ -621,7 +624,7 @@ namespace dxvk {
HMONITOR D3D9Adapter::GetMonitor() { HMONITOR D3D9Adapter::GetMonitor() {
return GetDefaultMonitor(); return wsi::getDefaultMonitor();
} }
@ -680,20 +683,14 @@ namespace dxvk {
if (pRotation != nullptr) if (pRotation != nullptr)
*pRotation = D3DDISPLAYROTATION_IDENTITY; *pRotation = D3DDISPLAYROTATION_IDENTITY;
DEVMODEW devMode = DEVMODEW(); wsi::WsiMode mode = { };
devMode.dmSize = sizeof(devMode);
if (!GetMonitorDisplayMode(GetDefaultMonitor(), ENUM_CURRENT_SETTINGS, &devMode)) { if (!wsi::getCurrentDisplayMode(wsi::getDefaultMonitor(), &mode)) {
Logger::err("D3D9Adapter::GetAdapterDisplayModeEx: Failed to enum display settings"); Logger::err("D3D9Adapter::GetAdapterDisplayModeEx: Failed to enum display settings");
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
pMode->Size = sizeof(D3DDISPLAYMODEEX); *pMode = ConvertDisplayMode(mode);
pMode->Width = devMode.dmPelsWidth;
pMode->Height = devMode.dmPelsHeight;
pMode->RefreshRate = devMode.dmDisplayFrequency;
pMode->Format = D3DFMT_X8R8G8B8;
pMode->ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
return D3D_OK; return D3D_OK;
} }
@ -768,32 +765,27 @@ namespace dxvk {
// Walk over all modes that the display supports and // Walk over all modes that the display supports and
// return those that match the requested format etc. // return those that match the requested format etc.
DEVMODEW devMode = { }; wsi::WsiMode devMode = { };
devMode.dmSize = sizeof(DEVMODEW);
uint32_t modeIndex = 0; uint32_t modeIndex = 0;
const auto forcedRatio = Ratio<DWORD>(options.forceAspectRatio); const auto forcedRatio = Ratio<DWORD>(options.forceAspectRatio);
while (GetMonitorDisplayMode(GetDefaultMonitor(), modeIndex++, &devMode)) { while (wsi::getDisplayMode(wsi::getDefaultMonitor(), modeIndex++, &devMode)) {
// Skip interlaced modes altogether // Skip interlaced modes altogether
if (devMode.dmDisplayFlags & DM_INTERLACED) if (devMode.interlaced)
continue; continue;
// Skip modes with incompatible formats // Skip modes with incompatible formats
if (devMode.dmBitsPerPel != GetMonitorFormatBpp(Format)) if (devMode.bitsPerPixel != GetMonitorFormatBpp(Format))
continue; continue;
if (!forcedRatio.undefined() && Ratio<DWORD>(devMode.dmPelsWidth, devMode.dmPelsHeight) != forcedRatio) if (!forcedRatio.undefined() && Ratio<DWORD>(devMode.width, devMode.height) != forcedRatio)
continue; continue;
D3DDISPLAYMODEEX mode; D3DDISPLAYMODEEX mode = ConvertDisplayMode(devMode);
mode.Size = sizeof(D3DDISPLAYMODEEX); // Fix up the D3DFORMAT to match what we are enumerating
mode.Width = devMode.dmPelsWidth;
mode.Height = devMode.dmPelsHeight;
mode.RefreshRate = devMode.dmDisplayFrequency;
mode.Format = static_cast<D3DFORMAT>(Format); mode.Format = static_cast<D3DFORMAT>(Format);
mode.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
m_modes.push_back(mode); m_modes.push_back(mode);
} }