r300-gallium: Add Z/stencil buffer format emit.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 14 Feb 2009 10:06:17 +0000 (02:06 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 14 Feb 2009 10:06:17 +0000 (02:06 -0800)
Also set BEGIN_CS correctly.

src/gallium/drivers/r300/r300_emit.c

index 21803443fe2585491e074923e97ccda12d05f647..75864c0ef621556683a5f01b2c14be884a37ab6c 100644 (file)
@@ -151,7 +151,7 @@ uint32_t translate_out_fmt(enum pipe_format format)
     return 0;
 }
 
-/* XXX add pitch, stride, z/stencil buf */
+/* XXX add pitch, stride */
 void r300_emit_fb_state(struct r300_context* r300,
                         struct pipe_framebuffer_state* fb)
 {
@@ -159,7 +159,7 @@ void r300_emit_fb_state(struct r300_context* r300,
     struct r300_texture* tex;
     int i;
 
-    BEGIN_CS((3 * fb->nr_cbufs) + 6);
+    BEGIN_CS((5 * fb->nr_cbufs) + (fb->zsbuf ? 5 : 0) + 6);
     for (i = 0; i < fb->nr_cbufs; i++) {
         tex = (struct r300_texture*)fb->cbufs[i]->texture;
         OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
@@ -173,6 +173,12 @@ void r300_emit_fb_state(struct r300_context* r300,
         tex = (struct r300_texture*)fb->zsbuf->texture;
         OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
         OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+        if (fb->zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) {
+            OUT_CS_REG(R300_ZB_FORMAT,
+                R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL);
+        } else {
+            OUT_CS_REG(R300_ZB_FORMAT, 0x0);
+        }
     }
 
     OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,