summaryrefslogtreecommitdiff
path: root/tools/gfx/cpu
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-20 12:24:00 -0800
committerGitHub <noreply@github.com>2024-02-20 12:24:00 -0800
commit4d20fd329956ac89408b1628a8291fea01bc9a6d (patch)
tree8e62d9c1ec05142fd25d0b31073fdb56d44691b0 /tools/gfx/cpu
parent8e9b61e3bac69dbb37a1451b62302e688a017ced (diff)
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.
Diffstat (limited to 'tools/gfx/cpu')
-rw-r--r--tools/gfx/cpu/cpu-device.cpp5
-rw-r--r--tools/gfx/cpu/cpu-device.h1
-rw-r--r--tools/gfx/cpu/cpu-shader-object-layout.cpp13
-rw-r--r--tools/gfx/cpu/cpu-shader-object-layout.h7
4 files changed, 15 insertions, 11 deletions
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<ShaderObjectLayoutImpl> cpuLayout = new ShaderObjectLayoutImpl(this, typeLayout);
+ RefPtr<ShaderObjectLayoutImpl> cpuLayout = new ShaderObjectLayoutImpl(this, session, typeLayout);
returnRefPtrMove(outLayout, cpuLayout);
return SLANG_OK;
@@ -166,7 +167,7 @@ namespace cpu
if (!slangProgramLayout)
return SLANG_FAIL;
- RefPtr<RootShaderObjectLayoutImpl> cpuProgramLayout = new RootShaderObjectLayoutImpl(this, slangProgramLayout);
+ RefPtr<RootShaderObjectLayoutImpl> 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<RefPtr<EntryPointLayoutImpl>> 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);