diff options
| -rw-r--r-- | slang-gfx.h | 4 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.cpp | 16 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.h | 1 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-pipeline-state.cpp | 50 |
4 files changed, 61 insertions, 10 deletions
diff --git a/slang-gfx.h b/slang-gfx.h index 9b45d2397..c3b6e7e3d 100644 --- a/slang-gfx.h +++ b/slang-gfx.h @@ -2639,6 +2639,10 @@ public: 0xc3d5f782, 0xeae1, 0x4da6, { 0xab, 0x40, 0x75, 0x32, 0x31, 0x2, 0xb7, 0xdc } \ } +#define SLANG_UUID_IVulkanPipelineCreationAPIDispatcher \ + { \ + 0x4fcf1274, 0x8752, 0x4743, { 0xb3, 0x51, 0x47, 0xcb, 0x83, 0x71, 0xef, 0x99 } \ + } // Global public functions diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp index 5111edee5..54311dd47 100644 --- a/tools/gfx/renderer-shared.cpp +++ b/tools/gfx/renderer-shared.cpp @@ -46,6 +46,7 @@ const Slang::Guid GfxGUID::IID_IAccelerationStructure = SLANG_UUID_IAcceleration const Slang::Guid GfxGUID::IID_IFence = SLANG_UUID_IFence; const Slang::Guid GfxGUID::IID_IShaderTable = SLANG_UUID_IShaderTable; const Slang::Guid GfxGUID::IID_IPipelineCreationAPIDispatcher = SLANG_UUID_IPipelineCreationAPIDispatcher; +const Slang::Guid GfxGUID::IID_IVulkanPipelineCreationAPIDispatcher = SLANG_UUID_IVulkanPipelineCreationAPIDispatcher; const Slang::Guid GfxGUID::IID_ITransientResourceHeapD3D12 = SLANG_UUID_ITransientResourceHeapD3D12; @@ -397,9 +398,18 @@ SLANG_NO_THROW Result SLANG_MCALL RendererBase::initialize(const Desc& desc) if (desc.apiCommandDispatcher) { - desc.apiCommandDispatcher->queryInterface( - GfxGUID::IID_IPipelineCreationAPIDispatcher, - (void**)m_pipelineCreationAPIDispatcher.writeRef()); + if (desc.deviceType == DeviceType::Vulkan) + { + desc.apiCommandDispatcher->queryInterface( + GfxGUID::IID_IVulkanPipelineCreationAPIDispatcher, + (void**)m_pipelineCreationAPIDispatcher.writeRef()); + } + else + { + desc.apiCommandDispatcher->queryInterface( + GfxGUID::IID_IPipelineCreationAPIDispatcher, + (void**)m_pipelineCreationAPIDispatcher.writeRef()); + } } return SLANG_OK; } diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index d39b64873..5c67de885 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -44,6 +44,7 @@ struct GfxGUID static const Slang::Guid IID_IFence; static const Slang::Guid IID_IShaderTable; static const Slang::Guid IID_IPipelineCreationAPIDispatcher; + static const Slang::Guid IID_IVulkanPipelineCreationAPIDispatcher; static const Slang::Guid IID_ITransientResourceHeapD3D12; }; diff --git a/tools/gfx/vulkan/vk-pipeline-state.cpp b/tools/gfx/vulkan/vk-pipeline-state.cpp index 712811f9a..d861a343c 100644 --- a/tools/gfx/vulkan/vk-pipeline-state.cpp +++ b/tools/gfx/vulkan/vk-pipeline-state.cpp @@ -273,8 +273,20 @@ Result PipelineStateImpl::createVKGraphicsPipelineState() pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; pipelineInfo.pDynamicState = &dynamicStateInfo; - SLANG_VK_CHECK(m_device->m_api.vkCreateGraphicsPipelines( - m_device->m_device, pipelineCache, 1, &pipelineInfo, nullptr, &m_pipeline)); + if (m_device->m_pipelineCreationAPIDispatcher) + { + SLANG_RETURN_ON_FAIL( + m_device->m_pipelineCreationAPIDispatcher->createGraphicsPipelineState( + m_device, + programImpl->linkedProgram.get(), + &pipelineInfo, + (void**)&m_pipeline)); + } + else + { + SLANG_VK_CHECK(m_device->m_api.vkCreateGraphicsPipelines( + m_device->m_device, pipelineCache, 1, &pipelineInfo, nullptr, &m_pipeline)); + } return SLANG_OK; } @@ -287,14 +299,26 @@ Result PipelineStateImpl::createVKComputePipelineState() SLANG_RETURN_ON_FAIL(programImpl->compileShaders(m_device)); } - VkPipelineCache pipelineCache = VK_NULL_HANDLE; - VkComputePipelineCreateInfo computePipelineInfo = { - VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; computePipelineInfo.stage = programImpl->m_stageCreateInfos[0]; computePipelineInfo.layout = programImpl->m_rootObjectLayout->m_pipelineLayout; - SLANG_VK_CHECK(m_device->m_api.vkCreateComputePipelines( - m_device->m_device, pipelineCache, 1, &computePipelineInfo, nullptr, &m_pipeline)); + + if (m_device->m_pipelineCreationAPIDispatcher) + { + SLANG_RETURN_ON_FAIL( + m_device->m_pipelineCreationAPIDispatcher->createComputePipelineState( + m_device, + programImpl->linkedProgram.get(), + &computePipelineInfo, + (void**)&m_pipeline)); + } + else + { + VkPipelineCache pipelineCache = VK_NULL_HANDLE; + SLANG_VK_CHECK(m_device->m_api.vkCreateComputePipelines( + m_device->m_device, pipelineCache, 1, &computePipelineInfo, nullptr, &m_pipeline)); + } return SLANG_OK; } @@ -424,6 +448,12 @@ Result RayTracingPipelineStateImpl::createVKRayTracingPipelineState() raytracingPipelineInfo.basePipelineHandle = VK_NULL_HANDLE; raytracingPipelineInfo.basePipelineIndex = 0; + if (m_device->m_pipelineCreationAPIDispatcher) + { + m_device->m_pipelineCreationAPIDispatcher->beforeCreateRayTracingState( + m_device, programImpl->linkedProgram.get()); + } + VkPipelineCache pipelineCache = VK_NULL_HANDLE; SLANG_VK_CHECK(m_device->m_api.vkCreateRayTracingPipelinesKHR( m_device->m_device, @@ -434,6 +464,12 @@ Result RayTracingPipelineStateImpl::createVKRayTracingPipelineState() nullptr, &m_pipeline)); shaderGroupCount = shaderGroupInfos.getCount(); + + if (m_device->m_pipelineCreationAPIDispatcher) + { + m_device->m_pipelineCreationAPIDispatcher->afterCreateRayTracingState( + m_device, programImpl->linkedProgram.get()); + } return SLANG_OK; } Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated() |
