[PATCH 2/2] etnaviv: Add support for DP2 instruction

Christian Gmeiner christian.gmeiner at gmail.com
Sun Oct 1 12:04:16 UTC 2017


2017-10-01 11:21 GMT+02:00 Wladimir J. van der Laan <laanwj at gmail.com>:
> A two-component dot product instruction is supported with HALTI2, use it
> on hardware that supports it.
>
> Signed-off-by: Wladimir J. van der Laan <laanwj at gmail.com>

Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>

> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 3 ++-
>  src/gallium/drivers/etnaviv/etnaviv_disasm.c   | 1 +
>  src/gallium/drivers/etnaviv/etnaviv_internal.h | 2 ++
>  src/gallium/drivers/etnaviv/etnaviv_screen.c   | 2 ++
>  4 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 2a2af45..5d327dd 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -1752,6 +1752,7 @@ static const struct instr_translater translaters[TGSI_OPCODE_LAST] = {
>     INSTR(RSQ, trans_instr, .opc = INST_OPCODE_RSQ, .src = {2, -1, -1}),
>     INSTR(MUL, trans_instr, .opc = INST_OPCODE_MUL, .src = {0, 1, -1}),
>     INSTR(ADD, trans_instr, .opc = INST_OPCODE_ADD, .src = {0, 2, -1}),
> +   INSTR(DP2, trans_instr, .opc = INST_OPCODE_DP2, .src = {0, 1, -1}),
>     INSTR(DP3, trans_instr, .opc = INST_OPCODE_DP3, .src = {0, 1, -1}),
>     INSTR(DP4, trans_instr, .opc = INST_OPCODE_DP4, .src = {0, 1, -1}),
>     INSTR(DST, trans_instr, .opc = INST_OPCODE_DST, .src = {0, 1, -1}),
> @@ -2293,7 +2294,7 @@ etna_compile_shader(struct etna_shader_variant *v)
>        .lower_POW = true,
>        .lower_EXP = true,
>        .lower_LOG = true,
> -      .lower_DP2 = true,
> +      .lower_DP2 = !specs->has_halti2_instructions,
>        .lower_TRUNC = true,
>     };
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_disasm.c b/src/gallium/drivers/etnaviv/etnaviv_disasm.c
> index 918d24e..9ae99da 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_disasm.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_disasm.c
> @@ -513,6 +513,7 @@ static const struct opc_info {
>     OPC(AND),
>     OPC(XOR),
>     OPC(NOT),
> +   OPC(DP2),
>  };
>
>  static void
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> index a6544f6..896bbf5 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> @@ -72,6 +72,8 @@ struct etna_specs {
>     unsigned has_shader_range_registers : 1;
>     /* has the new sin/cos/log functions */
>     unsigned has_new_transcendentals : 1;
> +   /* has the new dp2/dpX_norm instructions, among others */
> +   unsigned has_halti2_instructions : 1;
>     /* supports single-buffer rendering with multiple pixel pipes */
>     unsigned single_buffer : 1;
>     /* has unified uniforms memory */
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index ea2581b..84da2a2 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -701,6 +701,8 @@ etna_get_specs(struct etna_screen *screen)
>        VIV_FEATURE(screen, chipMinorFeatures1, NON_POWER_OF_TWO);
>     screen->specs.has_new_transcendentals =
>        VIV_FEATURE(screen, chipMinorFeatures3, HAS_FAST_TRANSCENDENTALS);
> +   screen->specs.has_halti2_instructions =
> +      VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
>
>     if (VIV_FEATURE(screen, chipMinorFeatures3, INSTRUCTION_CACHE)) {
>        /* GC3000 - this core is capable of loading shaders from
> --
> 2.7.4
>

greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info


More information about the etnaviv mailing list