yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// cuda-shader-object.h 2#pragma once 3#include "cuda-base.h" 4#include "cuda-buffer.h" 5#include "cuda-resource-views.h" 6 7namespace gfx 8{ 9#ifdef GFX_ENABLE_CUDA 10using namespace Slang ; 11 12namespace cuda 13{ 14 15class ShaderObjectData 16{ 17public : 18bool isHostOnly = false; 19Slang ::RefPtr < BufferResourceImpl > m_bufferResource ; 20Slang ::RefPtr < ResourceViewImpl > m_bufferView ; 21Slang ::List < uint8_t > m_cpuBuffer ; 22 23Result setCount (Index count ); 24Slang ::Index getCount (); 25void * getBuffer (); 26 27/// Returns a resource view for GPU access into the buffer content. 28ResourceViewBase * getResourceView ( 29RendererBase * device , 30slang ::TypeLayoutReflection * elementLayout , 31slang ::BindingType bindingType ); 32}; 33 34class ShaderObjectImpl 35 :public ShaderObjectBaseImpl < ShaderObjectImpl ,ShaderObjectLayoutImpl ,ShaderObjectData > 36{ 37typedef ShaderObjectBaseImpl < ShaderObjectImpl ,ShaderObjectLayoutImpl ,ShaderObjectData > Super ; 38 39public : 40List < RefPtr < ResourceViewImpl >>resources ; 41 42virtual SLANG_NO_THROW Result SLANG_MCALL 43init (IDevice * device ,ShaderObjectLayoutImpl * typeLayout ); 44 45virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount ()override ; 46virtual SLANG_NO_THROW Result SLANG_MCALL 47getEntryPoint ( GfxIndex index, IShaderObject ** outEntryPoint) override; 48 49virtual SLANG_NO_THROW const void * SLANG_MCALL getRawData () override; 50 51virtual SLANG_NO_THROW Size SLANG_MCALL getSize () override; 52 53virtual SLANG_NO_THROW Result SLANG_MCALL 54setData ( ShaderOffset const & offset, void const * data, Size size) override; 55virtual SLANG_NO_THROW Result SLANG_MCALL 56setResource ( ShaderOffset const & offset, IResourceView * resourceView) override; 57virtual SLANG_NO_THROW Result SLANG_MCALL 58setObject ( ShaderOffset const & offset, IShaderObject * object) override; 59virtual SLANG_NO_THROW Result SLANG_MCALL 60setSampler ( ShaderOffset const & offset, ISamplerState * sampler) override; 61virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler ( 62ShaderOffset const & offset, 63IResourceView * textureView, 64ISamplerState * sampler) override; 65}; 66 67class MutableShaderObjectImpl 68: public MutableShaderObject < MutableShaderObjectImpl, ShaderObjectLayoutImpl > 69{ 70}; 71 72class EntryPointShaderObjectImpl : public ShaderObjectImpl 73{ 74public : 75EntryPointShaderObjectImpl (); 76}; 77 78class RootShaderObjectImpl : public ShaderObjectImpl 79{ 80public : 81virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef () override ; 82virtual SLANG_NO_THROW uint32_t SLANG_MCALL release () override; 83 84public: 85List < RefPtr < EntryPointShaderObjectImpl>> entryPointObjects; 86virtual SLANG_NO_THROW Result SLANG_MCALL 87init ( IDevice * device, ShaderObjectLayoutImpl * typeLayout) override; 88virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount () override; 89virtual SLANG_NO_THROW Result SLANG_MCALL 90getEntryPoint ( GfxIndex index, IShaderObject ** outEntryPoint) override; 91virtual Result collectSpecializationArgs ( ExtendedShaderObjectTypeList & args) override; 92}; 93 94} // namespace cuda 95#endif 96} // namespace gfx