freedreno/a4xx: only compute texture offset once for the view
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 22 Nov 2015 17:13:46 +0000 (12:13 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 23 Nov 2015 16:17:15 +0000 (11:17 -0500)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_texture.c
src/gallium/drivers/freedreno/a4xx/fd4_texture.h

index 1df0657357ebed710f3ad3a3fb1ec623f7ee8ac2..0e4a8cad8c7bc39433d9c7c53fc688813a86a73e 100644 (file)
@@ -181,9 +181,7 @@ emit_textures(struct fd_context *ctx, 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 fd4_pipe_sampler_view dummy_view = {
-                               .base.target = PIPE_TEXTURE_1D,
-                       };
+                       static const struct fd4_pipe_sampler_view dummy_view = {};
                        const struct fd4_pipe_sampler_view *view = tex->textures[i] ?
                                        fd4_pipe_sampler_view(tex->textures[i]) :
                                        &dummy_view;
@@ -194,16 +192,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
                        OUT_RING(ring, view->texconst3);
                        if (view->base.texture) {
                                struct fd_resource *rsc = fd_resource(view->base.texture);
-                               unsigned start = fd_sampler_first_level(&view->base);
-                               uint32_t offset;
-                               if (rsc->base.b.target == PIPE_BUFFER) {
-                                       offset = view->base.u.buf.first_element *
-                                               util_format_get_blocksize(view->base.format);
-                               } else {
-                                       offset = fd_resource_offset(
-                                                       rsc, start, view->base.u.tex.first_layer);
-                               }
-                               OUT_RELOC(ring, rsc->bo, offset, view->texconst4, 0);
+                               OUT_RELOC(ring, rsc->bo, view->offset, view->texconst4, 0);
                        } else {
                                OUT_RING(ring, 0x00000000);
                        }
index 5217c8a1dc571535f218984cdb81306cdf21e726..0eba75577b05a5021442f4485d9b68c30cbb99f5 100644 (file)
@@ -243,6 +243,8 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                so->texconst2 =
                        A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(cso->format)) |
                        A4XX_TEX_CONST_2_PITCH(elements * rsc->cpp);
+               so->offset = cso->u.buf.first_element *
+                       util_format_get_blocksize(cso->format);
        } else {
                unsigned miplevels;
 
@@ -259,6 +261,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                        A4XX_TEX_CONST_2_PITCH(
                                        util_format_get_nblocksx(
                                                        cso->format, rsc->slices[lvl].pitch) * rsc->cpp);
+               so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
        }
 
        switch (cso->target) {
index d74d88701a850104f5544569ed1b28525b9cfefc..6ca34ade60db3043148f47bb41c200efcd9c9c08 100644 (file)
@@ -52,6 +52,7 @@ fd4_sampler_stateobj(struct pipe_sampler_state *samp)
 struct fd4_pipe_sampler_view {
        struct pipe_sampler_view base;
        uint32_t texconst0, texconst1, texconst2, texconst3, texconst4;
+       uint32_t offset;
 };
 
 static inline struct fd4_pipe_sampler_view *