r300g: Moar MSAA setup.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 26 May 2010 05:33:21 +0000 (22:33 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 16 Jun 2010 17:54:08 +0000 (10:54 -0700)
Need to just add the resolve, then go switch to new DRM and test.

src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_texture.c

index aae2e49dca8934549051d9333e2d5d991fea4080..251e1700565d7c9aafc6fe7fbd7b981a01d2aefe 100644 (file)
@@ -475,22 +475,60 @@ void r300_emit_query_end(struct r300_context* r300)
 
 void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
 {
-    struct r300_rs_state* rs = (struct r300_rs_state*)state;
+    struct r300_rs_state* rs = state;
+    struct pipe_framebuffer_state* fb = r300->fb_state.state;
     float scale, offset;
+    unsigned mspos0, mspos1, aa_config;
     CS_LOCALS(r300);
 
     BEGIN_CS(size);
     OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
 
-    OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config);
-
-    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)) {
-        OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
-        OUT_CS(rs->multisample_position_0);
-        OUT_CS(rs->multisample_position_1);
+        if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
+            aa_config = R300_GB_AA_CONFIG_AA_ENABLE;
+            /* Subsample placement. These may not be optimal. */
+            switch (fb->cbufs[0]->texture->nr_samples) {
+                case 2:
+                    aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2;
+                    mspos0 = 0x33996633;
+                    mspos1 = 0x6666663;
+                    break;
+                case 3:
+                    aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3;
+                    mspos0 = 0x33936933;
+                    mspos1 = 0x6666663;
+                    break;
+                case 4:
+                    aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4;
+                    mspos0 = 0x33939933;
+                    mspos1 = 0x3966663;
+                    break;
+                case 6:
+                    aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6;
+                    mspos0 = 0x22a2aa22;
+                    mspos1 = 0x2a65672;
+                    break;
+                default:
+                    debug_printf("r300: Bad number of multisamples!\n");
+                    break;
+            }
+
+            OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
+            OUT_CS(mspos0);
+            OUT_CS(mspos1);
+
+            OUT_CS_REG(R300_GB_AA_CONFIG, aa_config);
+        } 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_GB_AA_CONFIG, rs->antialiasing_config);
+        }
     }
-    OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config);
+
     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 f0c562b76b33477d7ed607e97a697eaa91520f8f..c599f76e5648d7bd93607a70d0fec54cfd4473cf 100644 (file)
@@ -275,8 +275,17 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
         return FALSE;
     }
 
-   if (sample_count > 1)
-      return FALSE;
+    switch (sample_count) {
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+        case 4:
+        case 6:
+            break;
+        default:
+            return FALSE;
+    }
 
     /* Check sampler format support. */
     if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
index 815f969e5ecc13fc7587e89da9b0045723bcb48b..651ad7dd761d193937592d692641387a7f558289 100644 (file)
@@ -984,7 +984,8 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     }
 
     UPDATE_STATE(state, r300->rs_state);
-    r300->rs_state.size = 31 + (r300->polygon_offset_enabled ? 5 : 0);
+    r300->rs_state.size = 25 + (r300->polygon_offset_enabled ? 5 : 0 +
+        r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0) ? 6 : 0);
 
     if (last_sprite_coord_enable != r300->sprite_coord_enable ||
         last_two_sided_color != r300->two_sided_color) {
index 5d8bcff1ac133f579a6835aebc6796459b3125e6..f41c5301d904ad6f87900925d9171e7eb0d83d1b 100644 (file)
@@ -802,6 +802,10 @@ static void r300_setup_miptree(struct r300_screen* screen,
         nblocksy = r300_texture_get_nblocksy(tex, i);
         layer_size = stride * nblocksy;
 
+        if (base->nr_samples) {
+            layer_size *= base->nr_samples;
+        }
+
         if (base->target == PIPE_TEXTURE_CUBE)
             size = layer_size * 6;
         else