r300g: inline FLUSH_CS
[mesa.git] / src / gallium / drivers / r300 / r300_emit.c
index 55c6ce503044394a5399acbcf8d06ad2a763df0a..13ea7fdad170ecf1cfe20699e0253d67294c880a 100644 (file)
@@ -464,18 +464,13 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
         R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
         R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
 
-    /* Set the number of colorbuffers. */
-    if (fb->nr_cbufs > 1) {
-        if (r300->screen->caps.is_r500) {
-            OUT_CS_REG(R300_RB3D_CCTL,
-                R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs) |
-                R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE);
-        } else {
-            OUT_CS_REG(R300_RB3D_CCTL,
-                R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs));
-        }
+    /* NUM_MULTIWRITES replicates COLOR[0] to all colorbuffers, which is not
+     * what we usually want. */
+    if (r300->screen->caps.is_r500) {
+        OUT_CS_REG(R300_RB3D_CCTL,
+            R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE);
     } else {
-        OUT_CS_REG(R300_RB3D_CCTL, 0x0);
+        OUT_CS_REG(R300_RB3D_CCTL, 0);
     }
 
     /* Set up colorbuffers. */
@@ -815,25 +810,17 @@ void r300_emit_textures_state(struct r300_context *r300,
     END_CS;
 }
 
-void r300_emit_aos(struct r300_context* r300, unsigned offset, boolean indexed)
+void r300_emit_aos(struct r300_context* r300, int offset, boolean indexed)
 {
     struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer;
     struct pipe_vertex_element *velem = r300->velems->velem;
     struct r300_buffer *buf;
     int i;
+    unsigned *hw_format_size = r300->velems->hw_format_size;
     unsigned size1, size2, aos_count = r300->velems->count;
     unsigned packet_size = (aos_count * 3 + 1) / 2;
     CS_LOCALS(r300);
 
-    for (i = 0; i < aos_count; i++) {
-        if ((vbuf[velem[i].vertex_buffer_index].buffer_offset + velem[i].src_offset) % 4 != 0) {
-            /* XXX We must align the buffer. */
-            assert(0);
-            fprintf(stderr, "r300: Unaligned vertex buffer offsets aren't supported, aborting..\n");
-            abort();
-        }
-    }
-
     BEGIN_CS(2 + packet_size + aos_count * 2);
     OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size);
     OUT_CS(aos_count | (!indexed ? R300_VC_FORCE_PREFETCH : 0));
@@ -841,8 +828,8 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset, boolean indexed)
     for (i = 0; i < aos_count - 1; i += 2) {
         vb1 = &vbuf[velem[i].vertex_buffer_index];
         vb2 = &vbuf[velem[i+1].vertex_buffer_index];
-        size1 = util_format_get_blocksize(velem[i].src_format);
-        size2 = util_format_get_blocksize(velem[i+1].src_format);
+        size1 = hw_format_size[i];
+        size2 = hw_format_size[i+1];
 
         OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride) |
                R300_VBPNTR_SIZE1(size2) | R300_VBPNTR_STRIDE1(vb2->stride));
@@ -852,7 +839,7 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset, boolean indexed)
 
     if (aos_count & 1) {
         vb1 = &vbuf[velem[i].vertex_buffer_index];
-        size1 = util_format_get_blocksize(velem[i].src_format);
+        size1 = hw_format_size[i];
 
         OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride));
         OUT_CS(vb1->buffer_offset + velem[i].src_offset + offset * vb1->stride);