freedreno/a3xx: more layer/level fixes
authorRob Clark <robclark@freedesktop.org>
Wed, 15 Oct 2014 21:15:06 +0000 (17:15 -0400)
committerRob Clark <robclark@freedesktop.org>
Tue, 21 Oct 2014 01:42:44 +0000 (21:42 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
src/gallium/drivers/freedreno/freedreno_resource.c

index 050530e2267d3b0a83f07790e65a1b05f520d148..0439dc7b1d19631970293f250602b5299fb2fc48 100644 (file)
@@ -282,8 +282,13 @@ void
 fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct pipe_surface *psurf)
 {
        struct fd_resource *rsc = fd_resource(psurf->texture);
+       unsigned lvl = psurf->u.tex.level;
+       struct fd_resource_slice *slice = &rsc->slices[lvl];
+       uint32_t layer_offset = slice->size0 * psurf->u.tex.first_layer;
        enum pipe_format format = fd3_gmem_restore_format(psurf->format);
 
+       debug_assert(psurf->u.tex.first_layer == psurf->u.tex.last_layer);
+
        /* output sampler state: */
        OUT_PKT3(ring, CP_LOAD_STATE, 4);
        OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(FRAG_TEX_OFF) |
@@ -314,7 +319,7 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct pipe_surface *psurf
        OUT_RING(ring, A3XX_TEX_CONST_1_FETCHSIZE(TFETCH_DISABLE) |
                        A3XX_TEX_CONST_1_WIDTH(psurf->width) |
                        A3XX_TEX_CONST_1_HEIGHT(psurf->height));
-       OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(rsc->slices[0].pitch * rsc->cpp) |
+       OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(slice->pitch * rsc->cpp) |
                        A3XX_TEX_CONST_2_INDX(0));
        OUT_RING(ring, 0x00000000);
 
@@ -326,7 +331,7 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct pipe_surface *psurf
                        CP_LOAD_STATE_0_NUM_UNIT(1));
        OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
                        CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
-       OUT_RELOC(ring, rsc->bo, 0, 0, 0);
+       OUT_RELOC(ring, rsc->bo, layer_offset, 0, 0);
 }
 
 void
index 219c9e06a2da9c66f126fb7f302bfa2ab451bad2..2eefa9119dc2dcd3a15838e006fca93d397c97cc 100644 (file)
@@ -609,8 +609,11 @@ fd3_emit_sysmem_prep(struct fd_context *ctx)
        struct fd_ringbuffer *ring = ctx->ring;
        uint32_t pitch = 0;
 
-       if (pfb->cbufs[0])
-               pitch = fd_resource(pfb->cbufs[0]->texture)->slices[0].pitch;
+       if (pfb->cbufs[0]) {
+               struct pipe_surface *psurf = pfb->cbufs[0];
+               unsigned lvl = psurf->u.tex.level;
+               pitch = fd_resource(psurf->texture)->slices[lvl].pitch;
+       }
 
        fd3_emit_restore(ctx);
 
index b6b39f00db068b6edc4736ad6683e956bf84459d..49ae51715071934ec81478174dbbbe6749a1c173 100644 (file)
@@ -199,9 +199,8 @@ setup_slices(struct fd_resource *rsc)
 
        for (level = 0; level <= prsc->last_level; level++) {
                struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
-               uint32_t aligned_width = align(width, 32);
 
-               slice->pitch = aligned_width;
+               slice->pitch = align(width, 32);
                slice->offset = size;
                slice->size0 = slice->pitch * height * rsc->cpp;
 
@@ -229,9 +228,8 @@ setup_slices_array(struct fd_resource *rsc)
 
        for (level = 0; level <= prsc->last_level; level++) {
                struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
-               uint32_t aligned_width = align(width, 32);
 
-               slice->pitch = aligned_width;
+               slice->pitch = align(width, 32);
                slice->offset = size;
                slice->size0 = align(slice->pitch * height * rsc->cpp, 4096);