summaryrefslogtreecommitdiffstats
path: root/tools/gfx/render-vk.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-vk.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-vk.cpp')
-rw-r--r--tools/gfx/render-vk.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/tools/gfx/render-vk.cpp b/tools/gfx/render-vk.cpp
index defc08355..30eff04c9 100644
--- a/tools/gfx/render-vk.cpp
+++ b/tools/gfx/render-vk.cpp
@@ -948,8 +948,35 @@ SlangResult VKRenderer::initialize(const Desc& desc, void* inWindowHandle)
physicalDevices.SetSize(numPhysicalDevices);
SLANG_VK_RETURN_ON_FAIL(m_api.vkEnumeratePhysicalDevices(instance, &numPhysicalDevices, physicalDevices.Buffer()));
- // TODO: allow override of selected device
- uint32_t selectedDeviceIndex = 0;
+ int32_t selectedDeviceIndex = 0;
+
+ if (desc.adapter.Length())
+ {
+ selectedDeviceIndex = -1;
+
+ String lowerAdapter = desc.adapter.ToLower();
+
+ for (int i = 0; i < int(physicalDevices.Count()); ++i)
+ {
+ auto physicalDevice = physicalDevices[i];
+
+ VkPhysicalDeviceProperties basicProps = {};
+ m_api.vkGetPhysicalDeviceProperties(physicalDevice, &basicProps);
+
+ String lowerName = String(basicProps.deviceName).ToLower();
+
+ if (lowerName.IndexOf(lowerAdapter) != UInt(-1))
+ {
+ selectedDeviceIndex = i;
+ break;
+ }
+ }
+ if (selectedDeviceIndex < 0)
+ {
+ // Device not found
+ return SLANG_FAIL;
+ }
+ }
SLANG_RETURN_ON_FAIL(m_api.initPhysicalDevice(physicalDevices[selectedDeviceIndex]));
@@ -2704,7 +2731,7 @@ Result VKRenderer::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
VkPipeline pipeline = VK_NULL_HANDLE;
SLANG_VK_CHECK(m_api.vkCreateGraphicsPipelines(m_device, pipelineCache, 1, &pipelineInfo, nullptr, &pipeline));
- RefPtr<PipelineStateImpl> pipelineStateImpl;
+ RefPtr<PipelineStateImpl> pipelineStateImpl = new PipelineStateImpl(m_api);
pipelineStateImpl->m_pipeline = pipeline;
pipelineStateImpl->m_pipelineLayout = pipelineLayoutImpl;
pipelineStateImpl->m_shaderProgram = programImpl;