[Freedreno] [PATCH] freedreno/a4xx: add cube map array support

Ilia Mirkin imirkin at alum.mit.edu
Sun Aug 2 23:20:35 PDT 2015


On Mon, Aug 3, 2015 at 2:13 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> Untested, haven't gotten linux/freedreno running on my ifc6540
> yet. Should be easy to test out though.
>
>  src/gallium/drivers/freedreno/a4xx/fd4_texture.c     | 4 ++--
>  src/gallium/drivers/freedreno/freedreno_resource.c   | 1 -
>  src/gallium/drivers/freedreno/freedreno_screen.c     | 4 +++-
>  src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 5 +++++
>  4 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
> index 6ba25d0..0f9756d 100644
> --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
> +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
> @@ -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:
> diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
> index d649925..cbaef63 100644
> --- a/src/gallium/drivers/freedreno/freedreno_resource.c
> +++ b/src/gallium/drivers/freedreno/freedreno_resource.c
> @@ -450,7 +450,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:
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
> index 97e4161..0617162 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -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_TEXTURE_BUFFER_OBJECTS:
>         case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
>         case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
> @@ -183,6 +182,9 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>         case PIPE_CAP_DEPTH_CLIP_DISABLE:
>                 return is_a3xx(screen);
>
> +       case PIPE_CAP_CUBE_MAP_ARRAY:
> +               return is_a4xx(screen);
> +
>         case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
>                 return 256;
>
> diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
> index 53faf16..52dd12a 100644
> --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
> +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
> @@ -1635,6 +1635,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)

Actually I guess this last bit isn't strictly necessary -- there is no
texelFetch() variant for cube arrays... could easily drop it.

> +               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
> --
> 2.4.6
>


More information about the Freedreno mailing list