r600: fix viewport clipping handling (v2)
authorDave Airlie <airlied@redhat.com>
Sat, 19 Dec 2015 23:01:22 +0000 (23:01 +0000)
committerDave Airlie <airlied@redhat.com>
Mon, 21 Dec 2015 23:09:56 +0000 (09:09 +1000)
If oViewport is written, vertex reuse need to be turned off.
If oViewport is constant, vertex reuse is fine, and VPORT_PROVOKE_DISABLE
need to be set. (we don't have enough info to program VPORT_PROVOKE).

Fixes: arb_viewport_array-render-viewport-2 and some CTS tests.
v2: drop vport provoke write, drop initial state writing this
on evergreen, only program it on evergreen.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c

index d929947c113b883c4d7be35760b3806a8b134983..1443bc0c4afb40cd216b4c814957c19244a81fc4 100644 (file)
@@ -2414,7 +2414,7 @@ static void cayman_init_atom_start_cs(struct r600_context *rctx)
        struct r600_command_buffer *cb = &rctx->start_cs_cmd;
        int tmp, i;
 
-       r600_init_command_buffer(cb, 341);
+       r600_init_command_buffer(cb, 338);
 
        /* This must be first. */
        r600_store_value(cb, PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
@@ -2468,8 +2468,6 @@ static void cayman_init_atom_start_cs(struct r600_context *rctx)
 
        r600_store_context_reg(cb, R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0);
 
-       r600_store_context_reg(cb, R_028AB4_VGT_REUSE_OFF, 0);
-
        r600_store_config_reg(cb, R_008A14_PA_CL_ENHANCE, (3 << 1) | 1);
 
        r600_store_context_reg_seq(cb, CM_R_028BD4_PA_SC_CENTROID_PRIORITY_0, 2);
@@ -2669,7 +2667,7 @@ void evergreen_init_atom_start_cs(struct r600_context *rctx)
                return;
        }
 
-       r600_init_command_buffer(cb, 341);
+       r600_init_command_buffer(cb, 338);
 
        /* This must be first. */
        r600_store_value(cb, PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
@@ -2894,8 +2892,6 @@ void evergreen_init_atom_start_cs(struct r600_context *rctx)
        r600_store_value(cb, 0); /* R_028A3C_VGT_GROUP_VECT_1_FMT_CNTL */
        r600_store_value(cb, 0); /* R_028A40_VGT_GS_MODE */
 
-       r600_store_context_reg(cb, R_028AB4_VGT_REUSE_OFF, 0);
-
        r600_store_config_reg(cb, R_008A14_PA_CL_ENHANCE, (3 << 1) | 1);
 
         r600_store_context_reg(cb, R_0288F0_SQ_VTX_SEMANTIC_CLEAR, ~0);
@@ -3727,7 +3723,7 @@ void evergreen_init_state_functions(struct r600_context *rctx)
        r600_init_atom(rctx, &rctx->blend_color.atom, id++, r600_emit_blend_color, 6);
        r600_init_atom(rctx, &rctx->blend_state.atom, id++, r600_emit_cso_state, 0);
        r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, evergreen_emit_cb_misc_state, 4);
-       r600_init_atom(rctx, &rctx->clip_misc_state.atom, id++, r600_emit_clip_misc_state, 6);
+       r600_init_atom(rctx, &rctx->clip_misc_state.atom, id++, r600_emit_clip_misc_state, 9);
        r600_init_atom(rctx, &rctx->clip_state.atom, id++, evergreen_emit_clip_state, 26);
        r600_init_atom(rctx, &rctx->db_misc_state.atom, id++, evergreen_emit_db_misc_state, 10);
        r600_init_atom(rctx, &rctx->db_state.atom, id++, evergreen_emit_db_state, 14);
index 795fb9a951310987c6eae6c5f4b0aacbf4aec72b..31f2a729494fe2046f5f4bd9d010ae1b78475727 100644 (file)
@@ -152,6 +152,7 @@ struct r600_clip_misc_state {
        unsigned clip_plane_enable; /* from rasterizer    */
        unsigned clip_dist_write;   /* from vertex shader */
        boolean clip_disable;       /* from vertex shader */
+       boolean vs_out_viewport;    /* from vertex shader */
 };
 
 struct r600_alphatest_state {
index 6a666343b061ed66138c517fd2f30622da915f50..ca589fa7759c248e69a952fd98435afcc3017b20 100644 (file)
@@ -1377,11 +1377,13 @@ static void r600_update_clip_state(struct r600_context *rctx,
 {
        if (current->pa_cl_vs_out_cntl != rctx->clip_misc_state.pa_cl_vs_out_cntl ||
            current->shader.clip_dist_write != rctx->clip_misc_state.clip_dist_write ||
-           current->shader.vs_position_window_space != rctx->clip_misc_state.clip_disable) {
-                               rctx->clip_misc_state.pa_cl_vs_out_cntl = current->pa_cl_vs_out_cntl;
-                               rctx->clip_misc_state.clip_dist_write = current->shader.clip_dist_write;
-                               rctx->clip_misc_state.clip_disable = current->shader.vs_position_window_space;
-                               r600_mark_atom_dirty(rctx, &rctx->clip_misc_state.atom);
+           current->shader.vs_position_window_space != rctx->clip_misc_state.clip_disable ||
+           current->shader.vs_out_viewport != rctx->clip_misc_state.vs_out_viewport) {
+               rctx->clip_misc_state.pa_cl_vs_out_cntl = current->pa_cl_vs_out_cntl;
+               rctx->clip_misc_state.clip_dist_write = current->shader.clip_dist_write;
+               rctx->clip_misc_state.clip_disable = current->shader.vs_position_window_space;
+               rctx->clip_misc_state.vs_out_viewport = current->shader.vs_out_viewport;
+               r600_mark_atom_dirty(rctx, &rctx->clip_misc_state.atom);
        }
 }
 
@@ -1656,6 +1658,10 @@ void r600_emit_clip_misc_state(struct r600_context *rctx, struct r600_atom *atom
        radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
                               state->pa_cl_vs_out_cntl |
                               (state->clip_plane_enable & state->clip_dist_write));
+       /* reuse needs to be set off if we write oViewport */
+       if (rctx->b.chip_class >= EVERGREEN)
+               radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,
+                                      S_028AB4_REUSE_OFF(state->vs_out_viewport));
 }
 
 static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)