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-layout.h 2#pragma once 3#include "cuda-base.h" 4 5namespace gfx 6{ 7#ifdef GFX_ENABLE_CUDA 8using namespace Slang ; 9 10namespace cuda 11{ 12 13struct BindingRangeInfo 14{ 15slang ::BindingType bindingType ; 16Index count ; 17Index baseIndex ;// Flat index for sub-objects 18Index subObjectIndex ; 19 20// TODO: The `uniformOffset` field should be removed, 21// since it cannot be supported by the Slang reflection 22// API once we fix some design issues. 23// 24// It is only being used today for pre-allocation of sub-objects 25// for constant buffers and parameter blocks (which should be 26// deprecated/removed anyway). 27// 28// Note: We would need to bring this field back, plus 29// a lot of other complexity, if we ever want to support 30// setting of resources/buffers directly by a binding 31// range index and array index. 32// 33Index uniformOffset ;// Uniform offset for a resource typed field. 34 35bool isSpecializable ; 36}; 37 38struct SubObjectRangeInfo 39{ 40RefPtr < ShaderObjectLayoutImpl > layout ; 41Index bindingRangeIndex ; 42}; 43 44class ShaderObjectLayoutImpl :public ShaderObjectLayoutBase 45{ 46public : 47List < SubObjectRangeInfo > subObjectRanges ; 48List < BindingRangeInfo > m_bindingRanges ; 49 50Index m_subObjectCount = 0 ; 51Index m_resourceCount = 0 ; 52 53ShaderObjectLayoutImpl ( 54RendererBase * renderer , 55slang ::ISession * session , 56slang ::TypeLayoutReflection * layout ); 57 58Index getResourceCount ()const ; 59Index getSubObjectCount ()const ; 60List < SubObjectRangeInfo >& getSubObjectRanges (); 61BindingRangeInfo getBindingRange (Index index ); 62Index getBindingRangeCount ()const ; 63}; 64 65class RootShaderObjectLayoutImpl :public ShaderObjectLayoutImpl 66{ 67public : 68slang ::ProgramLayout * programLayout = nullptr ; 69List < RefPtr < ShaderObjectLayoutImpl >>entryPointLayouts ; 70RootShaderObjectLayoutImpl (RendererBase * renderer ,slang ::ProgramLayout * inProgramLayout ); 71 72int getKernelIndex (UnownedStringSlice kernelName ); 73 74void getKernelThreadGroupSize (int kernelIndex ,UInt * threadGroupSizes ); 75}; 76 77}// namespace cuda 78#endif 79}// namespace gfx