summaryrefslogtreecommitdiffstats
path: root/tools/gfx/renderer-shared.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-03-24 13:57:55 -0700
committerGitHub <noreply@github.com>2021-03-24 13:57:55 -0700
commit98afb421f408aa8651afff3dba1b21fad71131fe (patch)
treea8610d12ac7d74a8772cb6ecdd810da8216baa67 /tools/gfx/renderer-shared.cpp
parentd0f7b7f0ed1d0d1388ce944cd1ad906bbd9afb35 (diff)
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
Diffstat (limited to 'tools/gfx/renderer-shared.cpp')
-rw-r--r--tools/gfx/renderer-shared.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp
index a628cc997..2e6105793 100644
--- a/tools/gfx/renderer-shared.cpp
+++ b/tools/gfx/renderer-shared.cpp
@@ -1,5 +1,4 @@
#include "renderer-shared.h"
-#include "render-graphics-common.h"
#include "core/slang-io.h"
#include "core/slang-token-reader.h"
@@ -9,10 +8,7 @@ namespace gfx
{
const Slang::Guid GfxGUID::IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-const Slang::Guid GfxGUID::IID_IDescriptorSetLayout = SLANG_UUID_IDescriptorSetLayout;
-const Slang::Guid GfxGUID::IID_IDescriptorSet = SLANG_UUID_IDescriptorSet;
const Slang::Guid GfxGUID::IID_IShaderProgram = SLANG_UUID_IShaderProgram;
-const Slang::Guid GfxGUID::IID_IPipelineLayout = SLANG_UUID_IPipelineLayout;
const Slang::Guid GfxGUID::IID_IInputLayout = SLANG_UUID_IInputLayout;
const Slang::Guid GfxGUID::IID_IPipelineState = SLANG_UUID_IPipelineState;
const Slang::Guid GfxGUID::IID_IResourceView = SLANG_UUID_IResourceView;
@@ -113,49 +109,6 @@ gfx::StageType mapStage(SlangStage stage)
}
}
-Result createProgramFromSlang(IDevice* device, IShaderProgram::Desc const& originalDesc, IShaderProgram** outProgram)
-{
- SlangInt targetIndex = 0;
- auto slangProgram = originalDesc.slangProgram;
-
- auto programLayout = slangProgram->getLayout(targetIndex);
- if(!programLayout)
- return SLANG_FAIL;
-
- Int entryPointCount = (Int) programLayout->getEntryPointCount();
- if(entryPointCount == 0)
- return SLANG_FAIL;
-
- List<IShaderProgram::KernelDesc> kernelDescs;
- List<ComPtr<slang::IBlob>> kernelBlobs;
- for( Int i = 0; i < entryPointCount; ++i )
- {
- ComPtr<slang::IBlob> entryPointCodeBlob;
- SLANG_RETURN_ON_FAIL(slangProgram->getEntryPointCode(i, targetIndex, entryPointCodeBlob.writeRef()));
-
- auto entryPointLayout = programLayout->getEntryPointByIndex(i);
-
- kernelBlobs.add(entryPointCodeBlob);
-
- IShaderProgram::KernelDesc kernelDesc;
- kernelDesc.codeBegin = entryPointCodeBlob->getBufferPointer();
- kernelDesc.codeEnd = (const char*) kernelDesc.codeBegin + entryPointCodeBlob->getBufferSize();
- kernelDesc.entryPointName = entryPointLayout->getName();
- kernelDesc.stage = mapStage(entryPointLayout->getStage());
-
- kernelDescs.add(kernelDesc);
- }
- SLANG_ASSERT(kernelDescs.getCount() == entryPointCount);
-
- IShaderProgram::Desc programDesc;
- programDesc.pipelineType = originalDesc.pipelineType;
- programDesc.slangProgram = slangProgram;
- programDesc.kernelCount = kernelDescs.getCount();
- programDesc.kernels = kernelDescs.getBuffer();
-
- return device->createProgram(programDesc, outProgram);
-}
-
IShaderObject* gfx::ShaderObjectBase::getInterface(const Guid& guid)
{
if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IShaderObject)
@@ -243,19 +196,6 @@ void PipelineStateBase::initializeBase(const PipelineStateDesc& inDesc)
auto program = desc.getProgram();
m_program = program;
isSpecializable = (program->slangProgram && program->slangProgram->getSpecializationParamCount() != 0);
-
- switch (desc.type)
- {
- case PipelineType::Graphics:
- m_pipelineLayout = inDesc.graphics.pipelineLayout;
- break;
- case PipelineType::Compute:
- m_pipelineLayout = inDesc.compute.pipelineLayout;
- break;
- default:
- assert(!"unknown pipeline type");
- break;
- }
}
IDevice* gfx::RendererBase::getInterface(const Guid& guid)