freedreno/a4xx: add ARB_texture_view support
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 22 Nov 2015 02:24:48 +0000 (21:24 -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/freedreno_screen.c

index e488450498e160d581f33fb4e8822ec8f8b3456f..1df0657357ebed710f3ad3a3fb1ec623f7ee8ac2 100644 (file)
@@ -200,7 +200,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
                                        offset = view->base.u.buf.first_element *
                                                util_format_get_blocksize(view->base.format);
                                } else {
-                                       offset = fd_resource_offset(rsc, start, 0);
+                                       offset = fd_resource_offset(
+                                                       rsc, start, view->base.u.tex.first_layer);
                                }
                                OUT_RELOC(ring, rsc->bo, offset, view->texconst4, 0);
                        } else {
index a37c64473bdbfa7470b3df7ea5b4b6fc05d75f43..5217c8a1dc571535f218984cdb81306cdf21e726 100644 (file)
@@ -212,7 +212,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 {
        struct fd4_pipe_sampler_view *so = CALLOC_STRUCT(fd4_pipe_sampler_view);
        struct fd_resource *rsc = fd_resource(prsc);
-       unsigned lvl;
+       unsigned lvl, layers;
        uint32_t sz2 = 0;
 
        if (!so)
@@ -225,7 +225,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
        so->base.context = pctx;
 
        so->texconst0 =
-               A4XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
+               A4XX_TEX_CONST_0_TYPE(tex_type(cso->target)) |
                A4XX_TEX_CONST_0_FMT(fd4_pipe2tex(cso->format)) |
                fd4_tex_swiz(cso->format, cso->swizzle_r, cso->swizzle_g,
                                cso->swizzle_b, cso->swizzle_a);
@@ -233,7 +233,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
        if (util_format_is_srgb(cso->format))
                so->texconst0 |= A4XX_TEX_CONST_0_SRGB;
 
-       if (prsc->target == PIPE_BUFFER) {
+       if (cso->target == PIPE_BUFFER) {
                unsigned elements = cso->u.buf.last_element -
                        cso->u.buf.first_element + 1;
                lvl = 0;
@@ -248,6 +248,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
                lvl = fd_sampler_first_level(cso);
                miplevels = fd_sampler_last_level(cso) - lvl;
+               layers = cso->u.tex.last_layer - cso->u.tex.first_layer + 1;
 
                so->texconst0 |= A4XX_TEX_CONST_0_MIPLVLS(miplevels);
                so->texconst1 =
@@ -260,17 +261,17 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                                                        cso->format, rsc->slices[lvl].pitch) * rsc->cpp);
        }
 
-       switch (prsc->target) {
+       switch (cso->target) {
        case PIPE_TEXTURE_1D_ARRAY:
        case PIPE_TEXTURE_2D_ARRAY:
                so->texconst3 =
-                       A4XX_TEX_CONST_3_DEPTH(prsc->array_size) |
+                       A4XX_TEX_CONST_3_DEPTH(layers) |
                        A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
                break;
        case PIPE_TEXTURE_CUBE:
        case PIPE_TEXTURE_CUBE_ARRAY:
                so->texconst3 =
-                       A4XX_TEX_CONST_3_DEPTH(prsc->array_size / 6) |
+                       A4XX_TEX_CONST_3_DEPTH(layers / 6) |
                        A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
                break;
        case PIPE_TEXTURE_3D:
index 9e51c4e3c4b09ac64bf9c374704bac6cc72b123f..da7dbc91eb007b983f0862f046ba24ff00d456a9 100644 (file)
@@ -197,6 +197,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
        case PIPE_CAP_CUBE_MAP_ARRAY:
        case PIPE_CAP_START_INSTANCE:
+       case PIPE_CAP_SAMPLER_VIEW_TARGET:
                return is_a4xx(screen);
 
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
@@ -226,7 +227,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
        case PIPE_CAP_DRAW_INDIRECT:
        case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
-       case PIPE_CAP_SAMPLER_VIEW_TARGET:
        case PIPE_CAP_POLYGON_OFFSET_CLAMP:
        case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: