yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#ifndef SLANG_DOWNSTREAM_COMPILER_SET_H 2#define SLANG_DOWNSTREAM_COMPILER_SET_H 3 4#include "slang-downstream-compiler.h" 5 6namespace Slang 7{ 8 9class DownstreamCompilerSet :public RefObject 10{ 11public : 12typedef RefObject Super ; 13 14/// Find all the available compilers 15void getCompilerDescs (List < IDownstreamCompiler ::Desc >& outCompilerDescs )const ; 16/// Returns list of all compilers 17void getCompilers (List < IDownstreamCompiler *>& outCompilers )const ; 18 19/// Get a compiler 20IDownstreamCompiler * getCompiler (const DownstreamCompilerDesc & compilerDesc )const ; 21 22/// Will replace if there is one with same desc 23void addCompiler (IDownstreamCompiler * compiler ); 24 25/// Get a default compiler 26IDownstreamCompiler * getDefaultCompiler (SlangSourceLanguage sourceLanguage )const 27 { 28return m_defaultCompilers [int (sourceLanguage )]; 29 } 30/// Set the default compiler 31void setDefaultCompiler (SlangSourceLanguage sourceLanguage ,IDownstreamCompiler * compiler ) 32 { 33m_defaultCompilers [int (sourceLanguage )]= compiler ; 34 } 35 36/// True if has a compiler of the specified type 37bool hasCompiler (SlangPassThrough compilerType )const ; 38 39void remove (SlangPassThrough compilerType ); 40 41void clear () {m_compilers .clear (); } 42 43bool hasSharedLibrary (ISlangSharedLibrary * lib ); 44void addSharedLibrary (ISlangSharedLibrary * lib ); 45 46 ~DownstreamCompilerSet () 47 { 48// A compiler may be implemented in a shared library, so release all first. 49m_compilers .clearAndDeallocate (); 50for (auto& defaultCompiler :m_defaultCompilers ) 51 { 52defaultCompiler .setNull (); 53 } 54 55// Release any shared libraries 56m_sharedLibraries .clearAndDeallocate (); 57 } 58 59protected : 60Index _findIndex (const DownstreamCompilerDesc & desc )const ; 61 62 63ComPtr < IDownstreamCompiler > m_defaultCompilers [int (SLANG_SOURCE_LANGUAGE_COUNT_OF )]; 64// This could be a dictionary/map - but doing a linear search is going to be fine and it makes 65// somethings easier. 66List < ComPtr < IDownstreamCompiler >>m_compilers ; 67 68List < ComPtr < ISlangSharedLibrary >>m_sharedLibraries ; 69}; 70 71}// namespace Slang 72 73#endif