I am hooking D3D11CreateDevice for choosing GPU manually in a computer with more than one graphic card.
I am using Detour to hook D3D11CreateDevice, and in my function, I use EnumAdapters function to get specific IDXGIAdapter pointer. And pass it to origin D3D11CreateDevice(i set parameter DriverType to D3D_DRIVER_TYPE_UNKNOWN and Software to NULL as well).
in 32-bit Direct3D environment, everything is right. But in 64-bit Direct3D environment, i found something strange.
D3D11CreateDevice will call D3D11CreateDeviceAndSwapChain inside.IDXGISwapChain::Present will call D3D11CreateDevice (which will call D3D11CreateDeviceAndSwapChain) inside.I found if i change IDXGISwapChain::Present inside callD3D11CreateDevice's parameter to specific IDXGIAdapter, the program dose have a window, but no picture inside, and IDXGISwapChain::Present failed with 0x80070057(E_INVALIDARG).
If i leave IDXGISwapChain::Present inside callD3D11CreateDevice's aside(do not change the parameter this call only). Everything is right: the program runs in specific GPU and picture shows inside the window.
I wanna ask why IDXGISwapChain::Present call D3D11CreateDevice in this situation. Is there something wrong i did causing this ?
Thank you!
User contributions licensed under CC BY-SA 3.0