yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8000e0ede
master
1#ifndef SLANG_GLOBAL_SESSION_H 2#define SLANG_GLOBAL_SESSION_H 3 4#include "../../core/slang-smart-pointer.h" 5#include "record-manager.h" 6#include "slang-com-helper.h" 7#include "slang-com-ptr.h" 8#include "slang.h" 9 10namespace SlangRecord 11{ 12using namespace Slang ; 13 14class GlobalSessionRecorder :public RefObject ,public slang ::IGlobalSession 15{ 16public : 17explicit GlobalSessionRecorder ( 18const SlangGlobalSessionDesc * desc , 19slang ::IGlobalSession * session ); 20 21SLANG_REF_OBJECT_IUNKNOWN_ADD_REF 22SLANG_REF_OBJECT_IUNKNOWN_RELEASE 23 24SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface (SlangUUID const & uuid ,void ** outObject ) 25SLANG_OVERRIDE ; 26 27// slang::IGlobalSession 28SLANG_NO_THROW SlangResult SLANG_MCALL 29createSession (slang ::SessionDesc const & desc ,slang ::ISession ** outSession )override ; 30SLANG_NO_THROW SlangProfileID SLANG_MCALL findProfile (char const * name )override ; 31SLANG_NO_THROW void SLANG_MCALL 32setDownstreamCompilerPath (SlangPassThrough passThrough ,char const * path )override ; 33SLANG_NO_THROW void SLANG_MCALL 34setDownstreamCompilerPrelude (SlangPassThrough inPassThrough ,char const * prelude )override ; 35SLANG_NO_THROW void SLANG_MCALL 36getDownstreamCompilerPrelude (SlangPassThrough inPassThrough ,ISlangBlob ** outPrelude )override ; 37SLANG_NO_THROW const char * SLANG_MCALL getBuildTagString ()override ; 38SLANG_NO_THROW SlangResult SLANG_MCALL setDefaultDownstreamCompiler ( 39SlangSourceLanguage sourceLanguage , 40SlangPassThrough defaultCompiler )override ; 41SLANG_NO_THROW SlangPassThrough SLANG_MCALL 42getDefaultDownstreamCompiler (SlangSourceLanguage sourceLanguage )override ; 43 44SLANG_NO_THROW void SLANG_MCALL 45setLanguagePrelude (SlangSourceLanguage inSourceLanguage ,char const * prelude )override ; 46SLANG_NO_THROW void SLANG_MCALL 47getLanguagePrelude (SlangSourceLanguage inSourceLanguage ,ISlangBlob ** outPrelude )override ; 48 49SLANG_NO_THROW SlangResult SLANG_MCALL 50createCompileRequest (slang ::ICompileRequest ** outCompileRequest )override ; 51 52SLANG_NO_THROW void SLANG_MCALL 53addBuiltins (char const * sourcePath ,char const * sourceString )override ; 54SLANG_NO_THROW void SLANG_MCALL 55setSharedLibraryLoader (ISlangSharedLibraryLoader * loader )override ; 56SLANG_NO_THROW ISlangSharedLibraryLoader * SLANG_MCALL getSharedLibraryLoader ()override ; 57SLANG_NO_THROW SlangResult SLANG_MCALL 58checkCompileTargetSupport (SlangCompileTarget target )override ; 59SLANG_NO_THROW SlangResult SLANG_MCALL 60checkPassThroughSupport (SlangPassThrough passThrough )override ; 61 62SLANG_NO_THROW SlangResult SLANG_MCALL 63compileCoreModule (slang ::CompileCoreModuleFlags flags )override ; 64SLANG_NO_THROW SlangResult SLANG_MCALL 65loadCoreModule (const void * coreModule ,size_t coreModuleSizeInBytes )override ; 66SLANG_NO_THROW SlangResult SLANG_MCALL 67saveCoreModule (SlangArchiveType archiveType ,ISlangBlob ** outBlob )override ; 68 69virtual SLANG_NO_THROW SlangResult SLANG_MCALL compileBuiltinModule ( 70slang ::BuiltinModuleName module , 71slang ::CompileCoreModuleFlags flags )override ; 72virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadBuiltinModule ( 73slang ::BuiltinModuleName module , 74const void * moduleData , 75size_t sizeInBytes )override ; 76virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveBuiltinModule ( 77slang ::BuiltinModuleName module , 78SlangArchiveType archiveType , 79ISlangBlob ** outBlob )override ; 80 81SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability (char const * name )override ; 82 83SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerForTransition ( 84SlangCompileTarget source , 85SlangCompileTarget target , 86SlangPassThrough compiler )override ; 87SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDownstreamCompilerForTransition ( 88SlangCompileTarget source , 89SlangCompileTarget target )override ; 90SLANG_NO_THROW void SLANG_MCALL 91getCompilerElapsedTime (double * outTotalTime ,double * outDownstreamTime )override ; 92 93SLANG_NO_THROW SlangResult SLANG_MCALL setSPIRVCoreGrammar (char const * jsonPath )override ; 94 95SLANG_NO_THROW SlangResult SLANG_MCALL parseCommandLineArguments ( 96int argc , 97const char * const * argv , 98slang ::SessionDesc * outSessionDesc , 99ISlangUnknown ** outAllocation )override ; 100 101SLANG_NO_THROW SlangResult SLANG_MCALL 102getSessionDescDigest (slang ::SessionDesc * sessionDesc ,ISlangBlob ** outBlob )override ; 103 104RecordManager * getRecordManager () {return m_recordManager .get (); } 105 106private : 107SLANG_FORCE_INLINE slang ::IGlobalSession * asExternal (GlobalSessionRecorder * session ) 108 { 109return static_cast < slang ::IGlobalSession *> (session ); 110 } 111 112Slang ::ComPtr < slang ::IGlobalSession > m_actualGlobalSession ; 113 114// we will create one record file per IGlobalSession. 115// We don't try to reproduce the user application's threading model, because it requires lots of 116// effort and it's not necessary. Instead, we record all the compilation jobs associated with 117// the session in the same record file, so that during replay, those jobs will be executed 118// sequentially. This might violate the user application's threading model, because those jobs 119// might be executed in different threads. But it's not a big problem, because slang doesn't 120// allow multiple threads to access the same session at the same time. So even if there is one 121// session used by multiple threads, those threads will execute the compile jobs sequentially. 122Slang ::RefPtr < RecordManager > m_recordManager ; 123uint64_t m_globalSessionHandle = 0 ; 124}; 125}// namespace SlangRecord 126 127#endif