From dcb434a5fe801d42d1b5f385fd27d0c500687647 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 8 Mar 2022 14:34:53 -0800 Subject: GFX Vulkan: deferred shader compilation and pipeline creation. (#2153) * Vulkan: deferred shader compilation and pipeline creation. * Fix 32bit build. Co-authored-by: Yong He --- tools/gfx/d3d12/render-d3d12.cpp | 66 ++++++++-------------------------------- 1 file changed, 12 insertions(+), 54 deletions(-) (limited to 'tools/gfx/d3d12/render-d3d12.cpp') diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index a6a0c7790..0fc3b2874 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -2479,68 +2479,26 @@ public: { SlangStage stage; slang::EntryPointReflection* entryPointInfo; + String actualEntryPointNameInAPI; List code; }; class ShaderProgramImpl : public ShaderProgramBase { public: - List m_shaders; RefPtr m_rootObjectLayout; - Result compileShaders() - { - // For a fully specialized program, read and store its kernel code in `shaderProgram`. - auto compileShader = [&](slang::EntryPointReflection* entryPointInfo, - slang::IComponentType* entryPointComponent, - SlangInt entryPointIndex) - { - auto stage = entryPointInfo->getStage(); - ComPtr kernelCode; - ComPtr diagnostics; - auto compileResult = entryPointComponent->getEntryPointCode( - entryPointIndex, 0, kernelCode.writeRef(), diagnostics.writeRef()); - if (diagnostics) - { - getDebugCallback()->handleMessage( - compileResult == SLANG_OK ? DebugMessageType::Warning - : DebugMessageType::Error, - DebugMessageSource::Slang, - (char*)diagnostics->getBufferPointer()); - } - SLANG_RETURN_ON_FAIL(compileResult); - ShaderBinary shaderBin; - shaderBin.stage = stage; - shaderBin.entryPointInfo = entryPointInfo; - shaderBin.code.addRange( - reinterpret_cast(kernelCode->getBufferPointer()), - (Index)kernelCode->getBufferSize()); - m_shaders.add(_Move(shaderBin)); - return SLANG_OK; - }; + List m_shaders; - if (linkedEntryPoints.getCount() == 0) - { - // If the user does not explicitly specify entry point components, find them from - // `linkedEntryPoints`. - auto programReflection = linkedProgram->getLayout(); - for (SlangUInt i = 0; i < programReflection->getEntryPointCount(); i++) - { - SLANG_RETURN_ON_FAIL(compileShader( - programReflection->getEntryPointByIndex(i), - linkedProgram, - (SlangInt)i)); - } - } - else - { - // If the user specifies entry point components via the separated entry point array, - // compile code from there. - for (auto& entryPoint : linkedEntryPoints) - { - SLANG_RETURN_ON_FAIL(compileShader( - entryPoint->getLayout()->getEntryPointByIndex(0), entryPoint, 0)); - } - } + virtual Result createShaderModule( + slang::EntryPointReflection* entryPointInfo, ComPtr kernelCode) override + { + ShaderBinary shaderBin; + shaderBin.stage = entryPointInfo->getStage(); + shaderBin.entryPointInfo = entryPointInfo; + shaderBin.code.addRange( + reinterpret_cast(kernelCode->getBufferPointer()), + (Index)kernelCode->getBufferSize()); + m_shaders.add(_Move(shaderBin)); return SLANG_OK; } }; -- cgit v1.2.3