From 4d20fd329956ac89408b1628a8291fea01bc9a6d Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 20 Feb 2024 12:24:00 -0800 Subject: Refactor compiler option representations. (#3598) * Refactor compiler option representation. * Fix binary compatibility. * Add a test for specifying compiler options at link time. * Fix binary compatibility. * Fix binary compatibility. * Fix backward compatibility on matrix layout. * Fix. * Fix. * Fix. * Fix gfx. * Fix gfx. * Fix dynamic dispatch. * Polish. --- tools/gfx/cpu/cpu-device.cpp | 5 +++-- tools/gfx/cpu/cpu-device.h | 1 + tools/gfx/cpu/cpu-shader-object-layout.cpp | 13 +++++++------ tools/gfx/cpu/cpu-shader-object-layout.h | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'tools/gfx/cpu') diff --git a/tools/gfx/cpu/cpu-device.cpp b/tools/gfx/cpu/cpu-device.cpp index 4b8595e82..f248cf52a 100644 --- a/tools/gfx/cpu/cpu-device.cpp +++ b/tools/gfx/cpu/cpu-device.cpp @@ -106,10 +106,11 @@ namespace cpu } Result DeviceImpl::createShaderObjectLayout( + slang::ISession* session, slang::TypeLayoutReflection* typeLayout, ShaderObjectLayoutBase** outLayout) { - RefPtr cpuLayout = new ShaderObjectLayoutImpl(this, typeLayout); + RefPtr cpuLayout = new ShaderObjectLayoutImpl(this, session, typeLayout); returnRefPtrMove(outLayout, cpuLayout); return SLANG_OK; @@ -166,7 +167,7 @@ namespace cpu if (!slangProgramLayout) return SLANG_FAIL; - RefPtr cpuProgramLayout = new RootShaderObjectLayoutImpl(this, slangProgramLayout); + RefPtr cpuProgramLayout = new RootShaderObjectLayoutImpl(this, slangGlobalScope->getSession(), slangProgramLayout); cpuProgramLayout->m_programLayout = slangProgramLayout; cpuProgram->layout = cpuProgramLayout; diff --git a/tools/gfx/cpu/cpu-device.h b/tools/gfx/cpu/cpu-device.h index d90ce1e8b..c7b80e26d 100644 --- a/tools/gfx/cpu/cpu-device.h +++ b/tools/gfx/cpu/cpu-device.h @@ -39,6 +39,7 @@ public: IResourceView** outView) override; virtual Result createShaderObjectLayout( + slang::ISession* session, slang::TypeLayoutReflection* typeLayout, ShaderObjectLayoutBase** outLayout) override; diff --git a/tools/gfx/cpu/cpu-shader-object-layout.cpp b/tools/gfx/cpu/cpu-shader-object-layout.cpp index 2ff89efff..4f4c33a6a 100644 --- a/tools/gfx/cpu/cpu-shader-object-layout.cpp +++ b/tools/gfx/cpu/cpu-shader-object-layout.cpp @@ -8,13 +8,13 @@ using namespace Slang; namespace cpu { -ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::TypeLayoutReflection* layout) +ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::TypeLayoutReflection* layout) { - initBase(renderer, layout); + initBase(renderer, session, layout); m_subObjectCount = 0; m_resourceCount = 0; - + m_elementTypeLayout = _unwrapParameterGroups(layout, m_containerType); m_size = m_elementTypeLayout->getSize(); @@ -104,7 +104,7 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::Ty if (slangBindingType != slang::BindingType::ExistentialValue) { subObjectLayout = - new ShaderObjectLayoutImpl(renderer, slangLeafTypeLayout->getElementTypeLayout()); + new ShaderObjectLayoutImpl(renderer, m_slangSession, slangLeafTypeLayout->getElementTypeLayout()); } SubObjectRangeInfo subObjectRange; @@ -130,14 +130,15 @@ const char* EntryPointLayoutImpl::getEntryPointName() return m_entryPointLayout->getName(); } -RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ProgramLayout* programLayout) - : ShaderObjectLayoutImpl(renderer, programLayout->getGlobalParamsTypeLayout()) +RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::ProgramLayout* programLayout) + : ShaderObjectLayoutImpl(renderer, session, programLayout->getGlobalParamsTypeLayout()) , m_programLayout(programLayout) { for (UInt i =0; i< programLayout->getEntryPointCount(); i++) { m_entryPointLayouts.add(new EntryPointLayoutImpl( renderer, + session, programLayout->getEntryPointByIndex(i))); } diff --git a/tools/gfx/cpu/cpu-shader-object-layout.h b/tools/gfx/cpu/cpu-shader-object-layout.h index e421918f1..3bf2e2aa7 100644 --- a/tools/gfx/cpu/cpu-shader-object-layout.h +++ b/tools/gfx/cpu/cpu-shader-object-layout.h @@ -55,7 +55,7 @@ public: Index m_subObjectCount = 0; Index m_resourceCount = 0; - ShaderObjectLayoutImpl(RendererBase* renderer, slang::TypeLayoutReflection* layout); + ShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::TypeLayoutReflection* layout); size_t getSize(); Index getResourceCount() const; @@ -73,8 +73,9 @@ private: public: EntryPointLayoutImpl( RendererBase* renderer, + slang::ISession* session, slang::EntryPointLayout* entryPointLayout) - : ShaderObjectLayoutImpl(renderer, entryPointLayout->getTypeLayout()) + : ShaderObjectLayoutImpl(renderer, session, entryPointLayout->getTypeLayout()) , m_entryPointLayout(entryPointLayout) {} @@ -87,7 +88,7 @@ public: slang::ProgramLayout* m_programLayout = nullptr; List> m_entryPointLayouts; - RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ProgramLayout* programLayout); + RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::ProgramLayout* programLayout); int getKernelIndex(UnownedStringSlice kernelName); void getKernelThreadGroupSize(int kernelIndex, UInt* threadGroupSizes); -- cgit v1.2.3