From 7bf2e124a1fa81695fb82764fe3537e74c5fc956 Mon Sep 17 00:00:00 2001 From: BrennerLittle <46569863+BrennerLittle@users.noreply.github.com> Date: Wed, 29 Sep 2021 10:55:17 -0500 Subject: [PATCH] Makes NVidia Card Default in Ambient Occlusion example. (#740) Fixes the selection of iGPU before dGPU for this sample --- .../SampleCore/util/DeviceResources.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/SampleCore/util/DeviceResources.cpp b/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/SampleCore/util/DeviceResources.cpp index f65f64ddf..3a2f7340e 100644 --- a/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/SampleCore/util/DeviceResources.cpp +++ b/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/SampleCore/util/DeviceResources.cpp @@ -638,8 +638,15 @@ void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter) *ppAdapter = nullptr; ComPtr adapter; - for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID) + ComPtr factory6; + HRESULT hr = m_dxgiFactory.As(&factory6); + if (FAILED(hr)) { + throw exception("DXGI 1.6 not supported"); + } + for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != factory6->EnumAdapterByGpuPreference(adapterID, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(&adapter)); ++adapterID) + { + if (m_adapterIDoverride != UINT_MAX && adapterID != m_adapterIDoverride) { continue; @@ -694,4 +701,4 @@ void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter) } *ppAdapter = adapter.Detach(); -} \ No newline at end of file +}