r600g: fix and improve rasterizer discard for r600-r700
authorMarek Olšák <maraeo@gmail.com>
Sun, 26 Feb 2012 13:47:22 +0000 (14:47 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 5 Mar 2012 13:22:20 +0000 (14:22 +0100)
For polygons, we have been using face culling with success, but that doesn't
work for points and lines.

Setting the point size and line width to 0 fixes it.

Also improve it even more by setting SCREEN_SCISSOR to a zero area.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_state.c

index 1dc23fdcca58971f814da166361bc028ff2604ed..40e776107f659521c71b171b96d87f356f41a446 100644 (file)
@@ -374,6 +374,7 @@ static const struct r600_reg r600_context_reg_list[] = {
        {R_028010_DB_DEPTH_INFO, REG_FLAG_NEED_BO, 0},
        {R_028D24_DB_HTILE_SURFACE, 0, 0},
        {R_028D34_DB_PREFETCH_LIMIT, 0, 0},
+       {R_028034_PA_SC_SCREEN_SCISSOR_BR, 0, 0},
        {R_028204_PA_SC_WINDOW_SCISSOR_TL, 0, 0},
        {R_028208_PA_SC_WINDOW_SCISSOR_BR, 0, 0},
        {R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0, 0},
index 38b48a29b7d3933c93dfbf8e87ff2b9f4ecc6ec4..a13c9944d44b039d5b03e5173749ea05e9307db8 100644 (file)
@@ -818,10 +818,15 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_0286D4_SPI_INTERP_CONTROL_0, tmp, NULL, 0);
 
        /* point size 12.4 fixed point */
-       tmp = (unsigned)(state->point_size * 8.0);
+       /* For rasterizer discard, disable point rendering by forcing the point size to be 0. */
+       tmp = state->rasterizer_discard ? 0 : r600_pack_float_12p4(state->point_size/2);
        r600_pipe_state_add_reg(rstate, R_028A00_PA_SU_POINT_SIZE, S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp), NULL, 0);
 
-       if (state->point_size_per_vertex) {
+       if (state->rasterizer_discard) {
+               /* For rasterizer discard, disable point rendering by forcing the point size to be 0. */
+               psize_min = 0;
+               psize_max = 0;
+       } else if (state->point_size_per_vertex) {
                psize_min = util_get_min_point_size(state);
                psize_max = 8192;
        } else {
@@ -835,7 +840,8 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
                                S_028A04_MAX_SIZE(r600_pack_float_12p4(psize_max/2)),
                                NULL, 0);
 
-       tmp = (unsigned)state->line_width * 8;
+       /* For rasterizer discard, disable line rendering by forcing the line width to be 0. */
+       tmp = state->rasterizer_discard ? 0 : r600_pack_float_12p4(state->line_width/2);
        r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, S_028A08_WIDTH(tmp), NULL, 0);
 
        if (rctx->chip_class >= R700) {
@@ -872,6 +878,10 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
                                S_028814_POLYMODE_FRONT_PTYPE(r600_translate_fill(state->fill_front)) |
                                S_028814_POLYMODE_BACK_PTYPE(r600_translate_fill(state->fill_back)),
                                NULL, 0);
+
+       r600_pipe_state_add_reg(rstate, R_028034_PA_SC_SCREEN_SCISSOR_BR,
+                               state->rasterizer_discard ? 0 : (S_028034_BR_X(8192) | S_028034_BR_Y(8192)),
+                               NULL, 0);
        return rstate;
 }
 
@@ -2056,9 +2066,7 @@ void r600_init_atom_start_cs(struct r600_context *rctx)
 
        r600_store_context_reg(cb, R_028C48_PA_SC_AA_MASK, 0xFFFFFFFF);
 
-       r600_store_context_reg_seq(cb, R_028030_PA_SC_SCREEN_SCISSOR_TL, 2);
-       r600_store_value(cb, 0); /* R_028030_PA_SC_SCREEN_SCISSOR_TL */
-       r600_store_value(cb, S_028034_BR_X(8192) | S_028034_BR_Y(8192)); /* R_028034_PA_SC_SCREEN_SCISSOR_BR */
+       r600_store_context_reg(cb, R_028030_PA_SC_SCREEN_SCISSOR_TL, 0);
 
        r600_store_context_reg_seq(cb, R_028240_PA_SC_GENERIC_SCISSOR_TL, 2);
        r600_store_value(cb, 0); /* R_028240_PA_SC_GENERIC_SCISSOR_TL */