mojoshader_compiler.c
changeset 1012 04a23c4b0c70
parent 1011 0758e03a79d9
child 1013 b41b88d368b0
equal deleted inserted replaced
1011:0758e03a79d9 1012:04a23c4b0c70
  5304 {
  5304 {
  5305     // There are only three possible IR nodes that contain a struct:
  5305     // There are only three possible IR nodes that contain a struct:
  5306     //  an irTemp, an irMemory, or an irESeq that results in a temp or memory.
  5306     //  an irTemp, an irMemory, or an irESeq that results in a temp or memory.
  5307     //  As such, we figure out which it is, and offset appropriately for the
  5307     //  As such, we figure out which it is, and offset appropriately for the
  5308     //  member.
  5308     //  member.
       
  5309     const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype);
       
  5310     const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type;
       
  5311     const int elems = datatype_elems(ctx, dt);
  5309     MOJOSHADER_irExpression *expr = build_ir_expr(ctx, ast->identifier);
  5312     MOJOSHADER_irExpression *expr = build_ir_expr(ctx, ast->identifier);
  5310     MOJOSHADER_irExpression *finalexpr = expr;
  5313     MOJOSHADER_irExpression *finalexpr = expr;
  5311 
  5314 
  5312     assert(!ast->isswizzle);
  5315     assert(!ast->isswizzle);
  5313 
  5316 
  5318         finalexpr->temp.index += ast->member_index;
  5321         finalexpr->temp.index += ast->member_index;
  5319     else if (finalexpr->ir.type == MOJOSHADER_IR_MEMORY)
  5322     else if (finalexpr->ir.type == MOJOSHADER_IR_MEMORY)
  5320         finalexpr->memory.index += ast->member_index;
  5323         finalexpr->memory.index += ast->member_index;
  5321     else
  5324     else
  5322         assert(0 && "Unexpected condition");
  5325         assert(0 && "Unexpected condition");
       
  5326 
       
  5327     // Replace the struct type with the type of the member.
       
  5328     expr->info.type = type;
       
  5329     expr->info.elements = elems;
  5323 
  5330 
  5324     return expr;
  5331     return expr;
  5325 } // build_ir_derefstruct
  5332 } // build_ir_derefstruct
  5326 
  5333 
  5327 static MOJOSHADER_irExpression *build_ir_derefarray(Context *ctx, const MOJOSHADER_astExpressionBinary *ast)
  5334 static MOJOSHADER_irExpression *build_ir_derefarray(Context *ctx, const MOJOSHADER_astExpressionBinary *ast)