mojoshader_assembler.c
changeset 718 08e758f9aae3
parent 716 94a804b54078
child 719 c18465fa4cb7
equal deleted inserted replaced
717:4465cffe0a9f 718:08e758f9aae3
   805         else if (tokenlen != 4)
   805         else if (tokenlen != 4)
   806             invalid_swizzle = 1;
   806             invalid_swizzle = 1;
   807         tokenbytes[4] = '\0';
   807         tokenbytes[4] = '\0';
   808 
   808 
   809         uint32 val = 0;
   809         uint32 val = 0;
   810         int saw_xyzw = 0;
       
   811         int saw_rgba = 0;
       
   812         int i;
   810         int i;
   813         for (i = 0; i < 4; i++)
   811         for (i = 0; i < 4; i++)
   814         {
   812         {
   815             const int component = (int) tokenbytes[i];
   813             const int component = (int) tokenbytes[i];
   816             switch (component)
   814             switch (component)
   817             {
   815             {
   818                 case 'x': val = 0; saw_xyzw = 1; break;
   816                 case 'r': case 'x': val = 0; break;
   819                 case 'y': val = 1; saw_xyzw = 1; break;
   817                 case 'g': case 'y': val = 1; break;
   820                 case 'z': val = 2; saw_xyzw = 1; break;
   818                 case 'b': case 'z': val = 2; break;
   821                 case 'w': val = 3; saw_xyzw = 1; break;
   819                 case 'a': case 'w': val = 3; break;
   822                 case 'r': val = 0; saw_rgba = 1; break;
       
   823                 case 'g': val = 1; saw_rgba = 1; break;
       
   824                 case 'b': val = 2; saw_rgba = 1; break;
       
   825                 case 'a': val = 3; saw_rgba = 1; break;
       
   826                 default: invalid_swizzle = 1; break;
   820                 default: invalid_swizzle = 1; break;
   827             } // switch
   821             } // switch
   828             swizzle |= (val << (i * 2));
   822             swizzle |= (val << (i * 2));
   829         } // for
   823         } // for
   830 
       
   831         if (saw_xyzw && saw_rgba)
       
   832             invalid_swizzle = 1;
       
   833         else if (saw_rgba && !shader_is_pixel(ctx))
       
   834             invalid_swizzle = 1;
       
   835     } // else
   824     } // else
   836 
   825 
   837     if (invalid_swizzle)
   826     if (invalid_swizzle)
   838         fail(ctx, "Invalid swizzle");
   827         fail(ctx, "Invalid swizzle");
   839 
   828