[Mesa-dev] [PATCH 10/11] etnaviv: add support for rb swap
Christian Gmeiner
christian.gmeiner at gmail.com
Tue Mar 28 20:13:18 UTC 2017
Hi Lucas
2017-03-27 10:40 GMT+02:00 Lucas Stach <l.stach at pengutronix.de>:
> Am Sonntag, den 26.03.2017, 16:13 +0200 schrieb Christian Gmeiner:
>> If we render to rb swapped format we will create a shader variant doing
>> the involved swizzing in the pixel shader.
>>
>> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
>> ---
>> src/gallium/drivers/etnaviv/etnaviv_compiler.c | 17 +++++++++++++++++
>> src/gallium/drivers/etnaviv/etnaviv_compiler_cmdline.c | 8 ++++++++
>> src/gallium/drivers/etnaviv/etnaviv_context.c | 7 +++++++
>> src/gallium/drivers/etnaviv/etnaviv_shader.h | 6 ++++++
>> 4 files changed, 38 insertions(+)
>>
>> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
>> index ce8a651..eafb511 100644
>> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
>> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
>> @@ -1910,6 +1910,22 @@ etna_compile_add_z_div_if_needed(struct etna_compile *c)
>> }
>> }
>>
>> +static void
>> +etna_compile_frag_rb_swap(struct etna_compile *c)
>> +{
>> + if (c->info.processor == PIPE_SHADER_FRAGMENT && c->key->frag_rb_swap) {
>> + /* find color out */
>> + struct etna_reg_desc *color_reg =
>> + find_decl_by_semantic(c, TGSI_FILE_OUTPUT, TGSI_SEMANTIC_COLOR, 0);
>> +
>> + emit_inst(c, &(struct etna_inst) {
>> + .opcode = INST_OPCODE_MOV,
>> + .dst = etna_native_to_dst(color_reg->native, INST_COMPS_X | INST_COMPS_Y | INST_COMPS_Z | INST_COMPS_W),
>> + .src[2] = etna_native_to_src(color_reg->native, SWIZZLE(Z, Y, X, W)),
>> + });
>> + }
>> +}
>> +
>> /** add a NOP to the shader if
>> * a) the shader is empty
>> * or
>> @@ -2412,6 +2428,7 @@ etna_compile_shader(struct etna_shader_variant *v)
>> /* pass 3: generate instructions */
>> etna_compile_pass_generate_code(c);
>> etna_compile_add_z_div_if_needed(c);
>> + etna_compile_frag_rb_swap(c);
>> etna_compile_add_nop_if_needed(c);
>> etna_compile_fill_in_labels(c);
>>
>> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_cmdline.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_cmdline.c
>> index 1fea2d1..bdaa78e 100644
>> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_cmdline.c
>> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_cmdline.c
>> @@ -91,6 +91,7 @@ print_usage(void)
>> {
>> printf("Usage: etnaviv_compiler [OPTIONS]... FILE\n");
>> printf(" --verbose - verbose compiler/debug messages\n");
>> + printf(" --frag-rb-swap - swap rb in color output (FRAG)\n");
>> printf(" --help - show this message\n");
>> }
>>
>> @@ -121,6 +122,13 @@ main(int argc, char **argv)
>> continue;
>> }
>>
>> + if (!strcmp(argv[n], "--frag-rb-swap")) {
>> + debug_printf(" %s", argv[n]);
>> + key.frag_rb_swap = true;
>
> frag_rb_swap is of type unsigned so assigning a bool is at least
> confusing, even if it maps to the same thing in the end.
>
Me likes it that way but that is probably personal taste :)
If you can live with it I will keep it as-is - else I could do a
key.frag_rb_swap = 1 but yeah.
greets
--
Christian Gmeiner, MSc
https://www.youtube.com/user/AloryOFFICIAL
https://soundcloud.com/christian-gmeiner
More information about the mesa-dev
mailing list