From: Jerome Glisse <jgli...@redhat.com> DUAL_EXPORT can be enabled on r6xx/r7xx when all CBs use 16-bit export and there is no depth/stencil export.
Signed-off-by: Jerome Glisse <jgli...@redhat.com> --- src/gallium/drivers/r600/r600_pipe.h | 1 + src/gallium/drivers/r600/r600_state.c | 45 ++++++++++++++++++++------ src/gallium/drivers/r600/r600_state_common.c | 30 +++++++++++------ 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 2c107c8..4f5cf0e 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -462,6 +462,7 @@ boolean r600_is_format_supported(struct pipe_screen *screen, enum pipe_texture_target target, unsigned sample_count, unsigned usage); +void r600_update_dual_export_state(struct r600_context * rctx); /* r600_texture.c */ void r600_init_screen_texture_functions(struct pipe_screen *screen); diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index b314edc..a38cb53 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1495,8 +1495,11 @@ static void r600_cb(struct r600_context *rctx, struct r600_pipe_state *rstate, ntype != V_0280A0_NUMBER_UINT && ntype != V_0280A0_NUMBER_SINT) && G_0280A0_BLEND_CLAMP(color_info) && - !G_0280A0_BLEND_FLOAT32(color_info)) + !G_0280A0_BLEND_FLOAT32(color_info)) { color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM); + } else { + rctx->export_16bpc = false; + } } else { /* EXPORT_NORM can be enabled if: * - 11-bit or smaller UNORM/SNORM/SRGB @@ -1507,8 +1510,11 @@ static void r600_cb(struct r600_context *rctx, struct r600_pipe_state *rstate, desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT && ntype != V_0280A0_NUMBER_UINT && ntype != V_0280A0_NUMBER_SINT) || (desc->channel[i].size < 17 && - desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))) + desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))) { color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM); + } else { + rctx->export_16bpc = false; + } } /* for possible dual-src MRT write color info 1 */ @@ -1640,6 +1646,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx, /* build states */ rctx->have_depth_fb = 0; + rctx->export_16bpc = true; rctx->nr_cbufs = state->nr_cbufs; for (int i = 0; i < state->nr_cbufs; i++) { @@ -2234,6 +2241,7 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad int pos_index = -1, face_index = -1; unsigned tmp, sid, ufi = 0; int need_linear = 0; + unsigned z_export = 0, stencil_export = 0; rstate->nregs = 0; @@ -2273,23 +2281,23 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad db_shader_control = S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z); for (i = 0; i < rshader->noutput; i++) { if (rshader->output[i].name == TGSI_SEMANTIC_POSITION) - db_shader_control |= S_02880C_Z_EXPORT_ENABLE(1); + z_export = 1; if (rshader->output[i].name == TGSI_SEMANTIC_STENCIL) - db_shader_control |= S_02880C_STENCIL_REF_EXPORT_ENABLE(1); + stencil_export = 1; } + db_shader_control |= S_02880C_Z_EXPORT_ENABLE(z_export); + db_shader_control |= S_02880C_STENCIL_REF_EXPORT_ENABLE(stencil_export); if (rshader->uses_kill) db_shader_control |= S_02880C_KILL_ENABLE(1); exports_ps = 0; - num_cout = 0; for (i = 0; i < rshader->noutput; i++) { if (rshader->output[i].name == TGSI_SEMANTIC_POSITION || - rshader->output[i].name == TGSI_SEMANTIC_STENCIL) + rshader->output[i].name == TGSI_SEMANTIC_STENCIL) { exports_ps |= 1; - else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) { - num_cout++; } } + num_cout = rshader->nr_ps_color_exports; exports_ps |= S_028854_EXPORT_COLORS(num_cout); if (!exports_ps) { /* always at least export 1 component per pixel */ @@ -2335,8 +2343,8 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad R_028854_SQ_PGM_EXPORTS_PS, exports_ps); /* only set some bits here, the other bits are set in the dsa state */ - r600_pipe_state_add_reg(rstate, R_02880C_DB_SHADER_CONTROL, - db_shader_control); + shader->db_shader_control = db_shader_control; + shader->ps_depth_export = z_export | stencil_export; shader->sprite_coord_enable = rctx->sprite_coord_enable; if (rctx->rasterizer) @@ -2435,3 +2443,20 @@ void *r600_create_db_flush_dsa(struct r600_context *rctx) dsa_state->is_flush = true; return rstate; } + +void r600_update_dual_export_state(struct r600_context * rctx) +{ + unsigned dual_export = rctx->export_16bpc && rctx->nr_cbufs && + !rctx->ps_shader->ps_depth_export; + unsigned db_shader_control = rctx->ps_shader->db_shader_control | + S_02880C_DUAL_EXPORT_ENABLE(dual_export); + + if (db_shader_control != rctx->db_shader_control) { + struct r600_pipe_state rstate; + + rctx->db_shader_control = db_shader_control; + rstate.nregs = 0; + r600_pipe_state_add_reg(&rstate, R_02880C_DB_SHADER_CONTROL, db_shader_control); + r600_context_pipe_state_set(rctx, &rstate); + } +} diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index ebb3cfe..b79cf18 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -458,9 +458,6 @@ void r600_bind_ps_shader(struct pipe_context *ctx, void *state) r600_inval_shader_cache(rctx); r600_context_pipe_state_set(rctx, &rctx->ps_shader->rstate); - rctx->cb_color_control &= C_028808_MULTIWRITE_ENABLE; - rctx->cb_color_control |= S_028808_MULTIWRITE_ENABLE(!!rctx->ps_shader->shader.fs_write_all); - if (rctx->ps_shader && rctx->vs_shader) { r600_adjust_gprs(rctx); } @@ -515,8 +512,9 @@ static void r600_update_alpha_ref(struct r600_context *rctx) alpha_ref = rctx->alpha_ref; rstate.nregs = 0; - if (rctx->export_16bpc) + if (rctx->export_16bpc && rctx->chip_class >= EVERGREEN) { alpha_ref &= ~0x1FFF; + } r600_pipe_state_add_reg(&rstate, R_028438_SX_ALPHA_REF, alpha_ref); r600_context_pipe_state_set(rctx, &rstate); @@ -711,13 +709,17 @@ static void r600_update_derived_state(struct r600_context *rctx) r600_context_pipe_state_set(rctx, &rctx->ps_shader->rstate); } - if (rctx->chip_class >= EVERGREEN) + if (rctx->chip_class >= EVERGREEN) { evergreen_update_dual_export_state(rctx); + } else { + r600_update_dual_export_state(rctx); + } - if (rctx->dual_src_blend) + if (rctx->dual_src_blend) { rctx->cb_shader_mask = rctx->ps_shader->ps_cb_shader_mask | rctx->fb_cb_shader_mask; - else + } else { rctx->cb_shader_mask = rctx->fb_cb_shader_mask; + } } static unsigned r600_conv_prim_to_gs_out(unsigned mode) @@ -805,8 +807,13 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo) r600_pipe_state_add_reg(&rctx->vgt, R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, info.primitive_restart); r600_pipe_state_add_reg(&rctx->vgt, R_03CFF4_SQ_VTX_START_INST_LOC, info.start_instance); r600_pipe_state_add_reg(&rctx->vgt, R_028A0C_PA_SC_LINE_STIPPLE, 0); - if (rctx->chip_class <= R700) + if (rctx->chip_class <= R700) { + unsigned multi_write = !!rctx->ps_shader->shader.fs_write_all && + (rctx->nr_cbufs > 1); + rctx->cb_color_control &= C_028808_MULTIWRITE_ENABLE; + rctx->cb_color_control |= S_028808_MULTIWRITE_ENABLE(multi_write); r600_pipe_state_add_reg(&rctx->vgt, R_028808_CB_COLOR_CONTROL, rctx->cb_color_control); + } r600_pipe_state_add_reg(&rctx->vgt, R_02881C_PA_CL_VS_OUT_CNTL, 0); r600_pipe_state_add_reg(&rctx->vgt, R_028810_PA_CL_CLIP_CNTL, 0); } @@ -827,8 +834,13 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo) else if (prim == V_008958_DI_PT_LINESTRIP) ls_mask = 2; r600_pipe_state_mod_reg(&rctx->vgt, S_028A0C_AUTO_RESET_CNTL(ls_mask) | rctx->pa_sc_line_stipple); - if (rctx->chip_class <= R700) + if (rctx->chip_class <= R700) { + unsigned multi_write = !!rctx->ps_shader->shader.fs_write_all && + (rctx->nr_cbufs > 1); + rctx->cb_color_control &= C_028808_MULTIWRITE_ENABLE; + rctx->cb_color_control |= S_028808_MULTIWRITE_ENABLE(multi_write); r600_pipe_state_mod_reg(&rctx->vgt, rctx->cb_color_control); + } r600_pipe_state_mod_reg(&rctx->vgt, rctx->vs_shader->pa_cl_vs_out_cntl | (rctx->rasterizer->clip_plane_enable & rctx->vs_shader->shader.clip_dist_write)); -- 1.7.10.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev