Sitelet https://github.com/microsoft/DirectX-Graphics-Samples/pull/676/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a recent fix to make this a little more robust. Change this:

DXGI_ERROR_NOT_FOUND != m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID)

to

SUCCEEDED(m_dxgiFactory->EnumAdapters1(adapterID, &adapter); ++adapterID))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would definitely be an improvement, I'm only fixing one thing at (my own) time though, I don't think I will spend more time on this unless the core functionality of making it work on MSHybrid systems has issues.

{
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