yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// debug-shader-object.h 2#pragma once 3#include "debug-base.h" 4 5namespace gfx 6{ 7using namespace Slang ; 8 9namespace debug 10{ 11 12struct ShaderOffsetKey 13{ 14ShaderOffset offset ; 15bool operator == (ShaderOffsetKey other )const 16 { 17return offset .bindingArrayIndex == other .offset .bindingArrayIndex && 18offset .bindingRangeIndex == other .offset .bindingRangeIndex && 19offset .uniformOffset == other .offset .uniformOffset ; 20 } 21Slang ::HashCode getHashCode ()const 22 { 23return Slang ::combineHash ( 24 (Slang ::HashCode )offset .uniformOffset , 25Slang ::combineHash ( 26 (Slang ::HashCode )offset .bindingArrayIndex , 27 (Slang ::HashCode )offset .bindingRangeIndex )); 28 } 29}; 30 31class DebugShaderObject :public DebugObject < IShaderObject > 32{ 33public : 34SLANG_COM_OBJECT_IUNKNOWN_ALL ; 35void checkCompleteness (); 36 37public : 38IShaderObject * getInterface (const Slang ::Guid & guid ); 39virtual SLANG_NO_THROW slang ::TypeLayoutReflection * SLANG_MCALL getElementTypeLayout ()override ; 40virtual SLANG_NO_THROW ShaderObjectContainerType SLANG_MCALL getContainerType ()override ; 41virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount ()override ; 42virtual SLANG_NO_THROW Result SLANG_MCALL 43getEntryPoint (GfxIndex index ,IShaderObject ** entryPoint )override ; 44virtual SLANG_NO_THROW Result SLANG_MCALL 45setData (ShaderOffset const & offset ,void const * data ,size_t size )override ; 46virtual SLANG_NO_THROW Result SLANG_MCALL 47getObject (ShaderOffset const & offset ,IShaderObject ** object )override ; 48virtual SLANG_NO_THROW Result SLANG_MCALL 49setObject (ShaderOffset const & offset ,IShaderObject * object )override ; 50virtual SLANG_NO_THROW Result SLANG_MCALL 51setResource (ShaderOffset const & offset ,IResourceView * resourceView )override ; 52virtual SLANG_NO_THROW Result SLANG_MCALL 53setSampler (ShaderOffset const & offset ,ISamplerState * sampler )override ; 54virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler ( 55ShaderOffset const & offset , 56IResourceView * textureView , 57ISamplerState * sampler )override ; 58virtual SLANG_NO_THROW Result SLANG_MCALL setSpecializationArgs ( 59ShaderOffset const & offset , 60const slang ::SpecializationArg * args , 61GfxCount count )override ; 62 63virtual SLANG_NO_THROW Result SLANG_MCALL 64getCurrentVersion (ITransientResourceHeap * transientHeap ,IShaderObject ** outObject )override ; 65virtual SLANG_NO_THROW const void * SLANG_MCALL getRawData ()override ; 66virtual SLANG_NO_THROW size_t SLANG_MCALL getSize ()override ; 67virtual SLANG_NO_THROW Result SLANG_MCALL 68setConstantBufferOverride (IBufferResource * constantBuffer )override ; 69 70public : 71// Type name of an ordinary shader object. 72Slang ::String m_typeName ; 73 74// The slang Type of an ordinary shader object. This is null for root objects. 75slang ::TypeReflection * m_slangType = nullptr ; 76 77// The slang program from which a root shader object is created, this is null for ordinary 78// objects. 79Slang ::ComPtr < slang ::IComponentType > m_rootComponentType ; 80 81DebugDevice * m_device ; 82 83Slang ::List < Slang ::RefPtr < DebugShaderObject >>m_entryPoints ; 84Slang ::Dictionary < ShaderOffsetKey ,Slang ::RefPtr < DebugShaderObject >>m_objects ; 85Slang ::Dictionary < ShaderOffsetKey ,Slang ::RefPtr < DebugResourceView >>m_resources ; 86Slang ::Dictionary < ShaderOffsetKey ,Slang ::RefPtr < DebugSamplerState >>m_samplers ; 87Slang ::HashSet < SlangInt > m_initializedBindingRanges ; 88}; 89 90class DebugRootShaderObject :public DebugShaderObject 91{ 92public : 93virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef ()override {return 1 ; } 94virtual SLANG_NO_THROW uint32_t SLANG_MCALL release ()override {return 1 ; } 95virtual SLANG_NO_THROW Result SLANG_MCALL setSpecializationArgs ( 96ShaderOffset const & offset , 97const slang ::SpecializationArg * args , 98GfxCount count )override ; 99void reset (); 100}; 101 102}// namespace debug 103}// namespace gfx