From 98afb421f408aa8651afff3dba1b21fad71131fe Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Mar 2021 13:57:55 -0700 Subject: Reimplement Vulkan shader objects. (#1764) * Reimplement Vulkan shader objects. This change reimplements Vulkan shader objects in the `gfx` layer so that it is no longer layered on top of the `DescriptorSet` abstraction. Since this is the last implementation that uses `DescriptorSet`, the change also removes all `DescriptorSet` related API from public `gfx` interface. The Vulkan implementation now passes all test cases, but it still have two issues: 1. The PushConstant setting is not correct, this is because we don't seem to be able to get correct reflection data about the size of push constants for an entry-point. 2. The `shader-toy` example can't run on Vulkan, because it currently sets nullptr to `Texture` bindings, and this change doesn't properly handle setting resource to null in `ShaderObject`s yet. If we can use the `nullDescriptor` feature on vulkan, this implementation will be simple. However we still want to decide whether we want to use a Vulkan 1.2 feature for this. * Fix up --- tools/render-test/slang-support.cpp | 32 +------------------------------- tools/render-test/slang-support.h | 15 --------------- 2 files changed, 1 insertion(+), 46 deletions(-) (limited to 'tools/render-test') diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index c6d2b971e..72732363e 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -52,16 +52,10 @@ gfx::StageType translateStage(SlangStage slangStage) void ShaderCompilerUtil::Output::set( PipelineType pipelineType, - const IShaderProgram::KernelDesc* inKernelDescs, - Slang::Index kernelDescCount, slang::IComponentType* inSlangProgram) { - kernelDescs.clear(); - kernelDescs.addRange(inKernelDescs, kernelDescCount); slangProgram = inSlangProgram; desc.pipelineType = pipelineType; - desc.kernels = kernelDescs.getBuffer(); - desc.kernelCount = kernelDescCount; desc.slangProgram = inSlangProgram; } @@ -70,11 +64,8 @@ void ShaderCompilerUtil::Output::reset() { desc.pipelineType = PipelineType::Unknown; desc.slangProgram = nullptr; - desc.kernels = nullptr; - desc.kernelCount = 0; } - kernelDescs.clear(); if (m_requestForKernels && session) { spDestroyCompileRequest(m_requestForKernels); @@ -245,28 +236,7 @@ void ShaderCompilerUtil::Output::reset() actualEntryPoints = request.entryPoints; } - Slang::List kernelDescs; - - Index actualEntryPointCount = actualEntryPoints.getCount(); - for(Index ee = 0; ee < actualEntryPointCount; ++ee) - { - auto& actualEntryPoint = actualEntryPoints[ee]; - - size_t codeSize = 0; - char const* code = (char const*) spGetEntryPointCode(slangRequest, int(ee), &codeSize); - - auto gfxStage = translateStage(actualEntryPoint.slangStage); - - IShaderProgram::KernelDesc kernelDesc; - kernelDesc.stage = gfxStage; - kernelDesc.codeBegin = code; - kernelDesc.codeEnd = code + codeSize; - kernelDesc.entryPointName = actualEntryPoint.name; - - kernelDescs.add(kernelDesc); - } - - out.set(input.pipelineType, kernelDescs.getBuffer(), kernelDescs.getCount(), linkedSlangProgram); + out.set(input.pipelineType, linkedSlangProgram); return SLANG_OK; } diff --git a/tools/render-test/slang-support.h b/tools/render-test/slang-support.h index 6fa850874..7e00a2c72 100644 --- a/tools/render-test/slang-support.h +++ b/tools/render-test/slang-support.h @@ -60,8 +60,6 @@ struct ShaderCompilerUtil { void set( PipelineType pipelineType, - const IShaderProgram::KernelDesc* kernelDescs, - Slang::Index kernelDescCount, slang::IComponentType* slangProgram); void reset(); ~Output() @@ -69,19 +67,6 @@ struct ShaderCompilerUtil reset(); } - Slang::Index findKernelDescIndex(gfx::StageType stage) const - { - for (Slang::Index i = 0; i < kernelDescs.getCount(); ++i) - { - if (kernelDescs[i].stage == stage) - { - return i; - } - } - return -1; - } - - Slang::List kernelDescs; ComPtr slangProgram; IShaderProgram::Desc desc = {}; -- cgit v1.2.3