d3dcoder / d3d12book

Sample code for the book "Introduction to 3D Game Programming with DirectX 12"
1.47k stars 571 forks source link

When creating the device, use the one with the most video memory. #1

Open kuukunen opened 8 years ago

kuukunen commented 8 years ago

I will also send an email too explaining it more fully.

I had problems running some of the examples, they had very obscure crashes, and it turned out to be because I have two adapters on my laptop: Intel's integrated and an Nvidia one. As a suggestion I'm now sending code that selects the adapter with the most memory. I'm not sure if this is the preferred solution, but here it is anyway.

JoeSwindell commented 8 years ago

Interesting...I have integrated graphics disabled in my bios so my only available adapters are my 2 970's. I wonder if anyone else with a newer processor with integrated graphics has run into this as well!

kuukunen commented 8 years ago

Also btw, the error I got was just a weird access violation ""Exception thrown at 0x00007FFA866DF14C (D3D12.dll) in Ssao.exe: 0xC0000005: Access violation reading location 0x0000000000000018." in CDevice::UMSetError_ inside D3D12.dll originally from the line "ThrowIfFailed(md3dDevice->CreateGraphicsPipelineState(&opaquePsoDesc, IID_PPV_ARGS(&mPSOs["opaque"])));" It seemed like Intel's drivers were handling out of memory errors incorrectly and calling the function with a null pointer. Just putting it here in case someone Googles for it. Took a while to find out what was happening.

kuukunen commented 8 years ago

Also note that for the sake of actual correctness, it maybe "should" sort the adapters by memory size and then attempt to create the devices in order, just in case the biggest one doesn't support DirectX 12 or fails for some reason. But since it's sample code and the original wasn't doing anything like that, I left that kind of stuff out for simplicity as it felt like a pretty distant edge case.

kuukunen commented 8 years ago

Seems like I don't get a crash on new Intel drivers any more, though.