From 2f44d9e01234911dd563f0456b9d861fd8db286d Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 18 Oct 2021 12:19:45 -0700 Subject: GFX: implement mutable shader objects. (#1963) * GFX: implement mutable shader objects. * Revert unnecessary changes * Revert more changes. * Fix clang errors. * Fix clang/gcc errors. * Fix clang errors. * Remove CPU test. * Fix after merge. * Fix after merge. * Remove gl test * Code review fixes. * Fixing all vk validation errors. * Flush test output more often. * Fix a crash in `specializeDynamicAssociatedTypeLookup`. * temporarily disable std-lib-serialize test to see what happens * Fix crashes. * Make sure cpu gfx unit tests are properly disabled on TeamCity. * Disable cpu test. * Fix. * Fix cuda. * Disable nv-ray-tracing-motion-blur Co-authored-by: Yong He --- tools/gfx/renderer-shared.cpp | 45 +++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'tools/gfx/renderer-shared.cpp') diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp index c5a0c826d..791cb1859 100644 --- a/tools/gfx/renderer-shared.cpp +++ b/tools/gfx/renderer-shared.cpp @@ -1,4 +1,5 @@ #include "renderer-shared.h" +#include "mutable-shader-object.h" #include "core/slang-io.h" #include "core/slang-token-reader.h" @@ -128,22 +129,22 @@ IResourceView* ResourceViewBase::getInterface(const Guid& guid) return nullptr; } -IAccelerationStructure* AccelerationStructureBase::getInterface(const Slang::Guid& guid) +ISamplerState* SamplerStateBase::getInterface(const Slang::Guid& guid) { - if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IResourceView || - guid == GfxGUID::IID_IAccelerationStructure) - return static_cast(this); + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ISamplerState) + return static_cast(this); return nullptr; } -IShaderObject* ShaderObjectBase::getInterface(const Guid& guid) +IAccelerationStructure* AccelerationStructureBase::getInterface(const Slang::Guid& guid) { - if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IShaderObject) - return static_cast(this); + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IResourceView || + guid == GfxGUID::IID_IAccelerationStructure) + return static_cast(this); return nullptr; } -bool ShaderObjectBase::_doesValueFitInExistentialPayload( +bool _doesValueFitInExistentialPayload( slang::TypeLayoutReflection* concreteTypeLayout, slang::TypeLayoutReflection* existentialTypeLayout) { @@ -223,6 +224,20 @@ IFramebufferLayout* FramebufferLayoutBase::getInterface(const Guid& guid) return nullptr; } +IFramebuffer* FramebufferBase::getInterface(const Guid& guid) +{ + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IFramebuffer) + return static_cast(this); + return nullptr; +} + +IQueryPool* QueryPoolBase::getInterface(const Guid& guid) +{ + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IQueryPool) + return static_cast(this); + return nullptr; +} + IPipelineState* gfx::PipelineStateBase::getInterface(const Guid& guid) { if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IPipelineState) @@ -298,10 +313,20 @@ SLANG_NO_THROW Result SLANG_MCALL RendererBase::createShaderObject( IShaderObject** outObject) { RefPtr shaderObjectLayout; - SLANG_RETURN_FALSE_ON_FAIL(getShaderObjectLayout(type, container, shaderObjectLayout.writeRef())); + SLANG_RETURN_ON_FAIL(getShaderObjectLayout(type, container, shaderObjectLayout.writeRef())); return createShaderObject(shaderObjectLayout, outObject); } +SLANG_NO_THROW Result SLANG_MCALL RendererBase::createMutableShaderObject( + slang::TypeReflection* type, + ShaderObjectContainerType containerType, + IShaderObject** outObject) +{ + RefPtr shaderObjectLayout; + SLANG_RETURN_ON_FAIL(getShaderObjectLayout(type, containerType, shaderObjectLayout.writeRef())); + return createMutableShaderObject(shaderObjectLayout, outObject); +} + Result RendererBase::getAccelerationStructurePrebuildInfo( const IAccelerationStructure::BuildInputs& buildInputs, IAccelerationStructure::PrebuildInfo* outPrebuildInfo) @@ -452,7 +477,7 @@ Result ShaderObjectBase::_getSpecializedShaderObjectType(ExtendedShaderObjectTyp else { shaderObjectType.slangType = getRenderer()->slangContext.session->specializeType( - getElementTypeLayout()->getType(), + _getElementTypeLayout()->getType(), specializationArgs.components.getArrayView().getBuffer(), specializationArgs.getCount()); shaderObjectType.componentID = getRenderer()->shaderCache.getComponentId(shaderObjectType.slangType); } -- cgit v1.2.3