From dfab375c07545a9068a9b25efee746efd275bf89 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 17:06:36 +0200 Subject: [PATCH] tgsi/text: Allow optional component selection for indirect registers. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 43 +++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index bb1c7dc6ccf..a40fcab2126 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -358,9 +358,9 @@ parse_register_dst( /* Parse source register operand. * ::= `]' | - * `]' | - * `+' `]' | - * `-' `]' + * [`.' (`x' | `y' | `z' | `w')] `]' | + * [`.' (`x' | `y' | `z' | `w')] `+' `]' | + * [`.' (`x' | `y' | `z' | `w')] `-' `]' */ static boolean parse_register_src( @@ -368,11 +368,13 @@ 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 ); @@ -381,6 +383,32 @@ parse_register_src( 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; @@ -561,6 +589,7 @@ parse_src_operand( int index; uint ind_file; int ind_index; + uint ind_comp; uint swizzle[4]; boolean parsed_ext_negate_paren = FALSE; boolean parsed_swizzle; @@ -643,7 +672,7 @@ parse_src_operand( } } - 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; @@ -651,6 +680,10 @@ parse_src_operand( 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. -- 2.30.2