yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// slang-downstream-compiler-set.cpp 2#include "slang-downstream-compiler-set.h" 3 4namespace Slang 5{ 6 7/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DownstreamCompilerSet !!!!!!!!!!!!!!!!!!!!!!*/ 8 9void DownstreamCompilerSet ::getCompilerDescs (List < DownstreamCompilerDesc >& outCompilerDescs )const 10{ 11outCompilerDescs .clear (); 12for (IDownstreamCompiler * compiler :m_compilers ) 13 { 14outCompilerDescs .add (compiler -> getDesc ()); 15 } 16} 17 18Index DownstreamCompilerSet ::_findIndex (const DownstreamCompilerDesc & desc )const 19{ 20const Index count = m_compilers .getCount (); 21for (Index i = 0 ;i < count ;++ i ) 22 { 23if (m_compilers [i ]-> getDesc ()== desc ) 24 { 25return i ; 26 } 27 } 28return -1 ; 29} 30 31IDownstreamCompiler * DownstreamCompilerSet ::getCompiler ( 32const DownstreamCompilerDesc & compilerDesc )const 33{ 34const Index index = _findIndex (compilerDesc ); 35return index >=0 ?m_compilers [index ] :nullptr ; 36} 37 38void DownstreamCompilerSet ::getCompilers (List < IDownstreamCompiler *>& outCompilers )const 39{ 40outCompilers .clear (); 41outCompilers .addRange ((IDownstreamCompiler * const * )m_compilers .begin (),m_compilers .getCount ()); 42} 43 44bool DownstreamCompilerSet ::hasSharedLibrary (ISlangSharedLibrary * lib ) 45{ 46const Index foundIndex = m_sharedLibraries .findFirstIndex ( 47 [lib ](ISlangSharedLibrary * inLib )-> bool {return lib == inLib ; }); 48return (foundIndex >=0 ); 49} 50 51void DownstreamCompilerSet ::addSharedLibrary (ISlangSharedLibrary * lib ) 52{ 53SLANG_ASSERT (lib ); 54if (!hasSharedLibrary (lib )) 55 { 56m_sharedLibraries .add (ComPtr < ISlangSharedLibrary > (lib )); 57 } 58} 59 60bool DownstreamCompilerSet ::hasCompiler (SlangPassThrough compilerType )const 61{ 62for (IDownstreamCompiler * compiler :m_compilers ) 63 { 64const auto & desc = compiler -> getDesc (); 65if (desc .type == compilerType ) 66 { 67return true; 68 } 69 } 70return false; 71} 72 73void DownstreamCompilerSet ::remove (SlangPassThrough compilerType ) 74{ 75for (Index i = 0 ;i < m_compilers .getCount ();++ i ) 76 { 77IDownstreamCompiler * compiler = m_compilers [i ]; 78if (compiler -> getDesc ().type == compilerType ) 79 { 80m_compilers .fastRemoveAt (i ); 81i -- ; 82 } 83 } 84} 85 86void DownstreamCompilerSet ::addCompiler (IDownstreamCompiler * compiler ) 87{ 88const Index index = _findIndex (compiler -> getDesc ()); 89if (index >=0 ) 90 { 91m_compilers [index ]= compiler ; 92 } 93else 94 { 95m_compilers .add (ComPtr < IDownstreamCompiler > (compiler )); 96 } 97} 98 99}// namespace Slang