summaryrefslogtreecommitdiffstats
path: root/tools/gfx/debug-layer/debug-shader-object.h
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-08-04 16:59:28 -0700
committerGitHub <noreply@github.com>2022-08-04 16:59:28 -0700
commit12a846e8facf090aaeb68fcabf55867f5eaed747 (patch)
treecc7c70c447200c1b45f20efc47e43e17828ec84d /tools/gfx/debug-layer/debug-shader-object.h
parent11b29eff99910d55a54658b8a1d053cc4ec076fc (diff)
Split debug-layer into smaller files (#2344)
* checkpoint commit * debug-layer split, does not compile * Almost compiles, rebasing before making any further changes * everything compiles and passes tests locally * Added tools/gfx/debug-layer to premake and ran premake Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/debug-layer/debug-shader-object.h')
-rw-r--r--tools/gfx/debug-layer/debug-shader-object.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/tools/gfx/debug-layer/debug-shader-object.h b/tools/gfx/debug-layer/debug-shader-object.h
new file mode 100644
index 000000000..8007e653a
--- /dev/null
+++ b/tools/gfx/debug-layer/debug-shader-object.h
@@ -0,0 +1,101 @@
+// debug-shader-object.h
+#pragma once
+#include "debug-base.h"
+
+namespace gfx
+{
+using namespace Slang;
+
+namespace debug
+{
+
+struct ShaderOffsetKey
+{
+ ShaderOffset offset;
+ bool operator==(ShaderOffsetKey other)
+ {
+ return offset.bindingArrayIndex == other.offset.bindingArrayIndex &&
+ offset.bindingRangeIndex == other.offset.bindingRangeIndex &&
+ offset.uniformOffset == other.offset.uniformOffset;
+ }
+ Slang::HashCode getHashCode()
+ {
+ return Slang::combineHash(
+ (Slang::HashCode)offset.uniformOffset,
+ Slang::combineHash(
+ (Slang::HashCode)offset.bindingArrayIndex,
+ (Slang::HashCode)offset.bindingRangeIndex));
+ }
+};
+
+class DebugShaderObject : public DebugObject<IShaderObject>
+{
+public:
+ SLANG_COM_OBJECT_IUNKNOWN_ALL;
+
+public:
+ IShaderObject* getInterface(const Slang::Guid& guid);
+ virtual SLANG_NO_THROW slang::TypeLayoutReflection* SLANG_MCALL getElementTypeLayout() override;
+ virtual SLANG_NO_THROW ShaderObjectContainerType SLANG_MCALL getContainerType() override;
+ virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ getEntryPoint(GfxIndex index, IShaderObject** entryPoint) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ setData(ShaderOffset const& offset, void const* data, size_t size) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ getObject(ShaderOffset const& offset, IShaderObject** object) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ setObject(ShaderOffset const& offset, IShaderObject* object) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ setResource(ShaderOffset const& offset, IResourceView* resourceView) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ setSampler(ShaderOffset const& offset, ISamplerState* sampler) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler(
+ ShaderOffset const& offset,
+ IResourceView* textureView,
+ ISamplerState* sampler) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL setSpecializationArgs(
+ ShaderOffset const& offset,
+ const slang::SpecializationArg* args,
+ GfxCount count) override;
+
+ virtual SLANG_NO_THROW Result SLANG_MCALL getCurrentVersion(
+ ITransientResourceHeap* transientHeap, IShaderObject** outObject) override;
+ virtual SLANG_NO_THROW const void* SLANG_MCALL getRawData() override;
+ virtual SLANG_NO_THROW size_t SLANG_MCALL getSize() override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ setConstantBufferOverride(IBufferResource* constantBuffer) override;
+
+public:
+ // Type name of an ordinary shader object.
+ Slang::String m_typeName;
+
+ // The slang Type of an ordinary shader object. This is null for root objects.
+ slang::TypeReflection* m_slangType = nullptr;
+
+ // The slang program from which a root shader object is created, this is null for ordinary
+ // objects.
+ Slang::ComPtr<slang::IComponentType> m_rootComponentType;
+
+ DebugDevice* m_device;
+
+ Slang::List<Slang::RefPtr<DebugShaderObject>> m_entryPoints;
+ Slang::Dictionary<ShaderOffsetKey, Slang::RefPtr<DebugShaderObject>> m_objects;
+ Slang::Dictionary<ShaderOffsetKey, Slang::RefPtr<DebugResourceView>> m_resources;
+ Slang::Dictionary<ShaderOffsetKey, Slang::RefPtr<DebugSamplerState>> m_samplers;
+};
+
+class DebugRootShaderObject : public DebugShaderObject
+{
+public:
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
+ virtual SLANG_NO_THROW Result SLANG_MCALL setSpecializationArgs(
+ ShaderOffset const& offset,
+ const slang::SpecializationArg* args,
+ GfxCount count) override;
+ void reset();
+};
+
+} // namespace debug
+} // namespace gfx