radeonsi: add basic code for overrasterization
authorMarek Olšák <marek.olsak@amd.com>
Sun, 15 Mar 2015 16:14:53 +0000 (17:14 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 16 Mar 2015 11:54:18 +0000 (12:54 +0100)
This will be used for line and polygon smoothing.
This is GCN-only even though it's in shared code.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/radeon/cayman_msaa.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600d_common.h
src/gallium/drivers/radeonsi/si_state.c

index f0b04f004fbb65bd0886ffcb426d83cf2553a8db..edd886b96f2a3c4bd6ddc0d0ed53070c7142902b 100644 (file)
@@ -1692,7 +1692,7 @@ static void evergreen_emit_framebuffer_state(struct r600_context *rctx, struct r
                evergreen_emit_msaa_state(rctx, rctx->framebuffer.nr_samples, rctx->ps_iter_samples);
        } else {
                cayman_emit_msaa_sample_locs(cs, rctx->framebuffer.nr_samples);
-               cayman_emit_msaa_config(cs, rctx->framebuffer.nr_samples, rctx->ps_iter_samples);
+               cayman_emit_msaa_config(cs, rctx->framebuffer.nr_samples, rctx->ps_iter_samples, 0);
        }
 }
 
index 47fc5c497f1a03473ce79bea598339646fd42773..12a5f604755d6a7eede23bc45f3a7d2df1771e4a 100644 (file)
@@ -195,9 +195,12 @@ void cayman_emit_msaa_sample_locs(struct radeon_winsys_cs *cs, int nr_samples)
 }
 
 void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples,
-                            int ps_iter_samples)
+                            int ps_iter_samples, int overrast_samples)
 {
-       if (nr_samples > 1) {
+       int setup_samples = nr_samples > 1 ? nr_samples :
+                           overrast_samples > 1 ? overrast_samples : 0;
+
+       if (setup_samples > 1) {
                /* indexed by log2(nr_samples) */
                unsigned max_dist[] = {
                        0,
@@ -206,8 +209,7 @@ void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples,
                        cm_max_dist_8x,
                        cm_max_dist_16x
                };
-
-               unsigned log_samples = util_logbase2(nr_samples);
+               unsigned log_samples = util_logbase2(setup_samples);
                unsigned log_ps_iter_samples =
                        util_logbase2(util_next_power_of_two(ps_iter_samples));
 
@@ -218,15 +220,23 @@ void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples,
                            S_028BE0_MAX_SAMPLE_DIST(max_dist[log_samples]) |
                            S_028BE0_MSAA_EXPOSED_SAMPLES(log_samples)); /* CM_R_028BE0_PA_SC_AA_CONFIG */
 
-               r600_write_context_reg(cs, CM_R_028804_DB_EQAA,
-                                      S_028804_MAX_ANCHOR_SAMPLES(log_samples) |
-                                      S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) |
-                                      S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) |
-                                      S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples) |
-                                      S_028804_HIGH_QUALITY_INTERSECTIONS(1) |
-                                      S_028804_STATIC_ANCHOR_ASSOCIATIONS(1));
-               r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1,
-                                    EG_S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1));
+               if (nr_samples > 1) {
+                       r600_write_context_reg(cs, CM_R_028804_DB_EQAA,
+                                              S_028804_MAX_ANCHOR_SAMPLES(log_samples) |
+                                              S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) |
+                                              S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) |
+                                              S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples) |
+                                              S_028804_HIGH_QUALITY_INTERSECTIONS(1) |
+                                              S_028804_STATIC_ANCHOR_ASSOCIATIONS(1));
+                       r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1,
+                                            EG_S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1));
+               } else if (overrast_samples > 1) {
+                       r600_write_context_reg(cs, CM_R_028804_DB_EQAA,
+                                              S_028804_HIGH_QUALITY_INTERSECTIONS(1) |
+                                              S_028804_STATIC_ANCHOR_ASSOCIATIONS(1) |
+                                              S_028804_OVERRASTERIZATION_AMOUNT(log_samples));
+                       r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1, 0);
+               }
        } else {
                r600_write_context_reg_seq(cs, CM_R_028BDC_PA_SC_LINE_CNTL, 2);
                radeon_emit(cs, S_028BDC_LAST_PIXEL(1)); /* CM_R_028BDC_PA_SC_LINE_CNTL */
index 43efaa34b4c0aecded4e79fa0b24012142227712..a08d08cdf14cbfbe23aa8c0c2b342ae005b2ba2d 100644 (file)
@@ -526,7 +526,7 @@ void cayman_get_sample_position(struct pipe_context *ctx, unsigned sample_count,
 void cayman_init_msaa(struct pipe_context *ctx);
 void cayman_emit_msaa_sample_locs(struct radeon_winsys_cs *cs, int nr_samples);
 void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples,
-                            int ps_iter_samples);
+                            int ps_iter_samples, int overrast_samples);
 
 
 /* Inline helpers. */
index ba29fd0c2d66d18f062290f1813660d757fc4325..74c8d8782a693fce7f43903b1dd9ea0001caeeab 100644 (file)
 #define   S_028804_INTERPOLATE_SRC_Z(x)                        (((x) & 0x1) << 19)
 #define   S_028804_STATIC_ANCHOR_ASSOCIATIONS(x)       (((x) & 0x1) << 20)
 #define   S_028804_ALPHA_TO_MASK_EQAA_DISABLE(x)       (((x) & 0x1) << 21)
+#define   S_028804_OVERRASTERIZATION_AMOUNT(x)         (((x) & 0x7) << 24)
+#define   S_028804_ENABLE_POSTZ_OVERRASTERIZATION(x)   (((x) & 0x1) << 27)
 #define CM_R_028BDC_PA_SC_LINE_CNTL                  0x28bdc
 #define   S_028BDC_EXPAND_LINE_WIDTH(x)                (((x) & 0x1) << 9)
 #define   G_028BDC_EXPAND_LINE_WIDTH(x)                (((x) >> 9) & 0x1)
index 5de31c03192c51996db702508af60ae4bbf6d056..b20042ce8318f6f5cd2ff78f20ae2ad92f83abd3 100644 (file)
@@ -2206,7 +2206,7 @@ static void si_emit_msaa_config(struct r600_common_context *rctx, struct r600_at
        struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
 
        cayman_emit_msaa_config(cs, sctx->framebuffer.nr_samples,
-                               sctx->ps_iter_samples);
+                               sctx->ps_iter_samples, 0);
 }
 
 const struct r600_atom si_atom_msaa_config = { si_emit_msaa_config, 10 }; /* number of CS dwords */