mojoshader.c
changeset 1281 cfa04188aee2
parent 1261 3405ca546164
child 1282 a9b48833d3b6
equal deleted inserted replaced
1280:d2a0d76469f9 1281:cfa04188aee2
  3583                     item = prev;
  3583                     item = prev;
  3584                     break;
  3584                     break;
  3585 
  3585 
  3586                 case REG_TYPE_INPUT:
  3586                 case REG_TYPE_INPUT:
  3587                     // You don't have to dcl_ your inputs in Shader Model 1.
  3587                     // You don't have to dcl_ your inputs in Shader Model 1.
  3588                     if (shader_is_pixel(ctx)&&!shader_version_atleast(ctx,2,0))
  3588                     if (!shader_version_atleast(ctx,2,0))
  3589                     {
  3589                     {
  3590                         add_attribute_register(ctx, regtype, regnum,
  3590                         if (shader_is_pixel(ctx))
  3591                                                MOJOSHADER_USAGE_COLOR, regnum,
  3591                         {
  3592                                                0xF, 0);
  3592                             add_attribute_register(ctx, regtype, regnum,
  3593                         break;
  3593                                                    MOJOSHADER_USAGE_COLOR, regnum,
       
  3594                                                    0xF, 0);
       
  3595                             break;
       
  3596                         } // if
       
  3597                         else if (shader_is_vertex(ctx))
       
  3598                         {
       
  3599                             MOJOSHADER_usage usage = MOJOSHADER_USAGE_UNKNOWN;
       
  3600                             int index = 0;
       
  3601                             switch (regnum)  // these are hardcoded for Shader Model 1: v0 is POSITION, v1 is BLENDWEIGHT, etc.
       
  3602                             {
       
  3603                                 case 0: usage = MOJOSHADER_USAGE_POSITION; break;
       
  3604                                 case 1: usage = MOJOSHADER_USAGE_BLENDWEIGHT; break;
       
  3605                                 case 2: usage = MOJOSHADER_USAGE_BLENDINDICES; break;
       
  3606                                 case 3: usage = MOJOSHADER_USAGE_NORMAL; break;
       
  3607                                 case 4: usage = MOJOSHADER_USAGE_POINTSIZE; break;
       
  3608                                 case 5: usage = MOJOSHADER_USAGE_COLOR; break;  // diffuse
       
  3609                                 case 6: usage = MOJOSHADER_USAGE_COLOR; index = 1; break; // specular
       
  3610                                 case 7: usage = MOJOSHADER_USAGE_TEXCOORD; break;
       
  3611                                 case 8: usage = MOJOSHADER_USAGE_TEXCOORD; index = 1; break;
       
  3612                                 case 9: usage = MOJOSHADER_USAGE_TEXCOORD; index = 2; break;
       
  3613                                 case 10: usage = MOJOSHADER_USAGE_TEXCOORD; index = 3; break;
       
  3614                                 case 11: usage = MOJOSHADER_USAGE_TEXCOORD; index = 4; break;
       
  3615                                 case 12: usage = MOJOSHADER_USAGE_TEXCOORD; index = 5; break;
       
  3616                                 case 13: usage = MOJOSHADER_USAGE_TEXCOORD; index = 6; break;
       
  3617                                 case 14: usage = MOJOSHADER_USAGE_TEXCOORD; index = 7; break;
       
  3618                                 case 15: usage = MOJOSHADER_USAGE_POSITION; index = 1; break;
       
  3619                                 case 16: usage = MOJOSHADER_USAGE_NORMAL; index = 1; break;
       
  3620                                 default: break;
       
  3621                             } // switch
       
  3622 
       
  3623                             if (usage != MOJOSHADER_USAGE_UNKNOWN)
       
  3624                             {
       
  3625                                 add_attribute_register(ctx, regtype, regnum, usage, index, 0xF, 0);
       
  3626                                 break;
       
  3627                             } // if
       
  3628                         } // else if
  3594                     } // if
  3629                     } // if
       
  3630 
  3595                     // fall through...
  3631                     // fall through...
  3596 
  3632 
  3597                 default:
  3633                 default:
  3598                     fail(ctx, "BUG: we used a register we don't know how to define.");
  3634                     fail(ctx, "BUG: we used a register we don't know how to define.");
  3599             } // switch
  3635             } // switch