freedreno/a4xx: add cube map array support
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 3 Aug 2015 06:13:33 +0000 (02:13 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 15 Aug 2015 18:05:37 +0000 (14:05 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a4xx/fd4_texture.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c

index d2bc5fe..213b29c 100644 (file)
@@ -187,9 +187,9 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                        A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
                break;
        case PIPE_TEXTURE_CUBE:
-       case PIPE_TEXTURE_CUBE_ARRAY:  /* ?? not sure about _CUBE_ARRAY */
+       case PIPE_TEXTURE_CUBE_ARRAY:
                so->texconst3 =
-                       A4XX_TEX_CONST_3_DEPTH(1) |
+                       A4XX_TEX_CONST_3_DEPTH(prsc->array_size / 6) |
                        A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
                break;
        case PIPE_TEXTURE_3D:
index 709ad4e..800aaa8 100644 (file)
@@ -459,7 +459,6 @@ fd_resource_create(struct pipe_screen *pscreen,
        if (is_a4xx(fd_screen(pscreen))) {
                switch (tmpl->target) {
                case PIPE_TEXTURE_3D:
-                       /* TODO 3D_ARRAY? */
                        rsc->layer_first = false;
                        break;
                default:
index 0a20605..ef1a2e7 100644 (file)
@@ -163,7 +163,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_MULTISAMPLE:
        case PIPE_CAP_TEXTURE_BARRIER:
        case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
-       case PIPE_CAP_CUBE_MAP_ARRAY:
        case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
        case PIPE_CAP_START_INSTANCE:
        case PIPE_CAP_COMPUTE:
@@ -195,6 +194,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return is_a3xx(screen);
 
        case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
+       case PIPE_CAP_CUBE_MAP_ARRAY:
                return is_a4xx(screen);
 
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
index 0ab3345..13c395f 100644 (file)
@@ -1636,6 +1636,11 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex)
                        coord[i] = ir3_SHL_B(b, coord[i], 0, lod, 0);
        }
 
+       /* the array coord for cube arrays needs 0.5 added to it */
+       if (tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE && tex->is_array &&
+               opc != OPC_ISAML)
+               coord[3] = ir3_ADD_F(b, coord[3], 0, create_immed(b, fui(0.5)), 0);
+
        /*
         * lay out the first argument in the proper order:
         *  - actual coordinates first
@@ -1759,6 +1764,12 @@ emit_tex_txs(struct ir3_compile *ctx, nir_tex_instr *tex)
 
        tex_info(tex, &flags, &coords);
 
+       /* Actually we want the number of dimensions, not coordinates. This
+        * distinction only matters for cubes.
+        */
+       if (tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
+               coords = 2;
+
        dst = get_dst(ctx, &tex->dest, 4);
 
        compile_assert(ctx, tex->num_srcs == 1);