summaryrefslogtreecommitdiffstats
path: root/tools/gfx/renderer-shared.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx/renderer-shared.cpp')
-rw-r--r--tools/gfx/renderer-shared.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp
index 741b1eba5..fdee8b776 100644
--- a/tools/gfx/renderer-shared.cpp
+++ b/tools/gfx/renderer-shared.cpp
@@ -21,7 +21,6 @@ const Slang::Guid GfxGUID::IID_IResource = SLANG_UUID_IResource;
const Slang::Guid GfxGUID::IID_IBufferResource = SLANG_UUID_IBufferResource;
const Slang::Guid GfxGUID::IID_ITextureResource = SLANG_UUID_ITextureResource;
const Slang::Guid GfxGUID::IID_IRenderer = SLANG_UUID_IRenderer;
-const Slang::Guid GfxGUID::IID_IShaderObjectLayout = SLANG_UUID_IShaderObjectLayout;
const Slang::Guid GfxGUID::IID_IShaderObject = SLANG_UUID_IShaderObject;
gfx::StageType translateStage(SlangStage slangStage)
@@ -216,6 +215,30 @@ SLANG_NO_THROW Result SLANG_MCALL RendererBase::getSlangSession(slang::ISession*
return SLANG_OK;
}
+SLANG_NO_THROW Result SLANG_MCALL RendererBase::createShaderObject(slang::TypeReflection* type, IShaderObject** outObject)
+{
+ RefPtr<ShaderObjectLayoutBase> shaderObjectLayout;
+ SLANG_RETURN_FALSE_ON_FAIL(getShaderObjectLayout(type, shaderObjectLayout.writeRef()));
+ return createShaderObject(shaderObjectLayout, outObject);
+}
+
+Result RendererBase::getShaderObjectLayout(
+ slang::TypeReflection* type,
+ ShaderObjectLayoutBase** outLayout)
+{
+ RefPtr<ShaderObjectLayoutBase> shaderObjectLayout;
+ if( !m_shaderObjectLayoutCache.TryGetValue(type, shaderObjectLayout) )
+ {
+ auto typeLayout = slangContext.session->getTypeLayout(type);
+ SLANG_RETURN_ON_FAIL(createShaderObjectLayout(typeLayout, shaderObjectLayout.writeRef()));
+ m_shaderObjectLayoutCache.Add(type, shaderObjectLayout);
+ }
+ *outLayout = shaderObjectLayout.detach();
+ return SLANG_OK;
+}
+
+
+
ShaderComponentID ShaderCache::getComponentId(slang::TypeReflection* type)
{
ComponentKey key;
@@ -363,13 +386,6 @@ Result ShaderBinary::writeToBlob(ISlangBlob** outBlob)
return SLANG_OK;
}
-IShaderObjectLayout* ShaderObjectLayoutBase::getInterface(const Slang::Guid& guid)
-{
- if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IShaderObjectLayout)
- return static_cast<IShaderObjectLayout*>(this);
- return nullptr;
-}
-
void ShaderObjectLayoutBase::initBase(RendererBase* renderer, slang::TypeLayoutReflection* elementTypeLayout)
{
m_renderer = renderer;