r300g: move emission of the MSPOS regs into the framebuffer state
authorMarek Olšák <maraeo@gmail.com>
Fri, 25 Jun 2010 01:28:09 +0000 (03:28 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 27 Jun 2010 13:13:13 +0000 (15:13 +0200)
Now the question is whether we are allowed to ignore gl_rasterization_rules and
pipe_rasterizer_state::multisample. The former is invariant anyway and
I think the latter would need re-emitting the AA state which is quite costly,
considering that it implicitly flushes the whole pipeline (all AA regs
in the AA state are *unpipelined*).

src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c

index 7b7dafbc6faa5621c6ecd52d9fbc3e10a89c6fac..b14db16f7cdcd59fd4b5aec22ca52b82d7a5f76d 100644 (file)
@@ -143,7 +143,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(vs_state, 0);
     R300_INIT_ATOM(vs_constants, 0);
     R300_INIT_ATOM(clip_state, has_tcl ? 5 + (6 * 4) : 2);
-    /* VAP, RS, GA, GB. */
+    /* VAP, RS, GA, GB, SU, SC. */
     R300_INIT_ATOM(rs_block_state, 0);
     R300_INIT_ATOM(rs_state, 0);
     /* US. */
index cea3ab3418fb358a3bababf8279abbaa11be100c..5e35d8907122ec78ec970d73bfc0f80199e0c37e 100644 (file)
@@ -116,8 +116,6 @@ struct r300_rs_state {
     struct pipe_rasterizer_state rs_draw;
 
     uint32_t vap_control_status;    /* R300_VAP_CNTL_STATUS: 0x2140 */
-    uint32_t multisample_position_0;/* R300_GB_MSPOS0: 0x4010 */
-    uint32_t multisample_position_1;/* R300_GB_MSPOS1: 0x4014 */
     uint32_t point_size;            /* R300_GA_POINT_SIZE: 0x421c */
     uint32_t point_minmax;          /* R300_GA_POINT_MINMAX: 0x4230 */
     uint32_t line_control;          /* R300_GA_LINE_CNTL: 0x4234 */
index e4de081fdc738827042dbe5c6ed473c5545abade..65cddc88481c5646829d460f0f8246ec5a40b41e 100644 (file)
@@ -379,6 +379,42 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
     for (; i < 4; i++) {
         OUT_CS(R300_US_OUT_FMT_UNUSED);
     }
+
+    /* Multisampling. Depends on framebuffer sample count.
+     * These are pipelined regs and as such cannot be moved
+     * to the AA state. */
+    if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
+        unsigned mspos0 = 0x66666666;
+        unsigned mspos1 = 0x6666666;
+
+        if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
+            /* Subsample placement. These may not be optimal. */
+            switch (fb->cbufs[0]->texture->nr_samples) {
+                case 2:
+                    mspos0 = 0x33996633;
+                    mspos1 = 0x6666663;
+                    break;
+                case 3:
+                    mspos0 = 0x33936933;
+                    mspos1 = 0x6666663;
+                    break;
+                case 4:
+                    mspos0 = 0x33939933;
+                    mspos1 = 0x3966663;
+                    break;
+                case 6:
+                    mspos0 = 0x22a2aa22;
+                    mspos1 = 0x2a65672;
+                    break;
+                default:
+                    debug_printf("r300: Bad number of multisamples!\n");
+            }
+        }
+
+        OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
+        OUT_CS(mspos0);
+        OUT_CS(mspos1);
+    }
     END_CS;
 }
 
@@ -529,52 +565,11 @@ void r300_emit_invariant_state(struct r300_context *r300,
 void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
 {
     struct r300_rs_state* rs = state;
-    struct pipe_framebuffer_state* fb = r300->fb_state.state;
     float scale, offset;
-    unsigned mspos0, mspos1;
     CS_LOCALS(r300);
 
     BEGIN_CS(size);
     OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
-
-    /* Multisampling. Depends on framebuffer sample count. */
-    if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
-        if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
-            /* Subsample placement. These may not be optimal. */
-            switch (fb->cbufs[0]->texture->nr_samples) {
-                case 2:
-                    mspos0 = 0x33996633;
-                    mspos1 = 0x6666663;
-                    break;
-                case 3:
-                    mspos0 = 0x33936933;
-                    mspos1 = 0x6666663;
-                    break;
-                case 4:
-                    mspos0 = 0x33939933;
-                    mspos1 = 0x3966663;
-                    break;
-                case 6:
-                    mspos0 = 0x22a2aa22;
-                    mspos1 = 0x2a65672;
-                    break;
-                default:
-                    debug_printf("r300: Bad number of multisamples!\n");
-                    mspos0 = rs->multisample_position_0;
-                    mspos1 = rs->multisample_position_1;
-                    break;
-            }
-
-            OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
-            OUT_CS(mspos0);
-            OUT_CS(mspos1);
-        } else {
-            OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
-            OUT_CS(rs->multisample_position_0);
-            OUT_CS(rs->multisample_position_1);
-        }
-    }
-
     OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size);
     OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2);
     OUT_CS(rs->point_minmax);
index 27ec5bc2b3e004f08f20cc00425f9e55f6b1d574..ea1210fcb482ab435f70e86113039f1841b0a5ab 100644 (file)
@@ -708,7 +708,8 @@ static void
     r300->fb_state.size =
             7 +
             (8 * state->nr_cbufs) +
-            (state->zsbuf ? (r300->screen->caps.has_hiz ? 22 : 18) : 0);
+            (state->zsbuf ? (r300->screen->caps.has_hiz ? 22 : 18) : 0) +
+            (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0) ? 3 : 0);
 
     /* Polygon offset depends on the zbuffer bit depth. */
     if (state->zsbuf && r300->polygon_offset_enabled) {
@@ -975,11 +976,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
         }
     }
 
-    if (state->gl_rasterization_rules) {
-        rs->multisample_position_0 = 0x66666666;
-        rs->multisample_position_1 = 0x6666666;
-    }
-
     return (void*)rs;
 }
 
@@ -1009,8 +1005,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     }
 
     UPDATE_STATE(state, r300->rs_state);
-    r300->rs_state.size = 25 + (r300->polygon_offset_enabled ? 5 : 0) +
-        (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0) ? 3 : 0);
+    r300->rs_state.size = 25 + (r300->polygon_offset_enabled ? 5 : 0);
 
     if (last_sprite_coord_enable != r300->sprite_coord_enable ||
         last_two_sided_color != r300->two_sided_color) {