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

Function CastExpressionValue

shadercompiler/FXAnalyzer.cpp:386–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386bool CastExpressionValue( ExpressionValue& value, const Type& from, const Type& to )
387{
388 if( from == to )
389 {
390 return true;
391 }
392
393 if( from.width == 1 && from.height == 1 )
394 {
395 if( from.builtInType != to.builtInType )
396 {
397 if( !CastExpressionElementValue( value[0], from.builtInType, to.builtInType ) )
398 {
399 return false;
400 }
401 }
402 auto element = value[0];
403 value.resize( to.width * to.height, element );
404 return true;
405 }
406
407 if( to.width > from.width || to.height > from.height )
408 {
409 return false;
410 }
411
412 ExpressionValue result;
413 for( int j = 0; j < to.height; ++j )
414 {
415 for( int i = 0; i < to.width; ++i )
416 {
417 ExpressionValueElement element = value[std::min( j, from.height ) * from.width + std::min( i, from.width )];
418 if( from.builtInType != to.builtInType )
419 {
420 if( !CastExpressionElementValue( element, from.builtInType, to.builtInType ) )
421 {
422 return false;
423 }
424 }
425 result.push_back( element );
426 }
427 }
428 value.clear();
429 value.assign( result.begin(), result.end() );
430 return true;
431}
432
433static bool GetElementType( const Type& type, unsigned index, Type& elementType )
434{

Callers 4

EvaluateInitializerFunction · 0.85
EvaluateExpressionFunction · 0.85
GetStateValueFunction · 0.85

Calls 3

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected