[Mesa-dev] [PATCH] tgsi: support parsing texture offsets from text tgsi shaders
Ilia Mirkin
imirkin at alum.mit.edu
Wed May 7 18:25:49 PDT 2014
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/gallium/auxiliary/tgsi/tgsi_text.c | 53 ++++++++++++++++++++++++++++++----
1 file changed, 48 insertions(+), 5 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 2b2e7d5..7e50d8d 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;
--
1.8.3.2
More information about the mesa-dev
mailing list