summaryrefslogtreecommitdiffstats
path: root/tools/gfx/render-d3d11.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-25 11:48:10 -0400
committerGitHub <noreply@github.com>2019-03-25 11:48:10 -0400
commit2f4029a753f72833c30c4e6bad28c06b20540384 (patch)
treeca771b5e00c6126351079b2df920d014e4ed6a1e /tools/gfx/render-d3d11.cpp
parent5bdc3ef07373be62363deb64dedd4163589430b6 (diff)
Adapter selection for Renderer (#923)
* * Make adapter used selectable on the command line * Added 'adapter' to Renderer::Desc with dx11, dx12, vk honoring it * GL will check that the renderer matches, but cannot select a specific device * Share functionality on dx adapter selection in D3DUtil Note - that on tests that use OpenGL and the adapter doesn't match it will ignore the test (and display a message that the appropriate device couldn't be started) * Small function name improvement. * Variable rename to match type. * Fix typo in Dx12 device selection. * * Add checking if an adapter is warp * Improve some comments
Diffstat (limited to 'tools/gfx/render-d3d11.cpp')
-rw-r--r--tools/gfx/render-d3d11.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/gfx/render-d3d11.cpp b/tools/gfx/render-d3d11.cpp
index 8b961c8f2..afb8c3e5f 100644
--- a/tools/gfx/render-d3d11.cpp
+++ b/tools/gfx/render-d3d11.cpp
@@ -472,12 +472,33 @@ SlangResult D3D11Renderer::initialize(const Desc& desc, void* inWindowHandle)
for (int i = 0; i < numCombinations; ++i)
{
const auto deviceCheckFlags = combiner.getCombination(i);
- const D3D_DRIVER_TYPE driverType = (deviceCheckFlags & DeviceCheckFlag::UseHardwareDevice) ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_REFERENCE;
+
+ // If we have an adapter set on the desc, look it up. We only need to do so for hardware
+ ComPtr<IDXGIAdapter> adapter;
+ if (desc.adapter.Length() && (deviceCheckFlags & DeviceCheckFlag::UseHardwareDevice))
+ {
+ List<ComPtr<IDXGIAdapter>> dxgiAdapters;
+ D3DUtil::findAdapters(deviceCheckFlags, desc.adapter.getUnownedSlice(), dxgiAdapters);
+ if (dxgiAdapters.Count() == 0)
+ {
+ continue;
+ }
+ adapter = dxgiAdapters[0];
+ }
+
+ // The adapter can be nullptr - that just means 'default', but when so we need to select the driver type
+ D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_UNKNOWN;
+ if (adapter == nullptr)
+ {
+ // If we don't have an adapter, select directly
+ driverType = (deviceCheckFlags & DeviceCheckFlag::UseHardwareDevice) ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_REFERENCE;
+ }
+
const int startFeatureIndex = (deviceCheckFlags & DeviceCheckFlag::UseFullFeatureLevel) ? 0 : 1;
const UINT deviceFlags = (deviceCheckFlags & DeviceCheckFlag::UseDebug) ? D3D11_CREATE_DEVICE_DEBUG : 0;
res = D3D11CreateDeviceAndSwapChain_(
- nullptr, // adapter (use default)
+ adapter,
driverType,
nullptr, // software
deviceFlags,