mojoshader.c
changeset 1107 b18605919c3c
parent 1106 2bef26cc20f9
child 1108 b27629cb8124
equal deleted inserted replaced
1106:2bef26cc20f9 1107:b18605919c3c
  3501                             src3, sizeof (src3));
  3501                             src3, sizeof (src3));
  3502     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum,
  3502     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum,
  3503                             src4, sizeof (src4));
  3503                             src4, sizeof (src4));
  3504     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3504     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3505 
  3505 
       
  3506     RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER,
       
  3507                                       info->regnum);
       
  3508     const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
       
  3509     const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "Cube" : "3D";
       
  3510 
  3506     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3511     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3507         "texture3D(%s,"
  3512         "texture%s(%s,"
  3508             " vec3(dot(%s.xyz, %s.xyz),"
  3513             " vec3(dot(%s.xyz, %s.xyz),"
  3509             " dot(%s.xyz, %s.xyz),"
  3514             " dot(%s.xyz, %s.xyz),"
  3510             " dot(%s.xyz, %s.xyz)))",
  3515             " dot(%s.xyz, %s.xyz)))",
  3511         sampler, src0, src1, src2, src3, dst, src4);
  3516         ttypestr, sampler, src0, src1, src2, src3, dst, src4);
  3512 
  3517 
  3513     output_line(ctx, "%s", code);
  3518     output_line(ctx, "%s", code);
  3514 } // emit_GLSL_TEXM3X3TEX
  3519 } // emit_GLSL_TEXM3X3TEX
  3515 
  3520 
  3516 static void emit_GLSL_TEXM3X3SPEC_helper(Context *ctx)
  3521 static void emit_GLSL_TEXM3X3SPEC_helper(Context *ctx)
  3563                             src4, sizeof (src4));
  3568                             src4, sizeof (src4));
  3564     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[1].regnum,
  3569     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[1].regnum,
  3565                             src5, sizeof (src5));
  3570                             src5, sizeof (src5));
  3566     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3571     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3567 
  3572 
       
  3573     RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER,
       
  3574                                       info->regnum);
       
  3575     const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
       
  3576     const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "Cube" : "3D";
       
  3577 
  3568     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3578     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3569         "texture3D(%s, "
  3579         "texture%s(%s, "
  3570             "TEXM3X3SPEC_reflection("
  3580             "TEXM3X3SPEC_reflection("
  3571                 "vec3("
  3581                 "vec3("
  3572                     "dot(%s.xyz, %s.xyz), "
  3582                     "dot(%s.xyz, %s.xyz), "
  3573                     "dot(%s.xyz, %s.xyz), "
  3583                     "dot(%s.xyz, %s.xyz), "
  3574                     "dot(%s.xyz, %s.xyz)"
  3584                     "dot(%s.xyz, %s.xyz)"
  3575                 "),"
  3585                 "),"
  3576                 "%s.xyz,"
  3586                 "%s.xyz,"
  3577             ")"
  3587             ")"
  3578         ")",
  3588         ")",
  3579         sampler, src0, src1, src2, src3, dst, src4, src5);
  3589         ttypestr, sampler, src0, src1, src2, src3, dst, src4, src5);
  3580 
  3590 
  3581     output_line(ctx, "%s", code);
  3591     output_line(ctx, "%s", code);
  3582 } // emit_GLSL_TEXM3X3SPEC
  3592 } // emit_GLSL_TEXM3X3SPEC
  3583 
  3593 
  3584 static void emit_GLSL_TEXM3X3VSPEC(Context *ctx)
  3594 static void emit_GLSL_TEXM3X3VSPEC(Context *ctx)
  3612                             src3, sizeof (src3));
  3622                             src3, sizeof (src3));
  3613     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum,
  3623     get_GLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum,
  3614                             src4, sizeof (src4));
  3624                             src4, sizeof (src4));
  3615     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3625     get_GLSL_destarg_varname(ctx, dst, sizeof (dst));
  3616 
  3626 
       
  3627     RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER,
       
  3628                                       info->regnum);
       
  3629     const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
       
  3630     const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "Cube" : "3D";
       
  3631 
  3617     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3632     make_GLSL_destarg_assign(ctx, code, sizeof (code),
  3618         "texture3D(%s, "
  3633         "texture%s(%s, "
  3619             "TEXM3X3SPEC_reflection("
  3634             "TEXM3X3SPEC_reflection("
  3620                 "vec3("
  3635                 "vec3("
  3621                     "dot(%s.xyz, %s.xyz), "
  3636                     "dot(%s.xyz, %s.xyz), "
  3622                     "dot(%s.xyz, %s.xyz), "
  3637                     "dot(%s.xyz, %s.xyz), "
  3623                     "dot(%s.xyz, %s.xyz)"
  3638                     "dot(%s.xyz, %s.xyz)"
  3624                 "), "
  3639                 "), "
  3625                 "vec3(%s.w, %s.w, %s.w)"
  3640                 "vec3(%s.w, %s.w, %s.w)"
  3626             ")"
  3641             ")"
  3627         ")",
  3642         ")",
  3628         sampler, src0, src1, src2, src3, dst, src4, src0, src2, dst);
  3643         ttypestr, sampler, src0, src1, src2, src3, dst, src4, src0, src2, dst);
  3629 
  3644 
  3630     output_line(ctx, "%s", code);
  3645     output_line(ctx, "%s", code);
  3631 } // emit_GLSL_TEXM3X3VSPEC
  3646 } // emit_GLSL_TEXM3X3VSPEC
  3632 
  3647 
  3633 static void emit_GLSL_EXPP(Context *ctx)
  3648 static void emit_GLSL_EXPP(Context *ctx)