/* Parse source register operand.
* <register_src> ::= <register_file_bracket_index> `]' |
- * <register_file_bracket> <register_dst> `]' |
- * <register_file_bracket> <register_dst> `+' <uint> `]' |
- * <register_file_bracket> <register_dst> `-' <uint> `]'
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
*/
static boolean
parse_register_src(
uint *file,
int *index,
uint *ind_file,
- int *ind_index )
+ int *ind_index,
+ uint *ind_comp)
{
const char *cur;
uint uindex;
+ *ind_comp = TGSI_SWIZZLE_X;
if (!parse_register_file_bracket( ctx, file ))
return FALSE;
eat_opt_white( &ctx->cur );
if (!parse_register_dst( ctx, ind_file, ind_index ))
return FALSE;
eat_opt_white( &ctx->cur );
+
+ if (*ctx->cur == '.') {
+ ctx->cur++;
+ eat_opt_white(&ctx->cur);
+
+ switch (uprcase(*ctx->cur)) {
+ case 'X':
+ *ind_comp = TGSI_SWIZZLE_X;
+ break;
+ case 'Y':
+ *ind_comp = TGSI_SWIZZLE_Y;
+ break;
+ case 'Z':
+ *ind_comp = TGSI_SWIZZLE_Z;
+ break;
+ case 'W':
+ *ind_comp = TGSI_SWIZZLE_W;
+ break;
+ default:
+ report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'");
+ return FALSE;
+ }
+ ctx->cur++;
+ eat_opt_white(&ctx->cur);
+ }
+
if (*ctx->cur == '+' || *ctx->cur == '-') {
boolean negate;
int index;
uint ind_file;
int ind_index;
+ uint ind_comp;
uint swizzle[4];
boolean parsed_ext_negate_paren = FALSE;
boolean parsed_swizzle;
}
}
- if (!parse_register_src( ctx, &file, &index, &ind_file, &ind_index ))
+ if (!parse_register_src(ctx, &file, &index, &ind_file, &ind_index, &ind_comp))
return FALSE;
src->SrcRegister.File = file;
src->SrcRegister.Index = index;
src->SrcRegister.Indirect = 1;
src->SrcRegisterInd.File = ind_file;
src->SrcRegisterInd.Index = ind_index;
+ src->SrcRegisterInd.SwizzleX = ind_comp;
+ src->SrcRegisterInd.SwizzleY = ind_comp;
+ src->SrcRegisterInd.SwizzleZ = ind_comp;
+ src->SrcRegisterInd.SwizzleW = ind_comp;
}
/* Parse optional swizzle.