yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8000e0ede
master
1#include "decoder-helper.h" 2 3#include "parameter-decoder.h" 4 5#include <cstdlib> 6#include <vector> 7 8namespace SlangRecord 9{ 10DecoderAllocatorSingleton * DecoderAllocatorSingleton ::getInstance () 11{ 12 thread_localDecoderAllocatorSingleton instance ; 13return & instance ; 14} 15 16void * DecoderAllocatorSingleton ::allocate (size_t size ) 17{ 18void * data = calloc (1 ,size ); 19 20if (!data ) 21 { 22slangRecordLog (LogLevel ::Error ,"Failed to allocate memory\n" ); 23 std::abort (); 24 } 25 26m_allocations .add (data ); 27return data ; 28} 29 30DecoderAllocatorSingleton ::~DecoderAllocatorSingleton () 31{ 32for (auto allocation :m_allocations ) 33 { 34free (allocation ); 35 } 36} 37 38template < typename T ,typename U > 39size_t StructDecoder < T ,U > ::decode (const uint8_t * buffer ,int64_t bufferSize ) 40{ 41return ParameterDecoder ::decodeStruct (buffer ,bufferSize ,* this ); 42} 43 44size_t BlobDecoder ::decode (const uint8_t * buffer ,int64_t bufferSize ) 45{ 46size_t readByte = 0 ; 47readByte = ParameterDecoder ::decodeAddress (buffer ,bufferSize ,m_address ); 48 49if (!m_address ) 50 { 51readByte += 52ParameterDecoder ::decodePointer (buffer + readByte ,bufferSize - readByte ,m_blobData ); 53 } 54return readByte ; 55} 56 57template class StructDecoder < SlangGlobalSessionDesc > ; 58template class StructDecoder < slang:: SessionDesc > ; 59template class StructDecoder < slang:: PreprocessorMacroDesc > ; 60template class StructDecoder < slang:: CompilerOptionEntry > ; 61template class StructDecoder < slang:: CompilerOptionValue > ; 62template class StructDecoder < slang:: TargetDesc > ; 63template class StructDecoder < slang:: SpecializationArg > ; 64} // namespace SlangRecord