Mesa (master): r300-gallium: correct buffer stride calculation

Corbin Simpson csimpson at kemper.freedesktop.org
Mon Feb 23 05:51:10 UTC 2009


Module: Mesa
Branch: master
Commit: b11f1c35d556b0c2d6815e33745b02e740e69167
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b11f1c35d556b0c2d6815e33745b02e740e69167

Author: Joakim Sindholt <opensource at zhasha.com>
Date:   Fri Feb 20 03:53:20 2009 +0100

r300-gallium: correct buffer stride calculation

---

 src/gallium/drivers/r300/r300_surface.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
index e4589cc..e6180a3 100644
--- a/src/gallium/drivers/r300/r300_surface.c
+++ b/src/gallium/drivers/r300/r300_surface.c
@@ -37,12 +37,13 @@ static void r300_surface_fill(struct pipe_context* pipe,
     struct r300_texture* tex = (struct r300_texture*)dest->texture;
     int i;
     float r, g, b, a;
+    unsigned pixpitch = tex->stride / tex->tex.block.size;
     r = (float)((color >> 16) & 0xff) / 255.0f;
     g = (float)((color >>  8) & 0xff) / 255.0f;
     b = (float)((color >>  0) & 0xff) / 255.0f;
     debug_printf("r300: Filling surface %p at (%d,%d),"
-        " dimensions %dx%d (stride %d), color 0x%x\n",
-        dest, x, y, w, h, tex->stride, color);
+        " dimensions %dx%d (pixel pitch %d), color 0x%x\n",
+        dest, x, y, w, h, pixpitch, color);
 
     /* Fallback? */
     /*if (0) {
@@ -291,10 +292,8 @@ static void r300_surface_fill(struct pipe_context* pipe,
 
     OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
     OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
-    /* XXX (dest->stride >> 2) should be the buffer width in pixels however,
-     * this little calculation is only good as long as the buffer is 32bpp */
-    OUT_CS_REG(R300_RB3D_COLORPITCH0, (tex->stride >> 2) |
-        R300_COLOR_FORMAT_ARGB8888);
+    /* XXX Fix color format in case it's not ARGB8888 */
+    OUT_CS_REG(R300_RB3D_COLORPITCH0, pixpitch | R300_COLOR_FORMAT_ARGB8888);
     OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
     /* XXX Packet3 */
     OUT_CS(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8));




More information about the mesa-commit mailing list