freedreno/a3xx: handle first/last level properly
authorRob Clark <robclark@freedesktop.org>
Sat, 23 Aug 2014 15:35:31 +0000 (11:35 -0400)
committerRob Clark <robclark@freedesktop.org>
Sun, 24 Aug 2014 17:09:23 +0000 (13:09 -0400)
Fixes some assumptions about first_level being zero.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a3xx/fd3_texture.c
src/gallium/drivers/freedreno/a3xx/fd3_texture.h

index 44932dc241dc9f04775acc9d88f3a5e34601ac93..aae8ff13d19f65bf8f9578d087b0f66aa0e37787 100644 (file)
@@ -215,14 +215,19 @@ emit_textures(struct fd_ringbuffer *ring,
                OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
                                CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
                for (i = 0; i < tex->num_textures; i++) {
-                       static const struct fd3_pipe_sampler_view dummy_view = {};
+                       static const struct fd3_pipe_sampler_view dummy_view = {
+                                       .base.u.tex.first_level = 1,
+                       };
                        const struct fd3_pipe_sampler_view *view = tex->textures[i] ?
                                        fd3_pipe_sampler_view(tex->textures[i]) :
                                        &dummy_view;
                        struct fd_resource *rsc = view->tex_resource;
+                       unsigned start = view->base.u.tex.first_level;
+                       unsigned end   = view->base.u.tex.last_level;
 
-                       for (j = 0; j < view->mipaddrs; j++) {
-                               struct fd_resource_slice *slice = fd_resource_slice(rsc, j);
+                       for (j = 0; j < (end - start + 1); j++) {
+                               struct fd_resource_slice *slice =
+                                               fd_resource_slice(rsc, j + start);
                                OUT_RELOC(ring, rsc->bo, slice->offset, 0, 0);
                        }
 
index f28919f474e38a4145f0a3a08d148821587aa758..b0e5efb10a456d81dc4bee951f14e183a8592334 100644 (file)
@@ -144,7 +144,8 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 {
        struct fd3_pipe_sampler_view *so = CALLOC_STRUCT(fd3_pipe_sampler_view);
        struct fd_resource *rsc = fd_resource(prsc);
-       unsigned miplevels = cso->u.tex.last_level - cso->u.tex.first_level;
+       unsigned lvl = cso->u.tex.first_level;
+       unsigned miplevels = cso->u.tex.last_level - lvl;
 
        if (!so)
                return NULL;
@@ -156,7 +157,6 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
        so->base.context = pctx;
 
        so->tex_resource =  rsc;
-       so->mipaddrs = 1 + miplevels;
 
        so->texconst0 =
                        A3XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
@@ -170,11 +170,11 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
        so->texconst1 =
                        A3XX_TEX_CONST_1_FETCHSIZE(fd3_pipe2fetchsize(cso->format)) |
-                       A3XX_TEX_CONST_1_WIDTH(prsc->width0) |
-                       A3XX_TEX_CONST_1_HEIGHT(prsc->height0);
+                       A3XX_TEX_CONST_1_WIDTH(u_minify(prsc->width0, lvl)) |
+                       A3XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl));
        /* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */
        so->texconst2 =
-                       A3XX_TEX_CONST_2_PITCH(rsc->slices[0].pitch * rsc->cpp);
+                       A3XX_TEX_CONST_2_PITCH(rsc->slices[lvl].pitch * rsc->cpp);
        so->texconst3 = 0x00000000;  /* ??? */
 
        return &so->base;
index f7e5f0e650fab6bd6041a4d0f5ced9abfe3f9091..a83f527366b1dca0bfc4b770b47da684d38a3dac 100644 (file)
@@ -51,7 +51,6 @@ fd3_sampler_stateobj(struct pipe_sampler_state *samp)
 struct fd3_pipe_sampler_view {
        struct pipe_sampler_view base;
        struct fd_resource *tex_resource;
-       uint32_t mipaddrs;
        uint32_t texconst0, texconst1, texconst2, texconst3;
 };