Set render adapter for virtual display driver w/ show detailed virtual display driver status on config

This commit is contained in:
Yukino Song
2024-08-21 00:06:41 +08:00
parent 0f6d9ba66e
commit f2401c08f7
7 changed files with 61 additions and 7 deletions

View File

@@ -5,6 +5,10 @@
#include <initguid.h>
#include <combaseapi.h>
#include <thread>
#include <wrl/client.h>
#include <dxgi.h>
#include "virtual_display.h"
using namespace SUDOVDA;
@@ -163,6 +167,38 @@ bool startPingThread(std::function<void()> failCb) {
return true;
}
bool setRenderAdapterByName(const std::wstring& adapterName) {
if (SUDOVDA_DRIVER_HANDLE == INVALID_HANDLE_VALUE) {
return false;
}
Microsoft::WRL::ComPtr<IDXGIFactory1> factory;
if (!SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) {
return false;
}
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter;
DXGI_ADAPTER_DESC desc;
int i = 0;
while (SUCCEEDED(factory->EnumAdapters(i, &adapter))) {
i += 1;
if (!SUCCEEDED(adapter->GetDesc(&desc))) {
continue;
}
if (std::wstring_view(desc.Description) != adapterName) {
continue;
}
if (SetRenderAdapter(SUDOVDA_DRIVER_HANDLE, desc.AdapterLuid)) {
return true;
}
}
return false;
}
std::wstring createVirtualDisplay(
const char* s_client_uid,
const char* s_client_name,

View File

@@ -29,6 +29,7 @@ namespace VDISPLAY {
void closeVDisplayDevice();
DRIVER_STATUS openVDisplayDevice();
bool startPingThread(std::function<void()> failCb);
bool setRenderAdapterByName(const std::wstring& adapterName);
std::wstring createVirtualDisplay(
const char* s_client_uid,
const char* s_client_name,

View File

@@ -16,7 +16,7 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "YukiWorkshop\0"
VALUE "CompanyName", "SudoMaker\0"
VALUE "FileDescription", "Apollo\0"
VALUE "FileVersion", "@PROJECT_VERSION@\0"
VALUE "InternalName", "Apollo\0"