diff options
author | Dave Airlie <airlied@redhat.com> | 2014-08-27 09:56:14 +1000 |
---|---|---|
committer | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2014-10-31 11:32:57 +0200 |
commit | 9c8f99a3ef2c47108b63e64c95eac6050bc7ef3b (patch) | |
tree | f6f73c848ffce68a9660abd9fc0cb2a3c748455c | |
parent | 94666033135b3ab0e6bc2b0d810902415c36dde4 (diff) |
tgsi: add support for flt64 constants
These act like flt32 except they take up two slots, and you
can only add 2 x flt64 constants in one slot.
The main reason they are different is we don't want to match half a flt64
constants against a flt32 constant in the matching code, we need to make
sure we treat both parts of the flt64 as an single structure.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_parse.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_strings.c | 5 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_strings.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_text.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.c | 75 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.h | 5 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_shader_tokens.h | 1 |
8 files changed, 85 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 972a37e83e..eebb590240 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -239,6 +239,7 @@ dump_imm_data(struct tgsi_iterate_context *iter, for (i = 0; i < num_tokens; i++) { switch (data_type) { case TGSI_IMM_FLOAT32: + case TGSI_IMM_FLOAT64: FLT( data[i].Float ); break; case TGSI_IMM_UINT32: diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c index 5bf8f48397..296d1084d7 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_parse.c +++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c @@ -148,6 +148,7 @@ tgsi_parse_token( switch (imm->Immediate.DataType) { case TGSI_IMM_FLOAT32: + case TGSI_IMM_FLOAT64: for (i = 0; i < imm_count; i++) { next_token(ctx, &imm->u[i].Float); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c index f84cd79b8e..b6e05ebf79 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c @@ -179,11 +179,12 @@ const char *tgsi_fs_coord_pixel_center_names[2] = "INTEGER" }; -const char *tgsi_immediate_type_names[3] = +const char *tgsi_immediate_type_names[4] = { "FLT32", "UINT32", - "INT32" + "INT32", + "FLT64" }; diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.h b/src/gallium/auxiliary/tgsi/tgsi_strings.h index c842746779..90014a225b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_strings.h +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.h @@ -58,7 +58,7 @@ extern const char *tgsi_fs_coord_origin_names[2]; extern const char *tgsi_fs_coord_pixel_center_names[2]; -extern const char *tgsi_immediate_type_names[3]; +extern const char *tgsi_immediate_type_names[4]; const char * diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index f965b0130e..0ae755a99e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -1105,6 +1105,7 @@ static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type, switch (type) { case TGSI_IMM_FLOAT32: + case TGSI_IMM_FLOAT64: ret = parse_float(&ctx->cur, &values[i].Float); break; case TGSI_IMM_UINT32: diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 6d3ac918a5..40df962a01 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -713,7 +713,48 @@ ureg_DECL_sampler_view(struct ureg_program *ureg, } static int +match_or_expand_immediate64( const unsigned *v, + int type, + unsigned nr, + unsigned *v2, + unsigned *pnr2, + unsigned *swizzle ) +{ + unsigned nr2 = *pnr2; + unsigned i, j; + *swizzle = 0; + + for (i = 0; i < nr; i += 2) { + boolean found = FALSE; + + for (j = 0; j < nr2 && !found; j += 2) { + if (v[i] == v2[j] && v[i + 1] == v2[j + 1]) { + *swizzle |= (j << (i * 2)) | ((j + 1) << ((i + 1) * 2)); + found = TRUE; + } + } + if (!found) { + if ((nr2) >= 4) { + return FALSE; + } + + v2[nr2] = v[i]; + v2[nr2 + 1] = v[i + 1]; + + *swizzle |= (nr2 << (i * 2)) | ((nr2 + 1) << ((i + 1) * 2)); + nr2 += 2; + } + } + + /* Actually expand immediate only when fully succeeded. + */ + *pnr2 = nr2; + return TRUE; +} + +static int match_or_expand_immediate( const unsigned *v, + int type, unsigned nr, unsigned *v2, unsigned *pnr2, @@ -722,6 +763,9 @@ match_or_expand_immediate( const unsigned *v, unsigned nr2 = *pnr2; unsigned i, j; + if (type == TGSI_IMM_FLOAT64) + return match_or_expand_immediate64(v, type, nr, v2, pnr2, swizzle); + *swizzle = 0; for (i = 0; i < nr; i++) { @@ -770,6 +814,7 @@ decl_immediate( struct ureg_program *ureg, continue; } if (match_or_expand_immediate(v, + type, nr, ureg->immediate[i].value.u, &ureg->immediate[i].nr, @@ -782,6 +827,7 @@ decl_immediate( struct ureg_program *ureg, i = ureg->nr_immediates++; ureg->immediate[i].type = type; if (match_or_expand_immediate(v, + type, nr, ureg->immediate[i].value.u, &ureg->immediate[i].nr, @@ -796,10 +842,15 @@ out: /* Make sure that all referenced elements are from this immediate. * Has the effect of making size-one immediates into scalars. */ - for (j = nr; j < 4; j++) { - swizzle |= (swizzle & 0x3) << (j * 2); + if (type == TGSI_IMM_FLOAT64) { + for (j = nr; j < 4; j+=2) { + swizzle |= (swizzle & 0xf) << (j * 2); + } + } else { + for (j = nr; j < 4; j++) { + swizzle |= (swizzle & 0x3) << (j * 2); + } } - return ureg_swizzle(ureg_src_register(TGSI_FILE_IMMEDIATE, i), (swizzle >> 0) & 0x3, (swizzle >> 2) & 0x3, @@ -826,6 +877,24 @@ ureg_DECL_immediate( struct ureg_program *ureg, return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT32); } +struct ureg_src +ureg_DECL_immediate_f64( struct ureg_program *ureg, + const double *v, + unsigned nr ) +{ + union { + unsigned u[4]; + double d[2]; + } fu; + unsigned int i; + + assert((nr / 2) < 3); + for (i = 0; i < nr / 2; i++) { + fu.d[i] = v[i]; + } + + return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT64); +} struct ureg_src ureg_DECL_immediate_uint( struct ureg_program *ureg, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index f014b5304a..8fac8babc7 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -262,6 +262,11 @@ ureg_DECL_immediate( struct ureg_program *, unsigned nr ); struct ureg_src +ureg_DECL_immediate_f64( struct ureg_program *, + const double *v, + unsigned nr ); + +struct ureg_src ureg_DECL_immediate_uint( struct ureg_program *, const unsigned *v, unsigned nr ); diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 787d7afe99..42306f7361 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -226,6 +226,7 @@ struct tgsi_declaration_array { #define TGSI_IMM_FLOAT32 0 #define TGSI_IMM_UINT32 1 #define TGSI_IMM_INT32 2 +#define TGSI_IMM_FLOAT64 3 struct tgsi_immediate { |