summaryrefslogtreecommitdiffstats
path: root/tools/gfx/debug-layer
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-08-16 17:11:54 -0700
committerGitHub <noreply@github.com>2022-08-16 17:11:54 -0700
commit42f49937ffa69c82e333e886952eed027e12340e (patch)
tree08e3e9821dd40e23476060215d589e29092adb53 /tools/gfx/debug-layer
parente68fab2bda5d979f8d991fc41122bb9aa71849a6 (diff)
Add gfx interface definition in Slang. (#2364)
* Add gfx interface definition in Slang. - add gfx interface definitons in Slang. - fix slang compiler to correctly type-check `out` interface argument. - modify gfx interface to be fully COM compatible - add convenient ShaderProgram creation methods to gfx. * Fix compile errors and warnings. * Update project files * Fix cuda. * Properly implement queryInterface in command encoder impls. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/debug-layer')
-rw-r--r--tools/gfx/debug-layer/debug-command-encoder.h48
-rw-r--r--tools/gfx/debug-layer/debug-device.cpp18
-rw-r--r--tools/gfx/debug-layer/debug-device.h2
-rw-r--r--tools/gfx/debug-layer/debug-shader-program.cpp4
-rw-r--r--tools/gfx/debug-layer/debug-shader-program.h4
5 files changed, 66 insertions, 10 deletions
diff --git a/tools/gfx/debug-layer/debug-command-encoder.h b/tools/gfx/debug-layer/debug-command-encoder.h
index 8a0ffbfdb..b53a11074 100644
--- a/tools/gfx/debug-layer/debug-command-encoder.h
+++ b/tools/gfx/debug-layer/debug-command-encoder.h
@@ -15,7 +15,18 @@ public:
virtual DebugCommandBuffer* getCommandBuffer() = 0;
virtual bool getIsOpen() = 0;
virtual IResourceCommandEncoder* getBaseResourceEncoder() = 0;
-
+ virtual void* getInterface(SlangUUID const& uuid) = 0;
+ SlangResult queryInterface(SlangUUID const& uuid, void** outObject)
+ {
+ if (auto ptr = getInterface(uuid))
+ {
+ *outObject = ptr;
+ return SLANG_OK;
+ }
+ return SLANG_E_NO_INTERFACE;
+ }
+ uint32_t addRef() { return 1; }
+ uint32_t release() { return 1; }
public:
virtual SLANG_NO_THROW void SLANG_MCALL copyBuffer(
IBufferResource* dst,
@@ -97,6 +108,14 @@ public:
virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; }
virtual bool getIsOpen() override { return isOpen; }
virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; }
+ virtual void* getInterface(SlangUUID const& uuid) override
+ {
+ if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ {
+ return this;
+ }
+ return nullptr;
+ }
public:
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override;
@@ -122,7 +141,14 @@ public:
virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; }
virtual bool getIsOpen() override { return isOpen; }
virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; }
-
+ virtual void* getInterface(SlangUUID const& uuid) override
+ {
+ if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ {
+ return this;
+ }
+ return nullptr;
+ }
public:
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override;
@@ -144,7 +170,14 @@ public:
}
virtual bool getIsOpen() override { return isOpen; }
virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; }
-
+ virtual void* getInterface(SlangUUID const& uuid) override
+ {
+ if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRenderCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ {
+ return this;
+ }
+ return nullptr;
+ }
public:
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override;
virtual SLANG_NO_THROW Result SLANG_MCALL
@@ -212,7 +245,14 @@ public:
virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; }
virtual bool getIsOpen() override { return isOpen; }
virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; }
-
+ virtual void* getInterface(SlangUUID const& uuid) override
+ {
+ if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRayTracingCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ {
+ return this;
+ }
+ return nullptr;
+ }
public:
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override;
virtual SLANG_NO_THROW void SLANG_MCALL buildAccelerationStructure(
diff --git a/tools/gfx/debug-layer/debug-device.cpp b/tools/gfx/debug-layer/debug-device.cpp
index aae7f9cea..356c875d4 100644
--- a/tools/gfx/debug-layer/debug-device.cpp
+++ b/tools/gfx/debug-layer/debug-device.cpp
@@ -448,10 +448,26 @@ Result DebugDevice::createProgram(
{
SLANG_GFX_API_FUNC;
- RefPtr<DebugShaderProgram> outObject = new DebugShaderProgram(desc);
+ RefPtr<DebugShaderProgram> outObject = new DebugShaderProgram();
auto result = baseObject->createProgram(desc, outObject->baseObject.writeRef(), outDiagnostics);
if (SLANG_FAILED(result))
return result;
+ outObject->m_slangProgram = desc.slangGlobalScope;
+ returnComPtr(outProgram, outObject);
+ return result;
+}
+
+Result DebugDevice::createProgram2(
+ const IShaderProgram::CreateDesc2& desc, IShaderProgram** outProgram, ISlangBlob** outDiagnostics)
+{
+ SLANG_GFX_API_FUNC;
+ IShaderProgram::Desc desc1 = {};
+ RefPtr<DebugShaderProgram> outObject = new DebugShaderProgram();
+ auto result = baseObject->createProgram2(desc, outObject->baseObject.writeRef(), outDiagnostics);
+ if (SLANG_FAILED(result))
+ return result;
+ auto base = static_cast<ShaderProgramBase*>(outObject->baseObject.get());
+ outObject->m_slangProgram = base->desc.slangGlobalScope;
returnComPtr(outProgram, outObject);
return result;
}
diff --git a/tools/gfx/debug-layer/debug-device.h b/tools/gfx/debug-layer/debug-device.h
index 83a67428f..db07cdd1b 100644
--- a/tools/gfx/debug-layer/debug-device.h
+++ b/tools/gfx/debug-layer/debug-device.h
@@ -104,6 +104,8 @@ public:
createMutableRootShaderObject(IShaderProgram* program, IShaderObject** outObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
createProgram(const IShaderProgram::Desc& desc, IShaderProgram** outProgram, ISlangBlob** outDiagnostics) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ createProgram2(const IShaderProgram::CreateDesc2& desc, IShaderProgram** outProgram, ISlangBlob** outDiagnostics) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createGraphicsPipelineState(
const GraphicsPipelineStateDesc& desc,
IPipelineState** outState) override;
diff --git a/tools/gfx/debug-layer/debug-shader-program.cpp b/tools/gfx/debug-layer/debug-shader-program.cpp
index 264087abd..745fc8691 100644
--- a/tools/gfx/debug-layer/debug-shader-program.cpp
+++ b/tools/gfx/debug-layer/debug-shader-program.cpp
@@ -8,9 +8,9 @@ using namespace Slang;
namespace debug
{
-DebugShaderProgram::DebugShaderProgram(const IShaderProgram::Desc& desc)
+slang::TypeReflection* DebugShaderProgram::findTypeByName(const char* name)
{
- m_slangProgram = desc.slangGlobalScope;
+ return baseObject->findTypeByName(name);
}
} // namespace debug
diff --git a/tools/gfx/debug-layer/debug-shader-program.h b/tools/gfx/debug-layer/debug-shader-program.h
index 050ee8e3c..0f154f2a3 100644
--- a/tools/gfx/debug-layer/debug-shader-program.h
+++ b/tools/gfx/debug-layer/debug-shader-program.h
@@ -16,9 +16,7 @@ public:
public:
IShaderProgram* getInterface(const Slang::Guid& guid);
-
- DebugShaderProgram(const IShaderProgram::Desc& desc);
-
+ virtual SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL findTypeByName(const char* name) override;
public:
Slang::ComPtr<slang::IComponentType> m_slangProgram;
};