Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to select specifial GPU for one screen? #110

Open
gehaoyu-cn opened this issue Jun 21, 2024 · 15 comments
Open

How to select specifial GPU for one screen? #110

gehaoyu-cn opened this issue Jun 21, 2024 · 15 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gehaoyu-cn
Copy link

I have 2 GPUs and 2 vitrual screens, now 2 screens are working on single GPU, how to seperate 2 screens load into each GPU?

@itsmikethetech
Copy link
Owner

HDR release with GPU switching in testing now. https://github.com/itsmikethetech/Virtual-Display-Driver/releases/tag/24.7.18HDR

@matheusfaustino
Copy link

matheusfaustino commented Jul 31, 2024

Can confirm the manual switching thing works.

Basically, you need to find the name of your using the enum_dxgi (you can find in this thread nomi-san/parsec-vdd#47) and then, download his release above, put the name of your GPU in adapter.txt file , put it inside C:\IddSampleDriver together with the options.txt and, install the driver (just delete the old driver, if you have it) .
It should select your GPU now for the screen virtual display.

I think I will create a PR explaining this process in the README. The trick is that you need to do this before installing the driver, it is not hot-reload. you can disable and re-enable the driver (thanks @bud3699 )

@zjoasan
Copy link

zjoasan commented Jul 31, 2024

it is not hot-reload.

Have you tried, just disable and re-enable the driver after adding adapter.txt? That way you shouldn't have to uninstall and reinstall. But I didn't read the link in your post so I might be wrong.

Just my $0.02

@matheusfaustino
Copy link

matheusfaustino commented Jul 31, 2024

did not try it, but from what I've seen in the code, I think it only gets the content from the adapter.txt when it is adding it (might be wrong here - didn't check the whole code)

NTSTATUS IddSampleDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT pDeviceInit)
{
NTSTATUS Status = STATUS_SUCCESS;
WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerCallbacks;
UNREFERENCED_PARAMETER(Driver);
// Register for power callbacks - in this sample only power-on is needed
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&PnpPowerCallbacks);
PnpPowerCallbacks.EvtDeviceD0Entry = IddSampleDeviceD0Entry;
WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &PnpPowerCallbacks);
IDD_CX_CLIENT_CONFIG IddConfig;
IDD_CX_CLIENT_CONFIG_INIT(&IddConfig);
// If the driver wishes to handle custom IoDeviceControl requests, it's necessary to use this callback since IddCx
// redirects IoDeviceControl requests to an internal queue. This sample does not need this.
// IddConfig.EvtIddCxDeviceIoControl = IddSampleIoDeviceControl;
loadOptions("C:\\IddSampleDriver\\option.txt");
Options.Adapter.load("C:\\IddSampleDriver\\adapter.txt");

@bud3699
Copy link
Collaborator

bud3699 commented Jul 31, 2024

did not try it, but from what I've seen in the code, I think it only gets the content from the adapter.txt when it is adding it (might be wrong here - didn't check the whole code)

NTSTATUS IddSampleDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT pDeviceInit)
{
NTSTATUS Status = STATUS_SUCCESS;
WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerCallbacks;
UNREFERENCED_PARAMETER(Driver);
// Register for power callbacks - in this sample only power-on is needed
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&PnpPowerCallbacks);
PnpPowerCallbacks.EvtDeviceD0Entry = IddSampleDeviceD0Entry;
WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &PnpPowerCallbacks);
IDD_CX_CLIENT_CONFIG IddConfig;
IDD_CX_CLIENT_CONFIG_INIT(&IddConfig);
// If the driver wishes to handle custom IoDeviceControl requests, it's necessary to use this callback since IddCx
// redirects IoDeviceControl requests to an internal queue. This sample does not need this.
// IddConfig.EvtIddCxDeviceIoControl = IddSampleIoDeviceControl;
loadOptions("C:\\IddSampleDriver\\option.txt");
Options.Adapter.load("C:\\IddSampleDriver\\adapter.txt");

You can just disable and re-enable the driver. It calls all the code again on driver initialise. Not install

@matheusfaustino
Copy link

Perfekt. Thanks for checking. Better than installing

@bud3699
Copy link
Collaborator

bud3699 commented Jul 31, 2024

Perfekt. Thanks for checking. Better than installing

No problem :)

I already knew the answer so i would have been happy to share my knowledge. Better features to come soon enough!

@Nonary
Copy link

Nonary commented Aug 10, 2024

The latest changes in pre-release of this driver fixes the issue where it doesn't pick the proper GPU, but it will still be broken for Sunshine users due to how it is also mistakenly choosing the iGPU when attempting to capture the display.

Fortunately I fixed the issue on Sunshine, and I will be opening a PR later today.

Therefore, with the combination of these two changes, one from IDDSampleDriver side and one from sunshine, the issue where you can't stream in moonlight when using the virtual screen with more than one gpu will be resolved. No more black screens, also fixes the no video received from host error.

I'll comment here once I open that PR

@Nonary
Copy link

Nonary commented Aug 10, 2024

submitted LizardByte/Sunshine#3002

@zjoasan
Copy link

zjoasan commented Aug 11, 2024

@Nonary I glanced at your PR on Sunshines repo, although i don't know their repo. Is it likely that it's "our driver" that is "at fault" and perhaps we should some initial testing when grabbing GPU, and resasign if "blank". Or is it' Sunshine way of addressing our driver??

My thinking: How likely would it be for example OBS to experience the same? Or, I believe it was, Anydesk that had issues. Haven't tested any one of em. And I only have CPU based gpu (i7 gen4).

@bud3699 what do you think??

@Nonary
Copy link

Nonary commented Aug 11, 2024

@Nonary I glanced at your PR on Sunshines repo, although i don't know their repo. Is it likely that it's "our driver" that is "at fault" and perhaps we should some initial testing when grabbing GPU, and resasign if "blank". Or is it' Sunshine way of addressing our driver??

My thinking: How likely would it be for example OBS to experience the same? Or, I believe it was, Anydesk that had issues. Haven't tested any one of em. And I only have CPU based gpu (i7 gen4).

@bud3699 what do you think??

The issues with the virtual display were mainly due to how Sunshine handled things, but the fix you implemented does help. One of the problems was that the driver might mistakenly attach to the iGPU, but this wasn’t as frequent as the Sunshine bug was.

We have a small utility program that tests DXGI against different adapters and monitors. If the test passes, the program assigns that GPU as the preferred one for capturing. The problem was that the utility only checked if we could duplicate the display in DXGI, not if it could actually capture frames. I’ve fixed that, so now Sunshine won’t encounter this issue anymore because IDDSampleDriver will fail if it can’t capture frames.

The reason we have this utility is due to a limitation with setting GPU preferences in DXGI—it can only be done once per process. So, we created a helper program to test DXGI and then report back to Sunshine. If the test passed, it would set the GPU preferences. The issue was that it was reporting success just because it could duplicate the display, without checking if it could capture frames. And since this can only be done once per process, Sunshine couldn’t recover or test the second GPU. By fixing the utility, the issue is now resolved.

@zjoasan
Copy link

zjoasan commented Aug 11, 2024

@Nonary Thank you for the descriptive explanation, then we could add that bit later in the pipe perhaps. I'm a sucker for double checking and fallback solutions.

@sofmeright
Copy link

sofmeright commented Sep 5, 2024

it is not hot-reload.

Have you tried, just disable and re-enable the driver after adding adapter.txt? That way you shouldn't have to uninstall and reinstall. But I didn't read the link in your post so I might be wrong.

Just my $0.02

I wanted to add as you say you can avoid uninstall/reinstall by disable/re-enable... I have another solution that does not remove the display and allows remote clients that are dependent on the display to stay connected.

I saw this quoted recommendation while looking for a solution to a render resolution / aspect ratio issue I was having in Immortals Fenyx Rising. I resolved the issue and wanted to thank the devs of this Driver solution for doing all the hardest work of implementing microsofts driver whereas before we were unable to use any of these features without this wonderful implementation! I am also linking my current setup I derived from this capability! Thanks for your efforts! WE ARE SPOILED <3 http://sh.uni2.cc/28JLJ

Solution:
"Restarting the Virtual Display Adapter after making changes can be done by disabling and re-enabling it or also by a reboot, this was frustrating for me as it would require me to temporarily lose access to the stream of this system via Moonlight. My preferred method of resetting it when making changes is now selecting the "IddSampleDriver Device HDR" in "Display Adapters" within Device Manager and right clicking > Update Driver > Browse my computer for drivers and allow me to select from drivers on my PC > Have disk (essentially reinstall the driver over itself). By this method I do not get disconnected when it reloads any changes I have made."

@bud3699 bud3699 added enhancement New feature or request help wanted Extra attention is needed labels Oct 9, 2024
@fr1g
Copy link

fr1g commented Nov 11, 2024

How about in the newest beta? I've noticed that there's no longer any .txt file but a .xml file.

@fr1g
Copy link

fr1g commented Nov 11, 2024

How about in the newest beta? I've noticed that there's no longer any .txt file but a .xml file.

OKAY i found inside that xml here's a place that i can paste the friendly name of the gpu. But still is there any way to use device id though? or device id changes during each system start-up?

anyway this solution is the best for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants