aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_text.c
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2014-05-07 21:15:12 -0400
committerIlia Mirkin <[email protected]>2014-05-14 09:40:37 -0400
commit12d97fb7c100059d9aa37e1b6331ee1cfe977aa6 (patch)
treee5d99a2c9971d8938fdeb9057da2cd620ef84202 /src/gallium/auxiliary/tgsi/tgsi_text.c
parent04b7e65814cd2174185109d3c55c86eb4134f09b (diff)
tgsi: support parsing texture offsets from text tgsi shaders
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_text.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 2b2e7d58f4f..7e50d8d0ce3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -735,8 +735,9 @@ parse_dst_operand(
static boolean
parse_optional_swizzle(
struct translate_ctx *ctx,
- uint swizzle[4],
- boolean *parsed_swizzle )
+ uint *swizzle,
+ boolean *parsed_swizzle,
+ int components)
{
const char *cur = ctx->cur;
@@ -748,7 +749,7 @@ parse_optional_swizzle(
cur++;
eat_opt_white( &cur );
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < components; i++) {
if (uprcase( *cur ) == 'X')
swizzle[i] = TGSI_SWIZZLE_X;
else if (uprcase( *cur ) == 'Y')
@@ -816,7 +817,7 @@ parse_src_operand(
/* Parse optional swizzle.
*/
- if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle )) {
+ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 4 )) {
if (parsed_swizzle) {
src->Register.SwizzleX = swizzle[0];
src->Register.SwizzleY = swizzle[1];
@@ -839,6 +840,35 @@ parse_src_operand(
}
static boolean
+parse_texoffset_operand(
+ struct translate_ctx *ctx,
+ struct tgsi_texture_offset *src )
+{
+ uint file;
+ uint swizzle[3];
+ boolean parsed_swizzle;
+ struct parsed_bracket bracket;
+
+ if (!parse_register_src(ctx, &file, &bracket))
+ return FALSE;
+
+ src->File = file;
+ src->Index = bracket.index;
+
+ /* Parse optional swizzle.
+ */
+ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 3 )) {
+ if (parsed_swizzle) {
+ src->SwizzleX = swizzle[0];
+ src->SwizzleY = swizzle[1];
+ src->SwizzleZ = swizzle[2];
+ }
+ }
+
+ return TRUE;
+}
+
+static boolean
match_inst(const char **pcur,
unsigned *saturate,
const struct tgsi_opcode_info *info)
@@ -904,7 +934,7 @@ parse_instruction(
if (!parse_register_1d( ctx, &file, &index ))
return FALSE;
- if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle )) {
+ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 4 )) {
if (parsed_swizzle) {
inst.Predicate.SwizzleX = swizzle[0];
inst.Predicate.SwizzleY = swizzle[1];
@@ -1003,6 +1033,19 @@ parse_instruction(
cur = ctx->cur;
eat_opt_white( &cur );
+ for (i = 0; info->is_tex && *cur == ','; i++) {
+ cur++;
+ eat_opt_white( &cur );
+ ctx->cur = cur;
+ if (!parse_texoffset_operand( ctx, &inst.TexOffsets[i] ))
+ return FALSE;
+ cur = ctx->cur;
+ eat_opt_white( &cur );
+ }
+ inst.Texture.NumOffsets = i;
+
+ cur = ctx->cur;
+ eat_opt_white( &cur );
if (info->is_branch && *cur == ':') {
uint target;