yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
00746bf09
master
1#ifndef SLANG_SESSION_H 2#define SLANG_SESSION_H 3 4#include "../../core/slang-dictionary.h" 5#include "../../core/slang-smart-pointer.h" 6#include "../../slang/slang-compiler.h" 7#include "record-manager.h" 8#include "slang-com-helper.h" 9#include "slang-com-ptr.h" 10#include "slang-module.h" 11#include "slang.h" 12 13namespace SlangRecord 14{ 15using namespace Slang ; 16class SessionRecorder :public RefObject ,public slang ::ISession 17{ 18public : 19SLANG_REF_OBJECT_IUNKNOWN_ALL 20ISlangUnknown * getInterface (const Guid & guid ); 21 22explicit SessionRecorder (slang ::ISession * session ,RecordManager * recordManager ); 23 24SLANG_NO_THROW slang ::IGlobalSession * SLANG_MCALL getGlobalSession ()override ; 25SLANG_NO_THROW slang ::IModule * SLANG_MCALL 26loadModule (const char * moduleName ,slang ::IBlob ** outDiagnostics = nullptr)override ; 27SLANG_NO_THROW slang ::IModule * SLANG_MCALL loadModuleFromIRBlob ( 28const char * moduleName , 29const char * path , 30slang ::IBlob * source , 31slang ::IBlob ** outDiagnostics = nullptr)override ; 32SLANG_NO_THROW SlangResult SLANG_MCALL loadModuleInfoFromIRBlob ( 33slang ::IBlob * source , 34SlangInt & outModuleVersion , 35const char *& outModuleCompilerVersion , 36const char *& outModuleName )override ; 37SLANG_NO_THROW slang ::IModule * SLANG_MCALL loadModuleFromSource ( 38const char * moduleName , 39const char * path , 40slang ::IBlob * source , 41slang ::IBlob ** outDiagnostics = nullptr)override ; 42SLANG_NO_THROW slang ::IModule * SLANG_MCALL loadModuleFromSourceString ( 43const char * moduleName , 44const char * path , 45const char * string , 46slang ::IBlob ** outDiagnostics = nullptr )override ; 47SLANG_NO_THROW SlangResult SLANG_MCALL createCompositeComponentType ( 48slang ::IComponentType * const * componentTypes , 49SlangInt componentTypeCount , 50slang ::IComponentType ** outCompositeComponentType , 51ISlangBlob ** outDiagnostics = nullptr)override ; 52SLANG_NO_THROW slang ::TypeReflection * SLANG_MCALL specializeType ( 53slang ::TypeReflection * type , 54slang ::SpecializationArg const * specializationArgs , 55SlangInt specializationArgCount , 56ISlangBlob ** outDiagnostics = nullptr )override ; 57SLANG_NO_THROW slang ::TypeLayoutReflection * SLANG_MCALL getTypeLayout ( 58slang ::TypeReflection * type , 59SlangInt targetIndex = 0 , 60slang ::LayoutRules rules = slang ::LayoutRules ::Default , 61ISlangBlob ** outDiagnostics = nullptr )override ; 62SLANG_NO_THROW slang ::TypeReflection * SLANG_MCALL getContainerType ( 63slang ::TypeReflection * elementType , 64slang ::ContainerType containerType , 65ISlangBlob ** outDiagnostics = nullptr )override ; 66SLANG_NO_THROW slang ::TypeReflection * SLANG_MCALL getDynamicType ()override ; 67SLANG_NO_THROW SlangResult SLANG_MCALL 68getTypeRTTIMangledName (slang ::TypeReflection * type ,ISlangBlob ** outNameBlob )override ; 69SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessMangledName ( 70slang ::TypeReflection * type , 71slang ::TypeReflection * interfaceType , 72ISlangBlob ** outNameBlob )override ; 73SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessSequentialID ( 74slang ::TypeReflection * type , 75slang ::TypeReflection * interfaceType , 76uint32_t * outId )override ; 77SLANG_NO_THROW SlangResult SLANG_MCALL getDynamicObjectRTTIBytes ( 78slang ::TypeReflection * type , 79slang ::TypeReflection * interfaceType , 80uint32_t * outRTTIDataBuffer , 81uint32_t bufferSizeInBytes )override ; 82SLANG_NO_THROW SlangResult SLANG_MCALL createTypeConformanceComponentType ( 83slang ::TypeReflection * type , 84slang ::TypeReflection * interfaceType , 85slang ::ITypeConformance ** outConformance , 86SlangInt conformanceIdOverride , 87ISlangBlob ** outDiagnostics )override ; 88SLANG_NO_THROW SlangResult SLANG_MCALL 89createCompileRequest (SlangCompileRequest ** outCompileRequest )override ; 90SLANG_NO_THROW SlangInt SLANG_MCALL getLoadedModuleCount ()override ; 91SLANG_NO_THROW slang::IModule * SLANG_MCALL getLoadedModule ( SlangInt index) override; 92SLANG_NO_THROW bool SLANG_MCALL 93isBinaryModuleUpToDate ( const char * modulePath, slang ::IBlob * binaryModuleBlob) override; 94 95private: 96SLANG_FORCE_INLINE slang::ISession * asExternal ( SessionRecorder * session) 97{ 98return static_cast < slang::ISession *> (session); 99} 100 101// The IComponentType object is the record target, therefore `componentTypes` will not be 102// the actual component types, we have to use the COM interface to get the actual objects. 103SlangResult getActualComponentTypes ( 104slang ::IComponentType * const * componentTypes, 105SlangInt componentTypeCount, 106List < slang::IComponentType *>& outActualComponentTypes); 107 108IModuleRecorder * getModuleRecorder ( slang ::IModule * module); 109 110Slang ::ComPtr < slang::ISession > m_actualSession; 111uint64_t m_sessionHandle = 0 ; 112 113Dictionary < slang::IModule * , IModuleRecorder *> m_mapModuleToRecord; 114List < ComPtr < IModuleRecorder>> m_moduleRecordersAlloation; 115RecordManager * m_recordManager = nullptr ; 116}; 117} // namespace SlangRecord 118 119#endif // SLANG_SESSION_H