MCPcopy Create free account
hub / github.com/carbonengine/trinity / ParseGlobalInput

Function ParseGlobalInput

shadercompiler/ParserUtils.cpp:1251–1310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1249
1250
1251std::optional<std::vector<GlobalInputElement>> ParseGlobalInput( ParserState& state, const ScannerToken& input )
1252{
1253 auto processed = PreprocessString( input.stringValue );
1254 if( !processed )
1255 {
1256 return {};
1257 }
1258
1259 auto tokens = TokenizeGlobalInput( { processed->c_str(), processed->c_str() + processed->size() } );
1260 if( !tokens )
1261 {
1262 state.ShowMessage( input.fileLocation, EC_CUSTOM_ERROR, "Malformed globalinput string" );
1263 return {};
1264 }
1265
1266 std::vector<GlobalInputElement> result;
1267 for( auto& name : *tokens )
1268 {
1269 auto symbol = state.GetSymbolTable().LookupGlobal( ToString( name ).c_str() );
1270 bool isCBuffer = false;
1271 bool useCBuffers = false;
1272 if( useCBuffers )
1273 {
1274 if( symbol && symbol->type.IsStruct() )
1275 {
1276 symbol = nullptr;
1277 }
1278 if( !symbol )
1279 {
1280 symbol = state.GetSymbolTable().LookupBuffer( name );
1281 isCBuffer = true;
1282 }
1283 }
1284 else
1285 {
1286 if( !symbol )
1287 {
1288 symbol = state.GetSymbolTable().LookupBuffer( name );
1289 isCBuffer = true;
1290 }
1291 if( symbol && symbol->type.IsStruct() )
1292 {
1293 isCBuffer = true;
1294 }
1295 }
1296 if( !symbol )
1297 {
1298 state.ShowMessage( input.fileLocation, EC_UNDECLARED_IDENTIFIER, ToString( name ).c_str() );
1299 return {};
1300 }
1301 auto& type = symbol->type;
1302 if( !isCBuffer && !type.IsTexture() && !type.IsSampler() && !type.IsBuffer() && !( type.symbol == nullptr && type.builtInType == OP_RAYTRACING_ACCELERATION_STRUCTURE ) )
1303 {
1304 state.ShowMessage( input.fileLocation, EC_CUSTOM_ERROR, "Unsupported type for \"%s\" in the globalinput", ToString( name ).c_str() );
1305 return {};
1306 }
1307 result.push_back( { type, symbol->name, symbol->definition, symbol } );
1308 }

Callers 1

Calls 9

sizeMethod · 0.80
ShowMessageMethod · 0.80
LookupGlobalMethod · 0.80
IsStructMethod · 0.80
LookupBufferMethod · 0.80
IsTextureMethod · 0.80
IsSamplerMethod · 0.80
IsBufferMethod · 0.80
ToStringFunction · 0.70

Tested by

no test coverage detected