Set render adapter for virtual display driver w/ show detailed virtual display driver status on config
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace proc {
|
||||
if (vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||
if (!VDISPLAY::startPingThread(onVDisplayWatchdogFailed)) {
|
||||
onVDisplayWatchdogFailed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,6 +250,11 @@ namespace proc {
|
||||
if (vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||
std::wstring prevPrimaryDisplayName = VDISPLAY::getPrimaryDisplay();
|
||||
|
||||
// Try set the render adapter matching the capture adapter if user has specified one
|
||||
if (!config::video.adapter_name.empty()) {
|
||||
VDISPLAY::setRenderAdapterByName(platf::from_utf8(config::video.adapter_name));
|
||||
}
|
||||
|
||||
memcpy(&launch_session->display_guid, &http::uuid, sizeof(GUID));
|
||||
|
||||
std::wstring vdisplayName = VDISPLAY::createVirtualDisplay(
|
||||
|
||||
Reference in New Issue
Block a user