Re: [Mesa-dev] [PATCH libdrm] etnaviv: drop etna_bo_from_handle symbol

2019-05-29 Thread Philipp Zabel
On Wed, 2019-05-29 at 12:08 +0200, Lucas Stach wrote:
> There is no implementation and also no users, so there is no point
> in keeping it in the API.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

This makes https://patchwork.kernel.org/patch/9912089/ obsolete.

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH] etnaviv: fill missing offset in etna_resource_get_handle

2019-05-03 Thread Philipp Zabel
Without this gbm_bo_get_offset() can return 0 where it shouldn't.
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 83179d3cd088..ab77a80c72b3 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -622,6 +622,7 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
   rsc = etna_resource(rsc->external);
 
handle->stride = rsc->levels[0].stride;
+   handle->offset = rsc->levels[0].offset;
handle->modifier = layout_to_modifier(rsc->layout);
 
if (handle->type == WINSYS_HANDLE_TYPE_SHARED) {
-- 
2.20.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 8/8] etnaviv: handle YUV textures with the 2D GPU

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> This allows color space conversion and tiling in a single step, as
> well as handling multi-planar formats like NV12, which are really
> useful when dealing with hardware video decoders.
> 
> Signed-off-by: Lucas Stach 
> ---
>  .../drivers/etnaviv/etnaviv_clear_blit.c  |  2 +-
>  src/gallium/drivers/etnaviv/etnaviv_format.c  |  5 +++-
>  .../drivers/etnaviv/etnaviv_resource.c| 16 
>  src/gallium/drivers/etnaviv/etnaviv_rs.c  |  5 
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  |  5 +++-
>  src/gallium/drivers/etnaviv/etnaviv_texture.c | 25 ---
>  6 files changed, 46 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index 45c30cbf5076..5214162d8798 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -159,7 +159,7 @@ etna_copy_resource(struct pipe_context *pctx, struct 
> pipe_resource *dst,
> struct etna_resource *src_priv = etna_resource(src);
> struct etna_resource *dst_priv = etna_resource(dst);
>  
> -   assert(src->format == dst->format);
> +   assert(src->format == dst->format || util_format_is_yuv(src->format));
> assert(src->array_size == dst->array_size);
> assert(last_level <= dst->last_level && last_level <= src->last_level);
>  
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
> b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index 29e81c4a8b04..0879ddd6a6c8 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -282,8 +282,11 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> _T(ASTC_12x12_SRGB, ASTC_SRGB8_ALPHA8_12x12 | ASTC_FORMAT,  
> SWIZ(X, Y, Z, W), NONE, NONE),
>  
> /* YUV */
> -   _T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2, NONE),
> +   _T(YUYV, X8B8G8R8, SWIZ(X, Y, Z, W), NONE, NONE),
> _T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE, NONE),
> +
> +   /* multi-planar YUV */
> +   _T(NV12, X8B8G8R8, SWIZ(X, Y, Z, W), NONE, NONE),
>  };
>  
>  uint32_t
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 650c8e7eb7f5..5ba3eba5bd33 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -560,6 +560,17 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>
> level->padded_height);
> level->size = level->layer_stride;
>  
> +   rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer,
> +   _mesa_key_pointer_equal);
> +   if (!rsc->pending_ctx)
> +  goto fail;
> +
> +   /* YUV resources are handled by the 2D GPU, so the below constraint checks
> +* are invalid.
> +*/
> +   if (util_format_is_yuv(tmpl->format))
> +  return prsc;
> +
> /* The DDX must give us a BO which conforms to our padding size.
>  * The stride of the BO must be greater or equal to our padded
>  * stride. The size of the BO must accomodate the padded height. */
> @@ -576,11 +587,6 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>goto fail;
> }
>  
> -   rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer,
> -   _mesa_key_pointer_equal);
> -   if (!rsc->pending_ctx)
> -  goto fail;
> -
> if (rsc->layout == ETNA_LAYOUT_LINEAR) {
>/*
> * Both sampler and pixel pipes can't handle linear, create a 
> compatible
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> index fcc2342aedc3..22d07d8f9726 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> @@ -26,6 +26,7 @@
>  
>  #include "etnaviv_rs.h"
>  
> +#include "etnaviv_2d.h"
>  #include "etnaviv_clear_blit.h"
>  #include "etnaviv_context.h"
>  #include "etnaviv_emit.h"
> @@ -775,6 +776,10 @@ etna_blit_rs(struct pipe_context *pctx, const struct 
> pipe_blit_info *blit_info)
>return;
> }
>  
> +   if (util_format_is_yuv(blit_info->src.format) &&
> +   etna_try_2d_blit(pctx, blit_info))
> +  return;
> +
> if (etna_try_rs_blit(pctx, blit_info))
>return;
>  
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 0dea6056c75a..b0630e27b507 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -535,6 +535,9 @@ gpu_supports_texure_format(struct etna_screen *screen, 
> uint32_t fmt,
>supported = screen->specs.tex_astc;
> }
>  
> +   if (util_format_is_yuv(format))
> +  supported = !!screen->gpu2d;

Isn't screen->gpu2d == NULL for devices with combined 2D/3D 

Re: [Mesa-dev] [PATCH 4/6] st/dri: handle emulated YUV texture sampling in query_dma_buf_modifiers

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:33 +0200, Lucas Stach wrote:
> The Mesa state tracker will emulate YUV texture sampling for drivers that
> don't support it natively by using multiple R8/RG88 samplers. Teach
> dri2_query_dma_buf_modifiers about this special case.
> This allows clients like GStreamer glupload or Kodi to properly query
> the supported dma-buf import formats, without the need to take a special
> code path for the emulated OES_external texture handling.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/state_trackers/dri/dri2.c | 17 ++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/dri/dri2.c 
> b/src/gallium/state_trackers/dri/dri2.c
> index f139bd6722b9..4243a00cb38d 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -1358,19 +1358,30 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, 
> int fourcc, int max,
> const struct dri2_format_mapping *map = 
> dri2_get_mapping_by_fourcc(fourcc);
> enum pipe_format format;
>  
> -   if (!map)
> +   if (!map || !pscreen->query_dmabuf_modifiers)
>return false;
>  
> format = map->pipe_format;
>  
> -   if (pscreen->query_dmabuf_modifiers != NULL &&
> -   (pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
> +   if ((pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
>   PIPE_BIND_RENDER_TARGET) ||
>  pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
>   PIPE_BIND_SAMPLER_VIEW))) {
>pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers,
>external_only, count);
>return true;
> +   } else if (util_format_is_yuv(format) &&
> +  pscreen->is_format_supported(pscreen, PIPE_FORMAT_R8_UNORM,
> +   screen->target, 0, 0,
> +   PIPE_BIND_SAMPLER_VIEW)) {
> +  /* YUV format sampling can be emulated by the Mesa state tracker by
> +   * using multiple R8/RG88 samplers if the driver doesn't support those
> +   * formats natively, so we need a special case here to give a mostly
> +   * accurate answer to the modifiers query.
> +   */

"Mostly accurate" meaning that for IYUV this is correct, but for NV12 we
are assuming that the drivers will return the same modifiers for
PIPE_FORMAT_R8_UNORM as for PIPE_FORMAT_RG88_UNORM. As far as I can
tell, this is currently the case for all drivers that implement
query_dmabuf_modifiers.

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 6/6] st/mesa: skip any extra handling of YUV textures if driver supports them

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:33 +0200, Lucas Stach wrote:
> If the driver provides native support for YUV textures we can skip
> adding additional samplers and re-writing the shaders.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 5/6] st/dri: don't re-write plane format if supported by driver

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:33 +0200, Lucas Stach wrote:
> If the driver supports multi-planar formats natively we don't want to
> re-write the format of the planes on import. Split this out in a
> separate function for clarity.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 7/8] etnaviv: improve PIPE_BIND_LINEAR handling

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> We weren't handling this flag at all, which broke some assumptions
> made by the users of the resource_create interface. As we can't render
> to a linear surface and the usefulness of yet another layout transition
> to handle this case seems limited, we only respect the flag when the
> resource isn't used for rendering.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index f405b880a6c0..650c8e7eb7f5 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -369,6 +369,14 @@ etna_resource_create(struct pipe_screen *pscreen,
> if (templat->target == PIPE_TEXTURE_3D)
>layout = ETNA_LAYOUT_LINEAR;
>  
> +   /* The render pipe can't handle linear and there is no code to do yet 
> another
> +* layout transformation for this case, so we only respect the linear flag
> +* if the resource isn't meant to be rendered.
> +*/
> +   if ((templat->bind & PIPE_BIND_LINEAR) &&
> +   !(templat->bind & PIPE_BIND_RENDER_TARGET))
> +  layout = ETNA_LAYOUT_LINEAR;
> +
> /* modifier is only used for scanout surfaces, so safe to use LINEAR here 
> */
>     return etna_resource_alloc(pscreen, layout, mode, DRM_FORMAT_MOD_LINEAR, 
> templat);
>  }

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 6/8] etnaviv: use filter blit for 2D YUV import on old GC320

2019-04-15 Thread Philipp Zabel
gt; +  etna_set_state(stream, 1, 0);
> +  etna_set_state(stream, 1, 0);
> +  etna_set_state(stream, 1, 0);
> +   } else {
> +  etna_set_state_multi(stream, VIVS_DE_FILTER_KERNEL(0), KERNEL_STATE_SZ,
> +   filter_kernel);
> +
> +  etna_set_state(stream, VIVS_DE_VR_CONFIG,
> + VIVS_DE_VR_CONFIG_START_HORIZONTAL_BLIT);
> +   }
>  
> etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D);
>  
> @@ -160,5 +278,49 @@ bool etna_try_2d_blit(struct pipe_context *pctx,
>  */
> etna_cmd_stream_flush(ctx->stream2d);
>  
> +   if (temp_bo) {
> +  struct etna_resource *dst = etna_resource(res_dst);
> +  struct compiled_rs_state tile_blit;
> +
> +  etna_compile_rs_state(ctx, _blit, &(struct rs_state) {
> +.source_format = RS_FORMAT_X8R8G8B8,
> +.source_tiling = ETNA_LAYOUT_LINEAR,
> +.source = temp_bo,
> +.source_offset = 0,
> +.source_stride = dst->levels[0].stride,
> +.source_padded_width = dst->levels[0].padded_width,
> +.source_padded_height = dst->levels[0].padded_height,
> +.source_ts_valid = 0,
> +.dest_format = RS_FORMAT_X8R8G8B8,
> +.dest_tiling = ETNA_LAYOUT_TILED,
> +.dest = dst->bo,
> +.dest_offset = 0,
> +.dest_stride = dst->levels[0].stride,
> +.dest_padded_height = dst->levels[0].padded_height,
> +.downsample_x = 0,
> +.downsample_y = 0,
> +    .swap_rb = 0,
> +.dither = {0x, 0x},
> +.clear_mode = VIVS_RS_CLEAR_CONTROL_MODE_DISABLED,
> +.width = blit_info->dst.box.width,
> +.height = blit_info->dst.box.height,
> + });
> +
> +  /* The combined color/depth cache flush is required to avoid pixels 
> stuck
> +   * in the caches being flushed to the RS target. This seems to be some 
> bug
> +   * found on at least GC2000, with no other known workaround.
> +   */
> +  etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE,
> + VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH);
> +  etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_PE);
> +  etna_set_state(ctx->stream, VIVS_TS_MEM_CONFIG, 0);
> +  ctx->dirty |= ETNA_DIRTY_TS;
> +  etna_submit_rs_state(ctx, _blit);
> +
> +  /* flush now, so we can get rid of the temp BO right here */
> +  etna_cmd_stream_flush(ctx->stream);
> +  etna_bo_del(temp_bo);
> +   }
> +
> return TRUE;
>  }

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 4/8] etnaviv: add 2D GPU YUV->RGB blitter

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> This adds a blit path using the 2D GPU for a linear YUV to tiled RGB
> blit. This allows to implement importing of planar YUV textures with
> a single copy.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/Makefile.sources  |2 +
>  src/gallium/drivers/etnaviv/etnaviv_2d.c  |  164 ++
>  src/gallium/drivers/etnaviv/etnaviv_2d.h  |   37 +
>  src/gallium/drivers/etnaviv/hw/state_2d.xml.h | 1499 +
>  src/gallium/drivers/etnaviv/meson.build   |3 +
>  5 files changed, 1705 insertions(+)
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_2d.c
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_2d.h
>  create mode 100644 src/gallium/drivers/etnaviv/hw/state_2d.xml.h
> 
> diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
> b/src/gallium/drivers/etnaviv/Makefile.sources
> index 01e7e49a38ad..36dd7d1b6aa4 100644
> --- a/src/gallium/drivers/etnaviv/Makefile.sources
> +++ b/src/gallium/drivers/etnaviv/Makefile.sources
> @@ -3,11 +3,13 @@ C_SOURCES :=  \
>   hw/common.xml.h \
>   hw/common_3d.xml.h \
>   hw/isa.xml.h \
> + hw/state_2d.xml.h \
>   hw/state_3d.xml.h \
>   hw/state_blt.xml.h \
>   hw/state.xml.h \
>   hw/texdesc_3d.xml.h \
>   \
> + etnaviv_2d.c \
>   etnaviv_asm.c \
>   etnaviv_asm.h \
>   etnaviv_blend.c \
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_2d.c 
> b/src/gallium/drivers/etnaviv/etnaviv_2d.c
> new file mode 100644
> index ..457fa4e0cbd0
> --- /dev/null
> +++ b/src/gallium/drivers/etnaviv/etnaviv_2d.c
> @@ -0,0 +1,164 @@
> +/*
> + * Copyright (c) 2018 Etnaviv Project
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sub license,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> + * next paragraph) shall be included in all copies or substantial portions
> + * of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "etnaviv_2d.h"
> +#include "etnaviv_context.h"
> +#include "etnaviv_emit.h"
> +#include "etnaviv_screen.h"
> +
> +#include "pipe/p_state.h"
> +#include "util/u_format.h"
> +
> +#include "hw/state_2d.xml.h"
> +
> +#include 
> +
> +#define EMIT_STATE(state_name, src_value) \
> +   etna_coalsence_emit(stream, , VIVS_##state_name, src_value)
> +
> +#define EMIT_STATE_RELOC(state_name, src_value) \
> +   etna_coalsence_emit_reloc(stream, , VIVS_##state_name, src_value)
> +
> +bool etna_try_2d_blit(struct pipe_context *pctx,
> +  const struct pipe_blit_info *blit_info)
> +{
> +   struct etna_context *ctx = etna_context(pctx);
> +   struct etna_cmd_stream *stream = ctx->stream2d;
> +   struct etna_coalesce coalesce;
> +   struct etna_reloc ry, ru, rv, rdst;
> +   struct pipe_resource *res_y, *res_u, *res_v, *res_dst;
> +   uint32_t src_format;
> +
> +   assert(util_format_is_yuv(blit_info->src.format));
> +   assert(blit_info->dst.format == PIPE_FORMAT_R8G8B8A8_UNORM);
> +
> +   if (!stream)
> +  return FALSE;
> +
> +   switch (blit_info->src.format) {
> +   case PIPE_FORMAT_NV12:
> +  src_format = DE_FORMAT_NV12;
> +  break;
> +   case PIPE_FORMAT_YUYV:
> +  src_format = DE_FORMAT_YUY2;
> +  break;
> +   default:
> +  return FALSE;
> +   }
> +
> +   res_y = blit_info->src.resource;
> +   res_u = res_y->next ? res_y->next : res_y;
> +   res_v = res_u->next ? res_u->next : res_u;
> +
> +   ry.bo = etna_resource(res_y)->bo;
> +   ry.offset = etna_resource(res_y)->levels[blit_info->src.level].offset;
> +   ru.bo = etna_resource(res_u)->bo;
> +   ru.offset = etna_resource(res_u)->levels[blit_info->src.level].offset;
> +   rv.bo = etna_resource(res_v)->bo;
> +   rv.offset = etna_resource(res_v)->levels[blit_info->src.level].offset;
> +
> +   ry.flags = ru.flags = rv.flags = ETNA_RELOC_READ;
> +
> +   res_dst = blit_info->dst.resource;
> +   rdst.bo = etna_resource(res_dst)->bo;
> +   rdst.flags = ETNA_RELOC_WRITE;
> +   rdst.offset = 0;
> +
> +   etna_coalesce_start(stream, );
> +
> +   EMIT_STATE_RELOC(DE_SRC_ADDRESS, );
> +   

Re: [Mesa-dev] [PATCH 5/8] etnaviv: export etna_submit_rs_state

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> The new 2D YUV blit needs this in some cases, so make it available.

That is a bit unspecific.

Maybe
s/in some cases/to implement a workaround for a cache flushing bug on (at 
least) GC2000/
?

> Signed-off-by: Lucas Stach 

Either way,

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 2/8] etnaviv: clear out next pointer when allocating resource

2019-04-15 Thread Philipp Zabel
On Mon, 2019-04-15 at 12:31 +0200, Lucas Stach wrote:
> Am Montag, den 15.04.2019, 12:20 +0200 schrieb Philipp Zabel:
> > On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> > > We copy the template resource content into the newly allocated resource.
> > > If the template derived from a planar resource this leads to a non 
> > > reference
> > > counted copy of the next resource pointer. Make sure to clear this out 
> > > when
> > > allocating a new resource.
> > > 
> > > Signed-off-by: Lucas Stach 
> > > ---
> > >  src/gallium/drivers/etnaviv/etnaviv_resource.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> > > b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > > index 83179d3cd088..77d027ac806b 100644
> > > --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > > +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > > @@ -274,6 +274,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> > > unsigned layout,
> > 
> > Context:
> > 
> >    rsc = CALLOC_STRUCT(etna_resource);
> >    if (!rsc)
> > >    return NULL;
> > >  
> > > rsc->base = *templat;
> 
> This copies the content of templat into our resource base, so if
> templat has the next pointer set it will also be set in our resource.

Oh, and the patch description, which I should have read more closely,
even correctly points it out.

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 4/8] etnaviv: add 2D GPU YUV->RGB blitter

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> This adds a blit path using the 2D GPU for a linear YUV to tiled RGB
> blit. This allows to implement importing of planar YUV textures with
> a single copy.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 2/8] etnaviv: clear out next pointer when allocating resource

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> We copy the template resource content into the newly allocated resource.
> If the template derived from a planar resource this leads to a non reference
> counted copy of the next resource pointer. Make sure to clear this out when
> allocating a new resource.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 83179d3cd088..77d027ac806b 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -274,6 +274,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,

Context:

   rsc = CALLOC_STRUCT(etna_resource);
   if (!rsc)
>return NULL;
>  
> rsc->base = *templat;
> +   rsc->base.next = NULL;
> rsc->base.screen = pscreen;
> rsc->base.nr_samples = nr_samples;
> rsc->layout = layout;

The calloc just above already clears the memory to zero.

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 3/8] etnaviv: remember data offset into BO

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> Imported resources might not start at offset 0 into the buffer object.
> Make sure to remember the offset that is provided with the handle on
> import.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 77d027ac806b..f405b880a6c0 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -535,6 +535,7 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>  
> level->width = tmpl->width0;
> level->height = tmpl->height0;
> +   level->offset = handle->offset;
>  
> /* Determine padding of the imported resource. */
> unsigned paddingX = 0, paddingY = 0;

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 1/8] etnaviv: create optional 2d pipe in screen

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:38 +0200, Lucas Stach wrote:
> The 2D pipe is useful to implement fast planar and interleaved YUV buffer
> imports. Not all systems have a 2D capable core, so this is strictly
> optional.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_context.c |  6 ++
>  src/gallium/drivers/etnaviv/etnaviv_context.h |  1 +
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  | 68 +++
>  src/gallium/drivers/etnaviv/etnaviv_screen.h  |  6 ++
>  4 files changed, 81 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index a59338490b62..631f551d0ad4 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -78,6 +78,9 @@ etna_context_destroy(struct pipe_context *pctx)
> if (ctx->stream)
>etna_cmd_stream_del(ctx->stream);
>  
> +   if (ctx->stream2d)
> +  etna_cmd_stream_del(ctx->stream2d);
> +
> slab_destroy_child(>transfer_pool);
>  
> if (ctx->in_fence_fd != -1)
> @@ -434,6 +437,9 @@ etna_context_create(struct pipe_screen *pscreen, void 
> *priv, unsigned flags)
> if (ctx->stream == NULL)
>goto fail;
>  
> +   if (screen->pipe2d)
> +  ctx->stream2d = etna_cmd_stream_new(screen->pipe2d, 0x1000, NULL, 
> NULL);
> +
> /* context ctxate setup */
> ctx->specs = screen->specs;
> ctx->screen = screen;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
> b/src/gallium/drivers/etnaviv/etnaviv_context.h
> index a79d739100d9..2c6e5d6c3db1 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
> @@ -110,6 +110,7 @@ struct etna_context {
> struct etna_specs specs;
> struct etna_screen *screen;
> struct etna_cmd_stream *stream;
> +   struct etna_cmd_stream *stream2d;
>  
> /* which state objects need to be re-emit'd: */
> enum {
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 62b6f1c80fae..0dea6056c75a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -95,6 +95,12 @@ etna_screen_destroy(struct pipe_screen *pscreen)
> if (screen->gpu)
>etna_gpu_del(screen->gpu);
>  
> +   if (screen->pipe2d)
> +  etna_pipe_del(screen->pipe2d);
> +
> +   if (screen->gpu2d)
> +  etna_gpu_del(screen->gpu2d);
> +
> if (screen->ro)
>FREE(screen->ro);
>  
> @@ -891,6 +897,66 @@ etna_screen_bo_from_handle(struct pipe_screen *pscreen,
> return bo;
>  }
>  
> +static void etna_screen_init_2d(struct etna_screen *screen)
> +{
> +   struct etna_gpu *gpu2d = NULL;
> +   uint64_t val;
> +   int ret, i;
> +
> +   /* If the current GPU is a combined 2d/3D core, use it as 2D engine */
   ^ 2D

> +   if (screen->features[0] & chipFeatures_PIPE_2D)
> +  gpu2d = screen->gpu;

If the GPU is a combined 2D/3D core, is screen->gpu2d set anywhere?
I assume it isn't on purpose, so it can be used to check whether
etna_gpu_del(screen->gpu2d) must be called in etna_screen_destroy().

> +
> +   /* otherwise search for a 2D capable core */
> +   if (!gpu2d) {

This could just be

   else {
  /* otherwise search for a 2D capable core */

> +  for (i = 0;; i++) {
> + gpu2d = etna_gpu_new(screen->dev, i);
> + if (!gpu2d)
> +return;
> +
> + ret = etna_gpu_get_param(gpu2d, ETNA_GPU_FEATURES_0, );
> + if (!ret && (val & chipFeatures_PIPE_2D)) {
> +screen->gpu2d = gpu2d;
> +break;
> + }
> +
> + etna_gpu_del(gpu2d);
> +  }
> +   }
> +
> +   if (etna_gpu_get_param(screen->gpu2d, ETNA_GPU_FEATURES_0, ))

If the GPU is a combined 2D/3D core, and screen->gpu2d == NULL at this
point, won't this fail trying to dereference the gpu NULL pointer in
etna_gpu_get_param()? I suppose these should be using the local gpu2d
variable instead of screen->gpu2d.

Further, if the GPU is a combined 2D/3D core, we have already queried
GPU features just before etna_screen_init_2d() was called,
in etna_screen_create(). We could just copy features to features2d.

Nitpick: if the gpu2d is 2D-only, the only way we can arrive here is
from the break in the loop above, just after val was already set to the
ETNA_GPU_FEATURES_0 value. In that case the first call to
etna_gpu_get_parm() is superfluous.

> +  return;
> +   screen->features2d[0] = val;
> +
> +   if (etna_gpu_get_param(screen->gpu2d, ETNA_GPU_FEATURES_1, ))
> +  return;
> +   screen->features2d[1] = val;
> +
> +   if (etna_gpu_get_param(screen->gpu2d, ETNA_GPU_FEATURES_2, ))
> +  return;
> +   screen->features2d[2] = val;
> +
> +   if (etna_gpu_get_param(screen->gpu2d, ETNA_GPU_FEATURES_3, ))
> +  return;
> +   screen->features2d[3] = val;
> +
> +   if (etna_gpu_get_param(screen->gpu2d, 

Re: [Mesa-dev] [PATCH 1/6] st/dri: allow to create image for formats that only support SV or RT binding

2019-04-15 Thread Philipp Zabel
On Fri, 2019-04-12 at 19:33 +0200, Lucas Stach wrote:
> Unconditionally requesting both bindings can lead to premature
> failure to create a valid image.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/state_trackers/dri/dri2.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/dri/dri2.c 
> b/src/gallium/state_trackers/dri/dri2.c
> index efb43c0d7973..510b7f8d04a7 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -987,14 +987,23 @@ dri2_create_image_common(__DRIscreen *_screen,
>  {
> const struct dri2_format_mapping *map = 
> dri2_get_mapping_by_format(format);
> struct dri_screen *screen = dri_screen(_screen);
> +   struct pipe_screen *pscreen = screen->base.screen;
> __DRIimage *img;
> struct pipe_resource templ;
> -   unsigned tex_usage;
> +   unsigned tex_usage = 0;
>  
> if (!map)
>return NULL;
>  
> -   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
> +   if (pscreen->is_format_supported(pscreen, map->pipe_format, 
> screen->target,
> +0, 0, PIPE_BIND_RENDER_TARGET))
> +  tex_usage |= PIPE_BIND_RENDER_TARGET;
> +   if (pscreen->is_format_supported(pscreen, map->pipe_format, 
> screen->target,
> +0, 0, PIPE_BIND_SAMPLER_VIEW))
> +  tex_usage |= PIPE_BIND_SAMPLER_VIEW;
> +
> +   if (!tex_usage)
> +  return NULL;
>  
> if (use & __DRI_IMAGE_USE_SCANOUT)
>tex_usage |= PIPE_BIND_SCANOUT;

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH] nir: Optimize double-precision lower_round_even()

2019-01-29 Thread Philipp Zabel
On Tue, 2019-01-29 at 10:10 +0100, Erik Faye-Lund wrote:
> On Mon, 2019-01-28 at 09:31 -0800, Matt Turner wrote:
> > Use the trick of adding and then subtracting 2**52 (52 is the number
> > of
> > explicit mantissa bits a double-precision floating-point value has)
> > to
> > implement round-to-even.
> > 
> > Cuts the number of instructions on SKL of the piglit test
> > fs-roundEven-double.shader_test from 109 to 21.
> 
> Won't this approach only work for "small" values, that is values equal
> to or smaller than DBL_MAX - 2**52? Once you add 2**52, you'll get
> infinity, and you can't subtract 2**52 away again without being stuck
> with infinity, no...

2**52 is such a small value compared to anything close to DBL_MAX, it
will just be absorbed.

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/4] etnaviv: annotate variables only used in debug build

2018-11-15 Thread Philipp Zabel
On Thu, 2018-11-15 at 15:37 +0100, Lucas Stach wrote:
> Some of the status variables in the compiler are only used in asserts
> and thus may be unused in release builds. Annotate them accordingly
> to avoid 'unused but set' warnings from the compiler.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index bbc61a59fc67..386136e46836 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -477,7 +477,7 @@ static void
>  etna_compile_parse_declarations(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> -   unsigned status = TGSI_PARSE_OK;
> +   MAYBE_UNUSED unsigned status = TGSI_PARSE_OK;

Maybe out of scope for this patch, but the initial assignment is
superfluous here and in the next two instances:

> status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>  
> @@ -530,7 +530,7 @@ static void
>  etna_compile_pass_check_usage(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> -   unsigned status = TGSI_PARSE_OK;
> +   MAYBE_UNUSED unsigned status = TGSI_PARSE_OK;
> status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>  
> @@ -662,7 +662,7 @@ etna_compile_pass_optimize_outputs(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> int inst_idx = 0;
> -   unsigned status = TGSI_PARSE_OK;
> +   MAYBE_UNUSED unsigned status = TGSI_PARSE_OK;
> status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>  
> @@ -1812,7 +1812,7 @@ static void
>  etna_compile_pass_generate_code(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> -   unsigned status = tgsi_parse_init(, c->tokens);
> +   MAYBE_UNUSED unsigned status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>  
> int inst_idx = 0;

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/4] etnaviv: enable full overwrite in a few more cases

2018-11-15 Thread Philipp Zabel
On Thu, 2018-11-15 at 15:37 +0100, Lucas Stach wrote:
> Take into account the render target format when checking if the color
> mask affects all channels of the RT. This allows to enable full
> override in a few cases where a non-alpha format is used.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_blend.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c 
> b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> index 1792fd0fdd67..2bf081c2e710 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_blend.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> @@ -114,6 +114,7 @@ etna_update_blend(struct etna_context *ctx)
> struct pipe_blend_state *pblend = ctx->blend;
> struct etna_blend_state *blend = etna_blend_state(pblend);
> const struct pipe_rt_blend_state *rt0 = >rt[0];
> +   const struct util_format_description *desc;
> uint32_t colormask;
>  
> if (pfb->cbufs[0] &&
> @@ -131,8 +132,10 @@ etna_update_blend(struct etna_context *ctx)
>  * - The color mask is 
>  * - No blending is used
>  */
> -   bool full_overwrite = ((rt0->colormask == 0xf) && blend->fo_allowed) ||
> - !pfb->cbufs[0];
> +   if (pfb->cbufs[0])
> +  desc = util_format_description(pfb->cbufs[0]->format);
> +   bool full_overwrite = !pfb->cbufs[0] || ((blend->fo_allowed &&
> + util_format_colormask_full(desc, colormask)));

Is the comment above still accurate with this change?

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] etnaviv: use surface format directly

2018-11-15 Thread Philipp Zabel
On Thu, 2018-11-15 at 15:37 +0100, Lucas Stach wrote:
> There is no need to do the detour over the resource behind the
> surface to get the format. Use the surface format directly.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_blend.c   | 2 +-
>  src/gallium/drivers/etnaviv/etnaviv_context.c | 9 ++---
>  2 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c 
> b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> index 9c23411d4ff7..1792fd0fdd67 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_blend.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> @@ -117,7 +117,7 @@ etna_update_blend(struct etna_context *ctx)
> uint32_t colormask;
>  
> if (pfb->cbufs[0] &&
> -   translate_rs_format_rb_swap(pfb->cbufs[0]->texture->format)) {
> +   translate_rs_format_rb_swap(pfb->cbufs[0]->format)) {

There is another instance of this in etna_update_blend_color() below.

With that added,
Reviewed-by: Philipp Zabel 

>colormask = rt0->colormask & (PIPE_MASK_A | PIPE_MASK_G);
>if (rt0->colormask & PIPE_MASK_R)
>   colormask |= PIPE_MASK_B;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index 1c305d82a0fc..aa7425662898 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -212,13 +212,8 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
> pipe_draw_info *info)
> ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
>  
> struct etna_shader_key key = {};
> -   struct etna_surface *cbuf = etna_surface(pfb->cbufs[0]);
> -
> -   if (cbuf) {
> -  struct etna_resource *res = etna_resource(cbuf->base.texture);
> -
> -  key.frag_rb_swap = !!translate_rs_format_rb_swap(res->base.format);
> -   }
> +   if (pfb->cbufs[0])
> +  key.frag_rb_swap = 
> !!translate_rs_format_rb_swap(pfb->cbufs[0]->format);
>  
> if (!etna_get_vs(ctx, key) || !etna_get_fs(ctx, key)) {
>BUG("compiled shaders are not okay");

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] etnaviv: use dummy RT buffer when rendering without color buffer

2018-11-15 Thread Philipp Zabel
On Thu, 2018-11-15 at 15:37 +0100, Lucas Stach wrote:
> At least GC2000 seems to push some dirt from the PE color cache into
> the last bound render target when drawing depth only. Newer cores
> seem to behave properly and don't do this, but I have found no way
> to fix it on GC2000. Flushes and stalls don't seem to make any
> difference.
> 
> In order to stop the core from pushing the dirt into a precious real
> render target, plug in dummy buffer when rendering without a color
> buffer.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa 2/2] wsi/wayland: only finish() a successfully init()ed display

2018-11-05 Thread Philipp Zabel
On Mon, 2018-11-05 at 10:00 +, Eric Engestrom wrote:
> Cc: Dave Airlie 
> Cc: Philipp Zabel 
> Signed-off-by: Eric Engestrom 

Reviewed-by: Philipp Zabel 

> ---
>  src/vulkan/wsi/wsi_common_wayland.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
> b/src/vulkan/wsi/wsi_common_wayland.c
> index a799b427621d72b2927c..5d79d377f12df81b06ba 100644
> --- a/src/vulkan/wsi/wsi_common_wayland.c
> +++ b/src/vulkan/wsi/wsi_common_wayland.c
> @@ -456,7 +456,8 @@ wsi_wl_get_presentation_support(struct wsi_device 
> *wsi_device,
>  
> struct wsi_wl_display display;
> VkResult ret = wsi_wl_display_init(wsi, , wl_display, false);
> -   wsi_wl_display_finish();
> +   if (ret == VK_SUCCESS)
> +  wsi_wl_display_finish();
>  
> return ret == VK_SUCCESS;
>  }

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] vulkan/wsi/wayland: don't double free on error in get_presentation_support

2018-10-05 Thread Philipp Zabel
On Fri, 2018-10-05 at 10:13 +1000, Dave Airlie wrote:
> From: Dave Airlie 
> 
> If we fail the init path then don't call the free path.
> 
> Found by coverity
> ---
>  src/vulkan/wsi/wsi_common_wayland.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
> b/src/vulkan/wsi/wsi_common_wayland.c
> index 6b34e21bd98..ce20583315a 100644
> --- a/src/vulkan/wsi/wsi_common_wayland.c
> +++ b/src/vulkan/wsi/wsi_common_wayland.c
> @@ -455,8 +455,8 @@ wsi_wl_get_presentation_support(struct wsi_device 
> *wsi_device,
>(struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
>  
> struct wsi_wl_display display;
> -   int ret = wsi_wl_display_init(wsi, , wl_display, false);

This removes int ret ...

> -   wsi_wl_display_finish();
> +   if (wsi_wl_display_init(wsi, , wl_display, false))
> +  wsi_wl_display_finish();
>  
> return ret == 0;

... which is still used here.
Also it looks like this calls finish in the error case (result != 0).

Maybe

int ret = wsi_wl_display_init(wsi, , wl_display, false);
-   wsi_wl_display_finish();
+   if (ret == VK_SUCCESS)
+  wsi_wl_display_finish();

instead?

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes

2018-09-07 Thread Philipp Zabel
Hi Marek,

there are two comments that will be confusing if they are not updated as
well:

On Sat, 2018-09-01 at 02:54 -0400, Marek Olšák wrote:
> From: Marek Olšák 
> 
> ---
>  src/gallium/auxiliary/util/u_inlines.h | 86 +-
>  1 file changed, 43 insertions(+), 43 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_inlines.h 
> b/src/gallium/auxiliary/util/u_inlines.h
> index dee6f8f2d9e..7eb243779f7 100644
> --- a/src/gallium/auxiliary/util/u_inlines.h
> +++ b/src/gallium/auxiliary/util/u_inlines.h
> @@ -45,139 +45,139 @@
[...]
>  /**
>   * Update reference counting.
>   * The old thing pointed to, if any, will be unreferenced.
>   * Both 'ptr' and 'reference' may be NULL.

 * Both 'dst' and 'src' may be NULL.

>   * \return TRUE if the object's refcount hits zero and should be destroyed.
>   */
>  static inline boolean
> -pipe_reference_described(struct pipe_reference *ptr,
> - struct pipe_reference *reference,
> +pipe_reference_described(struct pipe_reference *dst,
> + struct pipe_reference *src,
>   debug_reference_descriptor get_desc)
[...]  
>  /**
>   * Set *ptr to \p view with proper reference counting.

 * Set *dst to \p src with proper reference counting.

>   *
>   * The caller must guarantee that \p view and *ptr must have been created in

 * The caller must guarantee that \p src and *dst must have been created in

>   * the same context (if they exist), and that this must be the current 
> context.
>   */
>  static inline void
> -pipe_sampler_view_reference(struct pipe_sampler_view **ptr,
> -struct pipe_sampler_view *view)
> +pipe_sampler_view_reference(struct pipe_sampler_view **dst,
> +struct pipe_sampler_view *src)

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 6/9] etnaviv: add 2D GPU YUV->RGB blitter

2018-07-17 Thread Philipp Zabel
On Mon, 2018-07-09 at 18:02 +0200, Lucas Stach wrote:
> This adds a blit path using the 2D GPU for a linear YUV to tiled RGB
> blit. This allows to implement importing of planar YUV textures with
> a single copy.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/Makefile.sources  |2 +
>  src/gallium/drivers/etnaviv/etnaviv_2d.c  |  166 ++
>  src/gallium/drivers/etnaviv/etnaviv_2d.h  |   37 +
>  src/gallium/drivers/etnaviv/hw/state_2d.xml.h | 1499 +
>  4 files changed, 1704 insertions(+)
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_2d.c
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_2d.h
>  create mode 100644 src/gallium/drivers/etnaviv/hw/state_2d.xml.h
> 
> diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
> b/src/gallium/drivers/etnaviv/Makefile.sources
> index 0b208122..d1c9c2db166e 100644
> --- a/src/gallium/drivers/etnaviv/Makefile.sources
> +++ b/src/gallium/drivers/etnaviv/Makefile.sources
> @@ -3,11 +3,13 @@ C_SOURCES :=  \
>   hw/common.xml.h \
>   hw/common_3d.xml.h \
>   hw/isa.xml.h \
> + hw/state_2d.xml.h \
>   hw/state_3d.xml.h \
>   hw/state_blt.xml.h \
>   hw/state.xml.h \
>   hw/texdesc_3d.xml.h \
>   \
> + etnaviv_2d.c \
>   etnaviv_asm.c \
>   etnaviv_asm.h \
>   etnaviv_blend.c \

This is patch is missing the corresponding meson.build changes:

--8<--
diff --git a/src/gallium/drivers/etnaviv/meson.build
b/src/gallium/drivers/etnaviv/meson.build
index 1733024ac988..103ed2a2b6a0 100644
--- a/src/gallium/drivers/etnaviv/meson.build
+++ b/src/gallium/drivers/etnaviv/meson.build
@@ -23,10 +23,13 @@ files_etnaviv = files(
   'hw/common.xml.h',
   'hw/common_3d.xml.h',
   'hw/isa.xml.h',
+  'hw/state_2d.xml.h',
   'hw/state_3d.xml.h',
   'hw/state_blt.xml.h',
   'hw/state.xml.h',
   'hw/texdesc_3d.xml.h',
+  'etnaviv_2d.c',
+  'etnaviv_2d.h',
   'etnaviv_asm.c',
   'etnaviv_asm.h',
   'etnaviv_blend.c',
-->8--

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/21] Towards NIR support for etnaviv

2018-06-06 Thread Philipp Zabel
Hi Christian,

On Tue, 2018-06-05 at 17:43 +0200, Christian Gmeiner wrote:
> Am Di., 5. Juni 2018 um 16:40 Uhr schrieb Philipp Zabel
> :
> Thanks for this nice patch series. I have been working for too long on
> the nir topic
> for etnaviv and never pushed any patches (which is quite sad). I have taken
> another route to tackle it. I have started with a low level library to
> generate valid
> Vivante binaries and to be able to disassemble them. On top of this, I
> have an eir
> library which is a simple block based ir which makes use of the low-level lib.

With your bottom-up vs our top-down approach it sounds like our efforts
might well complement each other. We haven't touched low level code
emission at all on purpose.

> And the last thing is the actual compiler which is nir based. All life outside
> of the gallium driver and have some gtest based unit tests. My main goal was 
> to
> start from a green field without looking at the current tgsi based compiler.
> 
> I will have a deeper look at your patches and review them.

Thanks, I'm looking forward to your review.

> I am quite unsure what I will do with my current code.
> I think the best would be to clean it up and push it.

I would appreciate being able to have a look.

> Hopefully, we can incorporate each work into a really nice new compiler.

Agreed!

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/21] etnaviv: nir: hardwire position location

2018-06-06 Thread Philipp Zabel
On Tue, 2018-06-05 at 11:50 -0400, Rob Clark wrote:
> On Tue, Jun 5, 2018 at 10:38 AM, Philipp Zabel  wrote:
> > The temporary input/output register 0 is reserved for position in the
> > fragment shader. Hardwire it to 0 and start other input/output variables
> > at 1. The intrinsic input load and output store base corresponds to the
> > temporary register number.
> 
> I didn't look at this very closely, but at RA time you can pre-color
> (pre-assign) specific registers, see ra_set_node_reg().. not sure if
> this would be a better approach.  I do this for a few frag shader
> registers, mostly because at the time I hadn't found the cmdstream
> register/bitfield to configure it to something other than r0.x..

Yes, thank you. We already pre-color, but with the output of this pass.
I'll have a look into whether this can be simplified by doing the pre-
color first and then afterwards fixing up the load/store intrinsics.
We keep around the intrinsics as we use them to configure the shader
inputs/outputs later.

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/21] etnaviv: nir: add virtual register classes

2018-06-06 Thread Philipp Zabel
On Tue, 2018-06-05 at 11:39 -0400, Rob Clark wrote:
> On Tue, Jun 5, 2018 at 10:38 AM, Philipp Zabel  wrote:
> > Since all threads share a global temporary vec4 register file, it is
> > important to reduce temporary register use of shaders.
> > Using source swizzles and destination write mask of ALU operations we
> > can layer smaller virtual registers on top of the physical base
> > registers that overlap with their base register and partially with each
> > other:
> > 
> >  ++-+-+-+
> >  |VEC4|  VEC3   |VEC2 | SCALAR  |
> >  ++-+-+-+
> >  |  X | X X X   | X X X   | X   |
> >  |  Y | Y Y   Y | Y Y Y   |   Y |
> >  |  Z | Z   Z Z |   Z   Z   Z | Z   |
> >  |  W |   W W W | W   W W |   W |
> >  ++-+-+-+
> > 
> > There are four possible virtual vec3 registers that leave the remaining
> > component usable as a scalar virtual register, six possible vec2
> > registers, and four possible scalar registers that only use a single
> > component.
> > 
> > This patch adds an interference graph for virtual registers to the
> > register allocator, using information about SSA interference and virtual
> > register overlap. If possible, SSAs with smaller num_components are
> > allocated from the unused components of already partially used temporary
> > registers.
> > 
> > Signed-off-by: Philipp Zabel 
> > Signed-off-by: Michael Tretter 
> > ---
> 
> so one quick note, constructing the register classes can be
> expensive.. you probably only want to do this once and then re-use for
> each shader

Thank you. Yes, that should be easily fixable.

The main reason we haven't already done this is that I hadn't added the
dummy RA node that grabs the forbidden register 0 in fragment shaders
until the last minute. Previously we had left out the register from the
graph altogether.

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 15/21] etnaviv: compiler: ignore nir_instr_type_ssa_undef

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Ignore ssa_undef nir instructions when generating code, because all
users of the undefined values are removed and undefined values are not
used. The instructions should be removed while rewriting the users of
undefined variables, but are not removed yet.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 66553199fe19..f17b9979b705 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2199,6 +2199,9 @@ etna_emit_instr(struct etna_compile *c, nir_instr *instr)
case nir_instr_type_load_const:
   /* Nothing to do */
   break;
+   case nir_instr_type_ssa_undef:
+  /* TODO: ssa_undef should be removed already */
+  break;
default:
   BUG("Unhandled nir_instr: %d", instr->type);
   assert(0);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 21/21] etnaviv: nir: globalize local registers

2018-06-05 Thread Philipp Zabel
We represent allocated temporaries as NIR global registers. Turn local
registers left over by the nir_convert_from_ssa pass into global
registers with the correct temporary number.

Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 36ec21fbd623..b50c9f16a456 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,26 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
 }
 
+/* Replace local registers created by the nir_convert_from_ssa pass to global
+ * registers, order them after the global registers created by register
+ * assignment.
+ */
+static void
+etna_globalize_local_registers(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_register_safe(reg, >impl->registers) {
+ nir_register *global_reg = nir_global_reg_create(shader);
+ global_reg->num_components = reg->num_components;
+ nir_foreach_use_safe(src, reg)
+nir_instr_rewrite_src(src->parent_instr, src, 
nir_src_for_reg(global_reg));
+ nir_foreach_def_safe(dest, reg)
+nir_instr_rewrite_dest(dest->reg.parent_instr, dest, 
nir_dest_for_reg(global_reg));
+ nir_reg_remove(reg);
+  }
+   }
+}
+
 /* Uniforms cannot directly be used as output. Add a move to register for
  * uniforms that are used as output. */
 static void
@@ -1062,6 +1082,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_fix_alu_uniform_src);
NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
+   NIR_PASS_V(s, etna_globalize_local_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
NIR_PASS_V(s, nir_opt_dce);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 06/21] etnaviv: nir: hardwire position location

2018-06-05 Thread Philipp Zabel
The temporary input/output register 0 is reserved for position in the
fragment shader. Hardwire it to 0 and start other input/output variables
at 1. The intrinsic input load and output store base corresponds to the
temporary register number.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 76 +++
 1 file changed, 76 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 1ddfbb818922..3b29ea9a0e76 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -81,6 +81,81 @@ etna_optimize_loop(nir_shader *s)
} while (progress);
 }
 
+/* The temporary PS input/output register 0 is reserved for the position */
+static void
+etna_hardwire_io_position(nir_shader *shader)
+{
+   bool fixup_needed = false;
+   int pos_in = -1, pos_out = -1;
+   int max_in = 0, max_out = 0;
+
+   if (shader->info.stage != MESA_SHADER_FRAGMENT)
+  return;
+
+   nir_foreach_variable(var, >inputs) {
+  if (var->data.location == VARYING_SLOT_POS) {
+ pos_in = var->data.driver_location;
+  } else {
+ max_in = MAX2(max_in, var->data.driver_location);
+ if (var->data.driver_location == 0)
+fixup_needed = true;
+  }
+   }
+   nir_foreach_variable(var, >outputs) {
+  if (var->data.location == FRAG_RESULT_DEPTH) {
+ pos_out = var->data.driver_location;
+  } else {
+ max_out = MAX2(max_out, var->data.driver_location);
+ if (var->data.driver_location == 0)
+fixup_needed = true;
+  }
+   }
+
+   fixup_needed |= (pos_in > 0) || (pos_out > 0);
+   if (!fixup_needed)
+  return;
+
+   if (pos_in == -1)
+  pos_in = max_in + 1;
+   if (pos_out == -1)
+  pos_out = max_out + 1;
+
+   nir_foreach_variable(var, >inputs) {
+  if (var->data.location == VARYING_SLOT_POS)
+ var->data.driver_location = 0;
+  else if (var->data.driver_location < pos_in)
+ var->data.driver_location++;
+   }
+   nir_foreach_variable(var, >outputs) {
+  if (var->data.location == FRAG_RESULT_DEPTH)
+ var->data.driver_location = 0;
+  else if (var->data.driver_location < pos_out)
+ var->data.driver_location++;
+   }
+
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr(instr, block) {
+if (instr->type != nir_instr_type_intrinsic)
+   continue;
+nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+unsigned pos;
+if (intr->intrinsic == nir_intrinsic_load_input)
+   pos = pos_in;
+else if (intr->intrinsic == nir_intrinsic_store_output)
+   pos = pos_out;
+else
+   continue;
+unsigned base = nir_intrinsic_base(intr);
+if (base <= pos)
+   nir_intrinsic_set_base(intr, (base == pos) ? 0 : (base + 1));
+ }
+  }
+  nir_metadata_preserve(function->impl,
+nir_metadata_block_index | nir_metadata_dominance);
+   }
+}
+
 /* Move const loads, input load intrinsics, and uniform load intrinsics to the
  * beginning of the function implementation.
  *
@@ -545,6 +620,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, nir_opt_global_to_local);
NIR_PASS_V(s, nir_lower_regs_to_ssa);
NIR_PASS_V(s, etna_move_load_intrinsics);
+   NIR_PASS_V(s, etna_hardwire_io_position);
 
etna_optimize_loop(s);
 
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 19/21] etnaviv: nir: add extra mov for uniforms used as output

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

If a uniform is source to an output store operation, we have to emit an
actual mov instruction that copies from the uniform register into the
temporary register that is used as a shader output.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index d8bd282eaeca..988b4bd62b6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,28 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
 }
 
+/* Uniforms cannot directly be used as output. Add a move to register for
+ * uniforms that are used as output. */
+static void
+etna_add_mov_for_uniform_output(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_intrinsic)
+   continue;
+
+nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+if (intr->intrinsic != nir_intrinsic_store_output ||
+!nir_src_is_dynamically_uniform(intr->src[0]))
+   continue;
+insert_mov(>instr, >src[0], shader);
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index);
+   }
+}
+
 /* Remove input_load and output_store intrinsics after global register
  * allocation. After the SSA destinations are replaced, these contain no useful
  * information anymore.
@@ -1002,6 +1024,7 @@ etna_optimize_nir(struct etna_shader *shader,
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, etna_fixup_tex);
+   NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 20/21] etnaviv: nir: avoid multiple uniform src for alu ops

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

The hardware does not allow two different uniform registers to be used
as sources in the same ALU instruction. Emit mov instructions to
temporary registers for all but one uniform register in this case.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 36 +++
 1 file changed, 36 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 988b4bd62b6e..36ec21fbd623 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -942,6 +942,41 @@ etna_add_mov_for_uniform_output(nir_shader *shader)
}
 }
 
+/* Accessing two different uniforms from one alu instruction is illegal.
+ * Insert a mov for all but one uniform before alu instructions.
+ */
+static void
+etna_fix_alu_uniform_src(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_alu)
+   continue;
+nir_alu_instr *alu = nir_instr_as_alu(instr);
+
+unsigned i;
+bool needs_fixup = false;
+
+for (i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
+   nir_src *src = >src[i].src;
+   if (!src->is_ssa || !nir_src_is_dynamically_uniform(*src))
+  continue;
+
+   /* FIXME The fixup unnecessarily fixes instructions where the
+* same uniform is used twice, which is allowed.
+*/
+   if (needs_fixup) {
+  insert_mov(>instr, src, shader);
+   } else
+  needs_fixup = true;
+}
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index);
+   }
+}
+
 /* Remove input_load and output_store intrinsics after global register
  * allocation. After the SSA destinations are replaced, these contain no useful
  * information anymore.
@@ -1024,6 +1059,7 @@ etna_optimize_nir(struct etna_shader *shader,
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, etna_fixup_tex);
+   NIR_PASS_V(s, etna_fix_alu_uniform_src);
NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 12/21] etnaviv: compiler: generate instructions for log2

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

flog2 is implemented as 2 instructions in the Vivante machine code. The
log calculates x and y, which have to be multiplied to get the actual
log result.

We need to allocate a temporary register for this, which will fail if to
many flog2 instructions are used (e.g. in the glmark2 ideas benchmark).

TODO: move this up into NIR as a lowering step.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 129c9115e783..66553199fe19 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2101,6 +2101,24 @@ etna_emit_alu(struct etna_compile *c, nir_alu_instr 
*instr)
  .src[2] = src[0],
   });
   break;
+   case nir_op_flog2:
+  {
+  struct etna_native_reg temp = etna_compile_get_inner_temp(c); /* only 
using .xy */
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .sat = 0,
+ .dst = etna_native_to_dst(temp, INST_COMPS_X | INST_COMPS_Y),
+ .src[2] = src[0],
+ .tex = { .amode=1 }, /* Unknown bit needs to be set */
+  });
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = dst,
+ .src[0] = etna_native_to_src(temp, SWIZZLE(X, X, X, X)),
+ .src[1] = etna_native_to_src(temp, SWIZZLE(Y, Y, Y, Y)),
+  });
+  }
+  break;
case nir_op_fexp2:
   emit_inst(c, &(struct etna_inst) {
  .opcode = INST_OPCODE_EXP,
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 04/21] etnaviv: add debug option to report NIR as supported and preferred shader IR

2018-06-05 Thread Philipp Zabel
Add a debug option ETNA_MESA_DEBUG="nir" that will cause the etnaviv
gallium pipe driver to advertise support and preference for NIR shaders.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_debug.h  |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 11 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_debug.h 
b/src/gallium/drivers/etnaviv/etnaviv_debug.h
index 4051e95dd5fb..8dacf6b2433e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_debug.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_debug.h
@@ -54,6 +54,9 @@
 #define ETNA_DBG_SHADERDB0x80 /* dump program compile information 
*/
 #define ETNA_DBG_NO_SINGLEBUF0x100 /* disable single buffer feature */
 
+/* Experimental features */
+#define ETNA_DBG_NIR   0x1000 /* Enable NIR compiler */
+
 extern int etna_mesa_debug; /* set in etna_screen.c from ETNA_DEBUG */
 
 #define DBG_ENABLED(flag) unlikely(etna_mesa_debug & (flag))
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index e031807117c0..d3b3f507adf0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -65,6 +65,7 @@ static const struct debug_named_value debug_options[] = {
{"cflush_all", ETNA_DBG_CFLUSH_ALL, "Flush every cash before state 
update"},
{"msaa2x", ETNA_DBG_MSAA_2X, "Force 2x msaa"},
{"msaa4x", ETNA_DBG_MSAA_4X, "Force 4x msaa"},
+   {"nir",ETNA_DBG_NIR, "Enable experimental NIR compiler"},
{"flush_all",  ETNA_DBG_FLUSH_ALL, "Flush after every rendered 
primitive"},
{"zero",   ETNA_DBG_ZERO, "Zero all resources after allocation"},
{"draw_stall", ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered 
primitive"},
@@ -454,7 +455,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
 ? screen->specs.fragment_sampler_count
 : screen->specs.vertex_sampler_count;
case PIPE_SHADER_CAP_PREFERRED_IR:
-  return PIPE_SHADER_IR_TGSI;
+  if (etna_mesa_debug & ETNA_DBG_NIR)
+ return PIPE_SHADER_IR_NIR;
+  else
+ return PIPE_SHADER_IR_TGSI;
case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
   return 4096;
case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED:
@@ -464,7 +468,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE:
   return false;
case PIPE_SHADER_CAP_SUPPORTED_IRS:
-  return 0;
+  if (etna_mesa_debug & ETNA_DBG_NIR)
+ return (1 << PIPE_SHADER_IR_TGSI) | (1 << PIPE_SHADER_IR_NIR);
+  else
+ return (1 << PIPE_SHADER_IR_TGSI);
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
   return 32;
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 11/21] etnaviv: compiler: add code emitter for alu operations

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Start emitting ALU instructions for nir_alu_instr structures from the
NIR shader's main function implementation.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 290 ++
 1 file changed, 290 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 59caff435e64..129c9115e783 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -1937,6 +1937,293 @@ etna_compile_pass_generate_code(struct etna_compile *c)
tgsi_parse_free();
 }
 
+static void
+translate_alu_sources(struct etna_compile *c, struct nir_alu_instr *instr,
+  struct etna_inst_src src[3])
+{
+   const nir_op_info *info = _op_infos[instr->op];
+
+   for (unsigned i = 0; i < info->num_inputs; i++) {
+  nir_alu_src nir_src = instr->src[i];
+  if (nir_src.src.is_ssa) {
+ nir_const_value *val = NULL;
+ if (nir_src.src.ssa->parent_instr->type == nir_instr_type_intrinsic) {
+nir_intrinsic_instr *intr = 
nir_instr_as_intrinsic(nir_src.src.ssa->parent_instr);
+// int indirect_offset = intr->src[0];
+src[i].use = 1;
+src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+src[i].reg = nir_intrinsic_base(intr);
+src[i].rgroup = INST_RGROUP_UNIFORM_0;
+ } else {
+val = nir_src_as_const_value(nir_src.src);
+src[i] = alloc_imm_vec4u(c, ETNA_IMMEDIATE_CONSTANT, val->u32);
+src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+ }
+  } else {
+ src[i].use = 1;
+ src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+ src[i].rgroup = INST_RGROUP_TEMP;
+ src[i].reg = nir_src.src.reg.reg->index;
+ src[i].amode = INST_AMODE_DIRECT;
+ src[i].neg = nir_src.negate;
+  }
+   }
+}
+
+static void
+etna_emit_alu(struct etna_compile *c, nir_alu_instr *instr)
+{
+   const nir_op_info *info = _op_infos[instr->op];
+
+   struct etna_inst_dst dst;
+   struct etna_inst_src src[3] = {};
+
+   nir_alu_dest nir_dest = instr->dest;
+
+   dst.use = 1;
+   dst.reg = nir_dest.dest.reg.reg->index;
+   dst.comps = nir_dest.write_mask;
+
+   translate_alu_sources(c, instr, src);
+
+   switch (instr->op) {
+   case nir_op_fceil:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_CEIL,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_ffloor:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_FLOOR,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmov:
+   case nir_op_imov:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MOV,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_frcp:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_RCP,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_frsq:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_RSQ,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmul:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_fadd:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_ADD,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[2] = src[1],
+  });
+  break;
+   case nir_op_fdot2:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_DP2,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_fdot3:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_DP3,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_ffma:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MAD,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+ .src[2] = src[2],
+  });
+  break;
+   case nir_op_fmin:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_SELECT,
+ .cond = INST_CONDITION_GT,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmax:
+  emit_inst(c, &(struc

[Mesa-dev] [PATCH 16/21] etnaviv: compiler: generate texture loads

2018-06-05 Thread Philipp Zabel
Emit TEXLD, TEXLDB, and TEXLDL instructions from nir_texop_tex,
nir_texop_txb, and nir_texop_txl texture loads, respectively.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 65 +++
 1 file changed, 65 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index f17b9979b705..b2499a7e2f6c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2186,6 +2186,68 @@ etna_emit_intr(struct etna_compile *c, 
nir_intrinsic_instr *intr)
}
 }
 
+static void
+etna_emit_tex(struct etna_compile *c, nir_tex_instr *instr)
+{
+   struct etna_inst_dst dst;
+   struct etna_inst_tex tex;
+   struct etna_inst_src src;
+
+   dst.use = 1;
+   dst.amode = 0;
+   dst.reg = instr->dest.is_ssa ? 0 : instr->dest.reg.reg->index;
+   /* nir_tex_instr does not support write mask */
+   dst.comps = INST_COMPS_X | INST_COMPS_Y | INST_COMPS_Z | INST_COMPS_W;
+
+   assert(!instr->texture);
+   assert(nir_tex_instr_src_index(instr, nir_tex_src_texture_offset) == -1);
+   tex.id = instr->texture_index;
+   tex.amode = 0;
+   tex.swiz = INST_SWIZ_IDENTITY;
+
+   src.use = 1;
+   src.reg = instr->src[0].src.is_ssa ? 0 : instr->src[0].src.reg.reg->index;
+   src.swiz = INST_SWIZ_IDENTITY;
+   src.neg = 0;
+   src.abs = 0;
+   src.amode = 0;
+   src.rgroup = 0;
+
+   switch (instr->op) {
+   case nir_texop_tex:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLD,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   case nir_texop_txb:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLDB,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   case nir_texop_txl:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLDL,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   default:
+  BUG("Unhandled nir_tex_instr: %d\n", instr->op);
+  assert(0);
+  break;
+   }
+}
+
 static void
 etna_emit_instr(struct etna_compile *c, nir_instr *instr)
 {
@@ -2193,6 +2255,9 @@ etna_emit_instr(struct etna_compile *c, nir_instr *instr)
case nir_instr_type_alu:
   etna_emit_alu(c, nir_instr_as_alu(instr));
   break;
+   case nir_instr_type_tex:
+  etna_emit_tex(c, nir_instr_as_tex(instr));
+  break;
case nir_instr_type_intrinsic:
   etna_emit_intr(c, nir_instr_as_intrinsic(instr));
   break;
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 18/21] etnaviv: nir: implement conditionals

2018-06-05 Thread Philipp Zabel
Emit conditional branches for nir_cf_code_if blocks following a
comparison operation. The NIR compiler does not assign registers to
the comparison operations, and the emitter does not emit any
instructions for them.
Instead, the nir_cf_code_if blocks cause emission of a conditional
branch instruction using the sources and condition flags from the
preceding conditional operation.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 75 +++
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 18 +
 2 files changed, 93 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index b2499a7e2f6c..0db961c5a751 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2162,6 +2162,12 @@ etna_emit_alu(struct etna_compile *c, nir_alu_instr 
*instr)
  .src[1] = src[1],
   });
   break;
+   case nir_op_feq:
+   case nir_op_fne:
+   case nir_op_flt:
+   case nir_op_fge:
+  /* Nothing to do, will be handled by the following nir_if */
+  break;
default:
   BUG("Unhandled nir_alu_instr: %s\n", info->name);
   assert(0);
@@ -2282,6 +2288,72 @@ etna_emit_block(struct etna_compile *c, nir_block 
*nblock)
}
 }
 
+static void etna_emit_cf_list(struct etna_compile *c, struct exec_list *list);
+
+static void
+etna_emit_if(struct etna_compile *c, nir_if *nif)
+{
+   struct etna_inst_src src[3] = {};
+
+   assert(nif->condition.is_ssa);
+
+   assert(nif->condition.ssa->parent_instr->type == nir_instr_type_alu);
+   nir_alu_instr *instr = nir_instr_as_alu(nif->condition.ssa->parent_instr);
+
+   assert(instr->op == nir_op_fne || instr->op == nir_op_feq);
+
+   translate_alu_sources(c, instr, src);
+
+   /* The NIR layer should have taken care of this */
+   assert(!etna_src_uniforms_conflict(src[0], src[1]));
+
+   unsigned sp = c->frame_sp++;
+   struct etna_compile_frame *f = >frame_stack[sp];
+   /* push IF to stack */
+   f->type = ETNA_COMPILE_FRAME_IF;
+   /* create "else" label */
+   f->lbl_else_idx = alloc_new_label(c);
+   f->lbl_endif_idx = -1;
+
+   /* mark position in instruction stream of label reference so that it can be
+* filled in in next pass */
+   label_mark_use(c, f->lbl_else_idx);
+
+   /* create conditional branch to else label if not src0 COND src1 */
+   emit_inst(c, &(struct etna_inst){
+  .opcode = INST_OPCODE_BRANCH,
+  .cond = (instr->op == nir_op_fne) ? INST_CONDITION_EQ : 
INST_CONDITION_NE,
+  .src[0] = src[0],
+  .src[1] = src[1],
+  /* imm is filled in later */
+   });
+
+   etna_emit_cf_list(c, >then_list);
+
+   /* create "endif" label, and branch to endif label */
+   f->lbl_endif_idx = alloc_new_label(c);
+   label_mark_use(c, f->lbl_endif_idx);
+   emit_inst(c, &(struct etna_inst) {
+  .opcode = INST_OPCODE_BRANCH,
+  .cond = INST_CONDITION_TRUE,
+  /* imm is filled in later */
+   });
+
+   /* mark "else" label at this position in instruction stream */
+   label_place(c, >labels[f->lbl_else_idx]);
+
+   etna_emit_cf_list(c, >else_list);
+
+   assert(--c->frame_sp == sp);
+
+   /* assign "endif" or "else" (if no ELSE) label to current position in
+* instruction stream, pop IF */
+   if (f->lbl_endif_idx != -1)
+  label_place(c, >labels[f->lbl_endif_idx]);
+   else
+  label_place(c, >labels[f->lbl_else_idx]);
+}
+
 static void
 etna_emit_cf_list(struct etna_compile *c, struct exec_list *list)
 {
@@ -2290,6 +2362,9 @@ etna_emit_cf_list(struct etna_compile *c, struct 
exec_list *list)
   case nir_cf_node_block:
  etna_emit_block(c, nir_cf_node_as_block(node));
  break;
+  case nir_cf_node_if:
+ etna_emit_if(c, nir_cf_node_as_if(node));
+ break;
   default:
  BUG("Unhandled nir node type %d\n", node->type);
  assert(0);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index af1684ed9091..d8bd282eaeca 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -399,6 +399,20 @@ etna_fixup_tex(nir_shader *shader)
}
 }
 
+static bool
+nir_op_is_comparison(nir_op op)
+{
+   switch (op) {
+   case nir_op_flt:
+   case nir_op_fge:
+   case nir_op_feq:
+   case nir_op_fne:
+  return true;
+   default:
+  return false;
+   }
+}
+
 /* Return the destination SSA if it should be replaced with a global register,
  * or NULL.
  */
@@ -423,6 +437,10 @@ etna_instr_replaceable_ssa_dest(nir_instr *instr)
if (instr->type == nir_instr_type_alu) {
   nir_alu_instr *alu = nir_instr_as_alu(instr);
 
+  /* Comparisons will be turned into

[Mesa-dev] [PATCH 17/21] etnaviv: nir: add texture fixup path before register assignment

2018-06-05 Thread Philipp Zabel
The texture instructions expect the source register to have the correct number
of components. Since we only have vec4 hardware registers, rewrite the number
of components to 4 and insert a mov instruction to a new vec4 SSA right before
the texture load instruction.

TODO: To support destination registers with the correct num_components
we have to add additional virtual scalar, vec2, and vec3 register
classes that only allow to use the X, XY, and XYZ components.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 7889adf473ab..af1684ed9091 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -373,6 +373,32 @@ etna_lower_store_intrinsics(nir_shader *shader)
}
 }
 
+/* The hardware only has vec4 registers, so rewrite all texture load
+ * instructions to require vec4 sources.
+ */
+static void
+etna_fixup_tex(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_metadata_require(function->impl, nir_metadata_live_ssa_defs);
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr(instr, block) {
+if (instr->type != nir_instr_type_tex)
+   continue;
+
+nir_tex_instr *tex = nir_instr_as_tex(instr);
+
+if (tex->src[0].src_type == nir_tex_src_coord) {
+   tex->coord_components = 4;
+   insert_mov(>instr, >src[0].src, shader);
+}
+ }
+  }
+  nir_metadata_preserve(function->impl,
+nir_metadata_block_index | nir_metadata_dominance);
+   }
+}
+
 /* Return the destination SSA if it should be replaced with a global register,
  * or NULL.
  */
@@ -957,6 +983,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_lower_store_intrinsics);
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
+   NIR_PASS_V(s, etna_fixup_tex);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 14/21] etnaviv: nir: remove undefined variables

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

If the source to a mov instruction is undefined, the result is undefined
as well. In that case it is valid to drop the mov instruction.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 1a71459c3a20..7889adf473ab 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -198,6 +198,40 @@ etna_opt_merge_alu_mov_pair(nir_shader *shader)
}
 }
 
+/* Remove mov alu_ops from undefined variables, because the destination will
+ * be undefined as well and the write is unnecessary.
+ */
+static void
+etna_opt_remove_mov_undef(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_alu)
+   continue;
+
+nir_alu_instr *alu = nir_instr_as_alu(instr);
+if (alu->op != nir_op_imov)
+   continue;
+
+unsigned i;
+for (i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
+   if (!alu->src[i].src.is_ssa ||
+   alu->src[i].src.ssa->parent_instr->type != 
nir_instr_type_ssa_undef)
+  break;
+}
+if (i != nir_op_infos[alu->op].num_inputs)
+   continue;
+
+nir_instr_remove(instr);
+/* TODO Remove nir_instr_type_ssa_undef instruction */
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index |
+nir_metadata_dominance);
+   }
+}
+
 /* Move const loads, input load intrinsics, and uniform load intrinsics to the
  * beginning of the function implementation.
  *
@@ -935,6 +969,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
NIR_PASS_V(s, nir_lower_vec_to_movs);
NIR_PASS_V(s, etna_opt_merge_alu_mov_pair);
+   NIR_PASS_V(s, etna_opt_remove_mov_undef);
 
nir_sweep(s);
 
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 13/21] etnaviv: nir: add a nop intrinsic to empty shaders

2018-06-05 Thread Philipp Zabel
The Vivante instruction set does not allow empty shaders.
If the shader is empty, add a nop to allow execution.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 752e87248e31..1a71459c3a20 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -888,6 +888,21 @@ etna_remove_io_intrinsics(nir_shader *shader)
}
 }
 
+static void
+etna_add_nop_if_empty(nir_shader *shader)
+{
+   /* TODO: add nop label if needed as jump target at the end of a function */
+   nir_foreach_function(function, shader) {
+  if (nir_index_instrs(function->impl) == 0) {
+ nir_intrinsic_instr *nop;
+
+ nop = nir_intrinsic_instr_create(shader, nir_intrinsic_nop);
+ nir_instr_insert_after_block(nir_start_block(function->impl),
+  >instr);
+  }
+   }
+}
+
 struct nir_shader *
 etna_optimize_nir(struct etna_shader *shader,
   struct nir_shader *s,
@@ -912,6 +927,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
NIR_PASS_V(s, nir_opt_dce);
+   NIR_PASS_V(s, etna_add_nop_if_empty);
 
/* Do this after register assignment to avoid creating temporary registers
 * that cause suboptimal register assignment.
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/21] etnaviv: nir: add virtual register classes

2018-06-05 Thread Philipp Zabel
Since all threads share a global temporary vec4 register file, it is
important to reduce temporary register use of shaders.
Using source swizzles and destination write mask of ALU operations we
can layer smaller virtual registers on top of the physical base
registers that overlap with their base register and partially with each
other:

 ++-+-+-+
 |VEC4|  VEC3   |VEC2 | SCALAR  |
 ++-+-+-+
 |  X | X X X   | X X X   | X   |
 |  Y | Y Y   Y | Y Y Y   |   Y |
 |  Z | Z   Z Z |   Z   Z   Z | Z   |
 |  W |   W W W | W   W W |   W |
 ++-+-+-+

There are four possible virtual vec3 registers that leave the remaining
component usable as a scalar virtual register, six possible vec2
registers, and four possible scalar registers that only use a single
component.

This patch adds an interference graph for virtual registers to the
register allocator, using information about SSA interference and virtual
register overlap. If possible, SSAs with smaller num_components are
allocated from the unused components of already partially used temporary
registers.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 282 --
 1 file changed, 259 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index b73d4be31bc6..752e87248e31 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -375,11 +375,111 @@ etna_instr_replaceable_ssa_dest(nir_instr *instr)
return NULL;
 }
 
-/* Return the NIR global register corresponding to a given temporary register,
- * creating it if necessary.
+/* Swizzles and write masks can be used to layer virtual non-interfering
+ * registers on top of the real VEC4 registers. For example, the virtual
+ * VEC3_XYZ register and the virtual SCALAR_W register that use the same
+ * physical VEC4 base register do not interfere.
+ */
+enum {
+   ETNA_REG_CLASS_VEC4,
+   ETNA_REG_CLASS_VIRT_VEC3,
+   ETNA_REG_CLASS_VIRT_VEC2,
+   ETNA_REG_CLASS_VIRT_SCALAR,
+   ETNA_NUM_REG_CLASSES,
+} etna_reg_class;
+
+enum {
+   ETNA_REG_TYPE_VEC4,
+   ETNA_REG_TYPE_VIRT_VEC3_XYZ,
+   ETNA_REG_TYPE_VIRT_VEC3_XYW,
+   ETNA_REG_TYPE_VIRT_VEC3_XZW,
+   ETNA_REG_TYPE_VIRT_VEC3_YZW,
+   ETNA_REG_TYPE_VIRT_VEC2_XY,
+   ETNA_REG_TYPE_VIRT_VEC2_XZ,
+   ETNA_REG_TYPE_VIRT_VEC2_XW,
+   ETNA_REG_TYPE_VIRT_VEC2_YZ,
+   ETNA_REG_TYPE_VIRT_VEC2_YW,
+   ETNA_REG_TYPE_VIRT_VEC2_ZW,
+   ETNA_REG_TYPE_VIRT_SCALAR_X,
+   ETNA_REG_TYPE_VIRT_SCALAR_Y,
+   ETNA_REG_TYPE_VIRT_SCALAR_Z,
+   ETNA_REG_TYPE_VIRT_SCALAR_W,
+   ETNA_NUM_REG_TYPES,
+} etna_reg_type;
+
+static const uint8_t
+etna_reg_writemask[ETNA_NUM_REG_TYPES] = {
+   [ETNA_REG_TYPE_VEC4] = 0xf,
+   [ETNA_REG_TYPE_VIRT_SCALAR_X] = 0x1,
+   [ETNA_REG_TYPE_VIRT_SCALAR_Y] = 0x2,
+   [ETNA_REG_TYPE_VIRT_VEC2_XY] = 0x3,
+   [ETNA_REG_TYPE_VIRT_SCALAR_Z] = 0x4,
+   [ETNA_REG_TYPE_VIRT_VEC2_XZ] = 0x5,
+   [ETNA_REG_TYPE_VIRT_VEC2_YZ] = 0x6,
+   [ETNA_REG_TYPE_VIRT_VEC3_XYZ] = 0x7,
+   [ETNA_REG_TYPE_VIRT_SCALAR_W] = 0x8,
+   [ETNA_REG_TYPE_VIRT_VEC2_XW] = 0x9,
+   [ETNA_REG_TYPE_VIRT_VEC2_YW] = 0xa,
+   [ETNA_REG_TYPE_VIRT_VEC3_XYW] = 0xb,
+   [ETNA_REG_TYPE_VIRT_VEC2_ZW] = 0xc,
+   [ETNA_REG_TYPE_VIRT_VEC3_XZW] = 0xd,
+   [ETNA_REG_TYPE_VIRT_VEC3_YZW] = 0xe,
+};
+
+static inline int etna_reg_get_type(int virt_reg)
+{
+   return virt_reg % ETNA_NUM_REG_TYPES;
+}
+
+static inline int etna_reg_get_base(int virt_reg)
+{
+   return virt_reg / ETNA_NUM_REG_TYPES;
+}
+
+static inline int etna_reg_get_class(int virt_reg)
+{
+   switch (etna_reg_get_type(virt_reg)) {
+   case ETNA_REG_TYPE_VEC4:
+  return ETNA_REG_CLASS_VEC4;
+   case ETNA_REG_TYPE_VIRT_VEC3_XYZ:
+   case ETNA_REG_TYPE_VIRT_VEC3_XYW:
+   case ETNA_REG_TYPE_VIRT_VEC3_XZW:
+   case ETNA_REG_TYPE_VIRT_VEC3_YZW:
+  return ETNA_REG_CLASS_VIRT_VEC3;
+   case ETNA_REG_TYPE_VIRT_VEC2_XY:
+   case ETNA_REG_TYPE_VIRT_VEC2_XZ:
+   case ETNA_REG_TYPE_VIRT_VEC2_XW:
+   case ETNA_REG_TYPE_VIRT_VEC2_YZ:
+   case ETNA_REG_TYPE_VIRT_VEC2_YW:
+   case ETNA_REG_TYPE_VIRT_VEC2_ZW:
+  return ETNA_REG_CLASS_VIRT_VEC2;
+   case ETNA_REG_TYPE_VIRT_SCALAR_X:
+   case ETNA_REG_TYPE_VIRT_SCALAR_Y:
+   case ETNA_REG_TYPE_VIRT_SCALAR_Z:
+   case ETNA_REG_TYPE_VIRT_SCALAR_W:
+  return ETNA_REG_CLASS_VIRT_SCALAR;
+   }
+
+   assert(false);
+}
+
+/* Q values for the full set. Each virtual register interferes
+ * with exactly one base register. And possibly with other virtual
+ * registers on top of the same base register.
+ */
+static const unsigned int
+q_val[ETNA_NUM_REG_CLASSES][ETNA_NUM_REG_CLASSES] = {
+   { 0, 4, 6, 4 },
+   { 1, 3, 6, 3 },
+   { 1, 4, 4, 2 },
+   { 1, 3, 3, 0 },
+};
+
+/* Return a NIR global register corresponding to a given temporary register.
+ * The register is created if necessary

[Mesa-dev] [PATCH 10/21] etnaviv: compiler: avoid using tgsi_shader_info

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

For NIR shaders, get the shader stage from the nir_shader structure
instead from tgsi_shader_info.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 37 ++-
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index f87708d33f03..59caff435e64 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -255,6 +255,39 @@ sort_rec_compar(const struct sort_rec *a, const struct 
sort_rec *b)
return 0;
 }
 
+static inline enum pipe_shader_type
+st_shader_stage_to_ptarget(gl_shader_stage stage)
+{
+   switch (stage) {
+   case MESA_SHADER_VERTEX:
+  return PIPE_SHADER_VERTEX;
+   case MESA_SHADER_FRAGMENT:
+  return PIPE_SHADER_FRAGMENT;
+   case MESA_SHADER_GEOMETRY:
+  return PIPE_SHADER_GEOMETRY;
+   case MESA_SHADER_TESS_CTRL:
+  return PIPE_SHADER_TESS_CTRL;
+   case MESA_SHADER_TESS_EVAL:
+  return PIPE_SHADER_TESS_EVAL;
+   case MESA_SHADER_COMPUTE:
+  return PIPE_SHADER_COMPUTE;
+   default:
+  break;
+   }
+
+   assert(!"Invalid shader type");
+   return PIPE_SHADER_VERTEX;
+}
+
+static inline bool
+etna_shader_is_stage(struct etna_compile *c, gl_shader_stage stage)
+{
+   if (!c->s)
+  return c->info.processor == st_shader_stage_to_ptarget(stage);
+   else
+  return c->s->info.stage == stage;
+}
+
 /* Calculate "mystery meat" load balancing value. This value determines how
  * work is scheduled between VS and PS in the unified shader architecture.
  * More precisely, it is determined from the number of VS outputs, as well as
@@ -658,7 +691,7 @@ etna_compile_pass_check_usage(struct etna_compile *c)
 static void
 assign_special_inputs(struct etna_compile *c)
 {
-   if (c->info.processor == PIPE_SHADER_FRAGMENT) {
+   if (etna_shader_is_stage(c, MESA_SHADER_FRAGMENT)) {
   /* never assign t0 as it is the position output, start assigning at t1 */
   c->next_free_native = 1;
 
@@ -2424,7 +2457,7 @@ fill_in_vs_outputs(struct etna_shader_variant *sobj, 
struct etna_compile *c)
 static bool
 etna_compile_check_limits(struct etna_compile *c)
 {
-   int max_uniforms = (c->info.processor == PIPE_SHADER_VERTEX)
+   int max_uniforms = etna_shader_is_stage(c, MESA_SHADER_VERTEX)
  ? c->specs->max_vs_uniforms
  : c->specs->max_ps_uniforms;
/* round up number of uniforms, including immediates, in units of four */
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 09/21] etnaviv: compiler: setup registers from nir

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Add etna_compile_shader_nir, set up shader inputs and outputs,
and start emitting instructions for optimized NIR shaders.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 224 +-
 1 file changed, 212 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 4caf0504d24b..f87708d33f03 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -66,11 +66,15 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
+#include 
+
 #include 
 #include 
 #include 
 #include 
 
+#include "nir/tgsi_to_nir.h"
+
 #define ETNA_MAX_INNER_TEMPS 2
 
 static const float sincos_const[2][4] = {
@@ -149,6 +153,9 @@ struct etna_compile {
 
struct tgsi_shader_info info;
 
+   struct nir_shader *s;
+   nir_function_impl *impl;
+
/* Register descriptions, per TGSI file, per register index */
struct etna_compile_file file[TGSI_FILE_COUNT];
 
@@ -1897,6 +1904,188 @@ etna_compile_pass_generate_code(struct etna_compile *c)
tgsi_parse_free();
 }
 
+static void
+etna_setup_registers_from_nir(struct etna_compile *c, struct 
etna_shader_variant *v)
+{
+   assert(c->s);
+
+   /* Fragment shaders must not use t0 */
+   if (etna_shader_is_stage(c, MESA_SHADER_FRAGMENT))
+  c->next_free_native = 1;
+
+   foreach_list_typed(nir_register, nir_reg, node, >s->registers) {
+  struct etna_reg_desc *reg = >decl[c->total_decls++];
+
+  reg->native = alloc_new_native_reg(c);
+  reg->native.valid = 1;
+
+  DBG_F(ETNA_DBG_COMPILER_MSGS,
+"temp: index=%d, id=%d",
+nir_reg->index, reg->native.id);
+   }
+
+   if (etna_shader_is_stage(c, MESA_SHADER_VERTEX))
+  c->next_free_native++;
+}
+
+static void
+etna_setup_uniforms_from_nir(struct etna_compile *c, struct 
etna_shader_variant *v)
+{
+   assert(c->s);
+
+   int i = 0;
+
+   nir_foreach_variable(u, >s->uniforms) {
+  unsigned array_len = MAX2(glsl_get_length(u->type), 1);
+
+  for (i = 0; i < array_len; i++) {
+ struct etna_reg_desc *reg = >decl[c->total_decls++];
+ reg->active = 1;
+ reg->native.valid = 1;
+ reg->native.rgroup = INST_RGROUP_UNIFORM_0;
+ reg->native.id = i;
+
+ DBG_F(ETNA_DBG_COMPILER_MSGS,
+   "uniform: id=%d, group=%d",
+   reg->native.id, reg->native.rgroup);
+  }
+   }
+   c->imm_base = i * 4;
+}
+
+static void
+etna_setup_inputs_from_nir(struct etna_compile *c, struct etna_shader_variant 
*v)
+{
+   assert(c->s);
+
+   struct etna_shader_io_file *sf = >infile;
+
+   sf->num_reg = 0;
+
+   nir_foreach_variable(in, >s->inputs) {
+  unsigned array_len = MAX2(glsl_get_length(in->type), 1);
+  unsigned ncomp = glsl_get_components(in->type);
+  unsigned n = in->data.driver_location;
+  unsigned slot = in->data.location;
+
+  DBG_F(ETNA_DBG_COMPILER_MSGS,
+"in: slot=%u, len=%ux%u, drvloc=%u",
+slot, array_len, ncomp, n);
+
+  assert(sf->num_reg < ETNA_NUM_INPUTS);
+  /* XXX exclude inputs with special semantics such as gl_frontFacing */
+  sf->reg[sf->num_reg].reg = n;
+  /* FIXME: drop TGSI semantics */
+  if (etna_shader_is_stage(c, MESA_SHADER_FRAGMENT)) {
+ unsigned semantic_name, semantic_index;
+ varying_slot_to_tgsi_semantic(slot, _name, _index);
+ if (semantic_name != TGSI_SEMANTIC_POSITION) {
+sf->reg[sf->num_reg].semantic.Name = semantic_name;
+sf->reg[sf->num_reg].semantic.Index = semantic_index;
+sf->reg[sf->num_reg].num_components = ncomp;
+sf->num_reg++;
+ }
+  } else {
+ sf->reg[sf->num_reg].semantic.Name = TGSI_SEMANTIC_POSITION;
+ sf->reg[sf->num_reg].num_components = ncomp;
+ sf->num_reg++;
+  }
+   }
+
+   c->num_varyings = sf->num_reg;
+
+   /* XXX what is this */
+   if (etna_shader_is_stage(c, MESA_SHADER_FRAGMENT)) {
+  v->input_count_unk8 = 31;
+   } else if (etna_shader_is_stage(c, MESA_SHADER_VERTEX)) {
+  v->input_count_unk8 = (sf->num_reg + 19) / 16;
+   }
+}
+
+static void
+build_output_index(struct etna_shader_variant *sobj);
+
+static void
+etna_setup_outputs_from_nir(struct etna_compile *c, struct etna_shader_variant 
*v)
+{
+   assert(c->s);
+
+   struct etna_shader_io_file *sf = >outfile;
+   unsigned num_variables = 0;
+
+   sf->num_reg = 0;
+
+   nir_foreach_variable(out, >s->outputs) {
+  unsigned array_len = MAX2(glsl_get_length(out->type), 1);
+  unsigned ncomp = glsl_get_components(out->type);
+  unsigned n = out-&

[Mesa-dev] [PATCH 07/21] etnaviv: nir: merge mov of result into alu op

2018-06-05 Thread Philipp Zabel
Remove unnecessary mov instructions. If the destination of an ALU
instruction is only used in a following mov, merge that mov into the ALU
instruction.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 3b29ea9a0e76..b73d4be31bc6 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -156,6 +156,48 @@ etna_hardwire_io_position(nir_shader *shader)
}
 }
 
+/* To be called after register assignment and the vec_to_movs lowering step.
+ * Merges ALU instructions whose destination is only used by the following
+ * mov instruction with that instruction.
+ */
+static void
+etna_opt_merge_alu_mov_pair(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_alu)
+   continue;
+
+nir_alu_instr *alu = nir_instr_as_alu(instr);
+if (alu->op != nir_op_imov)
+   continue;
+
+nir_instr *prev_instr = nir_instr_prev(instr);
+if (!prev_instr || prev_instr->type != nir_instr_type_alu)
+   continue;
+
+nir_alu_instr *prev_alu = nir_instr_as_alu(prev_instr);
+
+if (prev_alu->dest.dest.is_ssa ||
+alu->src[0].src.is_ssa ||
+alu->dest.dest.is_ssa ||
+prev_alu->dest.dest.reg.reg != alu->src[0].src.reg.reg ||
+prev_alu->dest.write_mask != alu->dest.write_mask)
+   continue;
+
+/* FIXME: there mustn't be any later uses of prev_instr->dest */
+
+nir_instr_rewrite_dest(prev_instr, _alu->dest.dest,
+   alu->dest.dest);
+nir_instr_remove(instr);
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index |
+nir_metadata_dominance);
+   }
+}
+
 /* Move const loads, input load intrinsics, and uniform load intrinsics to the
  * beginning of the function implementation.
  *
@@ -640,6 +682,7 @@ etna_optimize_nir(struct etna_shader *shader,
 */
NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
NIR_PASS_V(s, nir_lower_vec_to_movs);
+   NIR_PASS_V(s, etna_opt_merge_alu_mov_pair);
 
nir_sweep(s);
 
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 05/21] etnaviv: generate and optimize NIR

2018-06-05 Thread Philipp Zabel
If the "nir" debug option is enabled, actually process NIR shaders if
passed from the upper layers, or convert TGSI shaders to NIR before
processing them. We use a few common NIR lowering and optimization
passes as well as a few custom ones that are specific to the Vivante
hardware:

- etna_move_load_intrinsics moves load intrinsics to the beginning of
  the function implementation, as inputs are passed to the shader in the
  temporary register file. This ensures that the lifetime of an input
  temporary register properly extends from the beginning of the shader
  to its use.

- etna_lower_store_intrinsics splits output store intrinsics into the
  output store and an actual mov if the desired output temporary
  register is already in use over the lifetime of the output store's
  destination SSA. This allows to pin this SSA to the correct output
  temporary register during register assignment. Ideally this allows
  to remove input -> output copies entirely if the value can just
  be kept in the correct temporary register.

- etna_assign_registers uses the register allocator util to assign
  SSAs to regsters from the 64-register global temporary register file.
  We use NIR global registers with the correct index to represent these.
  For fragment shaders, the assigned temporary register number is
  derived from the input load / output store base.

- etna_remove_io_intrinsics removes input load and output store
  intrinsics from the nir_shader after register allocation, since
  they are not needed anymore.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/Makefile.am  |   5 +-
 src/gallium/drivers/etnaviv/Makefile.sources |   2 +
 src/gallium/drivers/etnaviv/etnaviv_nir.c| 577 +++
 src/gallium/drivers/etnaviv/etnaviv_nir.h|  39 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c |  12 +
 src/gallium/drivers/etnaviv/etnaviv_shader.c |  10 +
 src/gallium/drivers/etnaviv/etnaviv_shader.h |   3 +
 7 files changed, 647 insertions(+), 1 deletion(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.h

diff --git a/src/gallium/drivers/etnaviv/Makefile.am 
b/src/gallium/drivers/etnaviv/Makefile.am
index 81ef3c9f3701..8dea8f4d269b 100644
--- a/src/gallium/drivers/etnaviv/Makefile.am
+++ b/src/gallium/drivers/etnaviv/Makefile.am
@@ -26,6 +26,7 @@ include $(top_srcdir)/src/gallium/Automake.inc
 noinst_LTLIBRARIES = libetnaviv.la
 
 AM_CPPFLAGS = \
+   -I$(top_builddir)/src/compiler/nir \
$(GALLIUM_DRIVER_CFLAGS) \
$(ETNAVIV_CFLAGS)
 
@@ -39,8 +40,10 @@ etnaviv_compiler_SOURCES = \
 etnaviv_compiler_LDADD = \
libetnaviv.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
+   $(top_builddir)/src/compiler/nir/libnir.la \
$(top_builddir)/src/util/libmesautil.la \
$(GALLIUM_COMMON_LIB_DEPS) \
-   $(ETNAVIV_LIBS)
+   $(ETNAVIV_LIBS) \
+   -lstdc++
 
 EXTRA_DIST = meson.build
diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 0b208122..1e9818161d07 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -30,6 +30,8 @@ C_SOURCES :=  \
etnaviv_format.c \
etnaviv_format.h \
etnaviv_internal.h \
+   etnaviv_nir.c \
+   etnaviv_nir.h \
etnaviv_query.c \
etnaviv_query.h \
etnaviv_query_hw.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
new file mode 100644
index ..1ddfbb818922
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -0,0 +1,577 @@
+/*
+ * Copyright (c) 2018 Etnaviv Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *Phil

[Mesa-dev] [PATCH 02/21] etnaviv: extract get_mystery_meat_load_balancing

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Extract the mystery meat load balancing calculation into a function that
can also be called from the NIR compiler implementation.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 60 +++
 1 file changed, 34 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index bbc61a59fc67..ded5154c6f96 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -248,6 +248,37 @@ sort_rec_compar(const struct sort_rec *a, const struct 
sort_rec *b)
return 0;
 }
 
+/* Calculate "mystery meat" load balancing value. This value determines how
+ * work is scheduled between VS and PS in the unified shader architecture.
+ * More precisely, it is determined from the number of VS outputs, as well as
+ * chip-specific vertex output buffer size, vertex cache size, and the number
+ * of shader cores.
+ *
+ * XXX this is a conservative estimate, the "optimal" value is only known for
+ * sure at link time because some outputs may be unused and thus unmapped.
+ * Then again, in the general use case with GLSL the vertex and fragment
+ * shaders are linked already before submitting to Gallium, thus all outputs
+ * are used.
+ */
+static inline uint32_t
+get_mystery_meat_load_balancing(struct etna_compile *c, size_t reg_size)
+{
+   assert(etna_shader_is_stage(c, MESA_SHADER_VERTEX));
+
+   int half_out = (reg_size + 1) / 2;
+   assert(half_out);
+
+   uint32_t b = ((20480 / (c->specs->vertex_output_buffer_size -
+   2 * half_out * c->specs->vertex_cache_size)) +
+ 9) /
+10;
+   uint32_t a = (b + 256 / (c->specs->shader_core_count * half_out)) / 2;
+   return VIVS_VS_LOAD_BALANCING_A(MIN2(a, 255)) |
+  VIVS_VS_LOAD_BALANCING_B(MIN2(b, 255)) |
+  VIVS_VS_LOAD_BALANCING_C(0x3f) |
+  VIVS_VS_LOAD_BALANCING_D(0x0f);
+}
+
 /* create an index on a register set based on certain criteria. */
 static int
 sort_registers(struct sort_rec *sorted, struct etna_compile_file *file,
@@ -2196,32 +2227,9 @@ fill_in_vs_outputs(struct etna_shader_variant *sobj, 
struct etna_compile *c)
/* build two-level index for linking */
build_output_index(sobj);
 
-   /* fill in "mystery meat" load balancing value. This value determines how
-* work is scheduled between VS and PS
-* in the unified shader architecture. More precisely, it is determined from
-* the number of VS outputs, as well as chip-specific
-* vertex output buffer size, vertex cache size, and the number of shader
-* cores.
-*
-* XXX this is a conservative estimate, the "optimal" value is only known 
for
-* sure at link time because some
-* outputs may be unused and thus unmapped. Then again, in the general use
-* case with GLSL the vertex and fragment
-* shaders are linked already before submitting to Gallium, thus all outputs
-* are used.
-*/
-   int half_out = (c->file[TGSI_FILE_OUTPUT].reg_size + 1) / 2;
-   assert(half_out);
-
-   uint32_t b = ((20480 / (c->specs->vertex_output_buffer_size -
-   2 * half_out * c->specs->vertex_cache_size)) +
- 9) /
-10;
-   uint32_t a = (b + 256 / (c->specs->shader_core_count * half_out)) / 2;
-   sobj->vs_load_balancing = VIVS_VS_LOAD_BALANCING_A(MIN2(a, 255)) |
- VIVS_VS_LOAD_BALANCING_B(MIN2(b, 255)) |
- VIVS_VS_LOAD_BALANCING_C(0x3f) |
- VIVS_VS_LOAD_BALANCING_D(0x0f);
+   sobj->vs_load_balancing =
+  get_mystery_meat_load_balancing(c,
+  c->file[TGSI_FILE_OUTPUT].reg_size);
 }
 
 static bool
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 00/21] Towards NIR support for etnaviv

2018-06-05 Thread Philipp Zabel
Hi!

we have been interested in NIR support for etnaviv for a while, for the
obvious reasons: gaining access to common optimizations, better support
for non-trivial code transformations, better register allocation, and
the promise of OpenCL and SPIR-V support in the future.

Michael and I have used our annual exploratory "tech week" last year
and last week to get acquainted with NIR and the Vivante GPUs a bit and
to get started compiling NIR shaders from the GLSL compiler to Vivante
machine code.

The following patches are still very much work in progress. Until now,
this has only been tested with kmscube, weston, and glmark2 (and some
benchmarks are not working yet, missing instruction implementations).
We haven't even dared to run piglit yet. At this point we'd very much
like some feedback on where we are on the right path, and where things
could be done in a better way.
The NIR compiler is placed next to the current TGSI translation layer,
and still uses the same backend for code emission. NIR support is
disabled by default, and can be enabled using the etnaviv environment
option: ETNA_MESA_DEBUG="nir", so this could be merged without side
effects, once it is deemed acceptable, to support further development
in-tree.

Due to the shared global register file, reducing the amount of temporary
registers used by a shader is important for parallelism. We have added
added a layer of virtual registers with less than four components over
each vec4 base register using the register allocator utility, and use
source swizzles and destination write masks to reuse the free components
of partially occupied registers if possible.
We use the NIR global registers, indexed to represent the registers in
the global temporary register file, which allows us to do register
assignment in NIR and then reuse the current code emitter without
introducing another intermediate representation.

There are already a few Vivante specific lowering passes, but we
notably are still missing support for loops, and for lowering sin,
cos and log functions to the Vivante specific hardware instructions
that need prescaling and post-multiplication of the results' x and
y components (or to replace them with approximations where the
instructions are not supported).

The patches can also be found at:

  git://git.pengutronix.de/pza/mesa.git etnaviv-nir

regards
Philipp

Michael Tretter (10):
  etnaviv: extract get_mystery_meat_load_balancing
  etnaviv: compiler: extract compile shader from tgsi
  etnaviv: compiler: setup registers from nir
  etnaviv: compiler: avoid using tgsi_shader_info
  etnaviv: compiler: add code emitter for alu operations
  etnaviv: compiler: generate instructions for log2
  etnaviv: nir: remove undefined variables
  etnaviv: compiler: ignore nir_instr_type_ssa_undef
  etnaviv: nir: add extra mov for uniforms used as output
  etnaviv: nir: avoid multiple uniform src for alu ops

Philipp Zabel (11):
  etnaviv: prefix COMPARE_FUNC enum values in rnndb
  etnaviv: add debug option to report NIR as supported and preferred
shader IR
  etnaviv: generate and optimize NIR
  etnaviv: nir: hardwire position location
  etnaviv: nir: merge mov of result into alu op
  etnaviv: nir: add virtual register classes
  etnaviv: nir: add a nop intrinsic to empty shaders
  etnaviv: compiler: generate texture loads
  etnaviv: nir: add texture fixup path before register assignment
  etnaviv: nir: implement conditionals
  etnaviv: nir: globalize local registers

 src/gallium/drivers/etnaviv/Makefile.am   |5 +-
 src/gallium/drivers/etnaviv/Makefile.sources  |2 +
 .../drivers/etnaviv/etnaviv_compiler.c|  816 +++-
 src/gallium/drivers/etnaviv/etnaviv_debug.h   |3 +
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 1108 +
 src/gallium/drivers/etnaviv/etnaviv_nir.h |   39 +
 src/gallium/drivers/etnaviv/etnaviv_screen.c  |   23 +-
 src/gallium/drivers/etnaviv/etnaviv_shader.c  |   10 +
 src/gallium/drivers/etnaviv/etnaviv_shader.h  |3 +
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h |   16 +-
 10 files changed, 1956 insertions(+), 69 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.h

-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 03/21] etnaviv: compiler: extract compile shader from tgsi

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Prepare for compilation from NIR. etna_compile_shader will call either
etna_compile_shader_tgsi or etna_compile_shader_nir, depending on
whether the input is TGSI or NIR.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 46 +++
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index ded5154c6f96..4caf0504d24b 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2287,17 +2287,8 @@ copy_uniform_state_to_shader(struct etna_compile *c, 
struct etna_shader_variant
etna_set_shader_uniforms_dirty_flags(sobj);
 }
 
-bool
-etna_compile_shader(struct etna_shader_variant *v)
-{
-   /* Create scratch space that may be too large to fit on stack
-*/
-   bool ret;
-   struct etna_compile *c;
-
-   if (unlikely(!v))
-  return false;
-
+static void
+etna_compile_shader_tgsi(struct etna_compile *c, struct etna_shader_variant 
*v) {
const struct etna_specs *specs = v->shader->specs;
 
struct tgsi_lowering_config lconfig = {
@@ -2310,16 +2301,8 @@ etna_compile_shader(struct etna_shader_variant *v)
   .lower_TRUNC = true,
};
 
-   c = CALLOC_STRUCT(etna_compile);
-   if (!c)
-  return false;
-
-   memset(>lbl_usage, -1, sizeof(c->lbl_usage));
-
const struct tgsi_token *tokens = v->shader->tokens;
 
-   c->specs = specs;
-   c->key = >key;
c->tokens = tgsi_transform_lowering(, tokens, >info);
c->free_tokens = !!c->tokens;
if (!c->tokens) {
@@ -2445,6 +2428,31 @@ etna_compile_shader(struct etna_shader_variant *v)
etna_compile_add_z_div_if_needed(c);
etna_compile_frag_rb_swap(c);
etna_compile_add_nop_if_needed(c);
+}
+
+bool
+etna_compile_shader(struct etna_shader_variant *v)
+{
+   /* Create scratch space that may be too large to fit on stack
+*/
+   bool ret;
+   struct etna_compile *c;
+
+   if (unlikely(!v))
+  return false;
+
+   const struct etna_specs *specs = v->shader->specs;
+
+   c = CALLOC_STRUCT(etna_compile);
+   if (!c)
+  return false;
+
+   memset(>lbl_usage, -1, sizeof(c->lbl_usage));
+
+   c->specs = specs;
+   c->key = >key;
+
+   etna_compile_shader_tgsi(c, v);
 
ret = etna_compile_check_limits(c);
if (!ret)
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/21] etnaviv: prefix COMPARE_FUNC enum values in rnndb

2018-06-05 Thread Philipp Zabel
The COMPARE_FUNC enum values from rnndb state_3d.xml conflict with the
enum compare_func values from shader_enums.h, but they are not used
anywhere. Move them out of the way by adding a prefix.

TODO: The state_3d.xml.h header is generated and actually the generator
must be fixed to generate the prefixed macro.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/hw/state_3d.xml.h 
b/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
index 13122789ec12..ff5f1fde14db 100644
--- a/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
@@ -45,14 +45,14 @@ DEALINGS IN THE SOFTWARE.
 */
 
 
-#define COMPARE_FUNC_NEVER 0x
-#define COMPARE_FUNC_LESS  0x0001
-#define COMPARE_FUNC_EQUAL 0x0002
-#define COMPARE_FUNC_LEQUAL0x0003
-#define COMPARE_FUNC_GREATER   0x0004
-#define COMPARE_FUNC_NOTEQUAL  0x0005
-#define COMPARE_FUNC_GEQUAL0x0006
-#define COMPARE_FUNC_ALWAYS0x0007
+#define ETNA_COMPARE_FUNC_NEVER
0x
+#define ETNA_COMPARE_FUNC_LESS 0x0001
+#define ETNA_COMPARE_FUNC_EQUAL
0x0002
+#define ETNA_COMPARE_FUNC_LEQUAL   0x0003
+#define ETNA_COMPARE_FUNC_GREATER  0x0004
+#define ETNA_COMPARE_FUNC_NOTEQUAL 0x0005
+#define ETNA_COMPARE_FUNC_GEQUAL   0x0006
+#define ETNA_COMPARE_FUNC_ALWAYS   0x0007
 #define STENCIL_OP_KEEP
0x
 #define STENCIL_OP_ZERO
0x0001
 #define STENCIL_OP_REPLACE 0x0002
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl: autotools: add missing dependency on generated header

2018-05-25 Thread Philipp Zabel
platform_wayland.c includes linux-dmabuf-unstable-v1-client-protocol.h,
which is generated during build. Add the missing dependency to the
Makefile.

I have seen the following build failure due to a race between generation
of linux-dmabuf-unstable-v1-client-protocol.h and compilation of
platform_wayland.cc:

  GEN  drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
  GEN  drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
Using "code" is deprecated - use private-code or public-code.
See the help page for details.
  CC   drivers/dri2/platform_wayland.lo
../../../Mesa-18.1.0/src/egl/drivers/dri2/platform_wayland.c: In function 
'create_wl_buffer':
../../../Mesa-18.1.0/src/egl/drivers/dri2/platform_wayland.c:810:16: error: 
implicit declaration of function 'zwp_linux_dmabuf_v1_create_params' 
[-Werror=implicit-function-declaration]

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/egl/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
index 086a4a1e630..116ed4ebf50 100644
--- a/src/egl/Makefile.am
+++ b/src/egl/Makefile.am
@@ -80,6 +80,7 @@ drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h: 
$(WL_DMABUF_XML)
 if HAVE_PLATFORM_WAYLAND
 drivers/dri2/linux-dmabuf-unstable-v1-protocol.lo: 
drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
 drivers/dri2/egl_dri2.lo: 
drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
+drivers/dri2/platform_wayland.lo: 
drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
 
 AM_CFLAGS += $(WAYLAND_CLIENT_CFLAGS)
 libEGL_common_la_LIBADD += $(WAYLAND_CLIENT_LIBS)
-- 
2.17.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 04/14] etnaviv: put logic for rs clear format selection into caller

2018-05-15 Thread Philipp Zabel
On Tue, 2018-05-01 at 16:48 +0200, Christian Gmeiner wrote:
> We do no need to call translate_rs_format(..) as we can simplify
> things by using formats blocksize to choose the correct RS format
> for clearing.
> 
> No piglit regressions.
> 
> Signed-off-by: Christian Gmeiner 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_rs.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> index fc4f65dbee..3febd8daef 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> @@ -254,7 +254,19 @@ etna_rs_gen_clear_surface(struct etna_context *ctx, 
> struct etna_surface *surf,
>uint32_t clear_value)
>  {
> struct etna_resource *dst = etna_resource(surf->base.texture);
> -   uint32_t format = translate_rs_format(surf->base.format);
> +   uint32_t format;
> +
> +   switch (util_format_get_blocksize(surf->base.format)) {
> +   case 2:
> +  format = RS_FORMAT_A4R4G4B4;
> +  break;
> +   case 4:
> +  format = RS_FORMAT_A8R8G8B8;
> +  break;
> +   default:
> +  format = ETNA_NO_MATCH;
> +  break;
> +   }

Naively, this does not look like a simplification to me.

It effectively replaces a call to translate_rs_format with a call to
util_format_description. Is there an advantage to doing it this way?

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] etnaviv: remove not needed includes

2018-04-24 Thread Philipp Zabel
Hi Christian,

On Fri, 2018-04-20 at 14:55 +0200, Christian Gmeiner wrote:
> Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_translate.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_translate.h 
> b/src/gallium/drivers/etnaviv/etnaviv_translate.h
> index 7c85f81a70..88ce107a92 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_translate.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_translate.h
> @@ -30,7 +30,6 @@
>  
>  #include "etnaviv_debug.h"
>  #include "etnaviv_format.h"
> -#include "etnaviv_tiling.h"
>  #include "etnaviv_util.h"
>  #include "hw/cmdstream.xml.h"
>  #include "hw/common_3d.xml.h"
> @@ -40,8 +39,6 @@
>  #include "util/u_format.h"
>  #include "util/u_math.h"
>  
> -#include 
> -
>  /* Returned when there is no match of pipe value to etna value */
>  #define ETNA_NO_MATCH (~0)

Both
Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] gallium/util: implement util_format_is_yuv

2018-04-04 Thread Philipp Zabel
On Thu, 2018-03-29 at 16:15 +0200, Lucas Stach wrote:
> This adds a helper to check if a pipe format is in YUV color space.
> Drivers want to know about this, as YUV mostly needs special handling.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/auxiliary/util/u_format.h | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/util/u_format.h 
> b/src/gallium/auxiliary/util/u_format.h
> index 88bfd72d0538..e497b4b3375a 100644
> --- a/src/gallium/auxiliary/util/u_format.h
> +++ b/src/gallium/auxiliary/util/u_format.h
> @@ -557,6 +557,18 @@ util_format_is_depth_and_stencil(enum pipe_format format)
>util_format_has_stencil(desc);
>  }
>  
> +static inline boolean
> +util_format_is_yuv(enum pipe_format format)
> +{
> +   const struct util_format_description *desc = 
> util_format_description(format);
> +
> +   assert(desc);
> +   if (!desc) {
> +  return FALSE;
> +   }
> +
> +   return desc->colorspace == UTIL_FORMAT_COLORSPACE_YUV;
> +}
>  
>  /**
>   * Calculates the depth format type based upon the incoming format 
> description.

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] etnaviv: advertise YUV formats as external only

2018-04-04 Thread Philipp Zabel
On Thu, 2018-03-29 at 16:15 +0200, Lucas Stach wrote:
> We only support importing YUV as OES external resources.
> This will change in the future, but for now this fixes the
> advertised capabilities in eglQueryDmaBufModifiersEXT.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_screen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index e38e48c89436..3c2addb4aa5a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -632,7 +632,7 @@ etna_screen_query_dmabuf_modifiers(struct pipe_screen 
> *pscreen,
>if (modifiers)
>   modifiers[num_modifiers] = supported_modifiers[i];
>if (external_only)
> - external_only[num_modifiers] = 0;
> + external_only[num_modifiers] = util_format_is_yuv(format) ? 1 : 0;
>num_modifiers++;
> }

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] renderonly: fix dumb BO allocation for non 32bpp formats

2018-01-30 Thread Philipp Zabel
On Tue, 2018-01-30 at 15:22 +0100, Lucas Stach wrote:
> Take into account the resource format, instead of applying a hardcoded
> 32bpp. This not only over-allocates 16bpp formats, but also results in
> a wrong stride being filled into the handle.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/19] etnaviv: Use only DRAW_INSTANCED on GC3000+

2017-11-01 Thread Philipp Zabel
On Mon, 2017-10-30 at 17:16 +0100, Wladimir J. van der Laan wrote:
> The blob does this, as DRAW_INSTANCED can replace fully all the other
> draw commands - the other path is only there for compatibility and
> will go away (or at least rot to become buggy due to dis-use) in newer
> hardware.
> 
> Preparation for GC7000 support.

This also changes behaviour for <= GC2000 in the indexed case, should
this be mentioned in the commit message?

> Signed-off-by: Wladimir J. van der Laan <laa...@gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_context.c | 16 
>  src/gallium/drivers/etnaviv/etnaviv_emit.h| 21 +
>  2 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index 65c20d2..5aa9c66 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -188,6 +188,8 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
> pipe_draw_info *info)
>   BUG("Index buffer upload failed.");
>   return;
>}
> +  /* Add start to index offset, when rendering indexed */
> +  index_offset += info->start * info->index_size;
>  
>ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = 
> etna_resource(indexbuf)->bo;
>ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = index_offset;

So adding the start offset here makes up for always emitting a zero
start offset with DRAW_INDEXED_PRIMITIVES below.

> @@ -273,10 +275,16 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
> pipe_draw_info *info)
> /* First, sync state, then emit DRAW_PRIMITIVES or 
> DRAW_INDEXED_PRIMITIVES */
> etna_emit_state(ctx);
>  
> -   if (info->index_size)
> -  etna_draw_indexed_primitives(ctx->stream, draw_mode, info->start, 
> prims, info->index_bias);
> -   else
> -  etna_draw_primitives(ctx->stream, draw_mode, info->start, prims);
> +   if (ctx->specs.halti >= 2) {
> +  /* On HALTI2+ (GC3000 and higher) only use instanced drawing commands, 
> as the blob does */
> +  etna_draw_instanced(ctx->stream, info->index_size, draw_mode, 1,
> + info->count, info->index_size ? info->index_bias : info->start);
> +   } else {
> +  if (info->index_size)
> + etna_draw_indexed_primitives(ctx->stream, draw_mode, 0, prims, 
> info->index_bias);

Since this is the only place where etna_draw_indexed_primitives is
called, should the unused start parameter be removed from this
function?

> +  else
> + etna_draw_primitives(ctx->stream, draw_mode, info->start, prims);
> +   }
>  
> if (DBG_ENABLED(ETNA_DBG_DRAW_STALL)) {
>/* Stall the FE after every draw operation.  This allows better
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.h 
> b/src/gallium/drivers/etnaviv/etnaviv_emit.h
> index e0c0eda..3c3d129 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_emit.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.h
> @@ -117,6 +117,27 @@ etna_draw_indexed_primitives(struct etna_cmd_stream 
> *stream,
> etna_cmd_stream_emit(stream, 0);
>  }
>  
> +/* important: this takes a vertex count, not a primitive count */
> +static inline void
> +etna_draw_instanced(struct etna_cmd_stream *stream,
> +uint32_t indexed, uint32_t primitive_type,
> +uint32_t instance_count,
> +uint32_t vertex_count, uint32_t offset)
> +{
> +   etna_cmd_stream_reserve(stream, 3 + 1);
> +   etna_cmd_stream_emit(stream,
> +  VIV_FE_DRAW_INSTANCED_HEADER_OP_DRAW_INSTANCED |
> +  COND(indexed, VIV_FE_DRAW_INSTANCED_HEADER_INDEXED) |
> +  VIV_FE_DRAW_INSTANCED_HEADER_TYPE(primitive_type) |
> +  VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO(instance_count & 
> 0x));
> +   etna_cmd_stream_emit(stream,
> +  VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI(instance_count >> 16) |
> +  VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT(vertex_count));
> +   etna_cmd_stream_emit(stream,
> +  VIV_FE_DRAW_INSTANCED_START_INDEX(offset));
> +   etna_cmd_stream_emit(stream, 0);
> +}
> +
>  void
>  etna_emit_state(struct etna_context *ctx);

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/19] etnaviv: Const-correctness etnaviv_emit.h

2017-11-01 Thread Philipp Zabel
On Mon, 2017-10-30 at 17:16 +0100, Wladimir J. van der Laan wrote:
> The relocation structure is never changed by submitting it.
> 
> Signed-off-by: Wladimir J. van der Laan <laa...@gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_emit.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.h 
> b/src/gallium/drivers/etnaviv/etnaviv_emit.h
> index 6a3c772..e0c0eda 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_emit.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.h
> @@ -59,7 +59,7 @@ etna_set_state(struct etna_cmd_stream *stream, uint32_t 
> address, uint32_t value)
>  
>  static inline void
>  etna_set_state_reloc(struct etna_cmd_stream *stream, uint32_t address,
> - struct etna_reloc *reloc)
> + const struct etna_reloc *reloc)
>  {
> etna_cmd_stream_reserve(stream, 2);
> etna_emit_load_state(stream, address >> 2, 1, 0);

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] etnaviv: fix varying interpolation

2017-09-19 Thread Philipp Zabel
On Fri, 2017-09-15 at 18:04 +0200, Lucas Stach wrote:
> It seems that newer cores don't use the PA_ATTRIBUTES to decide if the
> varying should bypass the flat shading, but derive this from the
> component
> use. This fixes flat shading on GC880+.
> 
> VARYING_COMPONENT_USE_POINTCOORD is a bit of a misnomer now, as it
> isn't
> only used for pointcoords, but missing a better name I left it as-is.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
> v2: fix invalid vreg assignment
---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 23 ++-
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 165ab74298a4..d86d0561503a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2607,6 +2607,7 @@ etna_link_shader(struct etna_shader_link_info *info,
>    const struct etna_shader_inout *fsio = >infile.reg[idx];
>    const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio);
>    struct etna_varying *varying;
> +  bool interpolate = fsio->semantic.Name != TGSI_SEMANTIC_COLOR;
>  
>    assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings));
>  
> @@ -2616,28 +2617,24 @@ etna_link_shader(struct etna_shader_link_info *info,
>    varying = >varyings[fsio->reg - 1];
>    varying->num_components = fsio->num_components;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_COLOR) /* colors affected by 
> flat shading */
> +  if (interpolate) /* colors affected by flat shading */

This was (!interpolate) before, and looks like it should still be?
With that addressed,

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

>   varying->pa_attributes = 0x200;
>    else /* texture coord or other bypasses flat shading */
>   varying->pa_attributes = 0x2f1;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) {
> - varying->use[0] = VARYING_COMPONENT_USE_POINTCOORD_X;
> - varying->use[1] = VARYING_COMPONENT_USE_POINTCOORD_Y;
> - varying->use[2] = VARYING_COMPONENT_USE_USED;
> - varying->use[3] = VARYING_COMPONENT_USE_USED;
> - varying->reg = 0; /* replaced by point coord -- doesn't matter */
> +  varying->use[0] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_X : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[1] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_Y : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[2] = VARYING_COMPONENT_USE_USED;
> +  varying->use[3] = VARYING_COMPONENT_USE_USED;
> +
> +
> +  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD)
>   continue;

Since for point coord we just continue here without setting varying->reg 
at all ...

> -  }
>  
>    if (vsio == NULL)
>   return true; /* not found -- link error */
>  
> -  varying->use[0] = VARYING_COMPONENT_USE_USED;
> -  varying->use[1] = VARYING_COMPONENT_USE_USED;
> -  varying->use[2] = VARYING_COMPONENT_USE_USED;
> -  varying->use[3] = VARYING_COMPONENT_USE_USED;
> -  varying->reg = vsio->reg;
> +  varying->reg = vsio->reg; /* replaced by point coord -- doesn't matter 
> */

... is the comment still relevant here? Maybe this should be moved up
there.

> }
>  
> assert(info->num_varyings == fs->infile.num_reg);

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] egl/dri2: Allow modifiers to add FDs to imports

2017-08-11 Thread Philipp Zabel
On Wed, 2017-08-09 at 11:53 +0100, Daniel Stone wrote:
> When using dmabuf import, make sure that the modifier is actually
> allowed to add planes to the base format, as implied by the comment.
> 
> Signed-off-by: Daniel Stone <dani...@collabora.com>
---
>  src/egl/drivers/dri2/egl_dri2.c | 38 +++---
>  1 file changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index f0d1ded408..14decfed99 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2120,6 +2120,24 @@ dri2_check_dma_buf_format(const _EGLImageAttribs 
> *attrs)
>    return 0;
> }
>  
> +   for (unsigned i = plane_n; i < DMA_BUF_MAX_PLANES; i++) {
> +  /**
> +   * The modifiers extension spec says:
> +   *
> +   * "Modifiers may modify any attribute of a buffer import, including
> +   *  but not limited to adding extra planes to a format which
> +   *  otherwise does not have those planes. As an example, a modifier
> +   *  may add a plane for an external compression buffer to a
> +   *  single-plane format. The exact meaning and effect of any
> +   *  modifier is canonically defined by drm_fourcc.h, not as part of
> +   *  this extension."
> +   */
> +  if (attrs->DMABufPlaneModifiersLo[i].IsPresent &&
> +  attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> + plane_n = i + 1;
> +  }
> +   }
> +

Nice, this makes sure that all planes up to the last modifier have fds
present. And since all fds are guaranteed to be present, the modifier
equality check in dri2_check_dma_buf_attribs also makes sure that there
are no missing modifiers.

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/dri2: Allow modifiers to add FDs to imports

2017-08-08 Thread Philipp Zabel
On Tue, 2017-08-08 at 07:29 +0300, Tapani Pälli wrote:
> 
> On 08/07/2017 03:05 PM, Philipp Zabel wrote:
> > On Mon, 2017-07-31 at 18:35 +0100, Daniel Stone wrote:
> >> When using dmabuf import, make sure that the modifier is actually
> >> allowed to add planes to the base format, as implied by the comment.
> >>
> >> Signed-off-by: Daniel Stone <dani...@collabora.com>
> >> ---
> >>   src/egl/drivers/dri2/egl_dri2.c | 4 +++-
> >>   1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/src/egl/drivers/dri2/egl_dri2.c 
> >> b/src/egl/drivers/dri2/egl_dri2.c
> >> index b73dcd72b6..76294897a5 100644
> >> --- a/src/egl/drivers/dri2/egl_dri2.c
> >> +++ b/src/egl/drivers/dri2/egl_dri2.c
> >> @@ -2166,8 +2166,10 @@ dri2_check_dma_buf_format(const _EGLImageAttribs 
> >> *attrs)
> >> *  this extension."
> >> */
> >>if (attrs->DMABufPlaneModifiersLo[i].IsPresent &&
> >> - attrs->DMABufPlaneModifiersHi[i].IsPresent)
> >> + attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> >> +plane_n = i + 1;
> > 
> > Since this increments plane_n, Should a check be added that the
> > corresponding DMABufPlanFds[i] is present?
> 
> Check for the fd is right above this check.

I see this right above:

  if (attrs->DMABufPlaneFds[i].IsPresent || 
  attrs->DMABufPlaneOffsets[i].IsPresent ||
  attrs->DMABufPlanePitches[i].IsPresent ||
  attrs->DMABufPlaneModifiersLo[i].IsPresent ||
  attrs->DMABufPlaneModifiersHi[i].IsPresent) {

If modifiers are present, this is always true, regardless of whether the
fd is present.

The loop that checks for fd presence even before that only loops up to
the number of planes determined by the non-modified fourcc.

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/dri2: Allow modifiers to add FDs to imports

2017-08-07 Thread Philipp Zabel
On Mon, 2017-07-31 at 18:35 +0100, Daniel Stone wrote:
> When using dmabuf import, make sure that the modifier is actually
> allowed to add planes to the base format, as implied by the comment.
> 
> Signed-off-by: Daniel Stone <dani...@collabora.com>
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index b73dcd72b6..76294897a5 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2166,8 +2166,10 @@ dri2_check_dma_buf_format(const _EGLImageAttribs 
> *attrs)
>*  this extension."
>*/
>   if (attrs->DMABufPlaneModifiersLo[i].IsPresent &&
> - attrs->DMABufPlaneModifiersHi[i].IsPresent)
> + attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> +plane_n = i + 1;

Since this increments plane_n, Should a check be added that the
corresponding DMABufPlanFds[i] is present?
What if there are holes in DMABufPlaneModifiersLo/Hi?

>  continue;
> + }
>  
>   _eglError(EGL_BAD_ATTRIBUTE, "too many plane attributes");
>   return 0;

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Philipp Zabel
On Fri, 2017-08-04 at 18:15 +0200, Wladimir J. van der Laan wrote:
> On Fri, Aug 04, 2017 at 05:07:54PM +0200, Philipp Zabel wrote:
> > Look up BOs from the name table using the name parameter instead of
> > req.handle (which at this point is always zero).
> 
> Good catch.
> 
> Just out of interest: when is this used, what problems does this cause?

It is used by the etnaviv gallium driver in etna_screen_bo_from_handle
for DRM_API_HANDLE_TYPE_SHARED handles. Since this just falls back to
asking the kernel to DRM_IOCTL_GEM_OPEN if the BO is not found in the
name_table already, this bug caused no problems.

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Philipp Zabel
Look up BOs from the name table using the name parameter instead of
req.handle (which at this point is always zero).

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 etnaviv/etnaviv_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
index 4ad0434..4fe877f 100644
--- a/etnaviv/etnaviv_bo.c
+++ b/etnaviv/etnaviv_bo.c
@@ -173,7 +173,7 @@ struct etna_bo *etna_bo_from_name(struct etna_device *dev, 
uint32_t name)
pthread_mutex_lock(_lock);
 
/* check name table first, to see if bo is already open: */
-   bo = lookup_bo(dev->name_table, req.handle);
+   bo = lookup_bo(dev->name_table, name);
if (bo)
goto out_unlock;
 
-- 
2.1.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] etnaviv: add etna_bo_from_handle

2017-08-04 Thread Philipp Zabel
Although etnaviv_drmif.h declared etna_bo_from_handle from the start,
there was no implementation.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 etnaviv/etnaviv_bo.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
index 4fe877f..7566957 100644
--- a/etnaviv/etnaviv_bo.c
+++ b/etnaviv/etnaviv_bo.c
@@ -135,6 +135,25 @@ struct etna_bo *etna_bo_new(struct etna_device *dev, 
uint32_t size,
return bo;
 }
 
+struct etna_bo *
+etna_bo_from_handle(struct etna_device *dev, uint32_t handle, uint32_t size)
+{
+   struct etna_bo *bo = NULL;
+
+   pthread_mutex_lock(_lock);
+
+   bo = lookup_bo(dev->handle_table, handle);
+   if (bo)
+   goto out_unlock;
+
+   bo = bo_from_handle(dev, size, handle, 0);
+
+out_unlock:
+   pthread_mutex_unlock(_lock);
+
+   return bo;
+}
+
 struct etna_bo *etna_bo_ref(struct etna_bo *bo)
 {
atomic_inc(>refcnt);
-- 
2.1.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Add support for R8_UNORM textures

2017-07-28 Thread Philipp Zabel
On Fri, 2017-07-28 at 16:05 +0200, Wladimir J. van der Laan wrote:
> R8_UNORM textures can be emulated by means of L8 and a swizzle.
> 
> Signed-off-by: Wladimir J. van der Laan <laa...@gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
> b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index 69e07bc..a2e215b 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -90,7 +90,7 @@ struct etna_format {
>  
>  static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> /* 8-bit */
> -   V_(R8_UNORM,   UNSIGNED_BYTE, NONE),
> +   VT(R8_UNORM,   UNSIGNED_BYTE, L8, SWIZ(X, 0, 0, 1), NONE),
> V_(R8_SNORM,   BYTE,  NONE),
> V_(R8_UINT,UNSIGNED_BYTE, NONE),
> V_(R8_SINT,BYTE,  NONE),

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/dri: allow direct YUYV import

2017-07-19 Thread Philipp Zabel
On Fri, 2017-06-23 at 18:48 +0200, Lucas Stach wrote:
> Push this format to the pipe driver unchanged.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  include/GL/internal/dri_interface.h   | 1 +
>  src/gallium/state_trackers/dri/dri2.c | 7 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/include/GL/internal/dri_interface.h 
> b/include/GL/internal/dri_interface.h
> index fc2d4bbe22ef..69188a2a0da3 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1167,6 +1167,7 @@ struct __DRIdri2ExtensionRec {
>  #define __DRI_IMAGE_FORMAT_ARGB1555 0x100c
>  #define __DRI_IMAGE_FORMAT_R16  0x100d
>  #define __DRI_IMAGE_FORMAT_GR1616   0x100e
> +#define __DRI_IMAGE_FORMAT_YUYV 0x100f
>  
>  #define __DRI_IMAGE_USE_SHARE0x0001
>  #define __DRI_IMAGE_USE_SCANOUT  0x0002
> diff --git a/src/gallium/state_trackers/dri/dri2.c 
> b/src/gallium/state_trackers/dri/dri2.c
> index c5e69d639b16..3119a396ce29 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -115,6 +115,10 @@ static int convert_fourcc(int format, int 
> *dri_components_p)
>format = __DRI_IMAGE_FORMAT_GR88;
>dri_components = __DRI_IMAGE_COMPONENTS_RG;
>break;
> +   case __DRI_IMAGE_FOURCC_YUYV:
> +  format = __DRI_IMAGE_FORMAT_YUYV;
> +  dri_components = __DRI_IMAGE_COMPONENTS_Y_XUXV;
> +  break;
> /*
>  * For multi-planar YUV formats, we return the format of the first
>  * plane only.  Since there is only one caller which supports multi-
> @@ -195,6 +199,9 @@ static enum pipe_format dri2_format_to_pipe_format (int 
> format)
> case __DRI_IMAGE_FORMAT_GR88:
>pf = PIPE_FORMAT_RG88_UNORM;
>break;
> +   case __DRI_IMAGE_FORMAT_YUYV:
> +  pf = PIPE_FORMAT_YUYV;
> +  break;
> default:
>pf = PIPE_FORMAT_NONE;
>break;

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] st/mesa: release EGLImage on EGLImageTarget* error

2017-06-30 Thread Philipp Zabel
The smapi->get_egl_image() call in st_egl_image_get_surface() stores a
reference to the EGLImage's texture in stimg.texture. That reference is
released via pipe_resource_reference(, NULL) before stimg
goes out of scope at the end of the function, but not in the error path
if !is_format_supported().

Fixes: 83e9de25f325 ("st/mesa: EGLImageTarget* error handling")
Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/mesa/state_tracker/st_cb_eglimage.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/state_tracker/st_cb_eglimage.c 
b/src/mesa/state_tracker/st_cb_eglimage.c
index 0f649f4ab4..4b7b85db70 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -96,6 +96,7 @@ st_egl_image_get_surface(struct gl_context *ctx, 
GLeglImageOES image_handle,
 
if (!is_format_supported(screen, stimg.format, stimg.texture->nr_samples, 
usage)) {
   /* unable to specify a texture object using the specified EGL image */
+  pipe_resource_reference(, NULL);
   _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format not supported)", 
error);
   return NULL;
}
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: flush source TS before resolve

2017-06-28 Thread Philipp Zabel
On Mon, 2017-06-26 at 18:24 +0200, Lucas Stach wrote:
> If we blit from a rendertarget or a depthstencil buffer there might still
> be dirty data in the TS buffer which needs to be flushed out.
> 
> Fixes missing shadow tiles in glmark2 shadow.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
> This is on top of "etnaviv: flush color cache and depth cache together
> before resolves". Without this commit flushing the TS is causing
> rendering corruption.

Glad to see that there's a more straightworward test case for this issue
than running an animated web page in Qt WebEngine.

> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index e967595f424c..40a6832f8785 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -470,6 +470,10 @@ etna_try_rs_blit(struct pipe_context *pctx,
>etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE,
>VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH);
>etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_PE);
> +
> +  if (src->levels[blit_info->src.level].ts_size &&
> +  src->levels[blit_info->src.level].ts_valid)
> + etna_set_state(ctx->stream, VIVS_TS_FLUSH_CACHE, 
> VIVS_TS_FLUSH_CACHE_FLUSH);
> }
>  
> /* Set up color TS to source surface before blit, if needed */

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 07/11] etnaviv: implement resource import with modifier

2017-06-27 Thread Philipp Zabel
from_handle(pscreen, >base,
> -,
> -PIPE_HANDLE_USAGE_WRITE);
> -  close(handle.handle);
> -  if (!rsc->external)
> - goto free_rsc;
> -   }
> -
> if (DBG_ENABLED(ETNA_DBG_ZERO)) {
>void *map = etna_bo_map(bo);
>memset(map, 0, size);
> @@ -370,14 +398,21 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>goto fail;
>  
> rsc->seqno = 1;
> +   rsc->layout = modifier_to_layout(handle->modifier);
> +   rsc->halign = TEXTURE_HALIGN_FOUR;
> +

Superfluous whitespace.
 
> level->width = tmpl->width0;
> level->height = tmpl->height0;
>  
> -   /* We will be using the RS to copy with this resource, so we must
> -* ensure that it is appropriately aligned for the RS requirements. */
> -   unsigned paddingX = ETNA_RS_WIDTH_MASK + 1;
> -   unsigned paddingY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> +   /* Determine padding of the imported resource. */
> +   unsigned paddingX = 0, paddingY = 0;
> +   etna_layout_multiple(rsc->layout, screen->specs.pixel_pipes,
> +VIV_FEATURE(screen, chipMinorFeatures1, 
> TEXTURE_HALIGN),
> +, , >halign);
> +
> +   if (paddingY < 4 * screen->specs.pixel_pipes)
> +  paddingY = 4 * screen->specs.pixel_pipes;
>  
> level->padded_width = align(level->width, paddingX);
> level->padded_height = align(level->height, paddingY);
> @@ -396,12 +431,21 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>goto fail;
> }
>  
> -   if (handle->type == DRM_API_HANDLE_TYPE_SHARED && tmpl->bind & 
> PIPE_BIND_RENDER_TARGET) {
> -  /* Render targets are linear in Xorg but must be tiled
> -  * here. It would be nice if dri_drawable_get_format()
> -  * set scanout for these buffers too. */
> +   if (rsc->layout == ETNA_LAYOUT_LINEAR) {
> +  /*
> +   * Both sampler and pixel pipes can't handle linear, create a 
> compatible
> +   * base resource, where we can attach the imported buffer as an 
> external
> +   * resource.
> +   */
> +  struct pipe_resource tiled_templat = *tmpl;
> +
> +  /*
> +   * Remove BIND_SCANOUT to avoid recursion, as etna_resource_create uses
> +   * this function to import the scanout buffer and get a tiled resource.
> +   */
> +  tiled_templat.bind &= ~PIPE_BIND_SCANOUT;
>  
> -  ptiled = etna_resource_create(pscreen, tmpl);
> +  ptiled = etna_resource_create(pscreen, _templat);
>if (!ptiled)
>   goto fail;
>  

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/11] etnaviv: also update textures from external resources

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> This reworks the logic in etna_update_sampler_source to select the
> newest resource view for updating the texture view. This should make
> the logic easier to follow and fixes texture updates from imported
> dma-bufs.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_texture.c | 23 +++
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c 
> b/src/gallium/drivers/etnaviv/etnaviv_texture.c
> index df77829078c0..b7e424f89bba 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
> @@ -113,16 +113,23 @@ etna_delete_sampler_state(struct pipe_context *pctx, 
> void *ss)
>  static void
>  etna_update_sampler_source(struct pipe_sampler_view *view)
>  {
> -   struct etna_resource *res = etna_resource(view->texture);
> +   struct etna_resource *base = etna_resource(view->texture);
> +   struct etna_resource *to = base, *from = base;
>  
> -   if (res->texture && etna_resource_older(etna_resource(res->texture), 
> res)) {
> -  /* Texture is older than render buffer, copy the texture using RS */
> -  etna_copy_resource(view->context, res->texture, view->texture, 0,
> +   if (base->external && etna_resource_newer(etna_resource(base->external), 
> base))
> +  from = etna_resource(base->external);
> +
> +   if (base->texture)
> +  to = etna_resource(base->texture);
> +
> +   if ((to != from) && etna_resource_older(to, from)) {
> +  etna_copy_resource(view->context, >base, >base, 0,
> + view->texture->last_level);
> +  to->seqno = from->seqno;
> +   } else if ((to == from) && etna_resource_needs_flush(to)) {
> +  etna_copy_resource(view->context, >base, >base, 0,
>   view->texture->last_level);
> -  etna_resource(res->texture)->seqno = res->seqno;
> -   } else if (etna_resource_needs_flush(res)) {
> -  etna_copy_resource(view->context, view->texture, view->texture, 0, 0);
> -  res->flush_seqno = res->seqno;
> +  to->flush_seqno = from->seqno;
> }
>  }
>  

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: only flush resource to self if no scanout buffer exists

2017-06-26 Thread Philipp Zabel
On Mon, 2017-06-26 at 12:25 +0200, Lucas Stach wrote:
> Currently a resource flush may trigger a self resolve, even if a scanout 
> buffer
> exists, but is up to date. If a scanout buffer exists we only ever want to
> flush the resource to the scanout buffer. This fixes a performance regression.
> 
> Fixes: dda956340ce9 (etnaviv: resolve tile status when flushing resource)
> Cc: mesa-sta...@lists.freedesktop.org
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index e4620a3015e9..80967be3f93d 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -602,10 +602,11 @@ etna_flush_resource(struct pipe_context *pctx, struct 
> pipe_resource *prsc)
>  {
> struct etna_resource *rsc = etna_resource(prsc);
>  
> -   if (rsc->scanout &&
> -   etna_resource_older(etna_resource(rsc->scanout->prime), rsc)) {
> -  etna_copy_resource(pctx, rsc->scanout->prime, prsc, 0, 0);
> -  etna_resource(rsc->scanout->prime)->seqno = rsc->seqno;
> +   if (rsc->scanout) {
> +  if (etna_resource_older(etna_resource(rsc->scanout->prime), rsc)) {
> + etna_copy_resource(pctx, rsc->scanout->prime, prsc, 0, 0);
> + etna_resource(rsc->scanout->prime)->seqno = rsc->seqno;
> +  }
> } else if (etna_resource_needs_flush(rsc)) {
>etna_copy_resource(pctx, prsc, prsc, 0, 0);
>rsc->flush_seqno = rsc->seqno;

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/11] etnaviv: increment correct seqno for external resources

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> If we import a dma-buf with a sampler/pixel pipe incompatible modifier,
> the imported buffer will end up in an external resource view. As
> resource_changed signals the change of the imported resource, we need
> to update the external view seqno, instead of the base resource seqno.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 5cd20fafba49..43f63f8908a0 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -311,7 +311,10 @@ etna_resource_changed(struct pipe_screen *pscreen, 
> struct pipe_resource *prsc)
>  {
> struct etna_resource *res = etna_resource(prsc);
>  
> -   res->seqno++;
> +   if (res->external)
> +  etna_resource(res->external)->seqno++;
> +   else
> +  res->seqno++;
>  }
>  
>  static void

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 04/11] etnaviv: pad scanout buffer size to RS alignment

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> This fixes failures to import the scanout buffer with screen resolutions
> that don't satisfy teh RS alignment restrictions, like 1680x1050.
^^^ typo

> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index c6e7e98837b6..5cd20fafba49 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -215,9 +215,18 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> rsc->ts_bo = 0; /* TS is only created when first bound to surface */
>  
> if (templat->bind & PIPE_BIND_SCANOUT) {
> +  struct pipe_resource scanout_templat = *templat;
>struct winsys_handle handle;
> -  rsc->scanout = renderonly_scanout_for_resource(>base, screen->ro,
> - );
> +  unsigned padX, padY;
> +
> +  /* pad scanout buffer size to be compatible with the RS */
> +  padX = ETNA_RS_WIDTH_MASK + 1;
> +  padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> +  scanout_templat.width0 = align(scanout_templat.width0, padX);
> +  scanout_templat.height0 = align(scanout_templat.height0, padY);
> +
> +  rsc->scanout = renderonly_scanout_for_resource(_templat,
> +         screen->ro, );
>if (!rsc->scanout)
>   goto free_rsc;

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/11] etnaviv: fix memory leak when BO allocation fails

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> The resource struct is already allocated at this point and should be
> free properly.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index dfd087071193..97e0a15597fa 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -208,7 +208,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,
> struct etna_bo *bo = etna_bo_new(screen->dev, size, flags);
> if (unlikely(bo == NULL)) {
>BUG("Problem allocating video memory for resource");
> -  return NULL;
> +  goto free_rsc;
> }
>  
> rsc->bo = bo;
> @@ -223,6 +223,10 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> }
>  
> return >base;
> +
> +free_rsc:
> +   FREE(rsc);
> +   return NULL;
>  }
>  
>  static struct pipe_resource *

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/11] etnaviv: fill in layer_stride for imported resources

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> The layer stride information is used in various parts of the driver,
> so it needs to be present regardless if the driver allocated the
> buffer itself or merely imported it from an external source.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 1c098445b17a..dfd087071193 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -352,6 +352,8 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>  
> level->padded_width = align(level->width, paddingX);
> level->padded_height = align(level->height, paddingY);
> +   level->layer_stride = level->stride * 
> util_format_get_nblocksy(prsc->format,
> +  
> level->padded_height);
>  
> /* The DDX must give us a BO which conforms to our padding size.
>  * The stride of the BO must be greater or equal to our padded

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/11] renderonly/etnaviv: stop importing resource from renderonly

2017-06-26 Thread Philipp Zabel
On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> The current way of importing the resource from renderonly after allocation
> is opaque and is taking away control from the driver, which it needs in
> order to implement more advanced scenarios, than the simple linear
> scanout with matching stride alignments.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/auxiliary/renderonly/renderonly.c| 52 
> +++-
>  src/gallium/auxiliary/renderonly/renderonly.h| 20 -
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c |  8 ++--
>  src/gallium/drivers/etnaviv/etnaviv_resource.c   | 23 +++
>  src/gallium/drivers/etnaviv/etnaviv_resource.h   |  5 +++
>  5 files changed, 49 insertions(+), 59 deletions(-)
> 
[...]
> diff --git a/src/gallium/auxiliary/renderonly/renderonly.h 
> b/src/gallium/auxiliary/renderonly/renderonly.h
> index 70641c45878a..6a89c29e2ef6 100644
> --- a/src/gallium/auxiliary/renderonly/renderonly.h
> +++ b/src/gallium/auxiliary/renderonly/renderonly.h
> @@ -34,8 +34,6 @@
>  struct renderonly_scanout {
> uint32_t handle;
> uint32_t stride;
> -
> -   struct pipe_resource *prime;
>  };
>  
>  struct renderonly {
> @@ -59,7 +57,8 @@ struct renderonly {
>  *   to be done in flush_resource(..) like a resolve to linear.
>  */
> struct renderonly_scanout *(*create_for_resource)(struct pipe_resource 
> *rsc,
> - struct renderonly *ro);
> + struct renderonly *ro,
> + struct winsys_handle 
> *out_handle);
> int kms_fd;
> int gpu_fd;
>  };
> @@ -68,14 +67,13 @@ struct renderonly *
>  renderonly_dup(const struct renderonly *ro);
>  
>  static inline struct renderonly_scanout *
> -renderonly_scanout_for_resource(struct pipe_resource *rsc, struct renderonly 
> *ro)
> +renderonly_scanout_for_resource(struct pipe_resource *rsc,
> +struct renderonly *ro,
> +struct winsys_handle *out_handle)
>  {
> -   return ro->create_for_resource(rsc, ro);
> +   return ro->create_for_resource(rsc, ro, out_handle);
>  }

This changes the signature for renderonly_scanout_for_resource, which is
also called at:

src/gallium/drivers/vc4/vc4_resource.c:601:
renderonly_scanout_for_resource(prsc, screen->ro);

since commit 7029ec05e2c7 ("gallium: Add renderonly-based support for
pl111+vc4.").

> -struct renderonly_scanout *
> -renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly 
> *ro);
> -
>  void
>  renderonly_scanout_destroy(struct renderonly_scanout *scanout,
>  struct renderonly *ro);
[...]
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 97e0a15597fa..c6e7e98837b6 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -214,8 +214,20 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> rsc->bo = bo;
> rsc->ts_bo = 0; /* TS is only created when first bound to surface */
>  
> -   if (templat->bind & PIPE_BIND_SCANOUT)
> -  rsc->scanout = renderonly_scanout_for_resource(>base, screen->ro);
> +   if (templat->bind & PIPE_BIND_SCANOUT) {
> +  struct winsys_handle handle;
> +  rsc->scanout = renderonly_scanout_for_resource(>base, screen->ro,
> + );
> +  if (!rsc->scanout)
> + goto free_rsc;
> +
> +  rsc->external = pscreen->resource_from_handle(pscreen, >base,
> +,
> +PIPE_HANDLE_USAGE_WRITE);
> +  close(handle.handle);

Is the handle guaranteed to be DRM_API_HANDLE_TYPE_FD at this point?

> +  if (!rsc->external)
> + goto free_rsc;
> +   }
>  
> if (DBG_ENABLED(ETNA_DBG_ZERO)) {
>void *map = etna_bo_map(bo);
> @@ -310,6 +322,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct 
> pipe_resource *prsc)
> list_delinit(>list);
>  
> pipe_resource_reference(>texture, NULL);
> +   pipe_resource_reference(>external, NULL);
>  
> FREE(rsc);
>  }
> @@ -375,16 +388,12 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>/* Render targets are linear in Xorg but must be tiled
>* here. It would be nice if dri_drawable_get_format()
>* set scanout for these buffers too. */
> -  struct etna_resource *tiled;
>  
>ptiled = etna_resource_create(pscreen, tmpl);
>if (!ptiled)
>   goto fail;
>  
> -  tiled = etna_resource(ptiled);
> -  tiled->scanout = renderonly_scanout_for_prime(prsc, screen->ro);
> -  if (!tiled->scanout)
> - goto fail;
> +  etna_resource(ptiled)->external = prsc;
>  
>

[Mesa-dev] [RFC v2] etnaviv: flush color cache and depth cache together before resolves

2017-06-23 Thread Philipp Zabel
Before resolving a rendertarget or a depth/stencil resource into a
texture, flush both the color cache and the depth cache together.

It is unclear whether this is necessary for the following stall to
work properly, or whether the depth flush just adds enough time
for the color cache flush to finish before the resolver is started,
but this change removes artifacts that otherwise appear if a texture
is sampled directly after rendering into it.

The test case is a simple QML scene graph with a QtWebEngine based
WebView rendered on top of a blue background:

import QtQuick 2.0
import QtQuick.Window 2.2
import QtWebView 1.1

Window {
Rectangle {
id: background
anchors.fill: parent
color: "blue"
}

WebView {
id: webView
anchors.fill: parent
}

Component.onCompleted: {
webView.url = ""
}
}

If the website is animated, the WebView renders the site contents into
texture tiles and immediately afterwards samples from them to draw the
tiles into the Qt renderbuffer. Without this patch, a small irregular
triangle in the lower right of each browser tile appears solid blue, as
if the texture sampler samples zeroes instead of the website contents,
and the previously rendered blue Rectangle shows through.

Other attempts such as adding a pipeline stall before the color flush or
a TS cache flush afterwards or flushing multiple times, with stalls
before and after each flush, have shown no effect.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
Changes since v1:
 - Add a comment explaining why we flush color and depth cache together.
---
 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
index e4620a3015..d9538907fe 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
@@ -465,15 +465,19 @@ etna_try_rs_blit(struct pipe_context *pctx,
   ts_mem_config |= VIVS_TS_MEM_CONFIG_MSAA | msaa_format;
}
 
-   uint32_t to_flush = 0;
-
-   if (src->base.bind & PIPE_BIND_RENDER_TARGET)
-  to_flush |= VIVS_GL_FLUSH_CACHE_COLOR;
-   if (src->base.bind & PIPE_BIND_DEPTH_STENCIL)
-  to_flush |= VIVS_GL_FLUSH_CACHE_DEPTH;
-
-   if (to_flush) {
-  etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE, to_flush);
+   /* Always flush color and depth cache together before resolving. This works
+* around artifacts that appear in some cases when scanning out a texture
+* directly after it has been rendered to, such as rendering an animated web
+* page in a QtWebEngine based WebView on GC2000. The artifacts look like
+* the texture sampler samples zeroes instead of texture data in a small,
+* irregular triangle in the lower right of each browser tile quad. Other
+* attempts to avoid these artifacts, including a pipeline stall before the
+* color flush or a TS cache flush afterwards, or flushing multiple times,
+* with stalls before and after each flush, have shown no effect. */
+   if (src->base.bind & PIPE_BIND_RENDER_TARGET ||
+   src->base.bind & PIPE_BIND_DEPTH_STENCIL) {
+  etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE,
+VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH);
   etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_PE);
}
 
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] etnaviv: remove flat shading workaround

2017-06-09 Thread Philipp Zabel
On Thu, 2017-06-08 at 18:25 +0200, Lucas Stach wrote:
> It turned out not to be a hardware bug, but the shader compiler
> emitting wrong varying component use information. With that fixed
> we can turn flat shading back on.
> 
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_rasterizer.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> index 4990fd180257..56f2735e8a18 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> @@ -38,10 +38,6 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
> struct etna_rasterizer_state *cs;
> struct etna_context *ctx = etna_context(pctx);
>  
> -/* Disregard flatshading on GC880+, as a HW bug there seem to disable all
> - * varying interpolation if it's enabled */
> -   bool flatshade = ctx->screen->model < 880 ? so->flatshade : false;
> -
> if (so->fill_front != so->fill_back)
>DBG("Different front and back fill mode not supported");
>  
> @@ -51,7 +47,7 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
>  
> cs->base = *so;
>  
> -   cs->PA_CONFIG = (flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : 
> VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) |
> +   cs->PA_CONFIG = (so->flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : 
> VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) |
> translate_cull_face(so->cull_face, so->front_ccw) |
> translate_polygon_mode(so->fill_front) |
> COND(so->point_quad_rasterization, 
> VIVS_PA_CONFIG_POINT_SPRITE_ENABLE) |

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] etnaviv: fix varying interpolation

2017-06-09 Thread Philipp Zabel
On Thu, 2017-06-08 at 18:25 +0200, Lucas Stach wrote:
> It seems that newer cores don't use the PA_ATTRIBUTES to decide if the
> varying should bypass the flat shading, but derive this from the component
> use. This fixes flat shading on GC880+.
> 
> VARYING_COMPONENT_USE_POINTCOORD is a bit of a misnomer now, as it isn't
> only used for pointcoords, but missing a better name I left it as-is.
> 
> Signed-off-by: Lucas Stach 
>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 24 ++--
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index eafb511bb813..2605924613c7 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2552,6 +2552,7 @@ etna_link_shader(struct etna_shader_link_info *info,
>const struct etna_shader_inout *fsio = >infile.reg[idx];
>const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio);
>struct etna_varying *varying;
> +  bool interpolate = fsio->semantic.Name != TGSI_SEMANTIC_COLOR;
>  
>assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings));
>  
> @@ -2561,28 +2562,23 @@ etna_link_shader(struct etna_shader_link_info *info,
>varying = >varyings[fsio->reg - 1];
>varying->num_components = fsio->num_components;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_COLOR) /* colors affected by 
> flat shading */
> +  if (!interpolate) /* colors affected by flat shading */
>   varying->pa_attributes = 0x200;
>else /* texture coord or other bypasses flat shading */
>   varying->pa_attributes = 0x2f1;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) {
> - varying->use[0] = VARYING_COMPONENT_USE_POINTCOORD_X;
> - varying->use[1] = VARYING_COMPONENT_USE_POINTCOORD_Y;
> - varying->use[2] = VARYING_COMPONENT_USE_USED;
> - varying->use[3] = VARYING_COMPONENT_USE_USED;
> - varying->reg = 0; /* replaced by point coord -- doesn't matter */
> +  varying->use[0] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_X : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[1] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_Y : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[2] = VARYING_COMPONENT_USE_USED;
> +  varying->use[3] = VARYING_COMPONENT_USE_USED;

This only changins varying->use[0,1] to POINTCOORD in the
non-SEMANTIC_COLOR, non-SEMANTIC_PCOORD case, which is what the patch is
about.

> +  varying->reg = vsio->reg; /* replaced by point coord -- doesn't matter 
> */

This changes varying->vreg in the SEMANTIC_PCOORD case. As the comment
says, it shouldn't matter. But this also dereferences the vsio pointer,
which according to the check below could be NULL.

> +
> +
> +  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD)
>   continue;
> -  }
> 
>if (vsio == NULL)
>   return true; /* not found -- link error */

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [libdrm 1/4] etnaviv: submit full struct drm_etnaviv_gem_submit

2017-06-09 Thread Philipp Zabel
Hi Christian,

On Fri, 2017-06-09 at 12:27 +0200, Christian Gmeiner wrote:
> It is safe to submit the full struct even on older kernels as such
> kernels do not process the full struct. Without this change it
> becomes quite challenging to extned the submit struct.
> 
> Freedreno has no special treatment too. See git commits
> - freedreno: sync uapi header
> - freedreno: add fence fd support

Reading drm_ioctl() closely, I can see that it is safe to submit a
struct larger than what the kernel expects. I have applied this patch
and reverted kernel commits 78ec187f64fa ("drm/etnaviv: submit support
for out-fences") and 9ad59fea162c ("drm/etnaviv: submit support for
in-fences") to test, without ill effects.

> Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>
Tested-by: Philipp Zabel <p.za...@pengutronix.de>

regards
Philipp

> ---
>  etnaviv/etnaviv_cmd_stream.c | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/etnaviv/etnaviv_cmd_stream.c b/etnaviv/etnaviv_cmd_stream.c
> index 3c7b0ed..8d0e813 100644
> --- a/etnaviv/etnaviv_cmd_stream.c
> +++ b/etnaviv/etnaviv_cmd_stream.c
> @@ -203,14 +203,8 @@ static void flush(struct etna_cmd_stream *stream, int 
> in_fence_fd,
>   if (out_fence_fd)
>   req.flags |= ETNA_SUBMIT_FENCE_FD_OUT;
>  
> - /*
> -  * Pass the complete submit structure only if flags are set. Otherwise,
> -  * only pass the fields up to, but not including the flags field for
> -  * backwards compatiblity with older kernels.
> -  */
>   ret = drmCommandWriteRead(gpu->dev->fd, DRM_ETNAVIV_GEM_SUBMIT,
> - , req.flags ? sizeof(req) :
> - offsetof(struct drm_etnaviv_gem_submit, flags));
> + , sizeof(req));
>  
>   if (ret)
>   ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/6] etnaviv: honor PIPE_TRANSFER_UNSYNCHRONIZED flag

2017-05-30 Thread Philipp Zabel
On Fri, 2017-05-19 at 11:41 +0200, Lucas Stach wrote:
> This gets rid of quite a bit of CPU/GPU sync on frequent vertex buffer
> uploads and I haven't seen any of the issues mentioned in the comment,
> so this one seems stale.
> 
> Ignore the flag if there exists a temporary resource, as those ones are
> never busy.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 269bd498f89f..a2cd4e6234dd 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -114,7 +114,7 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
>}
> }
>  
> -   if (!trans->rsc)
> +   if (!trans->rsc && !(ptrans->usage & PIPE_TRANSFER_UNSYNCHRONIZED))

As we just talked about, this looks like it should be '||' ...

>etna_bo_cpu_fini(rsc->bo);
>  
> pipe_resource_reference(>rsc, NULL);
> @@ -260,19 +260,17 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
> (rsc->layout == ETNA_LAYOUT_TILED &&
>  util_format_is_compressed(prsc->format));
>  
> -   /* Ignore PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK here.
> -* It appears that Gallium operates the index/vertex buffers in a
> -* circular fashion, and the CPU can catch up with the GPU and starts
> -* overwriting yet-to-be-processed entries, causing rendering corruption. 
> */
> -   uint32_t prep_flags = 0;
> +   if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {

... for symmetry with etna_bo_cpu_prep call below.

> +  uint32_t prep_flags = 0;
>  
> -   if (usage & PIPE_TRANSFER_READ)
> -  prep_flags |= DRM_ETNA_PREP_READ;
> -   if (usage & PIPE_TRANSFER_WRITE)
> -  prep_flags |= DRM_ETNA_PREP_WRITE;
> +  if (usage & PIPE_TRANSFER_READ)
> + prep_flags |= DRM_ETNA_PREP_READ;
> +  if (usage & PIPE_TRANSFER_WRITE)
> + prep_flags |= DRM_ETNA_PREP_WRITE;
>  
> -   if (etna_bo_cpu_prep(rsc->bo, prep_flags))
> -  goto fail_prep;
> +  if (etna_bo_cpu_prep(rsc->bo, prep_flags))
> + goto fail_prep;
> +   }
>  
> /* map buffer object */
> void *mapped = etna_bo_map(rsc->bo);

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/6] etnaviv: always do cpu_fini in transfer_unmap

2017-05-30 Thread Philipp Zabel
On Fri, 2017-05-19 at 11:41 +0200, Lucas Stach wrote:
> The cpu_fini() call pushes the buffer back into the GPU domain, which needs
> to be done for all buffers, not just the ones with CPU written content. The
> etnaviv kernel driver currently doesn't validate this, but may start to do
> so at a later point in time. If there is a temporary resource the fini needs
> to happen before the RS uses this one as the source for the upload.
> 
> Also remove an invalid comment about flushing CPU caches, cpu_fini takes
> care of everything involved in this.
> 
> Fixes: c9e8b49b885 ("etnaviv: gallium driver for Vivante GPUs")
> Cc: mesa-sta...@lists.freedesktop.org
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 1a5aa7fc043c..4809b04ff95f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -70,6 +70,9 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
> if (rsc->texture && !etna_resource_newer(rsc, 
> etna_resource(rsc->texture)))
>rsc = etna_resource(rsc->texture); /* switch to using the texture 
> resource */
>  
> +   if (trans->rsc)
> +  etna_bo_cpu_fini(etna_resource(trans->rsc)->bo);
> +
> if (ptrans->usage & PIPE_TRANSFER_WRITE) {
>if (trans->rsc) {
>   /* We have a temporary resource due to either tile status or
> @@ -105,15 +108,15 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
>}
>  
>rsc->seqno++;
> -  etna_bo_cpu_fini(rsc->bo);
>  
>if (rsc->base.bind & PIPE_BIND_SAMPLER_VIEW) {
> - /* XXX do we need to flush the CPU cache too or start a write 
> barrier
> -  * to make sure the GPU sees it? */
>   ctx->dirty |= ETNA_DIRTY_TEXTURE_CACHES;
>}
> }
>  
> +   if (!trans->rsc)
> +  etna_bo_cpu_fini(rsc->bo);
> +
> pipe_resource_reference(>rsc, NULL);
> pipe_resource_reference(>resource, NULL);
> slab_free(>transfer_pool, trans);


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [RFC] etnaviv: flush color cache and depth cache together before resolves

2017-05-30 Thread Philipp Zabel
Before resolving a rendertarget or a depth/stencil resource into a
texture, flush both the color cache and the depth cache together.

It is unclear whether this is necessary for the following stall to
work properly, or whether the depth flush just adds enough time
for the color cache flush to finish before the resolver is started,
but this change removes artifacts that otherwise appear if a texture
is sampled directly after rendering into it.

The test case is a simple QML scene graph with a QtWebEngine based
WebView rendered on top of a blue background:

import QtQuick 2.0
import QtQuick.Window 2.2
import QtWebView 1.1

Window {
Rectangle {
id: background
anchors.fill: parent
color: "blue"
}

WebView {
id: webView
anchors.fill: parent
}

Component.onCompleted: {
webView.url = ""
}
}

If the website is animated, the WebView renders the site contents into
texture tiles and immediately afterwards samples from them to draw the
tiles into the Qt renderbuffer. Without this patch, a small irregular
triangle in the lower right of each browser tile appears solid blue, as
if the texture sampler samples zeroes instead of the website contents,
and the previously rendered blue Rectangle shows through.

Other attempts such as adding a pipeline stall before the color flush or
a TS cache flush afterwards or flushing multiple times, with stalls
before and after each flush, have shown no effect.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
index ae1c586288..faa6bd0436 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
@@ -455,15 +455,10 @@ etna_try_rs_blit(struct pipe_context *pctx,
   ts_mem_config |= VIVS_TS_MEM_CONFIG_MSAA | msaa_format;
}
 
-   uint32_t to_flush = 0;
-
-   if (src->base.bind & PIPE_BIND_RENDER_TARGET)
-  to_flush |= VIVS_GL_FLUSH_CACHE_COLOR;
-   if (src->base.bind & PIPE_BIND_DEPTH_STENCIL)
-  to_flush |= VIVS_GL_FLUSH_CACHE_DEPTH;
-
-   if (to_flush) {
-  etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE, to_flush);
+   if (src->base.bind & PIPE_BIND_RENDER_TARGET ||
+   src->base.bind & PIPE_BIND_DEPTH_STENCIL) {
+  etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE,
+VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH);
   etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_PE);
}
 
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 01/15] st/dri: refactor multi-planar YUV import path

2017-05-23 Thread Philipp Zabel
On Tue, 2017-05-23 at 14:40 +0530, Varad Gautam wrote:
> Hi Lucas,
> 
> On Mon, May 22, 2017 at 11:16 PM, Lucas Stach  wrote:
> > Am Mittwoch, den 10.05.2017, 23:15 +0530 schrieb Varad Gautam:
> >> From: Varad Gautam 
> >>
> >> we currently ignore the plane count when converting from
> >> __DRI_IMAGE_FORMAT* tokens to __DRI_IMAGE_FOURCC* for multiplanar
> >> images, and only return the first plane's simplified fourcc.
> >>
> >> this adds a fourcc to __DRI_IMAGE_FORMAT_* mapping to dri, allowing
> >> us to return the correct fourcc format from DRIimage queries, and
> >> simplifies the multiplane import logic.
> >>
> >> Signed-off-by: Varad Gautam 
> >> ---
> >>  src/gallium/state_trackers/dri/dri2.c   | 288 
> >> +++-
> >>  src/gallium/state_trackers/dri/dri_screen.h |  13 ++
> >>  2 files changed, 168 insertions(+), 133 deletions(-)
> >>
> >> diff --git a/src/gallium/state_trackers/dri/dri2.c 
> >> b/src/gallium/state_trackers/dri/dri2.c
> >> index ed6004f..0c5783c 100644
> >> --- a/src/gallium/state_trackers/dri/dri2.c
> >> +++ b/src/gallium/state_trackers/dri/dri2.c
> >> @@ -52,93 +52,133 @@
> >>  #include "dri_query_renderer.h"
> >>  #include "dri2_buffer.h"
> >>
> >> -static int convert_fourcc(int format, int *dri_components_p)
> >> +/* format list taken from intel_screen.c */
> >> +static struct image_format image_formats[] = {
> >> +   { __DRI_IMAGE_FOURCC_ARGB, __DRI_IMAGE_COMPONENTS_RGBA, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_ABGR, __DRI_IMAGE_COMPONENTS_RGBA, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR, 4 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_SARGB, __DRI_IMAGE_COMPONENTS_RGBA, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_SARGB8, 4 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_XRGB, __DRI_IMAGE_COMPONENTS_RGB, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB, 4 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_XBGR, __DRI_IMAGE_COMPONENTS_RGB, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR, 4 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_ARGB1555, __DRI_IMAGE_COMPONENTS_RGBA, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB1555, 2 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_RGB565, __DRI_IMAGE_COMPONENTS_RGB, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_RGB565, 2 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_R8, __DRI_IMAGE_COMPONENTS_R, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_R16, __DRI_IMAGE_COMPONENTS_R, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R16, 1 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_GR88, __DRI_IMAGE_COMPONENTS_RG, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_GR1616, __DRI_IMAGE_COMPONENTS_RG, 1,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR1616, 2 }, } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YUV411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YUV420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YUV444, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YVU410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YVU411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YVU420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
> >> +   { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
> >> +
> >> +   { __DRI_IMAGE_FOURCC_YVU422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
> >> + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
> 

[Mesa-dev] [PATCH] vulkan/wsi/wayland: Fix proxy wrappers for swapchain recreation

2017-05-19 Thread Philipp Zabel
Before the swapchain event queue is destroyed, all proxy objects that reference
it must be dropped. Otherwise we risk a use-after-free if a frame callback event
or buffer release events are received afterwards.
This happens when an application destroys and recreates a swapchain in FIFO
mode between two frames without using the VkSwapchainCreateInfoKHR::oldSwapchain
mechanism to keep the old swapchain until after the next redraw.

Fixes: 5034c615582a ("vulkan/wsi/wayland: Use proxy wrappers for swapchain")
Signed-off-by: Philipp Zabel <philipp.za...@gmail.com>
Cc: mesa-sta...@lists.freedesktop.org
---
 src/vulkan/wsi/wsi_common_wayland.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 8950798882..644ed62b41 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -537,6 +537,7 @@ struct wsi_wl_swapchain {
struct wl_surface *  surface;
uint32_t surface_version;
struct wl_drm *  drm_wrapper;
+   struct wl_callback * frame;
 
VkExtent2D   extent;
VkFormat vk_format;
@@ -616,6 +617,7 @@ frame_handle_done(void *data, struct wl_callback *callback, 
uint32_t serial)
 {
struct wsi_wl_swapchain *chain = data;
 
+   chain->frame = NULL;
chain->fifo_ready = true;
 
wl_callback_destroy(callback);
@@ -658,8 +660,8 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain 
*wsi_chain,
}
 
if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {
-  struct wl_callback *frame = wl_surface_frame(chain->surface);
-  wl_callback_add_listener(frame, _listener, chain);
+  chain->frame = wl_surface_frame(chain->surface);
+  wl_callback_add_listener(chain->frame, _listener, chain);
   chain->fifo_ready = false;
}
 
@@ -741,12 +743,16 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
 
for (uint32_t i = 0; i < chain->base.image_count; i++) {
-  if (chain->images[i].buffer)
+  if (chain->images[i].buffer) {
+ wl_buffer_destroy(chain->images[i].buffer);
  chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
chain->images[i].image,
chain->images[i].memory);
+  }
}
 
+   if (chain->frame)
+  wl_callback_destroy(chain->frame);
if (chain->surface)
   wl_proxy_wrapper_destroy(chain->surface);
if (chain->drm_wrapper)
@@ -791,6 +797,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
chain->queue = NULL;
chain->surface = NULL;
chain->drm_wrapper = NULL;
+   chain->frame = NULL;
 
bool alpha = pCreateInfo->compositeAlpha ==
   VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa/st: fix yuv EGLImage's

2017-05-17 Thread Philipp Zabel
On Tue, 2017-05-16 at 10:33 -0400, Rob Clark wrote:
> Don't reject YUV formats that the driver doesn't handle natively, since
> mesa/st already knows how to lower this in shader.
>
> Fixes: 83e9de2 ("st/mesa: EGLImageTarget* error handling")
> Cc: 17.1  Signed-off-by: Rob Clark 
> ---
>  src/mesa/state_tracker/st_cb_eglimage.c | 32 ++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_cb_eglimage.c 
> b/src/mesa/state_tracker/st_cb_eglimage.c
> index 3a62ef7..a104b64 100644
> --- a/src/mesa/state_tracker/st_cb_eglimage.c
> +++ b/src/mesa/state_tracker/st_cb_eglimage.c
> @@ -39,6 +39,35 @@
>  #include "st_sampler_view.h"
>  #include "util/u_surface.h"
>  
> +static bool
> +is_format_supported(struct pipe_screen *screen, enum pipe_format format,
> +unsigned nr_samples, unsigned usage)
> +{
> +   bool supported = screen->is_format_supported(screen, format, 
> PIPE_TEXTURE_2D,
> +nr_samples, usage);
> +
> +   /* for sampling, some formats can be emulated.. it doesn't matter that
> +* the surface will have a format that the driver can't cope with because
> +* we'll give it sampler view formats that it can deal with and generate
> +* a shader variant that converts.
> +*/
> +   if ((usage == PIPE_BIND_SAMPLER_VIEW) && !supported) {
> +  if (format == PIPE_FORMAT_IYUV) {
> + supported = screen->is_format_supported(screen, 
> PIPE_FORMAT_R8_UNORM,
> + PIPE_TEXTURE_2D, nr_samples,
> + usage);
> +  } else if (format == PIPE_FORMAT_NV12) {
> + supported = screen->is_format_supported(screen, 
> PIPE_FORMAT_R8_UNORM,
> + PIPE_TEXTURE_2D, nr_samples,
> + usage) &&
> + screen->is_format_supported(screen, 
> PIPE_FORMAT_R8G8_UNORM,
> + PIPE_TEXTURE_2D, nr_samples,
> + usage);
> +  }
> +   }
> +
> +   return supported;
> +}

But this only works for target == GL_TEXTURE_EXTERNAL_OES, right?
If so, I think we would have to pass the target enum through
st_egl_image_get_surface to is_format_supported and make a decision
based on that.

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: Check extended format availability on GPU

2017-05-16 Thread Philipp Zabel
Hi Wladimir,

On Tue, 2017-05-16 at 10:42 +0200, Wladimir J. van der Laan wrote:
> Current information shows that both extended texture/render formats
> and texture swizzling were introduced with the HALTI0 feature bit,
> available on GC2000/GC3000.

With this patch applied, trying to import R8_UNORM dma-buffers via
EGLImage results in an endless recursion:

etna_copy_resource -> etna_blit -> util_try_blit_via_copy_region ->
util_resource_copy_region -> etna_transfer_map -> etna_copy_resource ->
etna_blit -> ...

I think the problem is that etna_blit fails to blit via RS because of
missing compatible RS formats and falls through to call
util_blitter_blit, which in turn tries to map the resource to blit into
it in software using etna_transfer_map, which uses etna_copy_resource to
create a transfer copy, which calls etna_blit, and so on ...
I'm not exactly sure where the loop should be broken if the RS doesn't
support copying the format at all.

Is there any single-byte pixel format that could be returned from
etna_compatible_rs_format for PIPE_FORMAT_R8_UNORM ?

The only thing that looks remotely related is RS_FORMAT_R8I, but that is
marked as extended format in rnndb and doesn't fit into
RS_CONFIG_SOURCE/DEST_FORMAT. Is it even possible to tile R8/A8/L8
textures in hardware?

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] etnaviv: increment the resource seqno in resource_changed

2017-05-11 Thread Philipp Zabel
On Wed, 2017-05-10 at 20:14 +0200, Wladimir J. van der Laan wrote:
> Seems more straightforward, but I don't know the rationale
> why it was done the way it was.
> 
> Reviewed-By: Wladimir J. van der Laan <laa...@gmail.com> 

The rationale essentially was "the texture must be older than the
imported renderable so it will be resolved after importing" and "we
increase renderable seqno when we _render_ into it". I initially didn't
make the connection that reimporting a renderable with new content is
effectively the same thing as rendering new content into it.

regards
Philipp

> 
> On Wed, May 10, 2017 at 06:01:08PM +0200, Lucas Stach wrote:
> > From: Philipp Zabel <p.za...@pengutronix.de>
> > 
> > Just increment the resource seqno instead of setting the texture
> > seqno to be lower by one than the resource seqno.
> > 
> > Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
> > Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
> > ---
> >  src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +-
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> > b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > index 103b53c1c310..1341e1ea2314 100644
> > --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > @@ -286,11 +286,7 @@ etna_resource_changed(struct pipe_screen *pscreen, 
> > struct pipe_resource *prsc)
> >  {
> > struct etna_resource *res = etna_resource(prsc);
> >  
> > -   /* Make sure texture is older than the imported renderable buffer,
> > -* so etna_update_sampler_source will copy the pixel data again.
> > -*/
> > -   if (res->texture)
> > -  etna_resource(res->texture)->seqno = res->seqno - 1;
> > +   res->seqno++;
> >  }
> >  
> >  static void
> > -- 
> > 2.11.0
> > 
> > ___
> > etnaviv mailing list
> > etna...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/etnaviv
> 
> 


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] configure.ac: Fix help string for --disable-pwr8 configure option

2017-05-10 Thread Philipp Zabel
Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index df3eb6b29a..5c460f43d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -455,7 +455,7 @@ int main () {
 CFLAGS=$save_CFLAGS
 
 AC_ARG_ENABLE(pwr8,
-   [AS_HELP_STRING([--disable-pwr8-inst],
+   [AS_HELP_STRING([--disable-pwr8],
[disable POWER8-specific instructions])],
[enable_pwr8=$enableval], [enable_pwr8=auto])
 
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Sampling DRM_FORMAT_YUYV in GLSL

2017-05-09 Thread Philipp Zabel
On Tue, 2017-05-09 at 12:48 +0200, Volker Vogelhuber wrote:
[...]
> Ok thanks for the clarification. There is only one missing part for the
> GL_TEXTURE_2D case. The second EGLImage is created internally when
> calling eglCreateImage with EGL_LINUX_DMA_BUF_EXT, so I only
> have one return value I can bind to a texture using 
> glEGLImageTargetTexture2DOES.
> Is there any "get" function to access the ARGB eglimage to bind it to 
> another
> texture?

You create two separate EGLImages, calling eglCreateImage once for each
plane. See for example:

https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst-libs/gst/gl/gstglupload.c#n646

or

https://cgit.freedesktop.org/wayland/weston/tree/libweston/gl-renderer.c#n1536

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Sampling DRM_FORMAT_YUYV in GLSL

2017-05-09 Thread Philipp Zabel
On Tue, 2017-05-09 at 12:31 +0300, Tapani Pälli wrote:
> 
> On 05/09/2017 12:29 PM, Tapani Pälli wrote:
> > 
> > 
> > On 05/09/2017 12:14 PM, Volker Vogelhuber wrote:
> >> Hi,
> >>
> >> first sorry, for missing the subject in my mail to the mailing list, 
> >> then thanks
> >> for the hint with the "ext_image_dma_buf_import-sample_yuv". 
> >> Unfortunately
> >> things don't become clearer. In the samples as far as I can see, there 
> >> is also
> >> only one sampler defined in the shader. So how are the different 
> >> planes accessed
> >> in the shader? In the example only a simple copy is done:
> >> gl_FragColor = texture2D(sampler, texcoords);
> >> In the comment in intel_screen.c it says:
> >>
> >> /* For YUYV buffers, we set up two overlapping DRI images and treat
> >>  * them as planar buffers in the compositors.  Plane 0 is GR88 and
> >>  * samples YU or YV pairs and places Y into the R component, while
> >>  * plane 1 is ARGB and samples YUYV clusters and places pairs and
> >>  * places U into the G component and V into A.  This lets the
> >>  * texture sampler interpolate the Y components correctly when
> >>  * sampling from plane 0, and interpolate U and V correctly when
> >>  * sampling from plane 1. */
> >>
> >> So how are the pixels transfered from the YUYV memory to the vec4 in 
> >> the shader?
> >> Do I have to calculate the chroma values by interpolating myself based 
> >> on the
> >> current texture coordinate? Or is it done automatically in some way? 
> >>  From my
> >> experience the texture call only returns the values from plane0 which 
> >> leads me to the
> >> suspicion that I have to interpolate myself. But why is there then the 
> >> plane 1 which
> >> don't seem to be accessible in the shader?
> >>
> >> BTW: I'm using the OES_EGL_image extension not the 
> >> OES_EGL_image_external, so my
> >> sampler is sampler2D not samplerExternalOES but that shouldn't make a 
> >> difference should it?
> > 
> > IMO that is a big difference as samplerExternalOES does the YUV2RGB 
> > conversion and returns RGB values for you.
> 
> I have to add that "this is how I think it works", I haven't tried this 
> myself :)

This is correct. The OES_EGL_image_external extension states:

   "Sampling an external texture will return an RGBA vector in the same
colorspace as the source image.  If the source image is stored in YUV
(or some other basis) then the YUV values will be transformed to RGB
values. (But these RGB values will be in the same colorspace as the
original image."

Whereas when using a GL_TEXTURE_2D target, you have to do the conversion
yourself, sampling from to separate textures specified from two
EGLImages (one RG88 for Y, and one ARGB for UV, as described above).

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: add L8A8_UNORM texture format

2017-05-03 Thread Philipp Zabel
On Tue, 2017-05-02 at 22:06 +0200, Christian Gmeiner wrote:
> No piglit regressions.
> 
> Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>

Reviewed-by: Philipp Zabel <p.za...@pengutronix.de>

> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
> b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index 0794603..7c24386 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -103,6 +103,8 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> _T(B4G4R4A4_UNORM, A4R4G4B4, A4R4G4B4),
> _T(B4G4R4X4_UNORM, X4R4G4B4, X4R4G4B4),
>  
> +   _T(L8A8_UNORM, A8L8, NONE),
> +
> _T(Z16_UNORM,  D16,  A4R4G4B4),
> _T(B5G6R5_UNORM,   R5G6B5,   R5G6B5),
> _T(B5G5R5A1_UNORM, A1R5G5B5, A1R5G5B5),


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] renderonly: use drmIoctl

2017-04-28 Thread Philipp Zabel
To restart interrupted system calls, use drmIoctl.

Suggested-by: Emil Velikov <emil.l.veli...@gmail.com>
Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
Applies on top of the "renderonly: drop resources on destroy" patch:
https://patchwork.freedesktop.org/patch/153274/
---
 src/gallium/auxiliary/renderonly/renderonly.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c 
b/src/gallium/auxiliary/renderonly/renderonly.c
index f377c368e5..2fe1009016 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "state_tracker/drm_driver.h"
@@ -74,7 +73,7 @@ renderonly_scanout_destroy(struct renderonly_scanout *scanout,
pipe_resource_reference(>prime, NULL);
if (ro->kms_fd != -1) {
   destroy_dumb.handle = scanout->handle;
-  ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
+  drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
}
FREE(scanout);
 }
@@ -99,7 +98,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
   return NULL;
 
/* create dumb buffer at scanout GPU */
-   err = ioctl(ro->kms_fd, DRM_IOCTL_MODE_CREATE_DUMB, _dumb);
+   err = drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_CREATE_DUMB, _dumb);
if (err < 0) {
   fprintf(stderr, "DRM_IOCTL_MODE_CREATE_DUMB failed: %s\n",
 strerror(errno));
@@ -136,7 +135,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
 
 free_dumb:
destroy_dumb.handle = scanout->handle;
-   ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
+   drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
 
 free_scanout:
FREE(scanout);
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] renderonly: use drmIoctl

2017-04-28 Thread Philipp Zabel
To restart interrupted system calls, use drmIoctl.

Suggested-by: Emil Velikov <emil.l.veli...@gmail.com>
Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
Applies on top of the "renderonly: drop resources on destroy" patch:
https://patchwork.freedesktop.org/patch/153274/
---
 src/gallium/auxiliary/renderonly/renderonly.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c 
b/src/gallium/auxiliary/renderonly/renderonly.c
index f377c368e5..2fe1009016 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "state_tracker/drm_driver.h"
@@ -74,7 +73,7 @@ renderonly_scanout_destroy(struct renderonly_scanout *scanout,
pipe_resource_reference(>prime, NULL);
if (ro->kms_fd != -1) {
   destroy_dumb.handle = scanout->handle;
-  ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
+  drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
}
FREE(scanout);
 }
@@ -99,7 +98,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
   return NULL;
 
/* create dumb buffer at scanout GPU */
-   err = ioctl(ro->kms_fd, DRM_IOCTL_MODE_CREATE_DUMB, _dumb);
+   err = drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_CREATE_DUMB, _dumb);
if (err < 0) {
   fprintf(stderr, "DRM_IOCTL_MODE_CREATE_DUMB failed: %s\n",
 strerror(errno));
@@ -136,7 +135,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
 
 free_dumb:
destroy_dumb.handle = scanout->handle;
-   ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
+   drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
 
 free_scanout:
FREE(scanout);
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] renderonly: drop resources on destroy

2017-04-28 Thread Philipp Zabel
On Fri, 2017-04-28 at 11:19 +0100, Emil Velikov wrote:
> On 27 April 2017 at 17:44, Philipp Zabel <p.za...@pengutronix.de> wrote:
> > The renderonly_scanout holds a reference on its prime pipe resource,
> > which should be released when it is destroyed. If it was created by
> > renderonly_create_kms_dumb_buffer_for_resource, the dumb BO also has
> > to be destroyed.
> >
> > Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
> Fixes: 848b49b288f ("gallium: add renderonly library")
> Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>
> 
> > +  ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
> This and there other two instances should be drmIoctl, but that can
> happen with a later patch.

Thanks, I'll send a follow-up.

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] renderonly: close transfer prime_fd

2017-04-27 Thread Philipp Zabel
prime_fd is only used to transfer the scanout buffer to the GPU inside
renderonly_create_kms_dumb_buffer_for_resource. It should be closed
immediately to avoid leaking the DMA-BUF file handle.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/gallium/auxiliary/renderonly/renderonly.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c 
b/src/gallium/auxiliary/renderonly/renderonly.c
index 7e23769159..e17c32886d 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -116,6 +116,8 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
scanout->prime = screen->resource_from_handle(screen, rsc,
  , PIPE_HANDLE_USAGE_READ_WRITE);
 
+   close(prime_fd);
+
if (!scanout->prime) {
   fprintf(stderr, "failed to create resource_from_handle: %s\n", 
strerror(errno));
   goto free_dumb;
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] renderonly: drop resources on destroy

2017-04-27 Thread Philipp Zabel
The renderonly_scanout holds a reference on its prime pipe resource,
which should be released when it is destroyed. If it was created by
renderonly_create_kms_dumb_buffer_for_resource, the dumb BO also has
to be destroyed.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/gallium/auxiliary/renderonly/renderonly.c  | 11 ++-
 src/gallium/auxiliary/renderonly/renderonly.h  |  3 ++-
 src/gallium/drivers/etnaviv/etnaviv_resource.c |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c 
b/src/gallium/auxiliary/renderonly/renderonly.c
index e17c32886d..f377c368e5 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -34,6 +34,7 @@
 
 #include "state_tracker/drm_driver.h"
 #include "pipe/p_screen.h"
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 
 struct renderonly *
@@ -65,8 +66,16 @@ renderonly_scanout_for_prime(struct pipe_resource *rsc, 
struct renderonly *ro)
 }
 
 void
-renderonly_scanout_destroy(struct renderonly_scanout *scanout)
+renderonly_scanout_destroy(struct renderonly_scanout *scanout,
+  struct renderonly *ro)
 {
+   struct drm_mode_destroy_dumb destroy_dumb = { };
+
+   pipe_resource_reference(>prime, NULL);
+   if (ro->kms_fd != -1) {
+  destroy_dumb.handle = scanout->handle;
+  ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, _dumb);
+   }
FREE(scanout);
 }
 
diff --git a/src/gallium/auxiliary/renderonly/renderonly.h 
b/src/gallium/auxiliary/renderonly/renderonly.h
index 28989f202d..d543073298 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.h
+++ b/src/gallium/auxiliary/renderonly/renderonly.h
@@ -77,7 +77,8 @@ struct renderonly_scanout *
 renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro);
 
 void
-renderonly_scanout_destroy(struct renderonly_scanout *scanout);
+renderonly_scanout_destroy(struct renderonly_scanout *scanout,
+  struct renderonly *ro);
 
 static inline boolean
 renderonly_get_handle(struct renderonly_scanout *scanout,
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 2c5e9298e5..0e37345c0c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -305,7 +305,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct 
pipe_resource *prsc)
   etna_bo_del(rsc->ts_bo);
 
if (rsc->scanout)
-  renderonly_scanout_destroy(rsc->scanout);
+  renderonly_scanout_destroy(rsc->scanout, etna_screen(pscreen)->ro);
 
list_delinit(>list);
 
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: SINGLE_BUFFER support on GC3000

2017-04-13 Thread Philipp Zabel
Hi Wladimir,

On Thu, 2017-04-13 at 16:05 +0200, Wladimir J. van der Laan wrote:
> This patch adds support for the SINGLE_BUFFER feature on GC3000
> GPUs, which allows rendering to a single buffer using multiple pixel
> pipes.
> 
> This feature is always used when it is available, which means that
> multi-tiled formats are no longer being used in that case, and all
> buffers will be normal (super)tiled. This mimics the behavior of the
> blob on GC3000.
> 
> - Because the same format can be used to render to and texture from,
>   this avoids an extra resolve pass when rendering to texture.
> 
> - i.MX6qp includes a PRE which can scan-out directly from tiled formats,
>   avoiding untiling overhead.
>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_context.c  |  3 +++
>  src/gallium/drivers/etnaviv/etnaviv_emit.c |  6 --
>  src/gallium/drivers/etnaviv/etnaviv_internal.h |  3 +++
>  src/gallium/drivers/etnaviv/etnaviv_resource.c |  9 +++-
>  src/gallium/drivers/etnaviv/etnaviv_rs.c   | 29 
> ++
>  src/gallium/drivers/etnaviv/etnaviv_screen.c   |  5 +
>  src/gallium/drivers/etnaviv/etnaviv_state.c| 10 +++--
>  src/gallium/drivers/etnaviv/etnaviv_surface.c  | 21 +--
>  8 files changed, 66 insertions(+), 20 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index 555aa12..f2f709c 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -293,6 +293,9 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
> *stream, void *priv)
> etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
> etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
>  
> +   /* Enable SINGLE_BUFFER for resolve, if supported */
> +   etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
> COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
> +
> ctx->dirty = ~0L;
>  
> /* go through all the used resources and clear their status flag */
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_emit.c
> index af74cbb..7ced5fc 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
> @@ -603,10 +603,12 @@ etna_emit_state(struct etna_context *ctx)
> if (unlikely(dirty & (ETNA_DIRTY_STENCIL_REF))) {
>/*014A0*/ EMIT_STATE(PE_STENCIL_CONFIG_EXT, 
> ctx->stencil_ref.PE_STENCIL_CONFIG_EXT);
> }
> +   if (unlikely(dirty & (ETNA_DIRTY_BLEND | ETNA_DIRTY_FRAMEBUFFER))) {
> +  struct etna_blend_state *blend = etna_blend_state(ctx->blend);
> +  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP | 
> ctx->framebuffer.PE_LOGIC_OP);
> +   }
> if (unlikely(dirty & (ETNA_DIRTY_BLEND))) {
>struct etna_blend_state *blend = etna_blend_state(ctx->blend);
> -
> -  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP);
>for (int x = 0; x < 2; ++x) {
>   /*014A8*/ EMIT_STATE(PE_DITHER(x), blend->PE_DITHER[x]);
>}
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
> b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> index 2f09d55..2f8dacb 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> @@ -72,6 +72,8 @@ struct etna_specs {
> unsigned has_shader_range_registers : 1;
> /* has the new sin/cos functions */
> unsigned has_new_sin_cos : 1;
> +   /* supports single-buffer rendering with multiple pixel pipes */
> +   unsigned single_buffer : 1;
> /* can use any kind of wrapping mode on npot textures */
> unsigned npot_tex_any_wrap;
> /* number of bits per TS tile */
> @@ -191,6 +193,7 @@ struct compiled_framebuffer_state {
> uint32_t TS_COLOR_CLEAR_VALUE;
> struct etna_reloc TS_COLOR_STATUS_BASE;
> struct etna_reloc TS_COLOR_SURFACE_BASE;
> +   uint32_t PE_LOGIC_OP;
> bool msaa_mode; /* adds input (and possible temp) to PS */
>  };
>  
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 1f0582c..b4e853f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -248,9 +248,16 @@ etna_resource_create(struct pipe_screen *pscreen,
>if (util_format_is_compressed(templat->format))
>   layout = ETNA_LAYOUT_LINEAR;
> } else if (templat->target != PIPE_BUFFER) {
> -  bool want_multitiled = screen->specs.pixel_pipes > 1;
> +  bool want_multitiled = false;
>bool want_supertiled = screen->specs.can_supertile && 
> !DBG_ENABLED(ETNA_DBG_NO_SUPERTILE);
>  
> +  /* When this GPU supports single-buffer rendering, don't ever enable
> +   * multi-tiling. This replicates the blob behavior on GC3000.
> +   */
> +  if (!screen->specs.single_buffer) {
> + want_multitiled = screen->specs.pixel_pipes > 

[Mesa-dev] [PATCH] etnaviv: increment the resource seqno in resource_changed

2017-04-12 Thread Philipp Zabel
Just increment the resource seqno instead of setting the texture
seqno to be lower by one than the resource seqno.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 5f2b63f97c..32e0b15e45 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -283,11 +283,7 @@ etna_resource_changed(struct pipe_screen *pscreen, struct 
pipe_resource *prsc)
 {
struct etna_resource *res = etna_resource(prsc);
 
-   /* Make sure texture is older than the imported renderable buffer,
-* so etna_update_sampler_source will copy the pixel data again.
-*/
-   if (res->texture)
-  etna_resource(res->texture)->seqno = res->seqno - 1;
+   res->seqno++;
 }
 
 static void
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


  1   2   >