r600g: fixup pitch alignment like r600c.
authorDave Airlie <airlied@redhat.com>
Wed, 18 Aug 2010 01:49:51 +0000 (11:49 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 18 Aug 2010 02:49:59 +0000 (12:49 +1000)
This still needs work, passes tex3d, fbo-scissor-bitmap, scissor-bitmap

src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c

index 0059952cef4e606aa01c9cae379fda74b5d6c2c1..260688a9a8a9875e10ce93a1cedeb8df803c270a 100644 (file)
@@ -1217,7 +1217,7 @@ static struct radeon_state *r600_resource(struct r600_context *rctx,
        struct r600_resource *rbuffer;
        struct radeon_state *rstate;
        unsigned format;
-       uint32_t word4 = 0, yuv_format = 0;
+       uint32_t word4 = 0, yuv_format = 0, pitch = 0;
        unsigned char swizzle[4];
 
        swizzle[0] = view->swizzle_r;
@@ -1248,16 +1248,19 @@ static struct radeon_state *r600_resource(struct r600_context *rctx,
        rstate->placement[2] = RADEON_GEM_DOMAIN_GTT;
        rstate->placement[3] = RADEON_GEM_DOMAIN_GTT;
 
+       pitch = (tmp->pitch[0] / tmp->bpt);
+       pitch = (pitch + 0x7) & ~0x7;
+       
        /* FIXME properly handle first level != 0 */
        rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD0] =
                        S_038000_DIM(r600_tex_dim(view->texture->target)) |
-                       S_038000_PITCH(((tmp->pitch[0] / tmp->bpt) / 8) - 1) |
+                       S_038000_PITCH((pitch / 8) - 1) |
                        S_038000_TEX_WIDTH(view->texture->width0 - 1);
        rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD1] =
                        S_038004_TEX_HEIGHT(view->texture->height0 - 1) |
                        S_038004_TEX_DEPTH(view->texture->depth0 - 1) |
                        S_038004_DATA_FORMAT(format);
-       rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD2] = 0;
+       rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD2] = tmp->offset[0] >> 8;
        rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD3] = tmp->offset[1] >> 8;
        rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD4] =
                        word4 | 
index 55cceb6935beec6890f54d9b7e8258ac35f3591a..eabd7f77051230b6be3725d7126242da37ea2c21 100644 (file)
@@ -67,6 +67,7 @@ static void r600_setup_miptree(struct r600_screen *rscreen, struct r600_resource
                h = u_minify(ptex->height0, i);
                h = util_next_power_of_two(h);
                pitch = util_format_get_stride(ptex->format, align(w, 64));
+               pitch = align(pitch, 256);
                layer_size = pitch * h;
                if (ptex->target == PIPE_TEXTURE_CUBE)
                        size = layer_size * 6;