mojoshader.c
changeset 1111 7530b37979b8
parent 1109 51292bd4476b
child 1115 ce5fbd601bc0
equal deleted inserted replaced
1110:91a6af79b5e4 1111:7530b37979b8
  7006     else if (regtype != REG_TYPE_CONST)
  7006     else if (regtype != REG_TYPE_CONST)
  7007         fail(ctx, "DEF token using invalid register");
  7007         fail(ctx, "DEF token using invalid register");
  7008     else
  7008     else
  7009     {
  7009     {
  7010         ConstantsList *item = alloc_constant_listitem(ctx);
  7010         ConstantsList *item = alloc_constant_listitem(ctx);
  7011         item->constant.index = regnum;
  7011         if (item != NULL)
  7012         item->constant.type = MOJOSHADER_UNIFORM_FLOAT;
  7012         {
  7013         memcpy(item->constant.value.f, ctx->dwords,
  7013             item->constant.index = regnum;
  7014                sizeof (item->constant.value.f));
  7014             item->constant.type = MOJOSHADER_UNIFORM_FLOAT;
  7015         set_defined_register(ctx, regtype, regnum);
  7015             memcpy(item->constant.value.f, ctx->dwords,
       
  7016                    sizeof (item->constant.value.f));
       
  7017             set_defined_register(ctx, regtype, regnum);
       
  7018         } // if
  7016     } // else
  7019     } // else
  7017 } // state_DEF
  7020 } // state_DEF
  7018 
  7021 
  7019 static void state_DEFI(Context *ctx)
  7022 static void state_DEFI(Context *ctx)
  7020 {
  7023 {
  7028     else if (regtype != REG_TYPE_CONSTINT)
  7031     else if (regtype != REG_TYPE_CONSTINT)
  7029         fail(ctx, "DEFI token using invalid register");
  7032         fail(ctx, "DEFI token using invalid register");
  7030     else
  7033     else
  7031     {
  7034     {
  7032         ConstantsList *item = alloc_constant_listitem(ctx);
  7035         ConstantsList *item = alloc_constant_listitem(ctx);
  7033         item->constant.index = regnum;
  7036         if (item != NULL)
  7034         item->constant.type = MOJOSHADER_UNIFORM_INT;
  7037         {
  7035         memcpy(item->constant.value.i, ctx->dwords,
  7038             item->constant.index = regnum;
  7036                sizeof (item->constant.value.i));
  7039             item->constant.type = MOJOSHADER_UNIFORM_INT;
  7037 
  7040             memcpy(item->constant.value.i, ctx->dwords,
  7038         set_defined_register(ctx, regtype, regnum);
  7041                    sizeof (item->constant.value.i));
       
  7042 
       
  7043             set_defined_register(ctx, regtype, regnum);
       
  7044         } // if
  7039     } // else
  7045     } // else
  7040 } // state_DEFI
  7046 } // state_DEFI
  7041 
  7047 
  7042 static void state_DEFB(Context *ctx)
  7048 static void state_DEFB(Context *ctx)
  7043 {
  7049 {
  7051     else if (regtype != REG_TYPE_CONSTBOOL)
  7057     else if (regtype != REG_TYPE_CONSTBOOL)
  7052         fail(ctx, "DEFB token using invalid register");
  7058         fail(ctx, "DEFB token using invalid register");
  7053     else
  7059     else
  7054     {
  7060     {
  7055         ConstantsList *item = alloc_constant_listitem(ctx);
  7061         ConstantsList *item = alloc_constant_listitem(ctx);
  7056         item->constant.index = regnum;
  7062         if (item != NULL)
  7057         item->constant.type = MOJOSHADER_UNIFORM_BOOL;
  7063         {
  7058         item->constant.value.b = ctx->dwords[0] ? 1 : 0;
  7064             item->constant.index = regnum;
  7059         set_defined_register(ctx, regtype, regnum);
  7065             item->constant.type = MOJOSHADER_UNIFORM_BOOL;
       
  7066             item->constant.value.b = ctx->dwords[0] ? 1 : 0;
       
  7067             set_defined_register(ctx, regtype, regnum);
       
  7068         } // if
  7060     } // else
  7069     } // else
  7061 } // state_DEFB
  7070 } // state_DEFB
  7062 
  7071 
  7063 static void state_DCL(Context *ctx)
  7072 static void state_DCL(Context *ctx)
  7064 {
  7073 {