Skip to content

Commit

Permalink
Fixed the DXR samples so they can run on (I'm wheezing) Surface Book …
Browse files Browse the repository at this point in the history
…3 and other MSHybrid systems.
  • Loading branch information
sherief committed Nov 27, 2020
1 parent 76146b8 commit 287324f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,20 @@ void DeviceResources::MoveToNextFrame()
m_fenceValues[m_backBufferIndex] = currentFenceValue + 1;
}

// This method acquires the first available hardware adapter that supports Direct3D 12.
// This method acquires the first high-performance hardware adapter that supports Direct3D 12.
// If no such adapter can be found, try WARP. Otherwise throw an exception.
void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter)
{
*ppAdapter = nullptr;

ComPtr<IDXGIAdapter1> adapter;
for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID)
ComPtr<IDXGIFactory6> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,20 @@ void DeviceResources::MoveToNextFrame()
m_fenceValues[m_backBufferIndex] = currentFenceValue + 1;
}

// This method acquires the first available hardware adapter that supports Direct3D 12.
// This method acquires the first high-performance hardware adapter that supports Direct3D 12.
// If no such adapter can be found, try WARP. Otherwise throw an exception.
void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter)
{
*ppAdapter = nullptr;

ComPtr<IDXGIAdapter1> adapter;
for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID)
ComPtr<IDXGIFactory6> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,20 @@ void DeviceResources::MoveToNextFrame()
m_fenceValues[m_backBufferIndex] = currentFenceValue + 1;
}

// This method acquires the first available hardware adapter that supports Direct3D 12.
// This method acquires the first high-performance hardware adapter that supports Direct3D 12.
// If no such adapter can be found, try WARP. Otherwise throw an exception.
void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter)
{
*ppAdapter = nullptr;

ComPtr<IDXGIAdapter1> adapter;
for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID)
ComPtr<IDXGIFactory6> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,20 @@ void DeviceResources::MoveToNextFrame()
m_fenceValues[m_backBufferIndex] = currentFenceValue + 1;
}

// This method acquires the first available hardware adapter that supports Direct3D 12.
// This method acquires the first high-performance hardware adapter that supports Direct3D 12.
// If no such adapter can be found, try WARP. Otherwise throw an exception.
void DeviceResources::InitializeAdapter(IDXGIAdapter1** ppAdapter)
{
*ppAdapter = nullptr;

ComPtr<IDXGIAdapter1> adapter;
for (UINT adapterID = 0; DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID)
ComPtr<IDXGIFactory6> 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)
{
Expand Down

0 comments on commit 287324f

Please sign in to comment.