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

Function AssignGlobalInputRegisters

shadercompiler/ParserUtils.cpp:829–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827}
828
829void AssignGlobalInputRegisters( const std::vector<GlobalInputElement>& globalInput, Registers& registers, std::vector<RegisterSpecifier>& globalInputRegisters )
830{
831 for( auto& input : globalInput )
832 {
833 if( auto registerType = GetRegisterType( input.type ) )
834 {
835 bool isArray = input.type.arrayDimensions > 0;
836
837 RegisterSpecifier r;
838 r.shaderProfile = MakeInlineString( "" );
839 r.registerType = registerType;
840 r.registerNumber = AllocateRegister( *GetRegisterSet( registers, registerType ) );
841 if( isArray )
842 {
843 r.space = AllocateRegister( registers.spaces );
844 }
845 else
846 {
847 r.space = 0;
848 }
849 r.subComponent = -1;
850 r.explicitRegister = false;
851 r.explicitSpace = false;
852 globalInputRegisters.push_back( r );
853 }
854 else if( input.declaration && input.declaration->GetNodeType() == NT_CBUFFER )
855 {
856 bool assigned = false;
857 for( auto& r : input.declaration->GetSymbol()->registerSpecifier )
858 {
859 if( r.second.explicitRegister && r.first == "" )
860 {
861 assigned = true;
862 globalInputRegisters.push_back( r.second );
863 break;
864 }
865 }
866 if( !assigned )
867 {
868 RegisterSpecifier r;
869 r.shaderProfile = MakeInlineString( "" );
870 r.registerType = 'b';
871 r.registerNumber = AllocateRegister( registers.b );
872 r.subComponent = -1;
873 r.space = 0;
874 r.explicitRegister = false;
875 r.explicitSpace = false;
876 globalInputRegisters.push_back( r );
877 }
878 }
879 else
880 {
881 globalInputRegisters.push_back( RegisterSpecifier() );
882 }
883 }
884}
885
886void AssignRegisters( ASTNode* root, int32_t stage, const std::vector<GlobalInputElement>& globalInput )

Callers 1

AssignRegistersFunction · 0.85

Calls 7

MakeInlineStringFunction · 0.85
AllocateRegisterFunction · 0.85
GetRegisterSetFunction · 0.85
RegisterSpecifierClass · 0.85
GetNodeTypeMethod · 0.80
GetSymbolMethod · 0.80
GetRegisterTypeFunction · 0.70

Tested by

no test coverage detected