etnaviv: set output mode and saturate bits
authorJonathan Marek <jonathan@marek.ca>
Mon, 12 Aug 2019 18:19:59 +0000 (14:19 -0400)
committerJonathan Marek <jonathan@marek.ca>
Fri, 13 Dec 2019 14:09:08 +0000 (09:09 -0500)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_emit.c
src/gallium/drivers/etnaviv/etnaviv_internal.h
src/gallium/drivers/etnaviv/etnaviv_shader.c
src/gallium/drivers/etnaviv/etnaviv_state.c
src/gallium/drivers/etnaviv/etnaviv_translate.h

index ba3d8c021e7f69ad2061fb9f9717780f02472181..25431477a7a2e35529cdd78c6a698b0e0d7fd67b 100644 (file)
@@ -449,7 +449,8 @@ etna_emit_state(struct etna_context *ctx)
                            ctx->framebuffer.msaa_mode
                               ? ctx->shader_state.PS_TEMP_REGISTER_CONTROL_MSAA
                               : ctx->shader_state.PS_TEMP_REGISTER_CONTROL);
-      /*01010*/ EMIT_STATE(PS_CONTROL, ctx->shader_state.PS_CONTROL);
+      /*01010*/ EMIT_STATE(PS_CONTROL, ctx->framebuffer.PS_CONTROL);
+      /*01030*/ EMIT_STATE(PS_CONTROL_EXT, ctx->framebuffer.PS_CONTROL_EXT);
    }
    if (unlikely(dirty & (ETNA_DIRTY_ZSA | ETNA_DIRTY_FRAMEBUFFER | ETNA_DIRTY_SHADER))) {
       /*01400*/ EMIT_STATE(PE_DEPTH_CONFIG, (etna_zsa_state(ctx->zsa)->PE_DEPTH_CONFIG |
index 8655eac53c346bdb97e9574d720ceb523e0a4b0a..fcad76513d91af713575f2cc1f14c9a142efc90f 100644 (file)
@@ -216,6 +216,8 @@ struct compiled_framebuffer_state {
    struct etna_reloc TS_COLOR_STATUS_BASE;
    struct etna_reloc TS_COLOR_SURFACE_BASE;
    uint32_t PE_LOGIC_OP;
+   uint32_t PS_CONTROL;
+   uint32_t PS_CONTROL_EXT;
    bool msaa_mode; /* adds input (and possible temp) to PS */
 };
 
@@ -256,7 +258,6 @@ struct compiled_shader_state {
    uint32_t PS_INPUT_COUNT_MSAA; /* Adds an input */
    uint32_t PS_TEMP_REGISTER_CONTROL;
    uint32_t PS_TEMP_REGISTER_CONTROL_MSAA; /* Adds a temporary if needed to make space for extra input */
-   uint32_t PS_CONTROL;
    uint32_t PS_START_PC;
    uint32_t PE_DEPTH_CONFIG;
    uint32_t GL_VARYING_TOTAL_COMPONENTS;
index 72796065fb6155868133c2725b194606a3dd6e5a..0415538e28799036275f2acd8c4efe780efffcd2 100644 (file)
@@ -165,7 +165,6 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
       VIVS_PS_INPUT_COUNT_UNK8(fs->input_count_unk8);
    cs->PS_TEMP_REGISTER_CONTROL =
       VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(MAX2(fs->num_temps, link.num_varyings + 1));
-   cs->PS_CONTROL = VIVS_PS_CONTROL_SATURATE_RT0; /* XXX when can we set BYPASS? */
    cs->PS_START_PC = 0;
 
    /* Precompute PS_INPUT_COUNT and TEMP_REGISTER_CONTROL in the case of MSAA
index 314bd355c0955336c117d542f92b3cdcefb4a0e2..cf44a7ea12469e02988a54c9c4eab00f722af94c 100644 (file)
@@ -213,6 +213,10 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
 
       if (util_format_is_srgb(cbuf->base.format))
          pe_logic_op |= VIVS_PE_LOGIC_OP_SRGB;
+
+      cs->PS_CONTROL = COND(util_format_is_unorm(cbuf->base.format), VIVS_PS_CONTROL_SATURATE_RT0);
+      cs->PS_CONTROL_EXT =
+         VIVS_PS_CONTROL_EXT_OUTPUT_MODE0(translate_output_mode(cbuf->base.format, ctx->specs.halti >= 5));
    } else {
       /* Clearing VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK and
        * VIVS_PE_COLOR_FORMAT_OVERWRITE prevents us from overwriting the
index 6c367d7ed8b6ee1d4c3ab6a21145ccbc6f2c433e..e0811545e7455b1b554bc57d3b41fb0543302ea9 100644 (file)
@@ -306,6 +306,28 @@ translate_vertex_format_normalize(enum pipe_format fmt)
              : VIVS_FE_VERTEX_ELEMENT_CONFIG_NORMALIZE_OFF;
 }
 
+static inline uint32_t
+translate_output_mode(enum pipe_format fmt, bool halti5)
+{
+   const unsigned bits =
+      util_format_get_component_bits(fmt, UTIL_FORMAT_COLORSPACE_RGB, 0);
+
+   if (bits == 32)
+      return COLOR_OUTPUT_MODE_UIF32;
+
+   if (!util_format_is_pure_integer(fmt))
+      return COLOR_OUTPUT_MODE_NORMAL;
+
+   /* generic integer output mode pre-halti5 (?) */
+   if (bits == 10 || !halti5)
+      return COLOR_OUTPUT_MODE_A2B10G10R10UI;
+
+   if (util_format_is_pure_sint(fmt))
+      return bits == 8 ? COLOR_OUTPUT_MODE_I8 : COLOR_OUTPUT_MODE_I16;
+
+   return bits == 8 ? COLOR_OUTPUT_MODE_U8 : COLOR_OUTPUT_MODE_U16;
+}
+
 static inline uint32_t
 translate_index_size(unsigned index_size)
 {