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

Function FillDefaults

shadercompiler/EffectCompilerMetal.cpp:3506–3549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3504}
3505
3506bool FillDefaults( ParserState& state, ASTNode* node, void* outDefaultValues, const Type& type )
3507{
3508 Type expectedType = type;
3509 ExpressionValue value;
3510
3511 if( type.IsMatrix() )
3512 {
3513 state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() );
3514 return false;
3515 }
3516
3517 if( EvaluateInitializer( state, node, expectedType, value, nullptr ) )
3518 {
3519 uint32_t count = type.width * type.height;
3520 assert( count == value.size() );
3521
3522 if( type.builtInType == OP_FLOAT )
3523 {
3524 float* floatValues = (float*)outDefaultValues;
3525 for( size_t i = 0; i < count; ++i )
3526 {
3527 *floatValues++ = float( value[i].floatValue );
3528 }
3529 }
3530 else if( type.builtInType == OP_INT )
3531 {
3532 int32_t* intValues = (int32_t*)outDefaultValues;
3533 for( size_t i = 0; i < count; ++i )
3534 {
3535 *intValues++ = int32_t( value[i].intValue );
3536 }
3537 }
3538 else
3539 {
3540 // Type not supported.
3541 state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() );
3542 return false;
3543 }
3544
3545 return true;
3546 }
3547
3548 return false;
3549}
3550
3551bool CollectConstants( ParserState& state, StageData& stage, ASTNode* node, std::map<StringReference, ParameterAnnotation>& annotations )
3552{

Callers 1

CollectConstantsFunction · 0.85

Calls 5

EvaluateInitializerFunction · 0.85
IsMatrixMethod · 0.80
ShowMessageMethod · 0.80
sizeMethod · 0.80
ToStringMethod · 0.45

Tested by

no test coverage detected