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

Function CreateGlobalInputsStruct

shadercompiler/EffectCompilerMetal.cpp:4699–4788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4697}
4698
4699ASTNode* CreateGlobalInputsStruct( ParserState& state, const std::vector<GlobalInputElement>& globalInputs )
4700{
4701 state.GetSymbolTable().EnterScope();
4702 auto globalInputsStruct = NewStruct( state, state.AllocateName( "__RtGlobalInput" ) );
4703 for( auto& in : globalInputs )
4704 {
4705 auto existing = state.GetSymbolTable().LookupGlobal( ToString( in.name ).c_str() );
4706 if( !existing )
4707 {
4708 existing = state.GetSymbolTable().LookupBuffer( in.name );
4709 }
4710 auto symbol = state.GetSymbolTable().AddSymbol( existing->name );
4711 if( existing->isTypeName )
4712 {
4713 symbol->type.FromSymbol( existing );
4714 symbol->registerSpecifier = existing->registerSpecifier;
4715 }
4716 else
4717 {
4718 symbol->type = existing->type;
4719 }
4720 auto type = symbol->type;
4721 if( type.symbol &&
4722 type.symbol->definition &&
4723 type.symbol->definition->GetNodeType() == NT_STRUCT )
4724 {
4725 symbol->type = TypeFromTokenType( OP_STRUCTUREDBUFFER );
4726 symbol->type.templateParameter = new Type( type );
4727 symbol->addressSpace = AddressSpace::Constant;
4728 }
4729 else
4730 {
4731 switch( type.builtInType )
4732 {
4733 case OP_BUFFER:
4734 case OP_STRUCTUREDBUFFER:
4735 case OP_RWBUFFER:
4736 case OP_RWSTRUCTUREDBUFFER:
4737 case OP_RAYTRACING_ACCELERATION_STRUCTURE:
4738 symbol->addressSpace = AddressSpace::Device;
4739 if( type.arrayDimensions )
4740 {
4741 symbol->resourceRefWrapped = true;
4742 }
4743 break;
4744 default:
4745 if( type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) )
4746 {
4747 symbol->addressSpace = AddressSpace::Device;
4748 symbol->resourceRefWrapped = true;
4749 }
4750 break;
4751 }
4752 }
4753 auto decl = state.NewNode( NT_NAME_DECLARATION );
4754 decl->SetSymbol( symbol );
4755 decl->SetType( symbol->type );
4756

Callers 1

CompileEffectMethod · 0.85

Calls 15

NewStructFunction · 0.85
TypeFromTokenTypeFunction · 0.85
EnterScopeMethod · 0.80
AllocateNameMethod · 0.80
LookupGlobalMethod · 0.80
LookupBufferMethod · 0.80
AddSymbolMethod · 0.80
FromSymbolMethod · 0.80
GetNodeTypeMethod · 0.80
IsTextureMethod · 0.80
IsSamplerMethod · 0.80
NewNodeMethod · 0.80

Tested by

no test coverage detected