Re: [Mesa-dev] [PATCH] etnaviv: make use of TEXTURE_TYPE_1D

2017-10-26 Thread Christian Gmeiner
2017-10-26 9:45 GMT+02:00 Lucas Stach <l.st...@pengutronix.de>:
> Am Donnerstag, den 26.10.2017, 03:17 +0200 schrieb Christian Gmeiner:
>> Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
>
> Has this been tested on older GPU cores like the GC600?
>

Not yet... only looked what binary blob is using.

>> ---
>>  src/gallium/drivers/etnaviv/etnaviv_texture.c | 7 ++-
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c
>> b/src/gallium/drivers/etnaviv/etnaviv_texture.c
>> index b8ebab6082..f71169d227 100644
>> --- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
>> +++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
>> @@ -212,11 +212,8 @@ etna_create_sampler_view(struct pipe_context
>> *pctx, struct pipe_resource *prsc,
>>
>> switch (sv->base.target) {
>> case PIPE_TEXTURE_1D:
>> -  /* For 1D textures, we will have a height of 1, so we can use
>> 2D
>> -   * but set T wrap to repeat */
>> -  sv->TE_SAMPLER_CONFIG0_MASK =
>> ~VIVS_TE_SAMPLER_CONFIG0_VWRAP__MASK;
>> -  sv->TE_SAMPLER_CONFIG0 |=
>> VIVS_TE_SAMPLER_CONFIG0_VWRAP(TEXTURE_WRAPMODE_REPEAT);
>> -  /* fallthrough */
>> +  sv->TE_SAMPLER_CONFIG0 |=
>> VIVS_TE_SAMPLER_CONFIG0_TYPE(TEXTURE_TYPE_1D);
>> +  break;
>> case PIPE_TEXTURE_2D:
>> case PIPE_TEXTURE_RECT:
>>sv->TE_SAMPLER_CONFIG0 |=
>> VIVS_TE_SAMPLER_CONFIG0_TYPE(TEXTURE_TYPE_2D);

greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] etnaviv: dirty TS state when framebuffer has changed

2018-01-21 Thread Christian Gmeiner
2018-01-11 11:29 GMT+01:00 Lucas Stach <l.st...@pengutronix.de>:
> When switching between framebuffers with and without TS, the TS state
> needs to be flushed to the command stream even if the derived state
> isn't changed.
>
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

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

> ---
>  src/gallium/drivers/etnaviv/etnaviv_state.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c 
> b/src/gallium/drivers/etnaviv/etnaviv_state.c
> index b859f40c29fe..e4ad0f62f176 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_state.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
> @@ -611,7 +611,8 @@ etna_update_ts_config(struct etna_context *ctx)
>}
> }
>
> -   if (new_ts_config != ctx->framebuffer.TS_MEM_CONFIG) {
> +   if (new_ts_config != ctx->framebuffer.TS_MEM_CONFIG ||
> +   (ctx->dirty & ETNA_DIRTY_FRAMEBUFFER)) {
>ctx->framebuffer.TS_MEM_CONFIG = new_ts_config;
>ctx->dirty |= ETNA_DIRTY_TS;
> }
> --
> 2.11.0
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] etnaviv: add useful information to BO import errors

2018-02-13 Thread Christian Gmeiner
2018-02-12 15:25 GMT+01:00 Lucas Stach <l.st...@pengutronix.de>:
> From: Philipp Zabel <p.za...@pengutronix.de>
>
> Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>

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

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index d70152e082dd..4365947a1573 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -535,11 +535,15 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>  * The stride of the BO must be greater or equal to our padded
>  * stride. The size of the BO must accomodate the padded height. */
> if (level->stride < util_format_get_stride(tmpl->format, 
> level->padded_width)) {
> -  BUG("BO stride is too small for RS engine width padding");
> +  BUG("BO stride %u is too small for RS engine width padding (%u, format 
> %s)",
> +  level->stride, util_format_get_stride(tmpl->format, 
> level->padded_width),
> +  util_format_name(tmpl->format));
>goto fail;
> }
> if (etna_bo_size(rsc->bo) < level->stride * level->padded_height) {
> -  BUG("BO size is too small for RS engine height padding");
> +  BUG("BO size %u is too small for RS engine height padding (%u, format 
> %s)",
> +  etna_bo_size(rsc->bo), level->stride * level->padded_height,
> +  util_format_name(tmpl->format));
>goto fail;
>     }
>
> --
> 2.15.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 1/3] etnaviv: add debug switch to disable single buffer feature

2018-02-13 Thread Christian Gmeiner
2018-02-06 10:36 GMT+01:00 Lucas Stach <l.st...@pengutronix.de>:
> This feature has caused some trouble already. Add a debug switch to
> allow users to quickly check if a specific issue is caused by this
> feature.
>
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

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

> ---
>  src/gallium/drivers/etnaviv/etnaviv_debug.h  | 1 +
>  src/gallium/drivers/etnaviv/etnaviv_screen.c | 3 +++
>  2 files changed, 4 insertions(+)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_debug.h 
> b/src/gallium/drivers/etnaviv/etnaviv_debug.h
> index f47dffe59008..4051e95dd5fb 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_debug.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_debug.h
> @@ -52,6 +52,7 @@
>  #define ETNA_DBG_ZERO0x20 /* Zero all resources after 
> allocation */
>  #define ETNA_DBG_DRAW_STALL  0x40 /* Stall FE/PE after every draw op 
> */
>  #define ETNA_DBG_SHADERDB0x80 /* dump program compile 
> information */
> +#define ETNA_DBG_NO_SINGLEBUF0x100 /* disable single buffer feature 
> */
>
>  extern int etna_mesa_debug; /* set in etna_screen.c from ETNA_DEBUG */
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index d5d1f4fdad2c..7b4034641d18 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -68,6 +68,7 @@ static const struct debug_named_value debug_options[] = {
> {"zero",   ETNA_DBG_ZERO, "Zero all resources after allocation"},
> {"draw_stall", ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered 
> primitive"},
> {"shaderdb",   ETNA_DBG_SHADERDB, "Enable shaderdb output"},
> +   {"no_singlebuffer",ETNA_DBG_NO_SINGLEBUF, "Disable single buffer 
> feature"},
> DEBUG_NAMED_VALUE_END
>  };
>
> @@ -967,6 +968,8 @@ etna_screen_create(struct etna_device *dev, struct 
> etna_gpu *gpu,
>screen->features[viv_chipMinorFeatures1] &= 
> ~chipMinorFeatures1_AUTO_DISABLE;
> if (DBG_ENABLED(ETNA_DBG_NO_SUPERTILE))
>screen->specs.can_supertile = 0;
> +   if (DBG_ENABLED(ETNA_DBG_NO_SINGLEBUF))
> +  screen->specs.single_buffer = 0;
>
> pscreen->destroy = etna_screen_destroy;
> pscreen->get_param = etna_screen_get_param;
> --
> 2.15.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] etnaviv: enable glsl/tgsi on-disk cache

2018-02-20 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 36 
 src/gallium/drivers/etnaviv/etnaviv_screen.h |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 3dd628bd9b..361745214c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -79,6 +79,8 @@ etna_screen_destroy(struct pipe_screen *pscreen)
 {
struct etna_screen *screen = etna_screen(pscreen);
 
+   disk_cache_destroy(screen->disk_shader_cache);
+
if (screen->pipe)
   etna_pipe_del(screen->pipe);
 
@@ -94,6 +96,36 @@ etna_screen_destroy(struct pipe_screen *pscreen)
FREE(screen);
 }
 
+static void etna_disk_cache_create(struct etna_screen *screen)
+{
+   uint32_t mesa_timestamp;
+
+   if (disk_cache_get_function_timestamp(etna_disk_cache_create,
+ _timestamp)) {
+  char *timestamp_str;
+  int res = -1;
+
+  res = asprintf(_str, "%u", mesa_timestamp);
+  if (res != -1) {
+ char name[128];
+
+ util_snprintf(name, sizeof(name), "gc%x_%04x", screen->model,
+   screen->revision);
+
+ screen->disk_shader_cache = disk_cache_create(name, timestamp_str, 0);
+ free(timestamp_str);
+  }
+   }
+}
+
+static struct disk_cache *
+etna_get_disk_shader_cache(struct pipe_screen *pscreen)
+{
+   struct etna_screen *priv = etna_screen(pscreen);
+
+   return priv->disk_shader_cache;
+}
+
 static const char *
 etna_screen_get_name(struct pipe_screen *pscreen)
 {
@@ -978,12 +1010,16 @@ etna_screen_create(struct etna_device *dev, struct 
etna_gpu *gpu,
pscreen->is_format_supported = etna_screen_is_format_supported;
pscreen->query_dmabuf_modifiers = etna_screen_query_dmabuf_modifiers;
 
+   pscreen->get_disk_shader_cache = etna_get_disk_shader_cache;
+
etna_fence_screen_init(pscreen);
etna_query_screen_init(pscreen);
etna_resource_screen_init(pscreen);
 
slab_create_parent(>transfer_pool, sizeof(struct etna_transfer), 
16);
 
+   etna_disk_cache_create(screen);
+
return pscreen;
 
 fail:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h 
b/src/gallium/drivers/etnaviv/etnaviv_screen.h
index dc57a38dbb..f9eb8ffe6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
@@ -33,6 +33,7 @@
 #include "os/os_thread.h"
 #include "pipe/p_screen.h"
 #include "renderonly/renderonly.h"
+#include "util/disk_cache.h"
 #include "util/slab.h"
 
 struct etna_bo;
@@ -68,6 +69,7 @@ struct etna_screen {
struct renderonly *ro;
 
struct slab_parent_pool transfer_pool;
+   struct disk_cache *disk_shader_cache;
 
uint32_t model;
uint32_t revision;
-- 
2.14.3

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


[Mesa-dev] [PATCH] etnaviv: npot_tex_any_wrap needs one bit only

2018-02-20 Thread Christian Gmeiner
Reduces size of struct etna_specs from 100 to 94 bytes.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index b8d2186433..3424d8a771 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -87,7 +87,7 @@ struct etna_specs {
/* has BLT engine instead of RS */
unsigned use_blt : 1;
/* can use any kind of wrapping mode on npot textures */
-   unsigned npot_tex_any_wrap;
+   unsigned npot_tex_any_wrap : 1;
/* number of bits per TS tile */
unsigned bits_per_tile;
/* clear value for TS (dependent on bits_per_tile) */
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] etnaviv: disable in-place resolve for non-supertiled surfaces

2018-01-01 Thread Christian Gmeiner
2017-12-19 17:35 GMT+01:00 Lucas Stach <l.st...@pengutronix.de>:
> The in-place resolve probably has some additional restrictions when not
> operating on a super tiled surface. Disable it on non-supertiled surfaces
> for now to work around a GPU hang.
>
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

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

> ---
>  src/gallium/drivers/etnaviv/etnaviv_rs.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> index 60c2c39101dd..2c9b267f724a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> @@ -126,6 +126,7 @@ etna_compile_rs_state(struct etna_context *ctx, struct 
> compiled_rs_state *cs,
>   rs->source_offset == rs->dest_offset &&
>   rs->source_format == rs->dest_format &&
>   rs->source_tiling == rs->dest_tiling &&
> + (rs->source_tiling & ETNA_LAYOUT_BIT_SUPER) &&
>   rs->source_stride == rs->dest_stride &&
>   !rs->downsample_x && !rs->downsample_y &&
>   !rs->swap_rb && !rs->flip &&
> --
> 2.11.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 1/2] loader: add loader_open_name(..)

2018-08-02 Thread Christian Gmeiner
Hi Eric

Thanks for you code review!

Am Do., 2. Aug. 2018 um 13:09 Uhr schrieb Eric Engestrom
:
>
> On Wednesday, 2018-08-01 23:07:02 +0200, Christian Gmeiner wrote:
> > Add an improved drmOpenWithType(..) clone which fixes some serious
> > flaws. Some highlights:
> >  - using busid works only with PCI devices
> >  - open() w/o O_CLOEXEC
> >  - when build w/o udev - it creates a node: mkdir, chown(root), chmod, mknod
> >  - calls back into Xserver/DDX module
> >  - last but no least - borderline hacks with massive documentation [1]
> >to keep this running.
> >
> > Signed-off-by: Christian Gmeiner 
>
> The idea sounds good, but I have a few remarks below.
>
> > ---
> >  src/loader/loader.c | 79 +
> >  src/loader/loader.h |  3 ++
> >  2 files changed, 82 insertions(+)
> >
> > diff --git a/src/loader/loader.c b/src/loader/loader.c
> > index 43275484cc..c2d2122bb8 100644
> > --- a/src/loader/loader.c
> > +++ b/src/loader/loader.c
> > @@ -82,6 +82,85 @@ loader_open_device(const char *device_name)
> > return fd;
> >  }
> >
> > +static int
> > +open_minor(int minor, int type)
> > +{
> > +   const char *dev_name;
> > +   char buf[64];
> > +
> > +   switch (type) {
> > +   case DRM_NODE_PRIMARY:
> > +  dev_name = DRM_DEV_NAME;
> > +  break;
> > +   case DRM_NODE_CONTROL:
> > +  dev_name = DRM_CONTROL_DEV_NAME;
> > +  break;
> > +   case DRM_NODE_RENDER:
> > +  dev_name = DRM_RENDER_DEV_NAME;
> > +  break;
> > +   default:
> > +  return -EINVAL;
>
> This function is returning an fd, so this should be -1.
> That said, giving an invalid type here is a serious misuse of the api,
> so I think you should replace the default return here and below ([1])
> with an `unreachable("invalid DRM node type");`
>

Good idea.

> > +   };
>
> Nit: no need for `;` after a switch
>
> > +
> > +   sprintf(buf, dev_name, DRM_DIR_NAME, minor);
>
> unlikely, but you should probably use snprintf(buf, sizeof(buf), ...)
>
> You should also use the `util_*` versions from u_string.h for
> compatibility with toolchains that don't support them natively.
>

Will be changed in v2.

> > +
> > +   return loader_open_device(buf);
> > +}
> > +
> > +static int minor_base(int type)
> > +{
> > +switch (type) {
> > +case DRM_NODE_PRIMARY:
> > +return 0;
> > +case DRM_NODE_CONTROL:
> > +return 64;
> > +case DRM_NODE_RENDER:
> > +return 128;
> > +default:
> > +return -1;
>
> [1] ^ to replace with unreachable()
>

yep

> > +};
>
> (`;` again)
>
> > +}
> > +
> > +int
> > +loader_open_name(const char *name, int type)
> > +{
> > +   int base = minor_base(type);
> > +   drmVersionPtr version;
> > +   int i, fd;
> > +   char *id;
> > +
> > +   if (base < 0)
> > +  return -1;
>
> with unreachable() above, this can go
>

correct

> > +
> > +   /*
> > +   * Open the first minor number that matches the driver name and isn't
> > +   * already in use.  If it's in use it will have a busid assigned already.
> > +   */
> > +   for (i = base; i < base + DRM_MAX_MINOR; i++) {
> > +  if ((fd = open_minor(i, type)) >= 0) {
> > + if ((version = drmGetVersion(fd))) {
> > +if (!strcmp(version->name, name)) {
>
> I would suggest inverting these `if`s to avoid nesting so deep.
>

Makes lot of sense - yes.

> > +   drmFreeVersion(version);
> > +   id = drmGetBusid(fd);
> > +   drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
> > +   if (!id || !*id) {
> > +  if (id)
> > + drmFreeBusid(id);
> > +  return fd;
>
> This condition looks wrong; surely you want to keep the one that has
> a bus id, not the one that doesn't?
>
> The `if(!id) if(id)` also looks weird; I suggest rewriting this bit of
> your code. Flattening your logic should also make it more readable.
>

Btw, you have just reviewed big parts of existing stuff I have taken
1:1 which can be found here :)
https://cgit.freedesktop.org/mesa/drm/tree/xf86drm.c

> > +   } else {
> > +  drmFreeBusid(id);
> > +   }
> > +} else {
> > +   drmFreeVersion(version);
> > +}
> > +  

[Mesa-dev] [PATCH v2 01/11] util/list: Make some helpers take const lists

2018-07-29 Thread Christian Gmeiner
Reviewed-by: Christian Gmeiner 

Jason Ekstrand  schrieb am So., 29. Juli 2018, 07:46:

> They're all just querying things about the list and not mutating
> anything.
>
> Reviewed-by: Thomas Helland
> ---
>  src/util/list.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/util/list.h b/src/util/list.h
> index 6edb7501109..09d1b4cae64 100644
> --- a/src/util/list.h
> +++ b/src/util/list.h
> @@ -72,7 +72,7 @@ static inline void list_addtail(struct list_head *item,
> struct list_head *list)
>  list->prev = item;
>  }
>
> -static inline bool list_empty(struct list_head *list);
> +static inline bool list_empty(const struct list_head *list);
>
>  static inline void list_replace(struct list_head *from, struct list_head
> *to)
>  {
> @@ -101,7 +101,7 @@ static inline void list_delinit(struct list_head *item)
>  item->prev = item;
>  }
>
> -static inline bool list_empty(struct list_head *list)
> +static inline bool list_empty(const struct list_head *list)
>  {
> return list->next == list;
>  }
> @@ -114,7 +114,7 @@ static inline bool list_is_singular(const struct
> list_head *list)
> return list->next != NULL && list->next != list && list->next->next ==
> list;
>  }
>
> -static inline unsigned list_length(struct list_head *list)
> +static inline unsigned list_length(const struct list_head *list)
>  {
> struct list_head *node;
> unsigned length = 0;
> @@ -145,7 +145,7 @@ static inline void list_splicetail(struct list_head
> *src, struct list_head *dst)
> dst->prev = src->prev;
>  }
>
> -static inline void list_validate(struct list_head *list)
> +static inline void list_validate(const struct list_head *list)
>  {
> struct list_head *node;
> assert(list->next->prev == list && list->prev->next == list);
> --
> 2.17.1
>
> _______
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>

 --
Christian Gmeiner, MSc

https://christian-gmeiner.info

-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH 1/2] loader: add loader_open_name(..)

2018-08-01 Thread Christian Gmeiner
Add an improved drmOpenWithType(..) clone which fixes some serious
flaws. Some highlights:
 - using busid works only with PCI devices
 - open() w/o O_CLOEXEC
 - when build w/o udev - it creates a node: mkdir, chown(root), chmod, mknod
 - calls back into Xserver/DDX module
 - last but no least - borderline hacks with massive documentation [1]
   to keep this running.

Signed-off-by: Christian Gmeiner 
---
 src/loader/loader.c | 79 +
 src/loader/loader.h |  3 ++
 2 files changed, 82 insertions(+)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 43275484cc..c2d2122bb8 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -82,6 +82,85 @@ loader_open_device(const char *device_name)
return fd;
 }
 
+static int
+open_minor(int minor, int type)
+{
+   const char *dev_name;
+   char buf[64];
+
+   switch (type) {
+   case DRM_NODE_PRIMARY:
+  dev_name = DRM_DEV_NAME;
+  break;
+   case DRM_NODE_CONTROL:
+  dev_name = DRM_CONTROL_DEV_NAME;
+  break;
+   case DRM_NODE_RENDER:
+  dev_name = DRM_RENDER_DEV_NAME;
+  break;
+   default:
+  return -EINVAL;
+   };
+
+   sprintf(buf, dev_name, DRM_DIR_NAME, minor);
+
+   return loader_open_device(buf);
+}
+
+static int minor_base(int type)
+{
+switch (type) {
+case DRM_NODE_PRIMARY:
+return 0;
+case DRM_NODE_CONTROL:
+return 64;
+case DRM_NODE_RENDER:
+return 128;
+default:
+return -1;
+};
+}
+
+int
+loader_open_name(const char *name, int type)
+{
+   int base = minor_base(type);
+   drmVersionPtr version;
+   int i, fd;
+   char *id;
+
+   if (base < 0)
+  return -1;
+
+   /*
+   * Open the first minor number that matches the driver name and isn't
+   * already in use.  If it's in use it will have a busid assigned already.
+   */
+   for (i = base; i < base + DRM_MAX_MINOR; i++) {
+  if ((fd = open_minor(i, type)) >= 0) {
+ if ((version = drmGetVersion(fd))) {
+if (!strcmp(version->name, name)) {
+   drmFreeVersion(version);
+   id = drmGetBusid(fd);
+   drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
+   if (!id || !*id) {
+  if (id)
+ drmFreeBusid(id);
+  return fd;
+   } else {
+  drmFreeBusid(id);
+   }
+} else {
+   drmFreeVersion(version);
+}
+ }
+ close(fd);
+  }
+   }
+
+   return -1;
+}
+
 #if defined(HAVE_LIBDRM)
 #ifdef USE_DRICONF
 static const char __driConfigOptionsLoader[] =
diff --git a/src/loader/loader.h b/src/loader/loader.h
index 3859b45dc4..7e1612301a 100644
--- a/src/loader/loader.h
+++ b/src/loader/loader.h
@@ -38,6 +38,9 @@ extern "C" {
 int
 loader_open_device(const char *);
 
+int
+loader_open_name(const char *name, int type);
+
 int
 loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/2] imx: make use of loader_open_name(..)

2018-08-01 Thread Christian Gmeiner
Gets rid of hard-coded gpu device path.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/winsys/imx/drm/imx_drm_winsys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/winsys/imx/drm/imx_drm_winsys.c 
b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
index cd72610b95..9678a0b8d4 100644
--- a/src/gallium/winsys/imx/drm/imx_drm_winsys.c
+++ b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
@@ -36,7 +36,7 @@ struct pipe_screen *imx_drm_screen_create(int fd)
struct renderonly ro = {
   .create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
   .kms_fd = fd,
-  .gpu_fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC)
+  .gpu_fd = loader_open_name("etnaviv", DRM_NODE_RENDER)
};
 
if (ro.gpu_fd < 0)
-- 
2.17.1

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


[Mesa-dev] [PATCH] etnaviv: fix typo in query names

2018-07-30 Thread Christian Gmeiner
Fixes: d0bed0b4944d ("etnaviv: support HI performance counters")
Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 981cfd2c4d..ade0b9790c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -59,7 +59,7 @@ static const char *group_names[] = {
 
 static const struct etna_perfmon_config query_config[] = {
{
-  .name = "hi-total-cyles",
+  .name = "hi-total-cycles",
   .type = ETNA_QUERY_HI_TOTAL_CYCLES,
   .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
@@ -67,7 +67,7 @@ static const struct etna_perfmon_config query_config[] = {
   }
},
{
-  .name = "hi-idle-cyles",
+  .name = "hi-idle-cycles",
   .type = ETNA_QUERY_HI_IDLE_CYCLES,
   .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
-- 
2.17.1

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


[Mesa-dev] [PATCH 4/4] imx: make use of loader_open_render_node(..) helper

2018-08-08 Thread Christian Gmeiner
Gets rid of hard-coded gpu device path.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/winsys/imx/drm/imx_drm_winsys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/imx/drm/imx_drm_winsys.c 
b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
index cd72610b95..4bd2125031 100644
--- a/src/gallium/winsys/imx/drm/imx_drm_winsys.c
+++ b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
@@ -26,6 +26,7 @@
 
 #include "imx_drm_public.h"
 #include "etnaviv/drm/etnaviv_drm_public.h"
+#include "loader/loader.h"
 #include "renderonly/renderonly.h"
 
 #include 
@@ -36,7 +37,7 @@ struct pipe_screen *imx_drm_screen_create(int fd)
struct renderonly ro = {
   .create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
   .kms_fd = fd,
-  .gpu_fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC)
+  .gpu_fd = loader_open_render_node("etnaviv")
};
 
if (ro.gpu_fd < 0)
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/4] loader: add loader_open_render_node(..)

2018-08-08 Thread Christian Gmeiner
This helper is almost a 1:1 copy of tegra_open_render_node().

Signed-off-by: Christian Gmeiner 
---
 src/loader/loader.c | 65 +
 src/loader/loader.h |  3 +++
 2 files changed, 68 insertions(+)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 43275484cc..60b5d71083 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -83,6 +83,65 @@ loader_open_device(const char *device_name)
 }
 
 #if defined(HAVE_LIBDRM)
+int
+loader_open_render_node(const char *name)
+{
+   drmDevicePtr *devices, device;
+   int err, render = -ENOENT, fd;
+   unsigned int num, i;
+
+   err = drmGetDevices2(0, NULL, 0);
+   if (err < 0)
+  return err;
+
+   num = err;
+
+   devices = calloc(num, sizeof(*devices));
+   if (!devices)
+  return -ENOMEM;
+
+   err = drmGetDevices2(0, devices, num);
+   if (err < 0) {
+  render = err;
+  goto free;
+   }
+
+   for (i = 0; i < num; i++) {
+  device = devices[i];
+
+  if ((device->available_nodes & (1 << DRM_NODE_RENDER)) &&
+  (device->bustype == DRM_BUS_PLATFORM)) {
+ drmVersionPtr version;
+
+ fd = open(device->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC);
+ if (fd < 0)
+continue;
+
+ version = drmGetVersion(fd);
+ if (!version) {
+close(fd);
+continue;
+ }
+
+ if (strcmp(version->name, name) != 0) {
+drmFreeVersion(version);
+close(fd);
+continue;
+ }
+
+ drmFreeVersion(version);
+ render = fd;
+ break;
+  }
+   }
+
+   drmFreeDevices(devices, num);
+
+free:
+   free(devices);
+   return render;
+}
+
 #ifdef USE_DRICONF
 static const char __driConfigOptionsLoader[] =
 DRI_CONF_BEGIN
@@ -262,6 +321,12 @@ int loader_get_user_preferred_fd(int default_fd, bool 
*different_device)
return default_fd;
 }
 #else
+int
+loader_open_render_node(const char *name)
+{
+   return -1;
+}
+
 int loader_get_user_preferred_fd(int default_fd, bool *different_device)
 {
*different_device = false;
diff --git a/src/loader/loader.h b/src/loader/loader.h
index 3859b45dc4..7b4dd01144 100644
--- a/src/loader/loader.h
+++ b/src/loader/loader.h
@@ -38,6 +38,9 @@ extern "C" {
 int
 loader_open_device(const char *);
 
+int
+loader_open_render_node(const char *name);
+
 int
 loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 3/4] tegra: make use loader_open_render_node(..) helper

2018-08-08 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/tegra/tegra_screen.c | 61 +---
 1 file changed, 2 insertions(+), 59 deletions(-)

diff --git a/src/gallium/drivers/tegra/tegra_screen.c 
b/src/gallium/drivers/tegra/tegra_screen.c
index 361ec034de..243bdde8d2 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 
+#include "loader/loader.h"
 #include "pipe/p_state.h"
 #include "util/u_debug.h"
 #include "util/u_inlines.h"
@@ -163,64 +164,6 @@ tegra_screen_can_create_resource(struct pipe_screen 
*pscreen,
return screen->gpu->can_create_resource(screen->gpu, template);
 }
 
-static int tegra_open_render_node(void)
-{
-   drmDevicePtr *devices, device;
-   int err, render = -ENOENT, fd;
-   unsigned int num, i;
-
-   err = drmGetDevices2(0, NULL, 0);
-   if (err < 0)
-  return err;
-
-   num = err;
-
-   devices = calloc(num, sizeof(*devices));
-   if (!devices)
-  return -ENOMEM;
-
-   err = drmGetDevices2(0, devices, num);
-   if (err < 0) {
-  render = err;
-  goto free;
-   }
-
-   for (i = 0; i < num; i++) {
-  device = devices[i];
-
-  if ((device->available_nodes & (1 << DRM_NODE_RENDER)) &&
-  (device->bustype == DRM_BUS_PLATFORM)) {
- drmVersionPtr version;
-
- fd = open(device->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC);
- if (fd < 0)
-continue;
-
- version = drmGetVersion(fd);
- if (!version) {
-drmFreeVersion(version);
-close(fd);
-continue;
- }
-
- if (strcmp(version->name, "nouveau") != 0) {
-close(fd);
-continue;
- }
-
- drmFreeVersion(version);
- render = fd;
- break;
-  }
-   }
-
-   drmFreeDevices(devices, num);
-
-free:
-   free(devices);
-   return render;
-}
-
 static int tegra_screen_import_resource(struct tegra_screen *screen,
 struct tegra_resource *resource)
 {
@@ -594,7 +537,7 @@ tegra_screen_create(int fd)
 
screen->fd = fd;
 
-   screen->gpu_fd = tegra_open_render_node();
+   screen->gpu_fd = loader_open_render_node("nouveau");
if (screen->gpu_fd < 0) {
   if (errno != ENOENT)
  fprintf(stderr, "failed to open GPU device: %s\n", strerror(errno));
-- 
2.17.1

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


[Mesa-dev] [PATCH 1/4] tegra: fix memory leak

2018-08-08 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/tegra/tegra_screen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/tegra/tegra_screen.c 
b/src/gallium/drivers/tegra/tegra_screen.c
index 034ea271ee..361ec034de 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -198,6 +198,7 @@ static int tegra_open_render_node(void)
 
  version = drmGetVersion(fd);
  if (!version) {
+drmFreeVersion(version);
 close(fd);
 continue;
  }
-- 
2.17.1

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


[Mesa-dev] [PATCH 0/4] Add and make use of loader_open_render_node(..)

2018-08-08 Thread Christian Gmeiner
Factor out tegra_open_render_node() into a helper and make use of it.

Suggested-by: Emil Velikov 

Christian Gmeiner (4):
  tegra: fix memory leak
  loader: add loader_open_render_node(..)
  tegra: make use loader_open_render_node(..) helper
  imx: make use of loader_open_render_node(..) helper

 src/gallium/drivers/tegra/tegra_screen.c| 60 +--
 src/gallium/winsys/imx/drm/imx_drm_winsys.c |  3 +-
 src/loader/loader.c | 65 +
 src/loader/loader.h |  3 +
 4 files changed, 72 insertions(+), 59 deletions(-)

-- 
2.17.1

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


Re: [Mesa-dev] [PATCH 1/4] tegra: fix memory leak

2018-08-09 Thread Christian Gmeiner
Am Do., 9. Aug. 2018 um 12:23 Uhr schrieb Emil Velikov
:
>
> On 9 August 2018 at 06:12, Christian Gmeiner
>  wrote:
> > Signed-off-by: Christian Gmeiner 
> > ---
> >  src/gallium/drivers/tegra/tegra_screen.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/gallium/drivers/tegra/tegra_screen.c 
> > b/src/gallium/drivers/tegra/tegra_screen.c
> > index 034ea271ee..361ec034de 100644
> > --- a/src/gallium/drivers/tegra/tegra_screen.c
> > +++ b/src/gallium/drivers/tegra/tegra_screen.c
> > @@ -198,6 +198,7 @@ static int tegra_open_render_node(void)
> >
> >   version = drmGetVersion(fd);
> >   if (!version) {
> > +drmFreeVersion(version);
> This should be in the next if hunk - the strcmp() call.

Yeah... that is what I wanted initially - but hacking to early in the
morning (and in the train)
does not seems to be my thing.

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [1/2] loader: add loader_open_name(..)

2018-08-14 Thread Christian Gmeiner
Am Fr., 10. Aug. 2018 um 19:52 Uhr schrieb Emil Velikov
:
>
> On 10 August 2018 at 13:25, Martin Fuzzey  
> wrote:
> > Hi Christian,
> >
> > On 01/08/18 23:07, Christian Gmeiner wrote:
> >>
> >> Add an improved drmOpenWithType(..) clone which fixes some serious
> >> flaws. Some highlights:
> >>   - using busid works only with PCI devices
> >>   - open() w/o O_CLOEXEC
> >>   - when build w/o udev - it creates a node: mkdir, chown(root), chmod,
> >> mknod
> >>   - calls back into Xserver/DDX module
> >>   - last but no least - borderline hacks with massive documentation [1]
> >> to keep this running.
> >>
> >> Signed-off-by: Christian Gmeiner 
> >
> >
> > Why do this in mesa rather than fixing (or adding a new version if necessary
> > for backwards compatibility) to the libdrm code?
> >
> By fixing the libdrm code, we'll break old users - something that is a
> no-go for open-source projects.

If we add a complete new api function to libdrm and it gets accepted I am okay
to put my effort into this direction.

> I've been slowly chipping on libdrm3 for far too long. Sadly it's not
> the most enjoyable thing to hack on in one's spare time.
>

libdrm3 sounds interesting... do you have some more information about
this beast?

> FWIW, Christian's second take on the topic is here [1].
>

Which I have planed to push by the end of the week.

> HTH
> Emil
>
> [1] https://patchwork.freedesktop.org/series/47923/



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] st/nir: Fix st_nir_opts() prototype.

2018-07-25 Thread Christian Gmeiner
Reviewed-by: Christian Gmeiner 

--
Christian Gmeiner, MSc

https://christian-gmeiner.info

Kenneth Graunke  schrieb am Di., 24. Juli 2018,
23:55:

> This wasn't updated for the new scalar ISA parameter.  It worked anyway
> because all the function's callers live in the same file, so it found
> the correct function.  Tim made this external for the new st prog_to_nir
> translator, which got reverted, but which I'd like to land eventually.
>
> So, fix the prototype.
> ---
>  src/mesa/state_tracker/st_nir.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/state_tracker/st_nir.h
> b/src/mesa/state_tracker/st_nir.h
> index 15f1ce93e5a..aa6e32758e8 100644
> --- a/src/mesa/state_tracker/st_nir.h
> +++ b/src/mesa/state_tracker/st_nir.h
> @@ -42,7 +42,7 @@ void st_finalize_nir(struct st_context *st, struct
> gl_program *prog,
>   struct gl_shader_program *shader_program,
>   struct nir_shader *nir);
>
> -void st_nir_opts(struct nir_shader *nir);
> +void st_nir_opts(struct nir_shader *nir, bool is_scalar);
>
>  bool
>  st_link_nir(struct gl_context *ctx,
> --
> 2.18.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] nir: add lowering for ffloor

2018-09-01 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/compiler/nir/nir.h| 3 +++
 src/compiler/nir/nir_opt_algebraic.py | 1 +
 2 files changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 169fa1fa20..d81eefc032 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2054,6 +2054,9 @@ typedef struct nir_shader_compiler_options {
 */
bool fdot_replicates;
 
+   /** lowers ffloor to fsub+ffract: */
+   bool lower_ffloor;
+
/** lowers ffract to fsub+ffloor: */
bool lower_ffract;
 
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index ae1261f874..3d2b861a42 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -118,6 +118,7 @@ optimizations = [
(('~flrp', a, 0.0, c), ('fadd', ('fmul', ('fneg', a), c), a)),
(('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
'options->lower_flrp32'),
(('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
'options->lower_flrp64'),
+   (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
(('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
(('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c, ('fmul', b, 
('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
(('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, 
c )), ('flrp', a, b, c), '!options->lower_flrp32'),
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/2] nir: add lowering for fceil

2018-09-01 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/compiler/nir/nir.h| 3 +++
 src/compiler/nir/nir_opt_algebraic.py | 1 +
 2 files changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index d81eefc032..1dcc221777 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2057,6 +2057,9 @@ typedef struct nir_shader_compiler_options {
/** lowers ffloor to fsub+ffract: */
bool lower_ffloor;
 
+   /** lowers fceil to fadd+ffract: */
+   bool lower_fceil;
+
/** lowers ffract to fsub+ffloor: */
bool lower_ffract;
 
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 3d2b861a42..43a1642aa5 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -119,6 +119,7 @@ optimizations = [
(('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
'options->lower_flrp32'),
(('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
'options->lower_flrp64'),
(('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
+   (('fceil', a), ('fadd', a, ('ffract', a)), 'options->lower_fceil'),
(('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
(('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c, ('fmul', b, 
('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
(('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, 
c )), ('flrp', a, b, c), '!options->lower_flrp32'),
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH 2/2] nir: add lowering for fceil

2018-09-01 Thread Christian Gmeiner
Am Sa., 1. Sep. 2018 um 21:15 Uhr schrieb Christian Gmeiner
:
>
> Signed-off-by: Christian Gmeiner 
> ---
>  src/compiler/nir/nir.h| 3 +++
>  src/compiler/nir/nir_opt_algebraic.py | 1 +
>  2 files changed, 4 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index d81eefc032..1dcc221777 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2057,6 +2057,9 @@ typedef struct nir_shader_compiler_options {
> /** lowers ffloor to fsub+ffract: */
> bool lower_ffloor;
>
> +   /** lowers fceil to fadd+ffract: */
> +   bool lower_fceil;
> +
> /** lowers ffract to fsub+ffloor: */
> bool lower_ffract;
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index 3d2b861a42..43a1642aa5 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -119,6 +119,7 @@ optimizations = [
> (('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
> 'options->lower_flrp32'),
> (('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
> 'options->lower_flrp64'),
> (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
> +   (('fceil', a), ('fadd', a, ('ffract', a)), 'options->lower_fceil'),

I missed a fneg(..) here .. will be fixed in v2.

> (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> (('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c, ('fmul', b, 
> ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
> (('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg',     c ))), ('fmul', 
> b, c )), ('flrp', a, b, c), '!options->lower_flrp32'),
> --
> 2.17.1
>


-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH v2 1/7] st/mesa: use real bool for can_ubo

2018-09-04 Thread Christian Gmeiner
Am Di., 4. Sep. 2018 um 11:09 Uhr schrieb Erik Faye-Lund
:
>
> We're doing full c99 now, so there's no point in using the old boolean
> type.
>
> Signed-off-by: Erik Faye-Lund 
> Reviewed-by: Marek Olšák 

Reviewed-by: Christian Gmeiner 

> ---
>  src/mesa/state_tracker/st_extensions.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_extensions.c 
> b/src/mesa/state_tracker/st_extensions.c
> index 29a3251308..8cb80f9932 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -81,7 +81,7 @@ void st_init_limits(struct pipe_screen *screen,
>  {
> int supported_irs;
> unsigned sh;
> -   boolean can_ubo = TRUE;
> +   bool can_ubo = true;
> int temp;
> bool ssbo_atomic = true;
>
> @@ -160,7 +160,7 @@ void st_init_limits(struct pipe_screen *screen,
> c->MaxUniformBlockSize = MIN2(c->MaxUniformBlockSize, INT_MAX - 127);
>
> if (c->MaxUniformBlockSize < 16384) {
> -  can_ubo = FALSE;
> +  can_ubo = false;
> }
>
> for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {
> @@ -301,7 +301,7 @@ void st_init_limits(struct pipe_screen *screen,
>
>if (pc->MaxNativeInstructions &&
>(options->EmitNoIndirectUniform || pc->MaxUniformBlocks < 12)) {
> - can_ubo = FALSE;
> + can_ubo = false;
>}
>
>if (options->EmitNoLoops)
> --
> 2.17.1
>
> _______
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] etnaviv: remove superfluous \n from DBG(..) callers

2018-03-10 Thread Christian Gmeiner
The DBG(..) macro appends a \n already so there is no
need to do it twice.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_blt.c   | 2 +-
 src/gallium/drivers/etnaviv/etnaviv_rs.c| 2 +-
 src/gallium/drivers/etnaviv/etnaviv_screen.c| 6 +++---
 src/gallium/drivers/etnaviv/etnaviv_texture_state.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_blt.c 
b/src/gallium/drivers/etnaviv/etnaviv_blt.c
index ec3eac9b2a..5d783a4ad9 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_blt.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_blt.c
@@ -556,7 +556,7 @@ etna_blit_blt(struct pipe_context *pctx, const struct 
pipe_blit_info *blit_info)
 void
 etna_clear_blit_blt_init(struct pipe_context *pctx)
 {
-   DBG("etnaviv: Using BLT blit engine\n");
+   DBG("etnaviv: Using BLT blit engine");
pctx->clear = etna_clear_blt;
pctx->blit = etna_blit_blt;
 }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
b/src/gallium/drivers/etnaviv/etnaviv_rs.c
index bd40cebb53..b8a3b12ae4 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
@@ -801,7 +801,7 @@ etna_blit_rs(struct pipe_context *pctx, const struct 
pipe_blit_info *blit_info)
 void
 etna_clear_blit_rs_init(struct pipe_context *pctx)
 {
-   DBG("etnaviv: Using RS blit engine\n");
+   DBG("etnaviv: Using RS blit engine");
pctx->clear = etna_clear_rs;
pctx->blit = etna_blit_rs;
 }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index de341c855b..6c5c00bf2d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -703,9 +703,9 @@ etna_get_specs(struct etna_screen *screen)
else
   screen->specs.halti = -1; /* GC7000nanolite / pre-GC2000 except GC880 */
if (screen->specs.halti >= 0)
-  DBG("etnaviv: GPU arch: HALTI%d\n", screen->specs.halti);
+  DBG("etnaviv: GPU arch: HALTI%d", screen->specs.halti);
else
-  DBG("etnaviv: GPU arch: pre-HALTI\n");
+  DBG("etnaviv: GPU arch: pre-HALTI");
 
screen->specs.can_supertile =
   VIV_FEATURE(screen, chipMinorFeatures0, SUPER_TILED);
@@ -821,7 +821,7 @@ etna_get_specs(struct etna_screen *screen)
 
screen->specs.single_buffer = VIV_FEATURE(screen, chipMinorFeatures4, 
SINGLE_BUFFER);
if (screen->specs.single_buffer)
-  DBG("etnaviv: Single buffer mode enabled with %d pixel pipes\n", 
screen->specs.pixel_pipes);
+  DBG("etnaviv: Single buffer mode enabled with %d pixel pipes", 
screen->specs.pixel_pipes);
 
screen->specs.tex_astc = VIV_FEATURE(screen, chipMinorFeatures4, 
TEXTURE_ASTC);
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c 
b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
index 0b00ad4969..faa073a71a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
@@ -319,7 +319,7 @@ void
 etna_texture_state_init(struct pipe_context *pctx)
 {
struct etna_context *ctx = etna_context(pctx);
-   DBG("etnaviv: Using state-based texturing\n");
+   DBG("etnaviv: Using state-based texturing");
ctx->base.create_sampler_state = etna_create_sampler_state_state;
ctx->base.delete_sampler_state = etna_delete_sampler_state_state;
ctx->base.create_sampler_view = etna_create_sampler_view_state;
-- 
2.14.3

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


[Mesa-dev] [PATCH] etnaviv: add layout string to resource debug output

2018-03-10 Thread Christian Gmeiner
This is quite helpful for debug purposes.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index c600eff45c..0fe8b19a0e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -77,6 +77,25 @@ static uint64_t layout_to_modifier(enum etna_surface_layout 
layout)
}
 }
 
+static inline const char *
+layout_to_string(unsigned layout)
+{
+   switch (layout) {
+   case ETNA_LAYOUT_LINEAR:
+  return "linear";
+   case ETNA_LAYOUT_TILED:
+  return "tiled";
+   case ETNA_LAYOUT_SUPER_TILED:
+  return "super tiled";
+   case ETNA_LAYOUT_MULTI_TILED:
+  return "multi tiled";
+   case ETNA_LAYOUT_MULTI_SUPERTILED:
+  return "multi super tiled";
+   default:
+  unreachable("unexpected/invalid layout");
+   }
+}
+
 /* A tile is 4x4 pixels, having 'screen->specs.bits_per_tile' of tile status.
  * So, in a buffer of N pixels, there are N / (4 * 4) tiles.
  * We need N * screen->specs.bits_per_tile / (4 * 4) bits of tile status, or
@@ -187,11 +206,12 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
layout,
 
DBG_F(ETNA_DBG_RESOURCE_MSGS,
  "target=%d, format=%s, %ux%ux%u, array_size=%u, "
- "last_level=%u, nr_samples=%u, usage=%u, bind=%x, flags=%x",
+ "last_level=%u, nr_samples=%u, usage=%u, bind=%x, flags=%x, "
+ "layout=%s",
  templat->target, util_format_name(templat->format), templat->width0,
  templat->height0, templat->depth0, templat->array_size,
  templat->last_level, templat->nr_samples, templat->usage,
- templat->bind, templat->flags);
+ templat->bind, templat->flags, layout_to_string(layout));
 
/* Determine scaling for antialiasing, allow override using debug flag */
int nr_samples = templat->nr_samples;
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] travis: bump libxcb version to 1.13

2018-03-10 Thread Christian Gmeiner
2018-03-10 16:19 GMT+01:00 Daniel Stone <dan...@fooishbar.org>:
> On 10 March 2018 at 14:53, Christian Gmeiner
> <christian.gmei...@gmail.com> wrote:
>> Fixes following dependency problem:
>>   Native dependency xcb-dri3 found: NO found '1.11' but need: '>= 1.13'
>
> Oh, oops! Thanks for the catch Christian.
>

You are welcome - pushed it.

> Reviewed-by: Daniel Stone <dani...@collabora.com>
> Fixes: c80c08e22603 ("vulkan/wsi/x11: Add support for DRI3 v1.2")
>
>
> Cheers,
> Daniel



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] travis: bump libxcb version to 1.13

2018-03-10 Thread Christian Gmeiner
Fixes following dependency problem:
  Native dependency xcb-dri3 found: NO found '1.11' but need: '>= 1.13'

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index dcd150b482..45c5b80cba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,8 +17,8 @@ env:
 - DRI2PROTO_VERSION=dri2proto-2.8
 - LIBPCIACCESS_VERSION=libpciaccess-0.13.4
 - LIBDRM_VERSION=libdrm-2.4.74
-- XCBPROTO_VERSION=xcb-proto-1.11
-- LIBXCB_VERSION=libxcb-1.11
+- XCBPROTO_VERSION=xcb-proto-1.13
+- LIBXCB_VERSION=libxcb-1.13
 - LIBXSHMFENCE_VERSION=libxshmfence-1.2
 - LIBVDPAU_VERSION=libvdpau-1.1
 - LIBVA_VERSION=libva-1.6.2
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] etnaviv: allow mixing different bit depths for color and depth surfaces

2018-03-09 Thread Christian Gmeiner
2018-03-08 10:20 GMT+01:00 Lucas Stach <l.st...@pengutronix.de>:
> Vivante hardware supports this just fine. There is no reason why this 
> shouldn't
> be advertised as a valid combination.
>
> Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

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

> ---
>  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 f589bd44eaf4..de341c855ba5 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -139,6 +139,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
> pipe_cap param)
> case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
> case PIPE_CAP_TGSI_TEXCOORD:
> case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
> +   case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
>return 1;
> case PIPE_CAP_NATIVE_FENCE_FD:
>return screen->drm_version >= ETNA_DRM_VERSION_FENCE_FD;
> @@ -238,7 +239,6 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
> pipe_cap param)
> case PIPE_CAP_MAX_WINDOW_RECTANGLES:
> case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
> case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
> -   case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
> case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
> case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS:
> case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
> --
> 2.16.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] freedreno: bump required libdrm version

2018-03-06 Thread Christian Gmeiner
Fixes: 26a9321d0a "freedreno: add global_bindings state"

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 configure.ac | 2 +-
 meson.build  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index d8093597dd..17c5363868 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,7 +78,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.90
 LIBDRM_INTEL_REQUIRED=2.4.75
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
-LIBDRM_FREEDRENO_REQUIRED=2.4.89
+LIBDRM_FREEDRENO_REQUIRED=2.4.91
 LIBDRM_ETNAVIV_REQUIRED=2.4.82
 
 dnl Versions for external dependencies
diff --git a/meson.build b/meson.build
index bb6a835084..b32e1f66e7 100644
--- a/meson.build
+++ b/meson.build
@@ -1008,7 +1008,7 @@ if with_gallium_etnaviv
   dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
 endif
 if with_gallium_freedreno
-  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.89')
+  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.91')
 endif
 
 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH 08/12] etnaviv: support TX performance counters

2018-04-06 Thread Christian Gmeiner
2018-03-29 16:25 GMT+02:00 Lucas Stach <l.st...@pengutronix.de>:
> Am Sonntag, den 25.03.2018, 22:30 +0200 schrieb Christian Gmeiner:
>> > Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
>> ---
>>  src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 63 
>> ++
>>  src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 10 
>>  2 files changed, 73 insertions(+)
>>
>> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
>> b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
>> index 3601d4086c..4c2a2ac7de 100644
>> --- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
>> +++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
>> @@ -276,6 +276,69 @@ static const struct etna_perfmon_config query_config[] 
>> = {
>>.source = (const struct etna_perfmon_source[]) {
>>   { "RA", "CULLED_QUAD_COUNT" }
>>}
>> +   },
>> +   {
>> +  .name = "tx-total-bilinear-requests",
>> +  .type = ETNA_QUERY_TX_TOTAL_BILINEAR_REQUESTS,
>> +  .source = (const struct etna_perfmon_source[]) {
>> + { "TX", "TOTAL_BILINEAR_REQUESTS" }
>> +  }
>> +   },
>> +   {
>> +  .name = "tx-total-trilinear-requests",
>> +  .type = ETNA_QUERY_TX_TOTAL_TRILINEAR_REQUESTS,
>> +  .source = (const struct etna_perfmon_source[]) {
>> + { "TX", "TOTAL_TRILINEAR_REQUESTS" }
>> +  }
>> +   },
>> +   {
>> +  .name = "tx-total-discarded-texutre-requests",
>
> ^ wrong spelling of texture.
>
>> +  .type = ETNA_QUERY_TX_TOTAL_DISCARDED_TEXTURE_REQUESTS,
>> +  .source = (const struct etna_perfmon_source[]) {
>> + { "TX", "TOTAL_DISCARDED_TEXTURE_REQUESTS" }
>> +  }
>> +   },
>> +   {
>> +  .name = "tx-total-texutre-requests",
>
> again
>

Fixed locally...

-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] etnaviv: sw queries: return correct number of groups

2018-04-06 Thread Christian Gmeiner
Fixes: 3d912bd742ed ("etnaviv: add query_group_info for sw counters")
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
index f955d8e210..bec8d0d588 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
@@ -145,7 +145,7 @@ etna_sw_get_driver_query_group_info(struct pipe_screen 
*pscreen,
 struct pipe_driver_query_group_info *info)
 {
if (!info)
-  return ARRAY_SIZE(list);
+  return 1;
 
if (index != 0)
   return 0;
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] etnaviv: meson: add etnaviv_query_pm.[ch] to the sources

2018-04-09 Thread Christian Gmeiner
Emil you are only minutes faster then me :) Will push this change in
some minutes.

2018-04-09 18:57 GMT+02:00 Emil Velikov <emil.l.veli...@gmail.com>:
> From: Emil Velikov <emil.veli...@collabora.com>
>
> Otherwise building the driver will fail with unresolved symbols.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105960
> Fixes: 72d2043be06 ("etnaviv: add perfmon query implementation")
> Cc: Christian Gmeiner <christian.gmei...@gmail.com>
> Cc: Clayton Craft <clayton.a.cr...@intel.com>
> Signed-off-by: Emil Velikov <emil.veli...@collabora.com>

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

> ---
>  src/gallium/drivers/etnaviv/meson.build | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/drivers/etnaviv/meson.build 
> b/src/gallium/drivers/etnaviv/meson.build
> index 2d091fbcbc..48e99d28c8 100644
> --- a/src/gallium/drivers/etnaviv/meson.build
> +++ b/src/gallium/drivers/etnaviv/meson.build
> @@ -54,6 +54,8 @@ files_etnaviv = files(
>'etnaviv_query_hw.h',
>'etnaviv_query_sw.c',
>'etnaviv_query_sw.h',
> +  'etnaviv_query_pm.c',
> +  'etnaviv_query_pm.h',
>'etnaviv_rasterizer.c',
>'etnaviv_rasterizer.h',
>'etnaviv_resource.c',
> --
> 2.16.0
>



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [RFC PATCH] nir: extend nir_shader_compiler_options with is_scalar

2018-04-05 Thread Christian Gmeiner
As not every (upcoming) backend compiler is happy with
nir_lower_xxx_to_scalar lowerings do them only if the backend
is scalar (and not vec4) based.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/amd/vulkan/radv_shader.c| 1 +
 src/broadcom/compiler/nir_to_vir.c  | 1 +
 src/compiler/nir/nir.h  | 3 +++
 src/gallium/drivers/freedreno/ir3/ir3_nir.c | 1 +
 src/gallium/drivers/radeonsi/si_get.c   | 1 +
 src/gallium/drivers/vc4/vc4_program.c   | 1 +
 src/intel/compiler/brw_compiler.c   | 1 +
 src/mesa/state_tracker/st_glsl_to_nir.cpp   | 8 ++--
 8 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 171802eede..22f61cb23d 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -49,6 +49,7 @@
 #include "util/string_buffer.h"
 
 static const struct nir_shader_compiler_options nir_options = {
+   .is_scalar = true,
.vertex_id_zero_based = true,
.lower_scmp = true,
.lower_flrp32 = true,
diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 595689d244..b4f29554ac 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1876,6 +1876,7 @@ nir_to_vir(struct v3d_compile *c)
 }
 
 const nir_shader_compiler_options v3d_nir_options = {
+.is_scalar = true,
 .lower_all_io_to_temps = true,
 .lower_extract_byte = true,
 .lower_extract_word = true,
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index c676331000..4796e3e88c 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1883,6 +1883,9 @@ typedef struct nir_shader_compiler_options {
 */
bool native_integers;
 
+   /* Indicates that the hw makes use of a scalar ISA */
+   bool is_scalar;
+
/* Indicates that the driver only has zero-based vertex id */
bool vertex_id_zero_based;
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c 
b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
index 0b637bb99b..a921c14565 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
@@ -47,6 +47,7 @@ static const nir_shader_compiler_options options = {
.lower_ldexp = true,
.fuse_ffma = true,
.native_integers = true,
+   .is_scalar = true,
.vertex_id_zero_based = true,
.lower_extract_byte = true,
.lower_extract_word = true,
diff --git a/src/gallium/drivers/radeonsi/si_get.c 
b/src/gallium/drivers/radeonsi/si_get.c
index e9657602f3..621ff86814 100644
--- a/src/gallium/drivers/radeonsi/si_get.c
+++ b/src/gallium/drivers/radeonsi/si_get.c
@@ -510,6 +510,7 @@ static const struct nir_shader_compiler_options nir_options 
= {
.lower_unpack_unorm_4x8 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
+   .is_scalar = true,
.max_unroll_iterations = 32,
.native_integers = true,
 };
diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index be80a851d2..1d7d0bdb0a 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2191,6 +2191,7 @@ static const nir_shader_compiler_options nir_options = {
 .lower_ldexp = true,
 .lower_negate = true,
 .native_integers = true,
+.is_scalar = true,
 .max_unroll_iterations = 32,
 };
 
diff --git a/src/intel/compiler/brw_compiler.c 
b/src/intel/compiler/brw_compiler.c
index 9340317492..9794362f5d 100644
--- a/src/intel/compiler/brw_compiler.c
+++ b/src/intel/compiler/brw_compiler.c
@@ -57,6 +57,7 @@
.lower_unpack_snorm_4x8 = true,\
.lower_unpack_unorm_2x16 = true,   \
.lower_unpack_unorm_4x8 = true,\
+   .is_scalar = true, \
.vs_inputs_dual_locations = true,  \
.max_unroll_iterations = 32
 
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 0bd9c4e4e3..9fd64166ae 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -262,13 +262,17 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
 static void
 st_nir_opts(nir_shader *nir)
 {
+   const struct nir_shader_compiler_options *options = nir->options;
bool progress;
do {
   progress = false;
 
   NIR_PASS_V(nir, nir_lower_vars_to_ssa);
-  NIR_PASS_V(nir, nir_lower_alu_to_scalar);
-  NIR_PASS_V(nir, nir_lower_phis_to_scalar);
+
+  if (options->is_scalar) {
+ NIR_PASS_V(nir, nir_lower_alu_to_scalar);
+ NIR_PASS_V(nir, ni

Re: [Mesa-dev] [PATCH kmscube 1/4] drm-atomic: Fix indentation

2018-04-05 Thread Christian Gmeiner
2018-04-05 15:44 GMT+02:00 Thierry Reding <thierry.red...@gmail.com>:
> From: Thierry Reding <tred...@nvidia.com>
>
> One of the error returns ended up being indented twice. Fix it.
>
> Signed-off-by: Thierry Reding <tred...@nvidia.com>

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

> ---
>  drm-atomic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drm-atomic.c b/drm-atomic.c
> index 82531d346d73..99ac33d6a686 100644
> --- a/drm-atomic.c
> +++ b/drm-atomic.c
> @@ -116,7 +116,7 @@ static int drm_atomic_commit(uint32_t fb_id, uint32_t 
> flags)
> if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) {
> if (add_connector_property(req, drm.connector_id, "CRTC_ID",
> drm.crtc_id) < 0)
> -   return -1;
> +   return -1;
>
> if (drmModeCreatePropertyBlob(drm.fd, drm.mode, 
> sizeof(*drm.mode),
>   _id) != 0)
> --
> 2.16.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH kmscube 2/4] Pass struct drm to init_gbm()

2018-04-05 Thread Christian Gmeiner
2018-04-05 15:44 GMT+02:00 Thierry Reding <thierry.red...@gmail.com>:
> From: Thierry Reding <tred...@nvidia.com>
>
> This helps cut down on the number of parameters that we need to pass
> around. Subsequent patches will also add more data to struct drm that
> init_gbm() needs to access, so passing in the struct make sure these
> will be available.
>
> Based on work by Lucas Stach <l.st...@pengutronix.de>.
>
> Signed-off-by: Thierry Reding <tred...@nvidia.com>

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

> ---
>  common.c  | 22 +++---
>  common.h  |  4 ++--
>  kmscube.c |  3 +--
>  3 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/common.c b/common.c
> index faecd4215039..3dcd9bd3d8f4 100644
> --- a/common.c
> +++ b/common.c
> @@ -30,6 +30,7 @@
>  #include 
>
>  #include "common.h"
> +#include "drm-common.h"
>
>  static struct gbm gbm;
>
> @@ -40,25 +41,24 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
>const uint64_t *modifiers,
>const unsigned int count);
>
> -const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier)
> +const struct gbm * init_gbm(const struct drm *drm, uint64_t modifier)
>  {

Just an idea:
To keep the diffstat smaller it could may help to create local vars like

int w = drm->mode->hdisplay;
int h = drm->mode->vdisplay;

> -   gbm.dev = gbm_create_device(drm_fd);
> +   gbm.dev = gbm_create_device(drm->fd);
> gbm.format = GBM_FORMAT_XRGB;
>
> if (gbm_surface_create_with_modifiers) {
> -   gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
> -   gbm.format,
> -   , 1);
> -
> +   gbm.surface = gbm_surface_create_with_modifiers(gbm.dev,
> +   drm->mode->hdisplay, drm->mode->vdisplay,
> +   gbm.format, , 1);
> } else {
> if (modifier != DRM_FORMAT_MOD_LINEAR) {
> fprintf(stderr, "Modifiers requested but support 
> isn't available\n");
> return NULL;
> }
> -   gbm.surface = gbm_surface_create(gbm.dev, w, h,
> -   gbm.format,
> -   GBM_BO_USE_SCANOUT | 
> GBM_BO_USE_RENDERING);
>
> +   gbm.surface = gbm_surface_create(gbm.dev, drm->mode->hdisplay,
> +   drm->mode->vdisplay, gbm.format,
> +   GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
> }
>
> if (!gbm.surface) {
> @@ -66,8 +66,8 @@ const struct gbm * init_gbm(int drm_fd, int w, int h, 
> uint64_t modifier)
> return NULL;
> }
>
> -   gbm.width = w;
> -   gbm.height = h;
> +   gbm.width = drm->mode->hdisplay;
> +   gbm.height = drm->mode->vdisplay;
>
> return 
>  }
> diff --git a/common.h b/common.h
> index 898010dd546f..8ff1ed3a6aa3 100644
> --- a/common.h
> +++ b/common.h
> @@ -83,8 +83,8 @@ struct gbm {
> int width, height;
>  };
>
> -const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier);
> -
> +struct drm;
> +const struct gbm *init_gbm(const struct drm *drm, uint64_t modifier);
>
>  struct egl {
> EGLDisplay display;
> diff --git a/kmscube.c b/kmscube.c
> index 87a4205ddc20..b05e57df7faf 100644
> --- a/kmscube.c
> +++ b/kmscube.c
> @@ -130,8 +130,7 @@ int main(int argc, char *argv[])
> return -1;
> }
>
> -   gbm = init_gbm(drm->fd, drm->mode->hdisplay, drm->mode->vdisplay,
> -   modifier);
> +   gbm = init_gbm(drm, modifier);
> if (!gbm) {
> printf("failed to initialize GBM\n");
> return -1;
> --
> 2.16.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [RFC PATCH] nir: extend nir_shader_compiler_options with is_scalar

2018-04-05 Thread Christian Gmeiner
2018-04-05 16:35 GMT+02:00 Rob Clark <robdcl...@gmail.com>:
> I'd vote for PIPE_CAP until there is any place inside nir passes were
> we'd want to do something differently.  Since this is just a decision
> in mesa/st I think a cap makes sense..
>

Makes sense.. will go that route - thanks for your comments!

-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH 1/2] etnaviv: remove redundant include

2018-04-20 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_rs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
b/src/gallium/drivers/etnaviv/etnaviv_rs.c
index b8a3b12ae4..fc4f65dbee 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
@@ -26,8 +26,6 @@
 
 #include "etnaviv_rs.h"
 
-#include "hw/common.xml.h"
-
 #include "etnaviv_clear_blit.h"
 #include "etnaviv_context.h"
 #include "etnaviv_emit.h"
-- 
2.14.3

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


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

2018-04-20 Thread Christian Gmeiner
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)
 
-- 
2.14.3

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


[Mesa-dev] [PATCH V2 kmscube] cube-tex: make use of modifiers

2018-04-02 Thread Christian Gmeiner
Fixes rendering issues with mode rgba on etnaviv. I have applied
the same change for nv12 variants but they are not supported on
etnaviv.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 common.c   |  3 +++
 common.h   | 19 +
 cube-tex.c | 91 +-
 3 files changed, 101 insertions(+), 12 deletions(-)

diff --git a/common.c b/common.c
index 1d97c91..faecd42 100644
--- a/common.c
+++ b/common.c
@@ -216,6 +216,9 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
get_proc_dpy(EGL_KHR_fence_sync, eglClientWaitSyncKHR);
get_proc_dpy(EGL_ANDROID_native_fence_sync, eglDupNativeFenceFDANDROID);
 
+   egl->modifiers_supported = has_ext(egl_exts_dpy,
+  
"EGL_EXT_image_dma_buf_import_modifiers");
+
printf("Using display %p with EGL version %d.%d\n",
egl->display, major, minor);
 
diff --git a/common.h b/common.h
index 42eb236..898010d 100644
--- a/common.h
+++ b/common.h
@@ -31,6 +31,7 @@
 
 #include 
 #include 
+#include 
 
 #ifndef DRM_FORMAT_MOD_LINEAR
 #define DRM_FORMAT_MOD_LINEAR 0
@@ -59,6 +60,22 @@ EGLAPI EGLSurface EGLAPIENTRY 
eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
 
 #define WEAK __attribute__((weak))
 
+/* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
+#ifndef EGL_EXT_image_dma_buf_import_modifiers
+#define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440
+#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441
+#define EGL_DMA_BUF_PLANE3_PITCH_EXT  0x3442
+#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
+#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
+#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
+#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
+#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
+#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
+#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
+#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
+#endif
+
 struct gbm {
struct gbm_device *dev;
struct gbm_surface *surface;
@@ -85,6 +102,8 @@ struct egl {
PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID;
 
+   bool modifiers_supported;
+
void (*draw)(unsigned i);
 };
 
diff --git a/cube-tex.c b/cube-tex.c
index 9e38ae8..71916e3 100644
--- a/cube-tex.c
+++ b/cube-tex.c
@@ -29,6 +29,7 @@
 #include "common.h"
 #include "esUtil.h"
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 struct {
struct egl egl;
@@ -213,7 +214,10 @@ static const char *fragment_shader_source_2img =
 
 static const uint32_t texw = 512, texh = 512;
 
-static int get_fd_rgba(uint32_t *pstride)
+WEAK uint64_t
+gbm_bo_get_modifier(struct gbm_bo *bo);
+
+static int get_fd_rgba(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -235,6 +239,11 @@ static int get_fd_rgba(uint32_t *pstride)
 
fd = gbm_bo_get_fd(bo);
 
+   if (gbm_bo_get_modifier)
+   *modifier = gbm_bo_get_modifier(bo);
+   else
+   *modifier = DRM_FORMAT_MOD_LINEAR;
+
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
 
@@ -243,7 +252,7 @@ static int get_fd_rgba(uint32_t *pstride)
return fd;
 }
 
-static int get_fd_y(uint32_t *pstride)
+static int get_fd_y(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -265,6 +274,11 @@ static int get_fd_y(uint32_t *pstride)
 
fd = gbm_bo_get_fd(bo);
 
+   if (gbm_bo_get_modifier)
+   *modifier = gbm_bo_get_modifier(bo);
+   else
+   *modifier = DRM_FORMAT_MOD_LINEAR;
+
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
 
@@ -273,7 +287,7 @@ static int get_fd_y(uint32_t *pstride)
return fd;
 }
 
-static int get_fd_uv(uint32_t *pstride)
+static int get_fd_uv(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -295,6 +309,11 @@ static int get_fd_uv(uint32_t *pstride)
 
fd = gbm_bo_get_fd(bo);
 
+   if (gbm_bo_get_modifier)
+   *modifier = gbm_bo_get_modifier(bo);
+   else
+   *modifier = DRM_FORMAT_MOD_LINEAR;
+
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
 
@@ -306,16 +325,27 @@ static int get_fd_uv(uint32_t *pstride)
 static int init_tex_rgba(void)
 {
uint32_t stride;
-   int fd = get_fd_rgba();
-   const EGLint attr[] = {
+   uint64_t modifier;
+   int fd = get_fd_rgba(, );
+   EGLint attr[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ABGR,
EGL_DMA_BUF_PLANE0_FD_EXT, 

Re: [Mesa-dev] [PATCH kmscube 1/2] Rework default modifier handling

2018-04-02 Thread Christian Gmeiner
2018-03-30 16:17 GMT+02:00 Emil Velikov <emil.l.veli...@gmail.com>:
> From: Emil Velikov <emil.veli...@collabora.com>
>
> Currently the default modifier is MOD_INVALID. At a later stage, if the
> modifier is the same (the user may have explicit selected MOD_INVALID),
> we'll fallback to MOD_LINEAR.
>
> Simplify things to a) use MOD_LINEAR by default b) use the user modifier
> - even if they request MOD_INVALID.
>
> Signed-off-by: Emil Velikov <emil.veli...@collabora.com>

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

> ---
>  common.c  | 23 ++-
>  kmscube.c |  2 +-
>  2 files changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/common.c b/common.c
> index a092cdb..332e3e9 100644
> --- a/common.c
> +++ b/common.c
> @@ -33,24 +33,13 @@
>
>  static struct gbm gbm;
>
> -#ifdef HAVE_GBM_MODIFIERS
> -static int
> -get_modifiers(uint64_t **mods)
> -{
> -   /* Assumed LINEAR is supported everywhere */
> -   static uint64_t modifiers[] = {DRM_FORMAT_MOD_LINEAR};
> -   *mods = modifiers;
> -   return 1;
> -}
> -#endif
> -
>  const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier)
>  {
> gbm.dev = gbm_create_device(drm_fd);
> gbm.format = GBM_FORMAT_XRGB;
>
>  #ifndef HAVE_GBM_MODIFIERS
> -   if (modifier != DRM_FORMAT_MOD_INVALID) {
> +   if (modifier != DRM_FORMAT_MOD_LINEAR) {
> fprintf(stderr, "Modifiers requested but support isn't 
> available\n");
> return NULL;
> }
> @@ -58,16 +47,8 @@ const struct gbm * init_gbm(int drm_fd, int w, int h, 
> uint64_t modifier)
> gbm.format,
> GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
>  #else
> -   uint64_t *mods;
> -   int count;
> -   if (modifier != DRM_FORMAT_MOD_INVALID) {
> -   count = 1;
> -   mods = 
> -   } else {
> -   count = get_modifiers();
> -   }
> gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
> -   gbm.format, mods, count);
> +   gbm.format, , 1);
>  #endif
>
> if (!gbm.surface) {
> diff --git a/kmscube.c b/kmscube.c
> index 3a2c4dd..87a4205 100644
> --- a/kmscube.c
> +++ b/kmscube.c
> @@ -76,7 +76,7 @@ int main(int argc, char *argv[])
> const char *device = "/dev/dri/card0";
> const char *video = NULL;
> enum mode mode = SMOOTH;
> -   uint64_t modifier = DRM_FORMAT_MOD_INVALID;
> +   uint64_t modifier = DRM_FORMAT_MOD_LINEAR;
> int atomic = 0;
> int opt;
>
> --
> 2.16.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH kmscube 2/2] Use weak functions to handle lack of gbm modifiers

2018-04-02 Thread Christian Gmeiner
2018-03-30 16:17 GMT+02:00 Emil Velikov <emil.l.veli...@gmail.com>:
> From: Emil Velikov <emil.veli...@collabora.com>
>
> Add weak function declaration and check if they're valid prior
> to calling the functions.
>
> This allows us to remove conditional compilation, yet allowing the
> modifiers codepath to work if API is available.
>
> Cc: Christian Gmeiner <christian.gmei...@gmail.com>
> Cc: Rob Clark <robdcl...@gmail.com>
> Signed-off-by: Emil Velikov <emil.veli...@collabora.com>

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

> ---
>  common.c | 32 +---
>  common.h |  2 ++
>  configure.ac | 16 
>  drm-common.c | 49 -
>  4 files changed, 55 insertions(+), 44 deletions(-)
>
> diff --git a/common.c b/common.c
> index 332e3e9..1d97c91 100644
> --- a/common.c
> +++ b/common.c
> @@ -33,23 +33,33 @@
>
>  static struct gbm gbm;
>
> +WEAK struct gbm_surface *
> +gbm_surface_create_with_modifiers(struct gbm_device *gbm,
> +  uint32_t width, uint32_t height,
> +  uint32_t format,
> +  const uint64_t *modifiers,
> +  const unsigned int count);
> +
>  const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier)
>  {
> gbm.dev = gbm_create_device(drm_fd);
> gbm.format = GBM_FORMAT_XRGB;
>
> -#ifndef HAVE_GBM_MODIFIERS
> -   if (modifier != DRM_FORMAT_MOD_LINEAR) {
> -   fprintf(stderr, "Modifiers requested but support isn't 
> available\n");
> -   return NULL;
> +   if (gbm_surface_create_with_modifiers) {
> +   gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
> +   gbm.format,
> +   , 1);
> +
> +   } else {
> +   if (modifier != DRM_FORMAT_MOD_LINEAR) {
> +   fprintf(stderr, "Modifiers requested but support 
> isn't available\n");
> +   return NULL;
> +   }
> +   gbm.surface = gbm_surface_create(gbm.dev, w, h,
> +   gbm.format,
> +   GBM_BO_USE_SCANOUT | 
> GBM_BO_USE_RENDERING);
> +
> }
> -   gbm.surface = gbm_surface_create(gbm.dev, w, h,
> -   gbm.format,
> -   GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
> -#else
> -   gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
> -   gbm.format, , 1);
> -#endif
>
> if (!gbm.surface) {
> printf("failed to create gbm surface\n");
> diff --git a/common.h b/common.h
> index dc87825..42eb236 100644
> --- a/common.h
> +++ b/common.h
> @@ -57,6 +57,8 @@ EGLAPI EGLSurface EGLAPIENTRY 
> eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
>  #endif
>  #endif /* EGL_EXT_platform_base */
>
> +#define WEAK __attribute__((weak))
> +
>  struct gbm {
> struct gbm_device *dev;
> struct gbm_surface *surface;
> diff --git a/configure.ac b/configure.ac
> index 8397f7b..5a63afb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -49,21 +49,5 @@ if test "x$HAVE_GST" = "xyes"; then
>  fi
>  AM_CONDITIONAL(ENABLE_GST, [test "x$HAVE_GST" = "xyes"])
>
> -AC_CHECK_LIB([gbm], [gbm_bo_get_modifier], [gbm_modifiers=yes], [])
> -
> -AC_ARG_ENABLE([gbm-modifiers],
> - [AS_HELP_STRING([--enable-gbm-modifiers],
> - [enable using GBM modifiers @<:@default=auto@:>@])],
> - [enable_gbm_modifiers="$enableval"],
> - [enable_gbm_modifiers=auto])
> -
> -if test "x$enable_gbm_modifiers" = xyes -a "x$gbm_modifiers" != xyes; then
> -   AC_MSG_ERROR([Cannot find gbm modifier supported mesa])
> -fi
> -
> -if test "x$enable_gbm_modifiers" = xyes; then
> -   AC_DEFINE(HAVE_GBM_MODIFIERS, 1, [Define if you can use GBM 
> properties.])
> -fi
> -
>  AC_CONFIG_FILES([Makefile])
>  AC_OUTPUT
> diff --git a/drm-common.c b/drm-common.c
> index 1ec2820..136fe69 100644
> --- a/drm-common.c
> +++ b/drm-common.c
> @@ -31,6 +31,18 @@
>  #include "common.h"
>  #include "drm-common.h"
>
> +WEAK uint64_t
> +gbm_bo_get_modifier(struct gbm_bo *bo);
> +
> +WEAK int
> +gbm_bo_get_plane_count(struct gbm_bo

[Mesa-dev] [PATCH 06/12] etnaviv: support SE performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 14 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 8e83eb185c..759e3a5d09 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -213,6 +213,20 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "PA", "CULLED_COUNTER" }
   }
+   },
+   {
+  .name = "se-culled-triangle-count",
+  .type = ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SE", "CULLED_TRIANGLE_COUNT" }
+  }
+   },
+   {
+  .name = "se-culled-lines-count",
+  .type = ETNA_QUERY_SE_CULLED_LINES_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SE", "CULLED_LINES_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 00fea71f23..d93d12c718 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -62,6 +62,9 @@ struct etna_screen;
 #define ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER   (ETNA_PM_QUERY_BASE + 
23)
 #define ETNA_QUERY_PA_CULLED_COUNTER (ETNA_PM_QUERY_BASE + 
24)
 
+#define ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT  (ETNA_PM_QUERY_BASE + 
25)
+#define ETNA_QUERY_SE_CULLED_LINES_COUNT (ETNA_PM_QUERY_BASE + 
26)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 04/12] etnaviv: support SH performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 63 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 10 
 2 files changed, 73 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 9be65cc6c5..eaad925e60 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -108,6 +108,69 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
   }
+   },
+   {
+  .name = "sh-shader-cycles",
+  .type = ETNA_QUERY_SH_SHADER_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "SHADER_CYCLES" }
+  }
+   },
+   {
+  .name = "sh-ps-inst-counter",
+  .type = ETNA_QUERY_SH_PS_INST_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PS_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-rendered-pixel-counter",
+  .type = ETNA_QUERY_SH_RENDERED_PIXEL_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "RENDERED_PIXEL_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vs-inst-counter",
+  .type = ETNA_QUERY_SH_VS_INST_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VS_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-rendered-vertice-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "RENDERED_VERTICE_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vtx-branch-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VTX_BRANCH_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vtx-texld-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VTX_TEXLD_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-plx-branch-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PXL_BRANCH_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-plx-texld-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PXL_TEXLD_INST_COUNTER" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 77fb37b333..b5e7fe5ad3 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -45,6 +45,16 @@ struct etna_screen;
 #define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE(ETNA_PM_QUERY_BASE + 
8)
 #define ETNA_QUERY_PE_PIXELS_RENDERED_2D (ETNA_PM_QUERY_BASE + 
9)
 
+#define ETNA_QUERY_SH_SHADER_CYCLES  (ETNA_PM_QUERY_BASE + 
10)
+#define ETNA_QUERY_SH_PS_INST_COUNTER(ETNA_PM_QUERY_BASE + 
11)
+#define ETNA_QUERY_SH_RENDERED_PIXEL_COUNTER (ETNA_PM_QUERY_BASE + 
12)
+#define ETNA_QUERY_SH_VS_INST_COUNTER(ETNA_PM_QUERY_BASE + 
13)
+#define ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER   (ETNA_PM_QUERY_BASE + 
14)
+#define ETNA_QUERY_SH_VTX_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
15)
+#define ETNA_QUERY_SH_VTX_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
16)
+#define ETNA_QUERY_SH_PXL_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
17)
+#define ETNA_QUERY_SH_PXL_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
18)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 02/12] etnaviv: support HI performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 35 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  6 +
 2 files changed, 41 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 2b09e5dac1..2feca9d1dd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -46,6 +46,41 @@ struct etna_perfmon_config
 };
 
 static const struct etna_perfmon_config query_config[] = {
+   {
+  .name = "hi-total-cyles",
+  .type = ETNA_QUERY_HI_TOTAL_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "TOTAL_CYCLES" }
+  }
+   },
+   {
+  .name = "hi-idle-cyles",
+  .type = ETNA_QUERY_HI_IDLE_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "IDLE_CYCLES" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-read-request-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_READ_REQUEST_STALLED" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-write-request-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_WRITE_REQUEST_STALLED" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-write-data-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
+  }
+   }
 };
 
 static const struct etna_perfmon_config *
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 3d8cf1419b..ce823cf3bf 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -33,6 +33,12 @@
 
 struct etna_screen;
 
+#define ETNA_QUERY_HI_TOTAL_CYCLES   (ETNA_PM_QUERY_BASE + 
0)
+#define ETNA_QUERY_HI_IDLE_CYCLES(ETNA_PM_QUERY_BASE + 
1)
+#define ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED(ETNA_PM_QUERY_BASE + 
2)
+#define ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED   (ETNA_PM_QUERY_BASE + 
3)
+#define ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED  (ETNA_PM_QUERY_BASE + 
4)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 07/12] etnaviv: support RA performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 49 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  8 +
 2 files changed, 57 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 759e3a5d09..3601d4086c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -227,6 +227,55 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "SE", "CULLED_LINES_COUNT" }
   }
+   },
+   {
+  .name = "ra-valid-pixel-count",
+  .type = ETNA_QUERY_RA_VALID_PIXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "VALID_PIXEL_COUNT" }
+  }
+   },
+   {
+  .name = "ra-total-quad-count",
+  .type = ETNA_QUERY_RA_TOTAL_QUAD_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "TOTAL_QUAD_COUNT" }
+  }
+   },
+   {
+  .name = "ra-valid-quad-count-after-early-z",
+  .type = ETNA_QUERY_RA_VALID_QUAD_COUNT_AFTER_EARLY_Z,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "VALID_QUAD_COUNT_AFTER_EARLY_Z" }
+  }
+   },
+   {
+  .name = "ra-total-primitive-count",
+  .type = ETNA_QUERY_RA_TOTAL_PRIMITIVE_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "TOTAL_PRIMITIVE_COUNT" }
+  }
+   },
+   {
+  .name = "ra-pipe-cache-miss-counter",
+  .type = ETNA_QUERY_RA_PIPE_CACHE_MISS_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "PIPE_CACHE_MISS_COUNTER" }
+  }
+   },
+   {
+  .name = "ra-prefetch-cache-miss-counter",
+  .type = ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "PREFETCH_CACHE_MISS_COUNTER" }
+  }
+   },
+   {
+  .name = "ra-pculled-quad-count",
+  .type = ETNA_QUERY_RA_CULLED_QUAD_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "CULLED_QUAD_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index d93d12c718..01dd135392 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -65,6 +65,14 @@ struct etna_screen;
 #define ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT  (ETNA_PM_QUERY_BASE + 
25)
 #define ETNA_QUERY_SE_CULLED_LINES_COUNT (ETNA_PM_QUERY_BASE + 
26)
 
+#define ETNA_QUERY_RA_VALID_PIXEL_COUNT  (ETNA_PM_QUERY_BASE + 
27)
+#define ETNA_QUERY_RA_TOTAL_QUAD_COUNT   (ETNA_PM_QUERY_BASE + 
28)
+#define ETNA_QUERY_RA_VALID_QUAD_COUNT_AFTER_EARLY_Z (ETNA_PM_QUERY_BASE + 
29)
+#define ETNA_QUERY_RA_TOTAL_PRIMITIVE_COUNT  (ETNA_PM_QUERY_BASE + 
30)
+#define ETNA_QUERY_RA_PIPE_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
31)
+#define ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
32)
+#define ETNA_QUERY_RA_CULLED_QUAD_COUNT  (ETNA_PM_QUERY_BASE + 
33)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 03/12] etnaviv: support PE performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 28 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  6 ++
 2 files changed, 34 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 2feca9d1dd..9be65cc6c5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -80,6 +80,34 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
   }
+   },
+   {
+  .name = "pe-pixel-count-killed-by-color-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_KILLED_BY_COLOR_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-killed-by-depth-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_KILLED_BY_DEPTH_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-drawn-by-color-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_DRAWN_BY_COLOR_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-drawn-by-depth-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index ce823cf3bf..77fb37b333 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -39,6 +39,12 @@ struct etna_screen;
 #define ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED   (ETNA_PM_QUERY_BASE + 
3)
 #define ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED  (ETNA_PM_QUERY_BASE + 
4)
 
+#define ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE   (ETNA_PM_QUERY_BASE + 
5)
+#define ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE   (ETNA_PM_QUERY_BASE + 
6)
+#define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE(ETNA_PM_QUERY_BASE + 
7)
+#define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE(ETNA_PM_QUERY_BASE + 
8)
+#define ETNA_QUERY_PE_PIXELS_RENDERED_2D (ETNA_PM_QUERY_BASE + 
9)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 01/12] etnaviv: add perfmon query implementation

2018-03-25 Thread Christian Gmeiner
Add needed infrastructure to use performance monitor
requests for queries.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 configure.ac   |   2 +-
 meson.build|   2 +-
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|  11 +-
 src/gallium/drivers/etnaviv/etnaviv_query.h|   1 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 272 +
 .../{etnaviv_query.h => etnaviv_query_pm.h}|  49 ++--
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |   8 +
 src/gallium/drivers/etnaviv/etnaviv_screen.h   |   4 +
 9 files changed, 321 insertions(+), 30 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.c
 copy src/gallium/drivers/etnaviv/{etnaviv_query.h => etnaviv_query_pm.h} (57%)

diff --git a/configure.ac b/configure.ac
index 99805e0f2b..d9b14c0850 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ LIBDRM_INTEL_REQUIRED=2.4.75
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
 LIBDRM_FREEDRENO_REQUIRED=2.4.91
-LIBDRM_ETNAVIV_REQUIRED=2.4.82
+LIBDRM_ETNAVIV_REQUIRED=2.4.89
 
 dnl Versions for external dependencies
 DRI2PROTO_REQUIRED=2.8
diff --git a/meson.build b/meson.build
index 041d2bfc70..2a9ca3b719 100644
--- a/meson.build
+++ b/meson.build
@@ -1051,7 +1051,7 @@ if with_gallium_nouveau or with_dri_nouveau
   dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
 endif
 if with_gallium_etnaviv
-  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
+  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.89')
 endif
 if with_gallium_freedreno
   dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.91')
diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 587d369dfb..05df2d9c5f 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -35,6 +35,8 @@ C_SOURCES :=  \
etnaviv_query_hw.h \
etnaviv_query_sw.c \
etnaviv_query_sw.h \
+   etnaviv_query_pm.c \
+   etnaviv_query_pm.h \
etnaviv_rasterizer.c \
etnaviv_rasterizer.h \
etnaviv_resource.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 2d257a9d34..00f87d22cb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -32,6 +32,7 @@
 #include "etnaviv_query.h"
 #include "etnaviv_query_hw.h"
 #include "etnaviv_query_sw.h"
+#include "etnaviv_query_pm.h"
 
 static struct pipe_query *
 etna_create_query(struct pipe_context *pctx, unsigned query_type,
@@ -43,6 +44,8 @@ etna_create_query(struct pipe_context *pctx, unsigned 
query_type,
q = etna_sw_create_query(ctx, query_type);
if (!q)
   q = etna_hw_create_query(ctx, query_type);
+   if (!q)
+  q = etna_pm_create_query(ctx, query_type);
 
return (struct pipe_query *)q;
 }
@@ -103,11 +106,15 @@ etna_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
struct pipe_driver_query_info *info)
 {
int nr_sw_queries = etna_sw_get_driver_query_info(pscreen, 0, NULL);
+   int nr_pm_queries = etna_pm_get_driver_query_info(pscreen, 0, NULL);
 
if (!info)
-  return nr_sw_queries;
+  return nr_sw_queries + nr_pm_queries;
+
+   if (index < nr_sw_queries)
+  return etna_sw_get_driver_query_info(pscreen, index, info);
 
-   return etna_sw_get_driver_query_info(pscreen, index, info);
+   return etna_pm_get_driver_query_info(pscreen, index - nr_sw_queries, info);
 }
 
 static int
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.h 
b/src/gallium/drivers/etnaviv/etnaviv_query.h
index 8927266057..d738fb9e81 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.h
@@ -54,6 +54,7 @@ etna_query(struct pipe_query *pq)
 }
 
 #define ETNA_SW_QUERY_BASE   (PIPE_QUERY_DRIVER_SPECIFIC + 0)
+#define ETNA_PM_QUERY_BASE   (PIPE_QUERY_DRIVER_SPECIFIC + 32)
 
 void
 etna_query_screen_init(struct pipe_screen *pscreen);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
new file mode 100644
index 00..2b09e5dac1
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2017 Etnaviv Project
+ * Copyright (C) 2017 Zodiac Inflight Innovations
+ *
+ * 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, me

[Mesa-dev] [PATCH 10/12] etnaviv: assign group_ids to perfmon queries

2018-03-25 Thread Christian Gmeiner
Prep work for AMD_performance_monitor support.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 48 +-
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  9 +
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 8a636476d5..d5871f8f86 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -42,6 +42,7 @@ struct etna_perfmon_config
 {
const char *name;
unsigned type;
+   unsigned group_id;
const struct etna_perfmon_source *source;
 };
 
@@ -49,6 +50,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-total-cyles",
   .type = ETNA_QUERY_HI_TOTAL_CYCLES,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "TOTAL_CYCLES" }
   }
@@ -56,6 +58,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-idle-cyles",
   .type = ETNA_QUERY_HI_IDLE_CYCLES,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "IDLE_CYCLES" }
   }
@@ -63,6 +66,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-read-request-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_READ_REQUEST_STALLED" }
   }
@@ -70,6 +74,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-write-request-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_REQUEST_STALLED" }
   }
@@ -77,6 +82,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-write-data-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
   }
@@ -84,6 +90,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-killed-by-color-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_KILLED_BY_COLOR_PIPE" }
   }
@@ -91,6 +98,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-killed-by-depth-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_KILLED_BY_DEPTH_PIPE" }
   }
@@ -98,6 +106,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-drawn-by-color-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_COLOR_PIPE" }
   }
@@ -105,6 +114,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-drawn-by-depth-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
   }
@@ -112,6 +122,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-shader-cycles",
   .type = ETNA_QUERY_SH_SHADER_CYCLES,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "SHADER_CYCLES" }
   }
@@ -119,6 +130,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-ps-inst-counter",
   .type = ETNA_QUERY_SH_PS_INST_COUNTER,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "PS_INST_COUNTER" }
   }
@@ -126,6 +138,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-rendered-pixel-counter",
   .type = ETNA_QUERY_SH_RENDERED_PIXEL_

[Mesa-dev] [PATCH 11/12] etnaviv: add query_group_info for perfmon counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 45 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  5 +++
 2 files changed, 50 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index d5871f8f86..644b8fe6ca 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -46,6 +46,17 @@ struct etna_perfmon_config
const struct etna_perfmon_source *source;
 };
 
+static const char *group_names[] = {
+   [ETNA_QUERY_HI_GROUP_ID] = "HI",
+   [ETNA_QUERY_PE_GROUP_ID] = "PE",
+   [ETNA_QUERY_SH_GROUP_ID] = "SH",
+   [ETNA_QUERY_PA_GROUP_ID] = "PA",
+   [ETNA_QUERY_SE_GROUP_ID] = "SE",
+   [ETNA_QUERY_RA_GROUP_ID] = "RA",
+   [ETNA_QUERY_TX_GROUP_ID] = "TX",
+   [ETNA_QUERY_MC_GROUP_ID] = "MC",
+};
+
 static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-total-cyles",
@@ -631,3 +642,37 @@ etna_pm_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
 
return 1;
 }
+
+static
+unsigned query_count(unsigned group)
+{
+   unsigned count = 0;
+
+   for (unsigned i = 0; i < ARRAY_SIZE(query_config); i++)
+  if (query_config[i].group_id == group)
+ count++;
+
+   assert(count);
+
+   return count;
+}
+
+int
+etna_pm_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info)
+{
+   if (!info)
+  return ARRAY_SIZE(group_names);
+
+   if (index >= ARRAY_SIZE(group_names))
+  return 0;
+
+   unsigned count = query_count(index);
+
+   info->name = group_names[index];
+   info->max_active_queries = count;
+   info->num_queries = count;
+
+   return 1;
+}
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 23d125f2f7..e80310cabf 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -121,4 +121,9 @@ int
 etna_pm_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
   struct pipe_driver_query_info *info);
 
+int
+etna_pm_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info);
+
 #endif
-- 
2.14.3

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


[Mesa-dev] [PATCH 09/12] etnaviv: support MC performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 21 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  4 
 2 files changed, 25 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 4c2a2ac7de..8a636476d5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -339,6 +339,27 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "TX", "CACHE_MISS_TEXEL_COUNT" }
   }
+   },
+   {
+  .name = "mc-total-read-req-8b-from-pipeline",
+  .type = ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_PIPELINE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_READ_REQ_8B_FROM_PIPELINE" }
+  }
+   },
+   {
+  .name = "mc-total-read-req-8b-from-ip",
+  .type = ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_IP,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_READ_REQ_8B_FROM_IP" }
+  }
+   },
+   {
+  .name = "mc-total-write-req-8b-from-pipeline",
+  .type = ETNA_QUERY_MC_TOTAL_WRITE_REQ_8B_FROM_PIPELINE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_WRITE_REQ_8B_FROM_PIPELINE" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 9cfd06e0ec..f6d27ee406 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -83,6 +83,10 @@ struct etna_screen;
 #define ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT  (ETNA_PM_QUERY_BASE + 
41)
 #define ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT (ETNA_PM_QUERY_BASE + 
42)
 
+#define ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_PIPELINE(ETNA_PM_QUERY_BASE + 
43)
+#define ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_IP  (ETNA_PM_QUERY_BASE + 
44)
+#define ETNA_QUERY_MC_TOTAL_WRITE_REQ_8B_FROM_PIPELINE   (ETNA_PM_QUERY_BASE + 
45)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 08/12] etnaviv: support TX performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 63 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 10 
 2 files changed, 73 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 3601d4086c..4c2a2ac7de 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -276,6 +276,69 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "RA", "CULLED_QUAD_COUNT" }
   }
+   },
+   {
+  .name = "tx-total-bilinear-requests",
+  .type = ETNA_QUERY_TX_TOTAL_BILINEAR_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_BILINEAR_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-trilinear-requests",
+  .type = ETNA_QUERY_TX_TOTAL_TRILINEAR_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_TRILINEAR_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-discarded-texutre-requests",
+  .type = ETNA_QUERY_TX_TOTAL_DISCARDED_TEXTURE_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_DISCARDED_TEXTURE_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-texutre-requests",
+  .type = ETNA_QUERY_TX_TOTAL_TEXTURE_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_TEXTURE_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-mem-read-count",
+  .type = ETNA_QUERY_TX_MEM_READ_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "MEM_READ_COUNT" }
+  }
+   },
+   {
+  .name = "tx-mem-read-in-8b-count",
+  .type = ETNA_QUERY_TX_MEM_READ_IN_8B_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "MEM_READ_IN_8B_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-miss-count",
+  .type = ETNA_QUERY_TX_CACHE_MISS_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_MISS_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-hit-texel-count",
+  .type = ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_HIT_TEXEL_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-miss-texel-count",
+  .type = ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_MISS_TEXEL_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 01dd135392..9cfd06e0ec 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -73,6 +73,16 @@ struct etna_screen;
 #define ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
32)
 #define ETNA_QUERY_RA_CULLED_QUAD_COUNT  (ETNA_PM_QUERY_BASE + 
33)
 
+#define ETNA_QUERY_TX_TOTAL_BILINEAR_REQUESTS(ETNA_PM_QUERY_BASE + 
34)
+#define ETNA_QUERY_TX_TOTAL_TRILINEAR_REQUESTS   (ETNA_PM_QUERY_BASE + 
35)
+#define ETNA_QUERY_TX_TOTAL_DISCARDED_TEXTURE_REQUESTS   (ETNA_PM_QUERY_BASE + 
36)
+#define ETNA_QUERY_TX_TOTAL_TEXTURE_REQUESTS (ETNA_PM_QUERY_BASE + 
37)
+#define ETNA_QUERY_TX_MEM_READ_COUNT (ETNA_PM_QUERY_BASE + 
38)
+#define ETNA_QUERY_TX_MEM_READ_IN_8B_COUNT   (ETNA_PM_QUERY_BASE + 
39)
+#define ETNA_QUERY_TX_CACHE_MISS_COUNT   (ETNA_PM_QUERY_BASE + 
40)
+#define ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT  (ETNA_PM_QUERY_BASE + 
41)
+#define ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT (ETNA_PM_QUERY_BASE + 
42)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 05/12] etnaviv: support PA performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 42 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  7 +
 2 files changed, 49 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index eaad925e60..8e83eb185c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -171,6 +171,48 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "PXL_TEXLD_INST_COUNTER" }
   }
+   },
+   {
+  .name = "pa-input-vtx-counter",
+  .type = ETNA_QUERY_PA_INPUT_VTX_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "INPUT_VTX_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-input-prim-counter",
+  .type = ETNA_QUERY_PA_INPUT_PRIM_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "INPUT_PRIM_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-output-prim-counter",
+  .type = ETNA_QUERY_PA_OUTPUT_PRIM_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "OUTPUT_PRIM_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-depth-clipped-counter",
+  .type = ETNA_QUERY_PA_DEPTH_CLIPPED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "DEPTH_CLIPPED_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-trivial-rejected-counter",
+  .type = ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "TRIVIAL_REJECTED_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-culled-counter",
+  .type = ETNA_QUERY_PA_CULLED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "CULLED_COUNTER" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index b5e7fe5ad3..00fea71f23 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -55,6 +55,13 @@ struct etna_screen;
 #define ETNA_QUERY_SH_PXL_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
17)
 #define ETNA_QUERY_SH_PXL_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
18)
 
+#define ETNA_QUERY_PA_INPUT_VTX_COUNTER  (ETNA_PM_QUERY_BASE + 
19)
+#define ETNA_QUERY_PA_INPUT_PRIM_COUNTER (ETNA_PM_QUERY_BASE + 
20)
+#define ETNA_QUERY_PA_OUTPUT_PRIM_COUNTER(ETNA_PM_QUERY_BASE + 
21)
+#define ETNA_QUERY_PA_DEPTH_CLIPPED_COUNTER  (ETNA_PM_QUERY_BASE + 
22)
+#define ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER   (ETNA_PM_QUERY_BASE + 
23)
+#define ETNA_QUERY_PA_CULLED_COUNTER (ETNA_PM_QUERY_BASE + 
24)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 00/12] etnaviv: support performance monitor

2018-03-25 Thread Christian Gmeiner
Starting with kernel 4.16 the etnaviv driver exports perfmon domains
and signals to userspace. This patch series adds support for those
queries to mesa and exposes them via amd_performance_monitor.

Passes all amd_performance_monitor piglits.

Christian Gmeiner (12):
  etnaviv: add perfmon query implementation
  etnaviv: support HI performance counters
  etnaviv: support PE performance counters
  etnaviv: support SH performance counters
  etnaviv: support PA performance counters
  etnaviv: support SE performance counters
  etnaviv: support RA performance counters
  etnaviv: support TX performance counters
  etnaviv: support MC performance counters
  etnaviv: assign group_ids to perfmon queries
  etnaviv: add query_group_info for perfmon counters
  etnaviv: expose perfmon query groups

 configure.ac   |   2 +-
 meson.build|   2 +-
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|  19 +-
 src/gallium/drivers/etnaviv/etnaviv_query.h|   1 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 678 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 129 +
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |   8 +
 src/gallium/drivers/etnaviv/etnaviv_screen.h   |   4 +
 9 files changed, 839 insertions(+), 6 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.h

-- 
2.14.3

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


[Mesa-dev] [PATCH 12/12] etnaviv: expose perfmon query groups

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 00f87d22cb..b076e87e78 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -122,11 +122,15 @@ etna_get_driver_query_group_info(struct pipe_screen 
*pscreen, unsigned index,
  struct pipe_driver_query_group_info *info)
 {
int nr_sw_groups = etna_sw_get_driver_query_group_info(pscreen, 0, NULL);
+   int nr_pm_groups = etna_pm_get_driver_query_group_info(pscreen, 0, NULL);
 
if (!info)
-  return nr_sw_groups;
+  return nr_sw_groups + nr_pm_groups;
 
-   return etna_sw_get_driver_query_group_info(pscreen, index, info);
+   if (index < nr_sw_groups)
+  return etna_sw_get_driver_query_group_info(pscreen, index, info);
+
+   return etna_pm_get_driver_query_group_info(pscreen, index, info);
 }
 
 static void
-- 
2.14.3

___
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 Christian Gmeiner
2018-03-29 16:15 GMT+02:00 Lucas Stach <l.st...@pengutronix.de>:
> 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>

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

> ---
>  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++;
> }
>
> --
> 2.16.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
___
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 Christian Gmeiner
2018-03-29 16:15 GMT+02:00 Lucas Stach <l.st...@pengutronix.de>:
> 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>

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

> ---
>  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.
> --
> 2.16.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH kmscube] cube-tex: make use of modifiers

2018-03-20 Thread Christian Gmeiner
Fixes rendering issues with mode rgba on etnaviv. I have applied
the same change for nv12 variants but they are not supported on
etnaviv.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 cube-tex.c | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/cube-tex.c b/cube-tex.c
index 9e38ae8..dba19ff 100644
--- a/cube-tex.c
+++ b/cube-tex.c
@@ -213,7 +213,7 @@ static const char *fragment_shader_source_2img =
 
 static const uint32_t texw = 512, texh = 512;
 
-static int get_fd_rgba(uint32_t *pstride)
+static int get_fd_rgba(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -234,6 +234,7 @@ static int get_fd_rgba(uint32_t *pstride)
gbm_bo_unmap(bo, map_data);
 
fd = gbm_bo_get_fd(bo);
+   *modifier = gbm_bo_get_modifier(bo);
 
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
@@ -243,7 +244,7 @@ static int get_fd_rgba(uint32_t *pstride)
return fd;
 }
 
-static int get_fd_y(uint32_t *pstride)
+static int get_fd_y(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -264,6 +265,7 @@ static int get_fd_y(uint32_t *pstride)
gbm_bo_unmap(bo, map_data);
 
fd = gbm_bo_get_fd(bo);
+   *modifier = gbm_bo_get_modifier(bo);
 
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
@@ -273,7 +275,7 @@ static int get_fd_y(uint32_t *pstride)
return fd;
 }
 
-static int get_fd_uv(uint32_t *pstride)
+static int get_fd_uv(uint32_t *pstride, uint64_t *modifier)
 {
struct gbm_bo *bo;
void *map_data = NULL;
@@ -294,6 +296,7 @@ static int get_fd_uv(uint32_t *pstride)
gbm_bo_unmap(bo, map_data);
 
fd = gbm_bo_get_fd(bo);
+   *modifier = gbm_bo_get_modifier(bo);
 
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
@@ -306,7 +309,8 @@ static int get_fd_uv(uint32_t *pstride)
 static int init_tex_rgba(void)
 {
uint32_t stride;
-   int fd = get_fd_rgba();
+   uint64_t modifier;
+   int fd = get_fd_rgba(, );
const EGLint attr[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
@@ -314,6 +318,8 @@ static int init_tex_rgba(void)
EGL_DMA_BUF_PLANE0_FD_EXT, fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+   EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, modifier & 0x,
+   EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifier >> 32,
EGL_NONE
};
EGLImage img;
@@ -339,8 +345,9 @@ static int init_tex_rgba(void)
 static int init_tex_nv12_2img(void)
 {
uint32_t stride_y, stride_uv;
-   int fd_y = get_fd_y(_y);
-   int fd_uv = get_fd_uv(_uv);
+   uint64_t modifier_y, modifier_uv;
+   int fd_y = get_fd_y(_y, _y);
+   int fd_uv = get_fd_uv(_uv, _uv);
const EGLint attr_y[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
@@ -348,6 +355,8 @@ static int init_tex_nv12_2img(void)
EGL_DMA_BUF_PLANE0_FD_EXT, fd_y,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride_y,
+   EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, modifier_y & 0x,
+   EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifier_y >> 32,
EGL_NONE
};
const EGLint attr_uv[] = {
@@ -357,6 +366,8 @@ static int init_tex_nv12_2img(void)
EGL_DMA_BUF_PLANE0_FD_EXT, fd_uv,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride_uv,
+   EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, modifier_uv & 0x,
+   EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifier_uv >> 32,
EGL_NONE
};
EGLImage img_y, img_uv;
@@ -397,8 +408,9 @@ static int init_tex_nv12_2img(void)
 static int init_tex_nv12_1img(void)
 {
uint32_t stride_y, stride_uv;
-   int fd_y = get_fd_y(_y);
-   int fd_uv = get_fd_uv(_uv);
+   uint64_t modifier_y, modifier_uv;
+   int fd_y = get_fd_y(_y, _y);
+   int fd_uv = get_fd_uv(_uv, _uv);
const EGLint attr[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
@@ -406,9 +418,13 @@ static int init_tex_nv12_1img(void)
EGL_DMA_BUF_PLANE0_FD_EXT, fd_y,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride_y,
+   EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, modifier_y & 0x,
+   EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifier_y >> 32,
EGL_DMA_BUF_PLANE1_FD_EXT, fd_uv,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE1_PITCH_EXT, stride_uv,
+   EGL_DMA_BUF_PL

[Mesa-dev] [PATCH 1/2] etnaviv: add query_group_info for sw counters

2018-03-05 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 30 --
 src/gallium/drivers/etnaviv/etnaviv_query_sw.h |  5 +
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
index 2e65065b28..f955d8e210 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
@@ -118,16 +118,16 @@ etna_sw_create_query(struct etna_context *ctx, unsigned 
query_type)
return q;
 }
 
+static const struct pipe_driver_query_info list[] = {
+   {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
+   {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
+   {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
+};
+
 int
 etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
   struct pipe_driver_query_info *info)
 {
-   static const struct pipe_driver_query_info list[] = {
-  {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
-  {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
-  {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
-   };
-
if (!info)
   return ARRAY_SIZE(list);
 
@@ -138,3 +138,21 @@ etna_sw_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
 
return 1;
 }
+
+int
+etna_sw_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info)
+{
+   if (!info)
+  return ARRAY_SIZE(list);
+
+   if (index != 0)
+  return 0;
+
+   info->name = "driver";
+   info->max_active_queries = ARRAY_SIZE(list);
+   info->num_queries = ARRAY_SIZE(list);
+
+   return 1;
+}
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
index 9321147094..f5a2dbef1a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
@@ -51,4 +51,9 @@ int
 etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
   struct pipe_driver_query_info *info);
 
+int
+etna_sw_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info);
+
 #endif
-- 
2.14.3

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


[Mesa-dev] [PATCH 2/2] etnaviv: add get_driver_query_group_info(..)

2018-03-05 Thread Christian Gmeiner
This enables AMD_performance_monitor extension.

Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 9e897cd75a..2d257a9d34 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -110,6 +110,18 @@ etna_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
return etna_sw_get_driver_query_info(pscreen, index, info);
 }
 
+static int
+etna_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
+ struct pipe_driver_query_group_info *info)
+{
+   int nr_sw_groups = etna_sw_get_driver_query_group_info(pscreen, 0, NULL);
+
+   if (!info)
+  return nr_sw_groups;
+
+   return etna_sw_get_driver_query_group_info(pscreen, index, info);
+}
+
 static void
 etna_set_active_query_state(struct pipe_context *pipe, boolean enable)
 {
@@ -119,6 +131,7 @@ void
 etna_query_screen_init(struct pipe_screen *pscreen)
 {
pscreen->get_driver_query_info = etna_get_driver_query_info;
+   pscreen->get_driver_query_group_info = etna_get_driver_query_group_info;
 }
 
 void
-- 
2.14.3

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


[Mesa-dev] [PATCH 0/2] etnaviv: amd_performance_monitor support

2018-03-05 Thread Christian Gmeiner
Nothing fancy - passes all amd_performance_monitor piglits.

Christian Gmeiner (2):
  etnaviv: add query_group_info for sw counters
  etnaviv: add get_driver_query_group_info(..)

 src/gallium/drivers/etnaviv/etnaviv_query.c| 13 +++
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 30 --
 src/gallium/drivers/etnaviv/etnaviv_query_sw.h |  5 +
 3 files changed, 42 insertions(+), 6 deletions(-)

-- 
2.14.3

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


[Mesa-dev] [PATCH] nir: call nir_index_local_regs(..) to update reg_alloc

2018-06-24 Thread Christian Gmeiner
After calling nir_lower_regs_to_ssa(..) nir_function_impl's reg_alloc
counter still hold its old value. Just call nir_index_local_regs(..) to
set reg_alloc to the correct value - which should be 0.

Signed-off-by: Christian Gmeiner 
---
 src/compiler/nir/nir_lower_regs_to_ssa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/nir/nir_lower_regs_to_ssa.c 
b/src/compiler/nir/nir_lower_regs_to_ssa.c
index d70e70260b..7214e92b90 100644
--- a/src/compiler/nir/nir_lower_regs_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -275,6 +275,8 @@ nir_lower_regs_to_ssa_impl(nir_function_impl *impl)
   }
}
 
+   nir_index_local_regs(impl);
+
free(state.values);
 
nir_metadata_preserve(impl, nir_metadata_block_index |
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH] mesa/st: Only call nir_lower_io_to_scalar_early on scalar ISAs

2018-10-21 Thread Christian Gmeiner
Am So., 21. Okt. 2018 um 20:37 Uhr schrieb Alyssa Rosenzweig
:
>
> On scalar ISAs, nir_lower_io_to_scalar_early enables significant
> optimizations. However, on vector ISAs, it is counterproductive and
> impedes optimal codegen. This patch only calls
> nir_lower_io_to_scalar_early for scalar ISAs. It appears that at present
> there are no upstreamed drivers using Gallium, NIR, and a vector ISA, so
> for existing code, this should be a no-op. However, this patch is
> necessary for the upcoming Panfrost (Midgard) and Lima (Utgard)
> compilers, which are vector.
>
> With this patch, Panfrost is able to consume NIR directly, rather than
> TGSI with the TGSI->NIR conversion.
>
> For how this affects Lima, see
> https://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg189216.html
>
> Signed-off-by: Alyssa Rosenzweig 

Reviewed-by: Christian Gmeiner 

> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 24776f7f9c..911284401e 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -665,7 +665,10 @@ st_link_nir(struct gl_context *ctx,
>   mask = (nir_variable_mode)(mask | nir_var_shader_out);
>
>nir_shader *nir = shader->Program->nir;
> -  NIR_PASS_V(nir, nir_lower_io_to_scalar_early, mask);
> +
> +  if (is_scalar[i])
> + NIR_PASS_V(nir, nir_lower_io_to_scalar_early, mask);
> +
>st_nir_opts(nir, is_scalar[i]);
> }
>

Do you need somebody to push it?

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [RFC 31/31] nir: Add a bool to float32 lowering pass

2018-10-22 Thread Christian Gmeiner
Am Di., 23. Okt. 2018 um 01:43 Uhr schrieb Jason Ekstrand
:
>
> On Mon, Oct 22, 2018 at 6:20 PM Alyssa Rosenzweig  
> wrote:
>>
>> For what it's worth, Midgard has real integers (including int32
>> support), using hardware-level D3D10 boolean conventions. I'm trying to
>> wrap my head around how this interacts with 5d85a0a.
>
>
> Right.  Sorry.  I forgot who's working on what chip these days.  Maybe Ilia 
> can CC the right person.
>

I really love this pass and will help me/etnaviv to
 - reduce my hand crafted handling for such cases
 - make it easy to support vivante gpus with and without integer support

I can give this pass a try over the weekend if you want.
-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [RFC 31/31] nir: Add a bool to float32 lowering pass

2018-10-23 Thread Christian Gmeiner
reak;
> >> +
> >> + case nir_instr_type_load_const: {
> >> +nir_load_const_instr *load = nir_instr_as_load_const(instr);
> >> +if (load->def.bit_size == 1) {
> >> +       nir_const_value value = load->value;
> >> +   for (unsigned i = 0; i < load->def.num_components; i++)
> >> +  load->value.u32[i] = value.b[i] ? NIR_TRUE : NIR_FALSE;
> >
> > value.f32[i] = value.b[i] ? 1.0 : 0.0
> >
> >> +   load->def.bit_size = 32;
> >> +   progress = true;
> >> +}
> >> +break;
> >> + }
> >> +
> >> + case nir_instr_type_intrinsic:
> >> + case nir_instr_type_ssa_undef:
> >> + case nir_instr_type_phi:
> >> + case nir_instr_type_tex:
> >> +nir_foreach_ssa_def(instr, rewrite_1bit_ssa_def_to_32bit,
> >> +);
> >> +break;
> >> +
> >> + default:
> >> +nir_foreach_ssa_def(instr, assert_ssa_def_is_not_1bit, NULL);
> >> + }
> >> +  }
> >> +   }
> >> +
> >> +   if (progress) {
> >> +  nir_metadata_preserve(impl, nir_metadata_block_index |
> >> +  nir_metadata_dominance);
> >> +   }
> >> +
> >> +   return progress;
> >> +}
> >> +
> >> +bool
> >> +nir_lower_bool_to_int32(nir_shader *shader)
> >
> > int32...
> >
> >> +{
> >> +   bool progress = false;
> >> +
> >> +   nir_foreach_function(function, shader) {
> >> +  if (function->impl && nir_lower_bool_to_int32_impl(function->impl))
> >> + progress = true;
> >> +   }
> >> +
> >> +   return progress;
> >> +}
> >> --
> >> 2.19.1
> >>
> >> ___
> >> mesa-dev mailing list
> >> mesa-dev@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH] Revert "imx: make use of loader_open_render_node(..) helper"

2018-10-29 Thread Christian Gmeiner
This reverts commit 773d6ea6e715d207bda3a53a9dfc8acf686035b0.

Since kernel 4.17 (drm/etnaviv: remove the need for a gpu-subsystem DT
node) the etnaviv DRM driver doesn't have an associated DT node
anymore. This is technically correct, as the etnaviv device is a
virtual device driving multiple hardware devices.

Before 4.17 the userspace had access to the following information:
DRIVER=etnaviv
OF_NAME=gpu-subsystem
OF_FULLNAME=/gpu-subsystem
OF_COMPATIBLE_0=fsl,imx-gpu-subsystem
OF_COMPATIBLE_N=1
MODALIAS=of:Ngpu-subsystemTCfsl,imx-gpu-subsystem
DRIVER=imx-drm
OF_NAME=display-subsystem
OF_FULLNAME=/display-subsystem
OF_COMPATIBLE_0=fsl,imx-display-subsystem
OF_COMPATIBLE_N=1

Afer 4.17:
DRIVER=etnaviv
MODALIAS=platform:etnaviv

The OF node has never been part of the etnaviv UABI, simply due to the
fact that it's still possible to instantiate the etnaviv driver from a
platform file, instead of a devicetree node.

A patch set to fix this problem was send out [1] but it looks like
that a proper solution needs more time to bake.

[1] https://lists.freedesktop.org/archives/dri-devel/2018-October/194651.html

Suggested-by: Emil Velikov 
Signed-off-by: Christian Gmeiner 
---
 src/gallium/winsys/imx/drm/imx_drm_winsys.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/winsys/imx/drm/imx_drm_winsys.c 
b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
index 4bd21250315..cd72610b955 100644
--- a/src/gallium/winsys/imx/drm/imx_drm_winsys.c
+++ b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
@@ -26,7 +26,6 @@
 
 #include "imx_drm_public.h"
 #include "etnaviv/drm/etnaviv_drm_public.h"
-#include "loader/loader.h"
 #include "renderonly/renderonly.h"
 
 #include 
@@ -37,7 +36,7 @@ struct pipe_screen *imx_drm_screen_create(int fd)
struct renderonly ro = {
   .create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
   .kms_fd = fd,
-  .gpu_fd = loader_open_render_node("etnaviv")
+  .gpu_fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC)
};
 
if (ro.gpu_fd < 0)
-- 
2.17.2

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


Re: [Mesa-dev] [PATCH 1/2] nir: add lowering for ffloor

2018-11-12 Thread Christian Gmeiner
Hi Jason

Am Sa., 1. Sep. 2018 um 21:23 Uhr schrieb Jason Ekstrand :
>
> I don't think either of these work for negative numbers
>

I would like to land this patch - can you provide some details why
this does not work for
negative numbers?

> On September 1, 2018 14:16:11 Christian Gmeiner
>  wrote:
>
> > Signed-off-by: Christian Gmeiner 
> > ---
> > src/compiler/nir/nir.h| 3 +++
> > src/compiler/nir/nir_opt_algebraic.py | 1 +
> > 2 files changed, 4 insertions(+)
> >
> > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> > index 169fa1fa20..d81eefc032 100644
> > --- a/src/compiler/nir/nir.h
> > +++ b/src/compiler/nir/nir.h
> > @@ -2054,6 +2054,9 @@ typedef struct nir_shader_compiler_options {
> > */
> >bool fdot_replicates;
> >
> > +   /** lowers ffloor to fsub+ffract: */
> > +   bool lower_ffloor;
> > +
> >/** lowers ffract to fsub+ffloor: */
> >bool lower_ffract;
> >
> > diff --git a/src/compiler/nir/nir_opt_algebraic.py
> > b/src/compiler/nir/nir_opt_algebraic.py
> > index ae1261f874..3d2b861a42 100644
> > --- a/src/compiler/nir/nir_opt_algebraic.py
> > +++ b/src/compiler/nir/nir_opt_algebraic.py
> > @@ -118,6 +118,7 @@ optimizations = [
> >(('~flrp', a, 0.0, c), ('fadd', ('fmul', ('fneg', a), c), a)),
> >(('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a),
> >'options->lower_flrp32'),
> >(('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a),
> >'options->lower_flrp64'),
> > +   (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
> >(('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> >(('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c, ('fmul', b,
> >('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
> >(('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', 
> > b,
> >c )), ('flrp', a, b, c), '!options->lower_flrp32'),
> > --
> > 2.17.1
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
>

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 1/3] nir: add fceil lowering

2018-11-12 Thread Christian Gmeiner
Am Mo., 12. Nov. 2018 um 19:17 Uhr schrieb Jonathan Marek :
>
> lowers ceil(x) as -floor(-x)
>
> Signed-off-by: Jonathan Marek 

Reviewed-by: Christian Gmeiner 

> ---
>  src/compiler/nir/nir.h| 3 +++
>  src/compiler/nir/nir_opt_algebraic.py | 1 +
>  2 files changed, 4 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index dc3c729dee..f9b32a5daf 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2086,6 +2086,9 @@ typedef struct nir_shader_compiler_options {
> /** lowers ffract to fsub+ffloor: */
> bool lower_ffract;
>
> +   /** lowers fceil to fneg+ffloor+fneg: */
> +   bool lower_fceil;
> +
> bool lower_ldexp;
>
> bool lower_pack_half_2x16;
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index 8b24daddfd..8f4df891b8 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -124,6 +124,7 @@ optimizations = [
> (('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
> 'options->lower_flrp32'),
> (('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 
> 'options->lower_flrp64'),
> (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> +   (('fceil', a), ('fneg', ('ffloor', ('fneg', a))), 'options->lower_fceil'),
> (('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c, ('fmul', b, 
> ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
> (('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', 
> b, c )), ('flrp', a, b, c), '!options->lower_flrp32'),
> (('~fadd@64', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', 
> b, c )), ('flrp', a, b, c), '!options->lower_flrp64'),
> --
> 2.17.1
>
> _______
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 02/11] util: Add macro to get number of elements in dynarray

2018-09-21 Thread Christian Gmeiner
Am Sa., 15. Sep. 2018 um 07:45 Uhr schrieb Caio Marcelo de Oliveira
Filho :
>
> ---
>
> I've ended up not using this macro in this series, but it is useful
> for other cases, so kept it here.
>

I could make use of it.

Reviewed-by: Christian Gmeiner 

>  src/util/u_dynarray.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
> index f74bfc7080b..53dde9241bb 100644
> --- a/src/util/u_dynarray.h
> +++ b/src/util/u_dynarray.h
> @@ -149,6 +149,7 @@ util_dynarray_trim(struct util_dynarray *buf)
>  #define util_dynarray_element(buf, type, idx) ((type*)(buf)->data + (idx))
>  #define util_dynarray_begin(buf) ((buf)->data)
>  #define util_dynarray_end(buf) ((void*)util_dynarray_element((buf), char, 
> (buf)->size))
> +#define util_dynarray_num_elements(buf, type) ((buf)->size / sizeof(type))
>
>  #define util_dynarray_foreach(buf, type, elem) \
> for (type *elem = (type *)(buf)->data; \
> --
> 2.19.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


[Mesa-dev] [PATCH v2] etnaviv: fix resource usage tracking across different pipe_context's

2019-01-02 Thread Christian Gmeiner
A pipe_resource can be shared by all the pipe_context's hanging off the
same pipe_screen.

Changes from v1 -> v2:
 - to remove the resource from the used_resources set when it is destroyed

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 21 
 src/gallium/drivers/etnaviv/etnaviv_context.h |  3 --
 .../drivers/etnaviv/etnaviv_resource.c| 48 ++-
 .../drivers/etnaviv/etnaviv_resource.h|  7 ++-
 src/gallium/drivers/etnaviv/etnaviv_screen.c  |  8 
 src/gallium/drivers/etnaviv/etnaviv_screen.h  |  4 ++
 6 files changed, 61 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 44b50925a4f..8d4956516f1 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -36,6 +36,7 @@
 #include "etnaviv_query.h"
 #include "etnaviv_query_hw.h"
 #include "etnaviv_rasterizer.h"
+#include "etnaviv_resource.h"
 #include "etnaviv_screen.h"
 #include "etnaviv_shader.h"
 #include "etnaviv_state.h"
@@ -329,7 +330,8 @@ static void
 etna_cmd_stream_reset_notify(struct etna_cmd_stream *stream, void *priv)
 {
struct etna_context *ctx = priv;
-   struct etna_resource *rsc, *rsc_tmp;
+   struct etna_screen *screen = ctx->screen;
+   struct set_entry *entry;
 
etna_set_state(stream, VIVS_GL_API_MODE, VIVS_GL_API_MODE_OPENGL);
etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x0001);
@@ -384,16 +386,13 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
ctx->dirty = ~0L;
ctx->dirty_sampler_views = ~0L;
 
-   /* go through all the used resources and clear their status flag */
-   LIST_FOR_EACH_ENTRY_SAFE(rsc, rsc_tmp, >used_resources, list)
-   {
-  debug_assert(rsc->status != 0);
-  rsc->status = 0;
-  rsc->pending_ctx = NULL;
-  list_delinit(>list);
-   }
+   /* go through all the used context resources and clear their status flag */
+   set_foreach(screen->used_resources, entry) {
+  struct etna_resource *rsc = (struct etna_resource *)entry->key;
 
-   assert(LIST_IS_EMPTY(>used_resources));
+  _mesa_set_remove_key(rsc->pending_ctx, ctx);
+  _mesa_set_remove(screen->used_resources, entry);
+   }
 }
 
 static void
@@ -437,8 +436,6 @@ etna_context_create(struct pipe_screen *pscreen, void 
*priv, unsigned flags)
/* need some sane default in case state tracker doesn't set some state: */
ctx->sample_mask = 0x;
 
-   list_inithead(>used_resources);
-
/*  Set sensible defaults for state */
etna_cmd_stream_reset_notify(ctx->stream, ctx);
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
b/src/gallium/drivers/etnaviv/etnaviv_context.h
index 6ad9f3431e1..50a2cdf3d07 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
@@ -136,9 +136,6 @@ struct etna_context {
uint32_t prim_hwsupport;
struct primconvert_context *primconvert;
 
-   /* list of resources used by currently-unsubmitted renders */
-   struct list_head used_resources;
-
struct slab_child_pool transfer_pool;
struct blitter_context *blitter;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index c0091288030..00b5f43bf3f 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -33,6 +33,7 @@
 #include "etnaviv_screen.h"
 #include "etnaviv_translate.h"
 
+#include "util/hash_table.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 
@@ -282,7 +283,6 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
layout,
rsc->halign = halign;
 
pipe_reference_init(>base.reference, 1);
-   list_inithead(>list);
 
size = setup_miptree(rsc, paddingX, paddingY, msaa_xscale, msaa_yscale);
 
@@ -303,6 +303,11 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
layout,
   memset(map, 0, size);
}
 
+   rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer,
+   _mesa_key_pointer_equal);
+   if (!rsc->pending_ctx)
+  goto free_rsc;
+
return >base;
 
 free_rsc:
@@ -462,8 +467,12 @@ etna_resource_changed(struct pipe_screen *pscreen, struct 
pipe_resource *prsc)
 static void
 etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
 {
+   struct etna_screen *screen = etna_screen(pscreen);
struct etna_resource *rsc = etna_resource(prsc);
 
+   _mesa_set_destroy(rsc->pending_ctx, NULL);
+   _mesa_set_remove_key(screen->used_resources, rsc);
+
if (rsc->bo)
   etna_bo_del(rsc->bo);
 
@@ -471,9 +480,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct 
pipe_resource *

[Mesa-dev] [PATCH 2/4] etnaviv: update headers from rnndb

2019-01-20 Thread Christian Gmeiner
Update to etna_viv commit 4d2f857.

Signed-off-by: Christian Gmeiner 
---
 .../drivers/etnaviv/hw/cmdstream.xml.h|   8 +-
 src/gallium/drivers/etnaviv/hw/common.xml.h   | 171 +-
 .../drivers/etnaviv/hw/common_3d.xml.h|  12 +-
 src/gallium/drivers/etnaviv/hw/isa.xml.h  |   6 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h|  22 +--
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h |  28 +--
 .../drivers/etnaviv/hw/state_blt.xml.h|  22 +--
 .../drivers/etnaviv/hw/texdesc_3d.xml.h   |  13 +-
 8 files changed, 227 insertions(+), 55 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
index 63d4e9342eb..77cbebfe365 100644
--- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
@@ -8,11 +8,11 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- cmdstream.xml (  16929 bytes, from 2017-10-13 12:22:46)
-- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
-- common.xml(  26187 bytes, from 2017-10-31 19:05:01)
+- cmdstream.xml (  16930 bytes, from 2019-01-04 11:37:39)
+- copyright.xml (   1597 bytes, from 2018-02-10 13:09:26)
+- common.xml(  35468 bytes, from 2018-02-10 13:09:26)
 
-Copyright (C) 2012-2017 by the following authors:
+Copyright (C) 2012-2019 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
b/src/gallium/drivers/etnaviv/hw/common.xml.h
index 60bde8b96b8..4af7ec3693a 100644
--- a/src/gallium/drivers/etnaviv/hw/common.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
@@ -8,12 +8,12 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- texdesc_3d.xml (   3183 bytes, from 2017-10-31 19:05:01)
-- copyright.xml  (   1597 bytes, from 2016-10-29 07:29:22)
-- common.xml (  26187 bytes, from 2017-10-31 19:05:01)
-- common_3d.xml  (  14615 bytes, from 2017-11-04 14:03:35)
+- texdesc_3d.xml (   3183 bytes, from 2018-02-10 13:09:26)
+- copyright.xml  (   1597 bytes, from 2018-02-10 13:09:26)
+- common.xml (  35468 bytes, from 2018-02-10 13:09:26)
+- common_3d.xml  (  14843 bytes, from 2019-01-18 10:13:41)
 
-Copyright (C) 2012-2017 by the following authors:
+Copyright (C) 2012-2018 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
@@ -320,5 +320,166 @@ DEALINGS IN THE SOFTWARE.
 #define chipMinorFeatures6_DEC 0x0004
 #define chipMinorFeatures6_VS_TILE_NV12
0x0008
 #define chipMinorFeatures6_VS_TILE_NV12_10BIT  0x0010
+#define chipMinorFeatures6_RENDER_TARGET_8 0x0020
+#define chipMinorFeatures6_TEX_LOD_FLOW_CORR   0x0040
+#define chipMinorFeatures6_FACE_LOD0x0080
+#define chipMinorFeatures6_MULTI_CORE_SEMAPHORE_STALL_V2   0x0100
+#define chipMinorFeatures6_VMSAA   0x0200
+#define chipMinorFeatures6_CHIP_ENABLE_LINK0x0400
+#define chipMinorFeatures6_MULTI_SRC_BLT_1_5_ENHANCEMENT   0x0800
+#define chipMinorFeatures6_MULTI_SRC_BLT_BILINEAR_FILTER   0x1000
+#define chipMinorFeatures6_RA_HZEZ_CLOCK_CONTROL   0x2000
+#define chipMinorFeatures6_CACHE128B256BPERLINE
0x4000
+#define chipMinorFeatures6_V4_COMPRESSION  0x8000
+#define chipMinorFeatures6_PE2D_MAJOR_SUPER_TILE   0x0001
+#define chipMinorFeatures6_PE_32BPC_COLORMASK_FIX  0x0002
+#define chipMinorFeatures6_ALPHA_BLENDING_OPT  0x0004
+#define chipMinorFeatures6_NEW_GPIPE   0x0008
+#define chipMinorFeatures6_PIPELINE_32_ATTRIBUTES  0x0010
+#define chipMinorFeatures6_MSAA_SHADING
0x0020
+#define chipMinorFeatures6_NO_ANISTRO_FILTER   0x0040
+#define chipMinorFeatures6_NO_ASTC 0x0080
+#define chipMinorFeatures6_NO_DXT  0x0100
+#define chipMinorFeatures6_HWTFB   0x0200
+#define chipMinorFeatures6_RA_DEPTH_WRITE_MSAA1X_FIX   0x0400
+#define chipMinorFeatures6_EZHZ_CLOCKGATE_FIX  0x0800
+#define chipMinorFeatures6_SH_SNAP2PAGE_FIX0x1000
+#define chipMinorFeatures6_SH_HALFDEPENDENCY_FIX   0x2000
+#define chipMinorFeatures6_USC_MCFILL_FIX  0x4000
+#define chipMinorFeatures6_TPG_TCPERF_FIX  0x8000
+#define chipMinorFeatures7_USC_MDFIFO_OVERFLOW_FIX

[Mesa-dev] [PATCH 4/4] etnaviv: hook up linear texture sampling support

2019-01-20 Thread Christian Gmeiner
If the GPU supports linear sampling, linear addressing mode
will be used as default.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 10 +++---
 src/gallium/drivers/etnaviv/etnaviv_texture.c  |  4 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 9a7ebf3064e..7d24b1f03bd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -318,9 +318,9 @@ etna_resource_create(struct pipe_screen *pscreen,
 {
struct etna_screen *screen = etna_screen(pscreen);
 
-   /* Figure out what tiling and address mode to use -- for now, assume that
-* texture cannot be linear. there is a capability LINEAR_TEXTURE_SUPPORT
-* (supported on gc880 and gc2000 at least), but not sure how it works.
+   /* Figure out what tiling and address mode to use.
+* Textures are TILED or LINEAR. If LINEAR_TEXTURE_SUPPORT capability is
+* available LINEAR gets prefered.
 * Buffers always have LINEAR layout.
 */
unsigned layout = ETNA_LAYOUT_LINEAR;
@@ -334,6 +334,10 @@ etna_resource_create(struct pipe_screen *pscreen,
 
   if (util_format_is_compressed(templat->format))
  layout = ETNA_LAYOUT_LINEAR;
+  else if (VIV_FEATURE(screen, chipMinorFeatures1, 
LINEAR_TEXTURE_SUPPORT)) {
+ layout = ETNA_LAYOUT_LINEAR;
+ mode = ETNA_ADDRESSING_MODE_LINEAR;
+  }
} else if (templat->target != PIPE_BUFFER) {
   bool want_multitiled = false;
   bool want_supertiled = screen->specs.can_supertile;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c 
b/src/gallium/drivers/etnaviv/etnaviv_texture.c
index 3993e31cec1..b06f20531fd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
@@ -172,7 +172,9 @@ etna_resource_sampler_compatible(struct etna_resource *res)
if (res->layout == ETNA_LAYOUT_SUPER_TILED && VIV_FEATURE(screen, 
chipMinorFeatures2, SUPERTILED_TEXTURE))
   return true;
 
-   /* TODO: LINEAR_TEXTURE_SUPPORT */
+   /* This GPU supports texturing from linear textures? */
+   if (res->layout == ETNA_LAYOUT_LINEAR && VIV_FEATURE(screen, 
chipMinorFeatures1, LINEAR_TEXTURE_SUPPORT))
+  return true;
 
/* Otherwise, only support tiled layouts */
if (res->layout != ETNA_LAYOUT_TILED)
-- 
2.20.1

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


[Mesa-dev] [PATCH 1/4] etnaviv: extend etna_resource with an addressing mode

2019-01-20 Thread Christian Gmeiner
Defines how sampler (and pixel pipes) needs to access the data
represented with a resource. The used default is mode is
ETNA_ADDRESSING_MODE_TILED.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 17 +++--
 src/gallium/drivers/etnaviv/etnaviv_resource.h |  9 -
 src/gallium/drivers/etnaviv/etnaviv_texture.c  |  1 +
 src/gallium/drivers/etnaviv/etnaviv_transfer.c |  3 ++-
 4 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index c0091288030..9a7ebf3064e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -188,7 +188,8 @@ static bool is_rs_align(struct etna_screen *screen,
 /* Create a new resource object, using the given template info */
 struct pipe_resource *
 etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
-uint64_t modifier, const struct pipe_resource *templat)
+enum etna_resource_addressing_mode mode, uint64_t modifier,
+const struct pipe_resource *templat)
 {
struct etna_screen *screen = etna_screen(pscreen);
struct etna_resource *rsc;
@@ -280,6 +281,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
layout,
rsc->base.nr_samples = nr_samples;
rsc->layout = layout;
rsc->halign = halign;
+   rsc->addressing_mode = mode;
 
pipe_reference_init(>base.reference, 1);
list_inithead(>list);
@@ -316,12 +318,14 @@ etna_resource_create(struct pipe_screen *pscreen,
 {
struct etna_screen *screen = etna_screen(pscreen);
 
-   /* Figure out what tiling to use -- for now, assume that texture cannot be 
linear.
-* there is a capability LINEAR_TEXTURE_SUPPORT (supported on gc880 and
-* gc2000 at least), but not sure how it works.
+   /* Figure out what tiling and address mode to use -- for now, assume that
+* texture cannot be linear. there is a capability LINEAR_TEXTURE_SUPPORT
+* (supported on gc880 and gc2000 at least), but not sure how it works.
 * Buffers always have LINEAR layout.
 */
unsigned layout = ETNA_LAYOUT_LINEAR;
+   enum etna_resource_addressing_mode mode = ETNA_ADDRESSING_MODE_TILED;
+
if (etna_resource_sampler_only(templat)) {
   /* The buffer is only used for texturing, so create something
* directly compatible with the sampler.  Such a buffer can
@@ -364,7 +368,7 @@ etna_resource_create(struct pipe_screen *pscreen,
   layout = ETNA_LAYOUT_LINEAR;
 
/* modifier is only used for scanout surfaces, so safe to use LINEAR here */
-   return etna_resource_alloc(pscreen, layout, DRM_FORMAT_MOD_LINEAR, templat);
+   return etna_resource_alloc(pscreen, layout, mode, DRM_FORMAT_MOD_LINEAR, 
templat);
 }
 
 enum modifier_priority {
@@ -445,7 +449,7 @@ etna_resource_create_modifiers(struct pipe_screen *pscreen,
tmpl.bind |= PIPE_BIND_SCANOUT;
 
return etna_resource_alloc(pscreen, modifier_to_layout(modifier),
-  modifier, );
+  ETNA_ADDRESSING_MODE_TILED, modifier, );
 }
 
 static void
@@ -518,6 +522,7 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
rsc->seqno = 1;
rsc->layout = modifier_to_layout(handle->modifier);
rsc->halign = TEXTURE_HALIGN_FOUR;
+   rsc->addressing_mode = ETNA_ADDRESSING_MODE_TILED;
 
 
level->width = tmpl->width0;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h 
b/src/gallium/drivers/etnaviv/etnaviv_resource.h
index 11ccf8f7bcb..75aa80b3d7a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
@@ -49,6 +49,11 @@ struct etna_resource_level {
bool ts_valid;
 };
 
+enum etna_resource_addressing_mode {
+   ETNA_ADDRESSING_MODE_TILED = 0,
+   ETNA_ADDRESSING_MODE_LINEAR,
+};
+
 /* status of queued up but not flushed reads and write operations.
  * In _transfer_map() we need to know if queued up rendering needs
  * to be flushed to preserve the order of cpu and gpu access. */
@@ -66,6 +71,7 @@ struct etna_resource {
/* only lod 0 used for non-texture buffers */
/* Layout for surface (tiled, multitiled, split tiled, ...) */
enum etna_surface_layout layout;
+   enum etna_resource_addressing_mode addressing_mode;
/* Horizontal alignment for texture unit (TEXTURE_HALIGN_*) */
unsigned halign;
struct etna_bo *bo; /* Surface video memory */
@@ -155,7 +161,8 @@ etna_screen_resource_alloc_ts(struct pipe_screen *pscreen,
 
 struct pipe_resource *
 etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
-uint64_t modifier, const struct pipe_resource *templat);
+enum etna_resource_addressing_mode mode, uint64_t modifier,
+const struct pipe_resource *templat);
 
 void
 etna_resource_screen_init(struct pipe_scr

[Mesa-dev] [PATCH 3/4] etnaviv: add linear sampling support

2019-01-20 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 .../drivers/etnaviv/etnaviv_texture_state.c   | 21 +++
 .../drivers/etnaviv/etnaviv_texture_state.h   |  1 +
 2 files changed, 22 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c 
b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
index 7100865f925..ef2a7bd581c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
@@ -131,6 +131,17 @@ etna_create_sampler_view_state(struct pipe_context *pctx, 
struct pipe_resource *
   return NULL;
}
 
+   if (res->addressing_mode == ETNA_ADDRESSING_MODE_LINEAR) {
+  sv->TE_SAMPLER_CONFIG0 |= 
VIVS_TE_SAMPLER_CONFIG0_ADDRESSING_MODE(TEXTURE_ADDRESSING_MODE_LINEAR);
+
+  for (int lod = 0; lod <= res->base.last_level; ++lod)
+ sv->TE_SAMPLER_LINEAR_STRIDE[lod] = res->levels[lod].stride;
+
+   } else {
+  sv->TE_SAMPLER_CONFIG0 |= 
VIVS_TE_SAMPLER_CONFIG0_ADDRESSING_MODE(TEXTURE_ADDRESSING_MODE_TILED);
+  memset(>TE_SAMPLER_LINEAR_STRIDE, 0, 
sizeof(sv->TE_SAMPLER_LINEAR_STRIDE));
+   }
+
sv->TE_SAMPLER_CONFIG1 = COND(ext, 
VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(format)) |
 COND(astc, 
VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(TEXTURE_FORMAT_EXT_ASTC)) |
 VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz;
@@ -294,6 +305,16 @@ etna_emit_texture_state(struct etna_context *ctx)
  }
   }
}
+   if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) {
+  for (int y = 0; y < VIVS_TE_SAMPLER_LINEAR_STRIDE__LEN; ++y) {
+ for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {
+if ((1 << x) & active_samplers) {
+   struct etna_sampler_view *sv = 
etna_sampler_view(ctx->sampler_view[x]);
+   /*02C00*/ EMIT_STATE(TE_SAMPLER_LINEAR_STRIDE(x, y), 
sv->TE_SAMPLER_LINEAR_STRIDE[y]);
+}
+ }
+  }
+   }
if (unlikely(ctx->specs.tex_astc && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS {
   for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {
  if ((1 << x) & active_samplers) {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.h 
b/src/gallium/drivers/etnaviv/etnaviv_texture_state.h
index 86bbcb3cf3c..816f42e3730 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.h
@@ -62,6 +62,7 @@ struct etna_sampler_view {
uint32_t TE_SAMPLER_SIZE;
uint32_t TE_SAMPLER_LOG_SIZE;
uint32_t TE_SAMPLER_ASTC0;
+   uint32_t TE_SAMPLER_LINEAR_STRIDE[VIVS_TE_SAMPLER_LINEAR_STRIDE__LEN];
struct etna_reloc TE_SAMPLER_LOD_ADDR[VIVS_TE_SAMPLER_LOD_ADDR__LEN];
unsigned min_lod, max_lod; /* 5.5 fixp */
 
-- 
2.20.1

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


[Mesa-dev] [PATCH] meson: make it possible to build etnaviv's cmdline compiler

2018-12-13 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 meson.build | 2 +-
 meson_options.txt   | 2 +-
 src/gallium/drivers/etnaviv/meson.build | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index fe647f682c..f516780115 100644
--- a/meson.build
+++ b/meson.build
@@ -57,7 +57,7 @@ with_osmesa = get_option('osmesa')
 with_swr_arches = get_option('swr-arches')
 with_tools = get_option('tools')
 if with_tools.contains('all')
-  with_tools = ['freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'xvmc']
+  with_tools = ['etnaviv', 'freedreno', 'glsl', 'intel', 'nir', 'nouveau', 
'xvmc']
 endif
 
 dri_drivers_path = get_option('dri-drivers-path')
diff --git a/meson_options.txt b/meson_options.txt
index a1d5ab0e18..005356b14c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -301,7 +301,7 @@ option(
   'tools',
   type : 'array',
   value : [],
-  choices : ['freedreno', 'glsl', 'intel', 'intel-ui', 'nir', 'nouveau', 
'xvmc', 'all'],
+  choices : ['etnaviv', 'freedreno', 'glsl', 'intel', 'intel-ui', 'nir', 
'nouveau', 'xvmc', 'all'],
   description : 'List of tools to build. (Note: `intel-ui` selects `intel`)',
 )
 option(
diff --git a/src/gallium/drivers/etnaviv/meson.build 
b/src/gallium/drivers/etnaviv/meson.build
index 1733024ac9..63553dec51 100644
--- a/src/gallium/drivers/etnaviv/meson.build
+++ b/src/gallium/drivers/etnaviv/meson.build
@@ -101,7 +101,8 @@ etnaviv_compiler = executable(
   include_directories : [inc_include, inc_src, inc_gallium, inc_gallium_aux],
   link_with : [libmesa_util, libgallium, libetnaviv],
   dependencies : [dep_libdrm_etnaviv],
-  build_by_default : false,
+  build_by_default : with_tools.contains('etnaviv'),
+  install : with_tools.contains('etnaviv'),
 )
 
 driver_etnaviv = declare_dependency(
-- 
2.19.2

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


Re: [Mesa-dev] [RFC PATCH 0/5] last call for autotools (meson travis fixes)

2018-12-12 Thread Christian Gmeiner
Am Mi., 12. Dez. 2018 um 09:44 Uhr schrieb Samuel Pitoiset
:
>
> What's the point of maintaining Travis? Shouldn't we just drop it in
> favour of Gitlab CI? IIRC, Igalia worked on it.
>

Until Gitlab CI is ready for public use I like the idea that my wip
mesa branches @github run through
Travis CI. I helped me to find missing parts in makefiles etc.

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] etnaviv: Consolidate buffer references from framebuffers

2018-12-17 Thread Christian Gmeiner
Am Mo., 17. Dez. 2018 um 09:56 Uhr schrieb Tomeu Vizoso
:
>
> We were leaking surfaces because the references taken in
> etna_set_framebuffer_state weren't being released on context destroy.
>
> Instead of just directly releasing those references in
> etna_context_destroy, use the util_copy_framebuffer_state helper.
>
> Take the chance to remove the duplicated buffer references in
> compiled_framebuffer_state to avoid confusion.
>
> The leak can be reproduced with a client that continuously creates and
> destroys contexts.
>
> Signed-off-by: Tomeu Vizoso 
> Reported-by: Sjoerd Simons 

Reviewed-by: Christian Gmeiner 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_context.c  | 10 ++
>  src/gallium/drivers/etnaviv/etnaviv_internal.h |  1 -
>  src/gallium/drivers/etnaviv/etnaviv_state.c|  8 +++-
>  3 files changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index 96cf2f3b59a8..2ecbc7449094 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -60,6 +60,8 @@ etna_context_destroy(struct pipe_context *pctx)
>  {
> struct etna_context *ctx = etna_context(pctx);
>
> +   util_copy_framebuffer_state(>framebuffer_s, NULL);
> +
> if (ctx->primconvert)
>util_primconvert_destroy(ctx->primconvert);
>
> @@ -299,10 +301,10 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
> pipe_draw_info *info)
> if (DBG_ENABLED(ETNA_DBG_FLUSH_ALL))
>pctx->flush(pctx, NULL, 0);
>
> -   if (ctx->framebuffer.cbuf)
> -  etna_resource(ctx->framebuffer.cbuf->texture)->seqno++;
> -   if (ctx->framebuffer.zsbuf)
> -  etna_resource(ctx->framebuffer.zsbuf->texture)->seqno++;
> +   if (ctx->framebuffer_s.cbufs[0])
> +  etna_resource(ctx->framebuffer_s.cbufs[0]->texture)->seqno++;
> +   if (ctx->framebuffer_s.zsbuf)
> +  etna_resource(ctx->framebuffer_s.zsbuf->texture)->seqno++;
> if (info->index_size && indexbuf != info->index.resource)
>pipe_resource_reference(, NULL);
>  }
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
> b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> index 3424d8a77153..77214d9ccba1 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
> @@ -182,7 +182,6 @@ struct compiled_viewport_state {
>
>  /* Compiled pipe_framebuffer_state */
>  struct compiled_framebuffer_state {
> -   struct pipe_surface *cbuf, *zsbuf; /* keep reference to surfaces */
> uint32_t GL_MULTI_SAMPLE_CONFIG;
> uint32_t PE_COLOR_FORMAT;
> uint32_t PE_DEPTH_CONFIG;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c 
> b/src/gallium/drivers/etnaviv/etnaviv_state.c
> index 87ba10b0dc98..520cc5a775fc 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_state.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
> @@ -37,6 +37,7 @@
>  #include "etnaviv_surface.h"
>  #include "etnaviv_translate.h"
>  #include "etnaviv_util.h"
> +#include "util/u_framebuffer.h"
>  #include "util/u_helpers.h"
>  #include "util/u_inlines.h"
>  #include "util/u_math.h"
> @@ -130,7 +131,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
>assert(res->layout & ETNA_LAYOUT_BIT_TILE); /* Cannot render to linear 
> surfaces */
>etna_update_render_resource(pctx, cbuf->base.texture);
>
> -  pipe_surface_reference(>cbuf, >base);
>cs->PE_COLOR_FORMAT =
>   VIVS_PE_COLOR_FORMAT_FORMAT(translate_rs_format(cbuf->base.format)) 
> |
>   VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK |
> @@ -182,7 +182,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
>
>nr_samples_color = cbuf->base.texture->nr_samples;
> } else {
> -  pipe_surface_reference(>cbuf, NULL);
>/* Clearing VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK and
> * VIVS_PE_COLOR_FORMAT_OVERWRITE prevents us from overwriting the
> * color target */
> @@ -201,7 +200,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
>
>etna_update_render_resource(pctx, zsbuf->base.texture);
>
> -  pipe_surface_reference(>zsbuf, >base);
>assert(res->layout _LAYOUT_BIT_TILE); /* Cannot render to linear 
> surfaces */
>
>uint32_t depth_format = translate_depth_format(zsbuf->base.format);
> @@ -252,7 +250,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
>
>nr_samples_depth = zsbuf-

[Mesa-dev] [PATCH] etnaviv: drop redundant ctx function parameter

2018-12-12 Thread Christian Gmeiner
There is no need to have an extra ctx paramter as all the other
parameters carry all the needed information.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_shader.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c 
b/src/gallium/drivers/etnaviv/etnaviv_shader.c
index 27c735b83b..d2d736bdee 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_shader.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c
@@ -230,8 +230,7 @@ etna_shader_link(struct etna_context *ctx)
 }
 
 static bool
-etna_shader_update_vs_inputs(struct etna_context *ctx,
- struct compiled_shader_state *cs,
+etna_shader_update_vs_inputs(struct compiled_shader_state *cs,
  const struct etna_shader_variant *vs,
  const struct compiled_vertex_elements_state *ves)
 {
@@ -246,7 +245,7 @@ etna_shader_update_vs_inputs(struct etna_context *ctx,
num_vs_inputs = MAX2(ves->num_elements, vs->infile.num_reg);
if (num_vs_inputs != ves->num_elements) {
   BUG("Number of elements %u does not match the number of VS inputs %zu",
-  ctx->vertex_elements->num_elements, ctx->shader.vs->infile.num_reg);
+  ves->num_elements, vs->infile.num_reg);
   return false;
}
 
@@ -312,7 +311,7 @@ dump_shader_info(struct etna_shader_variant *v, struct 
pipe_debug_callback *debu
 bool
 etna_shader_update_vertex(struct etna_context *ctx)
 {
-   return etna_shader_update_vs_inputs(ctx, >shader_state, ctx->shader.vs,
+   return etna_shader_update_vs_inputs(>shader_state, ctx->shader.vs,
ctx->vertex_elements);
 }
 
-- 
2.19.2

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


Re: [Mesa-dev] [PATCH] meson: make it possible to build etnaviv's cmdline compiler

2018-12-15 Thread Christian Gmeiner
Hi Dylan

Am Fr., 14. Dez. 2018 um 20:13 Uhr schrieb Dylan Baker :
>
> Quoting Christian Gmeiner (2018-12-13 12:07:23)
> > Signed-off-by: Christian Gmeiner 
> > ---
> >  meson.build | 2 +-
> >  meson_options.txt   | 2 +-
> >  src/gallium/drivers/etnaviv/meson.build | 3 ++-
> >  3 files changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index fe647f682c..f516780115 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -57,7 +57,7 @@ with_osmesa = get_option('osmesa')
> >  with_swr_arches = get_option('swr-arches')
> >  with_tools = get_option('tools')
> >  if with_tools.contains('all')
> > -  with_tools = ['freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'xvmc']
> > +  with_tools = ['etnaviv', 'freedreno', 'glsl', 'intel', 'nir', 'nouveau', 
> > 'xvmc']
> >  endif
> >
> >  dri_drivers_path = get_option('dri-drivers-path')
> > diff --git a/meson_options.txt b/meson_options.txt
> > index a1d5ab0e18..005356b14c 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -301,7 +301,7 @@ option(
> >'tools',
> >type : 'array',
> >value : [],
> > -  choices : ['freedreno', 'glsl', 'intel', 'intel-ui', 'nir', 'nouveau', 
> > 'xvmc', 'all'],
> > +  choices : ['etnaviv', 'freedreno', 'glsl', 'intel', 'intel-ui', 'nir', 
> > 'nouveau', 'xvmc', 'all'],
> >description : 'List of tools to build. (Note: `intel-ui` selects 
> > `intel`)',
> >  )
> >  option(
> > diff --git a/src/gallium/drivers/etnaviv/meson.build 
> > b/src/gallium/drivers/etnaviv/meson.build
> > index 1733024ac9..63553dec51 100644
> > --- a/src/gallium/drivers/etnaviv/meson.build
> > +++ b/src/gallium/drivers/etnaviv/meson.build
> > @@ -101,7 +101,8 @@ etnaviv_compiler = executable(
> >include_directories : [inc_include, inc_src, inc_gallium, 
> > inc_gallium_aux],
> >link_with : [libmesa_util, libgallium, libetnaviv],
> >dependencies : [dep_libdrm_etnaviv],
> > -  build_by_default : false,
> > +  build_by_default : with_tools.contains('etnaviv'),
> > +  install : with_tools.contains('etnaviv'),
> >  )
> >
> >  driver_etnaviv = declare_dependency(
> > --
> > 2.19.2
> >
>
> You technically can build it already, `ninja
> src/gallium/drivers/etnaviv/etnaviv_compiler` should do the trick. This patch 
> is
> obviously simpler and easier to use, and is in line with how other tools in 
> mesa
> work, but can we change the commit message to something like:
>
> meson: add etnaviv to the tools option
>
> Or something similar.
>

Sounds fine to me. Btw thanks for the meson trick - I was not aware of it.

> with that:
> Reviewed-by: Dylan Baker 


-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 1/3] nir: add fceil lowering

2018-11-19 Thread Christian Gmeiner
Am Mo., 12. Nov. 2018 um 19:17 Uhr schrieb Jonathan Marek :
>
> lowers ceil(x) as -floor(-x)
>
> Signed-off-by: Jonathan Marek 

Do you have push rights? As I am interested in this one I would push
it for you if needed.

-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 1/3] nir: add fceil lowering

2018-11-19 Thread Christian Gmeiner
Am Mo., 19. Nov. 2018 um 21:17 Uhr schrieb Jonathan marek :
>
> I don't have push rights, but robclark added this patch to his staging
> branch so I imagine he will push it soon.
>

Great..

> On 11/19/2018 03:15 PM, Christian Gmeiner wrote:
> > Am Mo., 12. Nov. 2018 um 19:17 Uhr schrieb Jonathan Marek 
> > :
> >>
> >> lowers ceil(x) as -floor(-x)
> >>
> >> Signed-off-by: Jonathan Marek 
> >
> > Do you have push rights? As I am interested in this one I would push
> > it for you if needed.
> >



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] etnaviv_screen: Fix typo in cflush_all description

2019-01-07 Thread Christian Gmeiner
Am Mo., 7. Jan. 2019 um 15:00 Uhr schrieb Guido Günther :
>
> Signed-off-by: Guido Günther 

Reviewed-by: Christian Gmeiner 

> ---
>  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 fb51aa5f4e8..fd320232528 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -63,7 +63,7 @@ static const struct debug_named_value debug_options[] = {
> {"no_autodisable", ETNA_DBG_NO_AUTODISABLE, "Disable autodisable"},
> {"no_supertile",   ETNA_DBG_NO_SUPERTILE, "Disable supertiles"},
> {"no_early_z", ETNA_DBG_NO_EARLY_Z, "Disable early z"},
> -   {"cflush_all", ETNA_DBG_CFLUSH_ALL, "Flush every cash before state 
> update"},
> +   {"cflush_all", ETNA_DBG_CFLUSH_ALL, "Flush every cache before state 
> update"},
> {"msaa2x", ETNA_DBG_MSAA_2X, "Force 2x msaa"},
> {"msaa4x", ETNA_DBG_MSAA_4X, "Force 4x msaa"},
> {"flush_all",  ETNA_DBG_FLUSH_ALL, "Flush after every rendered 
> primitive"},
> --
> 2.19.2
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
___
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: enable full overwrite in a few more cases

2018-12-28 Thread Christian Gmeiner
Am Mi., 19. Dez. 2018 um 16:27 Uhr schrieb Lucas Stach :
>
> 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 

Reviewed-by: Christian Gmeiner 

> ---
> v2: clarify comment
> ---
>  src/gallium/drivers/etnaviv/etnaviv_blend.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c 
> b/src/gallium/drivers/etnaviv/etnaviv_blend.c
> index 0e2299a50b30..061c9af5247f 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] &&
> @@ -128,11 +129,13 @@ etna_update_blend(struct etna_context *ctx)
> }
>
> /* If the complete render target is written, set full_overwrite:
> -* - The color mask is 
> -* - No blending is used
> +* - The color mask covers all channels of the render target
> +* - No blending or logicop 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)));
> blend->PE_COLOR_FORMAT =
>  VIVS_PE_COLOR_FORMAT_COMPONENTS(colormask) |
>  COND(full_overwrite, VIVS_PE_COLOR_FORMAT_OVERWRITE);
> --
> 2.19.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] etnaviv: implement check_resource_capability

2018-12-28 Thread Christian Gmeiner
Am Di., 18. Dez. 2018 um 19:09 Uhr schrieb Lucas Stach :
>
> We try to avoid sharing all resources with KMS side of renderonly, as this
> adds some overhead that isn't really needed for most resources. If
> someone tries to validate a resource for scanout, this is a good indication
> that the sharing with the KMS side is actually needed.
>
> Signed-off-by: Lucas Stach 
> ---
>  .../drivers/etnaviv/etnaviv_resource.c| 22 +++
>  1 file changed, 22 insertions(+)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index c00912880309..cd846e3ae36e 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -624,6 +624,27 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
> }
>  }
>
> +static bool
> +etna_check_resource_capability(struct pipe_screen *pscreen,
> +   struct pipe_resource *prsc,
> +   unsigned bind)
> +{
> +   struct etna_screen *screen = etna_screen(pscreen);
> +   struct etna_resource *rsc = etna_resource(prsc);
> +
> +   if ((bind & PIPE_BIND_LINEAR) && rsc->layout != ETNA_LAYOUT_LINEAR)
> +  return false;
> +
> +   if ((bind & PIPE_BIND_SCANOUT) && !rsc->scanout) {
> +  rsc->scanout = renderonly_create_gpu_import_for_resource(prsc, 
> screen->ro,
> +   NULL);

Can you explain me why the
renderonly_create_gpu_import_for_resource(..) call ends up here? Are
there really any cases where !rsc->scanout? I looked at the relevant
code parts and I have the feeling
the renderonly_create_gpu_import_for_resource(..) call happens much
earlier in the call chain. I could be
wrong as I am running out of coffee right now :)

> +  if (!rsc->scanout)
> + return false;
> +   }
> +
> +   return true;
> +}
> +
>  void
>  etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
> enum etna_resource_status status)
> @@ -667,4 +688,5 @@ etna_resource_screen_init(struct pipe_screen *pscreen)
> pscreen->resource_get_handle = etna_resource_get_handle;
> pscreen->resource_changed = etna_resource_changed;
> pscreen->resource_destroy = etna_resource_destroy;
> +   pscreen->check_resource_capability = etna_check_resource_capability;
>  }
> --
> 2.19.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] autotools: Deprecate the use of autotools

2019-01-11 Thread Christian Gmeiner
Am So., 16. Dez. 2018 um 12:24 Uhr schrieb Gert Wollny :
>
> Since Meson will eventually be the only build system deprecate autotools
> now. It can still be used by invoking configure with the flag
>   --enable-autotools
>
> Signed-off-by: Gert Wollny 

Reviewed-by: Christian Gmeiner 

> ---
> IMO autotools should be properly deprecated prior it its removal, so here
> is a patch to do just that. I think autotools should be marked as deprecated
> for the 19.0 release and, depending on feedback, it could be removed with 
> 19.1.
> Anyway, in the end it's up to the release team how to handle this.
>
> Best,
> Gert
>
>  configure.ac | 13 +
>  1 file changed, 13 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index 9b437a252c..73f5978bb7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -52,6 +52,19 @@ mingw*)
>  ;;
>  esac
>
> +AC_ARG_ENABLE(autotools,
> +   [AS_HELP_STRING([--enable-autotools],
> +   [Enable the use of this autotools based build 
> configuration])],
> +   [enable_autotools=$enableval], [enable_autotools=no])
> +
> +if test "x$enable_autotools" != "xyes" ; then
> +AC_MSG_ERROR([the autotools build system has been deprecated in favour of
> +meson and will be removed eventually. For instructions on how to use 
> meson
> +see https://www.mesa3d.org/meson.html.
> +If you still want to use the autotools build, then add --enable-autotools
> +to the configure command line.])
> +fi
> +
>  # Support silent build rules, requires at least automake-1.11. Disable
>  # by either passing --disable-silent-rules to configure or passing V=1
>  # to make
> --
> 2.19.2
>
> _______
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


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

2018-12-28 Thread Christian Gmeiner
Am Mi., 19. Dez. 2018 um 16:27 Uhr schrieb Lucas Stach :
>
> 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 

Reviewed-by: Christian Gmeiner 

> ---
> v2: get rid of superfluous variable initialization
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index bbc61a59fc67..ceca5b8af997 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -477,8 +477,7 @@ static void
>  etna_compile_parse_declarations(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> -   unsigned status = TGSI_PARSE_OK;
> -   status = tgsi_parse_init(, c->tokens);
> +   MAYBE_UNUSED unsigned status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>
> while (!tgsi_parse_end_of_tokens()) {
> @@ -530,8 +529,7 @@ static void
>  etna_compile_pass_check_usage(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> -   unsigned status = TGSI_PARSE_OK;
> -   status = tgsi_parse_init(, c->tokens);
> +   MAYBE_UNUSED unsigned status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>
> for (int idx = 0; idx < c->total_decls; ++idx) {
> @@ -662,8 +660,7 @@ etna_compile_pass_optimize_outputs(struct etna_compile *c)
>  {
> struct tgsi_parse_context ctx = { };
> int inst_idx = 0;
> -   unsigned status = TGSI_PARSE_OK;
> -   status = tgsi_parse_init(, c->tokens);
> +   MAYBE_UNUSED unsigned status = tgsi_parse_init(, c->tokens);
> assert(status == TGSI_PARSE_OK);
>
> while (!tgsi_parse_end_of_tokens()) {
> @@ -1812,7 +1809,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;
> --
> 2.19.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 04/16] nir: add nir_lower_bool_to_float

2018-12-19 Thread Christian Gmeiner
 +
> +static bool
> +lower_alu_instr(nir_alu_instr *alu)
> +{
> +   const nir_op_info *op_info = _op_infos[alu->op];
> +
> +   switch (alu->op) {
> +   case nir_op_vec2:
> +   case nir_op_vec3:
> +   case nir_op_vec4:
> +  /* These we expect to have booleans but the opcode doesn't change */
> +  break;
> +
> +   case nir_op_b2f32: alu->op = nir_op_fmov; break;
> +
> +   /* Note: we only expect these 5 opcodes with bools */
> +   case nir_op_imov: alu->op = nir_op_fmov; break;
> +   case nir_op_inot: alu->op = nir_op_fnot; break;
> +   case nir_op_iand: alu->op = nir_op_fand; break;
> +   case nir_op_ior: alu->op = nir_op_for; break;
> +   case nir_op_ixor: alu->op = nir_op_fxor; break;
> +
> +   /* We might want a new opcode (for the (x != 0.0) f2b op)  */
> +   case nir_op_f2b1: alu->op = nir_op_f2b32; break;
> +   case nir_op_i2b1: alu->op = nir_op_f2b32; break;
> +
> +   case nir_op_flt: alu->op = nir_op_slt; break;
> +   case nir_op_fge: alu->op = nir_op_sge; break;
> +   case nir_op_feq: alu->op = nir_op_seq; break;
> +   case nir_op_fne: alu->op = nir_op_sne; break;
> +   case nir_op_ilt: alu->op = nir_op_slt; break;
> +   case nir_op_ige: alu->op = nir_op_sge; break;
> +   case nir_op_ieq: alu->op = nir_op_seq; break;
> +   case nir_op_ine: alu->op = nir_op_sne; break;
> +   case nir_op_ult: alu->op = nir_op_slt; break;
> +   case nir_op_uge: alu->op = nir_op_sge; break;
> +
> +   case nir_op_ball_fequal2:  alu->op = nir_op_fall_equal2; break;
> +   case nir_op_ball_fequal3:  alu->op = nir_op_fall_equal3; break;
> +   case nir_op_ball_fequal4:  alu->op = nir_op_fall_equal4; break;
> +   case nir_op_bany_fnequal2: alu->op = nir_op_fany_nequal2; break;
> +   case nir_op_bany_fnequal3: alu->op = nir_op_fany_nequal3; break;
> +   case nir_op_bany_fnequal4: alu->op = nir_op_fany_nequal4; break;
> +   case nir_op_ball_iequal2:  alu->op = nir_op_fall_equal2; break;
> +   case nir_op_ball_iequal3:  alu->op = nir_op_fall_equal3; break;
> +   case nir_op_ball_iequal4:  alu->op = nir_op_fall_equal4; break;
> +   case nir_op_bany_inequal2: alu->op = nir_op_fany_nequal2; break;
> +   case nir_op_bany_inequal3: alu->op = nir_op_fany_nequal3; break;
> +   case nir_op_bany_inequal4: alu->op = nir_op_fany_nequal4; break;
> +
> +   case nir_op_bcsel: alu->op = nir_op_fcsel; break;
> +
> +   default:
> +  assert(alu->dest.dest.ssa.bit_size > 1);
> +  for (unsigned i = 0; i < op_info->num_inputs; i++)
> + assert(alu->src[i].src.ssa->bit_size > 1);
> +  return false;
> +   }
> +
> +   if (alu->dest.dest.ssa.bit_size == 1)
> +  alu->dest.dest.ssa.bit_size = 32;
> +
> +   return true;
> +}
> +
> +static bool
> +nir_lower_bool_to_float_impl(nir_function_impl *impl)
> +{
> +   bool progress = false;
> +
> +   nir_foreach_block(block, impl) {
> +  nir_foreach_instr_safe(instr, block) {
> + switch (instr->type) {
> + case nir_instr_type_alu:
> +progress |= lower_alu_instr(nir_instr_as_alu(instr));
> +break;
> +
> + case nir_instr_type_load_const: {
> +nir_load_const_instr *load = nir_instr_as_load_const(instr);
> +if (load->def.bit_size == 1) {
> +   nir_const_value value = load->value;
> +   for (unsigned i = 0; i < load->def.num_components; i++)
> +  load->value.f32[i] = value.b[i] ? 1.0f : 0.0f;
> +   load->def.bit_size = 32;
> +   progress = true;
> +}
> +break;
> + }
> +
> + case nir_instr_type_intrinsic:
> + case nir_instr_type_ssa_undef:
> + case nir_instr_type_phi:
> + case nir_instr_type_tex:
> +nir_foreach_ssa_def(instr, rewrite_1bit_ssa_def_to_32bit,
> +);
> +break;
> +
> + default:
> +nir_foreach_ssa_def(instr, assert_ssa_def_is_not_1bit, NULL);
> + }
> +  }
> +   }
> +
> +   if (progress) {
> +  nir_metadata_preserve(impl, nir_metadata_block_index |
> +  nir_metadata_dominance);
> +   }
> +
> +   return progress;
> +}
> +
> +bool
> +nir_lower_bool_to_float(nir_shader *shader)
> +{
> +   bool progress = false;
> +
> +   nir_foreach_function(function, shader) {
> +  if (function->impl && nir_lower_bool_to_float_impl(function->impl))
> + progress = true;
> +   }
> +
> +   return progress;
> +}
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH 2/2] etnaviv: flush all pending contexts when accessing a resource with the CPU

2019-03-27 Thread Christian Gmeiner
Am Mi., 27. März 2019 um 12:23 Uhr schrieb Lucas Stach :
>
> When setting up a transfer to a resource, all contexts where the resource
> is pending must be flushed. Otherwise a write transfer might be started
> in the current context before all contexts that access the resource in
> shared (read) mode have been executed.
>
> Fixes: 64813541d575 (etnaviv: fix resource usage tracking across
> different pipe_context's)
> Signed-off-by: Lucas Stach 

Reviewed-by: Christian Gmeiner 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 45cd31207f70..d875803bde26 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -360,8 +360,14 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>if ((trans->rsc && (etna_resource(trans->rsc)->status & 
> ETNA_PENDING_WRITE)) ||
>(!trans->rsc &&
> (((usage & PIPE_TRANSFER_READ) && (rsc->status & 
> ETNA_PENDING_WRITE)) ||
> -   ((usage & PIPE_TRANSFER_WRITE) && rsc->status
> - pctx->flush(pctx, NULL, 0);
> +   ((usage & PIPE_TRANSFER_WRITE) && rsc->status {
> + set_foreach(rsc->pending_ctx, entry) {
> +struct etna_context *pend_ctx = (struct etna_context 
> *)entry->key;
> +struct pipe_context *pend_pctx = _ctx->base;
> +
> +pend_pctx->flush(pend_pctx, NULL, 0);
> + }
> +  }
>
>mtx_unlock(>lock);
>
> --
> 2.20.1
>


-- 
greets
--
Christian Gmeiner, MSc

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

Re: [Mesa-dev] [PATCH 1/2] etnaviv: don't flush own context when updating resource use

2019-03-27 Thread Christian Gmeiner
Am Mi., 27. März 2019 um 12:23 Uhr schrieb Lucas Stach :
>
> The context is self synchronizing at the GPU side, as commands are
> executed in order. We must not flush our own context when updating the
> resource use, as that leads to excessive flushing on effectively every
> draw call, causing huge CPU overhead.
>
> Fixes: 64813541d575 (etnaviv: fix resource usage tracking across
> different pipe_context's)
> Signed-off-by: Lucas Stach 

Reviewed-by: Christian Gmeiner 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index ab40414fbe2c..c7eedab74187 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -666,9 +666,18 @@ etna_resource_used(struct etna_context *ctx, struct 
> pipe_resource *prsc,
>   struct etna_context *extctx = (struct etna_context *)entry->key;
>   struct pipe_context *pctx = >base;
>
> + if (extctx == ctx)
> +continue;
> +
>   pctx->flush(pctx, NULL, 0);
> + /* It's safe to clear the status here. If we need to flush it means
> +  * either another context had the resource in exclusive (write) use,
> +  * or we transition the resource to exclusive use in our context.
> +  * In both cases the new status accurately reflects the resource use
> +  * after the flush.
> +  */
> + rsc->status = 0;
>    }
> -  rsc->status = 0;
> }
>
> rsc->status |= status;
> --
> 2.20.1
>


-- 
greets
--
Christian Gmeiner, MSc

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

Re: [Mesa-dev] [PATCH] etnaviv: only try to construct scanout resource when on KMS winsys

2019-03-27 Thread Christian Gmeiner
Am Mi., 27. März 2019 um 12:25 Uhr schrieb Lucas Stach :
>
> Trying to construct a scanout capable buffer will only ever work when
> when we are on top of a KMS winsys, as the render node isn't capable
> of allocating contiguous buffers.
>
> Tested-by: Marius Vlad 
> Signed-off-by: Lucas Stach 

Reviewed-by: Christian Gmeiner 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index c7eedab74187..83179d3cd088 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -238,7 +238,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,
> if (!screen->specs.use_blt && templat->target != PIPE_BUFFER)
>etna_adjust_rs_align(screen->specs.pixel_pipes, NULL, );
>
> -   if (templat->bind & PIPE_BIND_SCANOUT) {
> +   if (templat->bind & PIPE_BIND_SCANOUT && screen->ro->kms_fd >= 0) {
>struct pipe_resource scanout_templat = *templat;
>struct renderonly_scanout *scanout;
>struct winsys_handle handle;
> --
> 2.20.1
>
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

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

[Mesa-dev] [PATCH] etnaviv: shrink struct etna_3d_state

2019-03-27 Thread Christian Gmeiner
Drop struct members which are only written to but never read from.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_emit.c | 17 -
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  6 --
 2 files changed, 23 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index f788896dd8..ed7b7ee3cb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -250,21 +250,6 @@ etna_emit_state(struct etna_context *ctx)
   etna_set_state(stream, VIVS_TS_FLUSH_CACHE, VIVS_TS_FLUSH_CACHE_FLUSH);
}
 
-   /* If MULTI_SAMPLE_CONFIG.MSAA_SAMPLES changed, clobber affected shader
-* state to make sure it is always rewritten. */
-   if (unlikely(dirty & (ETNA_DIRTY_FRAMEBUFFER))) {
-  if ((ctx->gpu3d.GL_MULTI_SAMPLE_CONFIG & 
VIVS_GL_MULTI_SAMPLE_CONFIG_MSAA_SAMPLES__MASK) !=
-  (ctx->framebuffer.GL_MULTI_SAMPLE_CONFIG & 
VIVS_GL_MULTI_SAMPLE_CONFIG_MSAA_SAMPLES__MASK)) {
- /* XXX what does the GPU set these states to on MSAA samples change?
-  * Does it do the right thing?
-  * (increase/decrease as necessary) or something else? Just set some
-  * invalid value until we know for
-  * sure. */
- ctx->gpu3d.PS_INPUT_COUNT = 0x;
- ctx->gpu3d.PS_TEMP_REGISTER_CONTROL = 0x;
-  }
-   }
-
/* Update vertex elements. This is different from any of the other states, 
in that
 * a) the number of vertex elements written matters: so write only active 
ones
 * b) the vertex element states must all be written: do not skip entries 
that stay the same */
@@ -693,8 +678,6 @@ etna_emit_state(struct etna_context *ctx)
   /* Copy uniforms to gpu3d, so that incremental updates to uniforms are
* possible as long as the
* same shader remains bound */
-  ctx->gpu3d.vs_uniforms_size = ctx->shader_state.vs_uniforms_size;
-  ctx->gpu3d.ps_uniforms_size = ctx->shader_state.ps_uniforms_size;
   memcpy(ctx->gpu3d.VS_UNIFORMS, ctx->shader_state.VS_UNIFORMS,
  ctx->shader_state.vs_uniforms_size * 4);
   memcpy(ctx->gpu3d.PS_UNIFORMS, ctx->shader_state.PS_UNIFORMS,
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index 77214d9ccb..29566dbd5e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -270,12 +270,6 @@ struct compiled_shader_state {
 
 /* state of some 3d and common registers relevant to etna driver */
 struct etna_3d_state {
-   unsigned vs_uniforms_size;
-   unsigned ps_uniforms_size;
-
-   uint32_t /*01008*/ PS_INPUT_COUNT;
-   uint32_t /*0100C*/ PS_TEMP_REGISTER_CONTROL;
-   uint32_t /*03818*/ GL_MULTI_SAMPLE_CONFIG;
uint32_t /*05000*/ VS_UNIFORMS[VIVS_VS_UNIFORMS__LEN];
uint32_t /*07000*/ PS_UNIFORMS[VIVS_PS_UNIFORMS__LEN];
 };
-- 
2.20.1

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

Re: [Mesa-dev] [PATCH v2 3/4] etnaviv: hook-up etc2 patching

2019-02-27 Thread Christian Gmeiner
Hi Lucas

Am Mi., 27. Feb. 2019 um 10:19 Uhr schrieb Lucas Stach :
>
> Am Dienstag, den 26.02.2019, 19:15 +0100 schrieb Christian Gmeiner:
> > Changes v1 -> v2:
> >  - Avoid the GPU sampling from the resource that gets mutated by the the
> >transfer map by setting DRM_ETNA_PREP_WRITE.
> >
> > > Signed-off-by: Christian Gmeiner 
> > ---
> >  .../drivers/etnaviv/etnaviv_resource.c|  3 +
> >  .../drivers/etnaviv/etnaviv_resource.h|  5 ++
> >  .../drivers/etnaviv/etnaviv_transfer.c| 55 +++
> >  3 files changed, 63 insertions(+)
> >
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> > b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > index db5ead4d0ba..45d5f69169e 100644
> > --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> > @@ -478,6 +478,9 @@ etna_resource_destroy(struct pipe_screen *pscreen, 
> > struct pipe_resource *prsc)
> > pipe_resource_reference(>texture, NULL);
> > pipe_resource_reference(>external, NULL);
> >
> > +   for (unsigned i = 0; i < ETNA_NUM_LOD; i++)
> > +  FREE(rsc->levels[i].patch_offsets);
> > +
> > FREE(rsc);
> >  }
> >
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h 
> > b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> > index 75aa80b3d7a..c45ff7586d1 100644
> > --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> > @@ -33,6 +33,7 @@
> >  #include "util/list.h"
> >
> >  struct pipe_screen;
> > +struct util_dynarray;
> >
> >  struct etna_resource_level {
> > unsigned width, padded_width; /* in pixels */
> > @@ -47,6 +48,10 @@ struct etna_resource_level {
> > uint32_t ts_size;
> > uint32_t clear_value; /* clear value of resource level (mainly for TS) 
> > */
> > bool ts_valid;
> > +
> > +   /* keep track if we have done some per block patching */
> > +   bool patched;
> > +   struct util_dynarray *patch_offsets;
> >  };
> >
> >  enum etna_resource_addressing_mode {
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> > b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> > index 01da393d211..9a83c481dce 100644
> > --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> > @@ -28,6 +28,7 @@
> >  #include "etnaviv_clear_blit.h"
> >  #include "etnaviv_context.h"
> >  #include "etnaviv_debug.h"
> > +#include "etnaviv_etc2.h"
> >  #include "etnaviv_screen.h"
> >
> >  #include "pipe/p_defines.h"
> > @@ -57,6 +58,46 @@ etna_compute_offset(enum pipe_format format, const 
> > struct pipe_box *box,
> >   util_format_get_blocksize(format);
> >  }
> >
> > +static void etna_patch_data(void *buffer, const struct pipe_transfer 
> > *ptrans)
> > +{
> > +   struct pipe_resource *prsc = ptrans->resource;
> > +   struct etna_resource *rsc = etna_resource(prsc);
> > +   struct etna_resource_level *level = >levels[ptrans->level];
> > +
> > +   if (!etna_etc2_needs_patching(prsc))
>
> Maybe likely() here?
>

okay.

> > +  return;
> > +
> > +   if (level->patched)
> > +  return;
> > +
> > +   /* do have the offsets of blocks to patch? */
> > +   if (!level->patch_offsets) {
> > +  level->patch_offsets = CALLOC_STRUCT(util_dynarray);
> > +
> > +  etna_etc2_calculate_blocks(buffer, ptrans->stride,
> > + ptrans->box.width, 
> > ptrans->box.height,
> > + prsc->format, 
> > level->patch_offsets);
> > +   }
> > +
> > +   etna_etc2_patch(buffer, level->patch_offsets);
> > +
> > +   level->patched = true;
> > +}
> > +
> > +static void etna_unpatch_data(void *buffer, const struct pipe_transfer 
> > *ptrans)
> > +{
> > +   struct pipe_resource *prsc = ptrans->resource;
> > +   struct etna_resource *rsc = etna_resource(prsc);
> > +   struct etna_resource_level *level = >levels[ptrans->level];
> > +
> > +   if (!level->patched)
> > +  return;
> > +
> > +   etna_etc2_patch(buffer, level->patch_offsets);
> > +
> > +   level->patched = false;
> > +}
> > +
> >  static void
> >  

Re: [Mesa-dev] [PATCH v2 1/4] etnaviv: implement ETC2 block patching for HALTI0

2019-02-27 Thread Christian Gmeiner
Hi Lucas

Am Mi., 27. Feb. 2019 um 10:22 Uhr schrieb Lucas Stach :
>
> Am Dienstag, den 26.02.2019, 19:15 +0100 schrieb Christian Gmeiner:
> > ETC2 is supported with HALTI0, however that implementation is buggy
> > in hardware. The blob driver does per-block patching to work around
> > this. We need to swap colors for t-mode etc2 blocks.
> >
> > > Signed-off-by: Christian Gmeiner 
> > ---
> >  src/gallium/drivers/etnaviv/Makefile.sources |   2 +
> >  src/gallium/drivers/etnaviv/etnaviv_etc2.c   | 149 +++
> >  src/gallium/drivers/etnaviv/etnaviv_etc2.h   |  51 +++
> >  src/gallium/drivers/etnaviv/meson.build  |   2 +
> >  4 files changed, 204 insertions(+)
> >  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_etc2.c
> >  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_etc2.h
> >
> > diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
> > b/src/gallium/drivers/etnaviv/Makefile.sources
> > index 0b208122999..01e7e49a38a 100644
> > --- a/src/gallium/drivers/etnaviv/Makefile.sources
> > +++ b/src/gallium/drivers/etnaviv/Makefile.sources
> > @@ -25,6 +25,8 @@ C_SOURCES :=  \
> > > etnaviv_disasm.h \
> > > etnaviv_emit.c \
> > > etnaviv_emit.h \
> > > +   etnaviv_etc2.c \
> > > +   etnaviv_etc2.h \
> > > etnaviv_fence.c \
> > > etnaviv_fence.h \
> > > etnaviv_format.c \
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_etc2.c 
> > b/src/gallium/drivers/etnaviv/etnaviv_etc2.c
> > new file mode 100644
> > index 000..64811c3038d
> > --- /dev/null
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_etc2.c
> > @@ -0,0 +1,149 @@
> > +/*
> > + * Copyright (c) 2019 Etnaviv Project
> > + * Copyright (C) 2019 Zodiac Inflight Innovations
> > + *
> > + * 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:
> > > + *Christian Gmeiner 
> > + */
> > +
> > +#include "etnaviv_etc2.h"
> > +#include "etnaviv_resource.h"
> > +#include "etnaviv_screen.h"
> > +#include "hw/common.xml.h"
> > +#include "util/u_format.h"
> > +
> > +bool
> > +etna_etc2_needs_patching(const struct pipe_resource *prsc)
> > +{
> > +   const struct etna_screen *screen = etna_screen(prsc->screen);
> > +
> > +   if (!util_format_is_etc(prsc->format))
> > +  return false;
> > +
> > +   if (prsc->format == PIPE_FORMAT_ETC1_RGB8)
> > +  return false;
>
> Isn't this format check redundant with the default case of the switch
> below?
>

As util_format_is_etc(..) fires for etc1 and etc2 I thought to be more
explicit here, but
I am fine to remove it.

-- 
greets
--
Christian Gmeiner, MSc

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

[Mesa-dev] [PATCH] gallium/u_transfer_helper: do not call resource_create(..) directly

2019-03-01 Thread Christian Gmeiner
Use u_transfer_helper_resource_create(..) instead which uses the
resource_create(..) function specified in u_transfer_vtbl.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/auxiliary/util/u_transfer_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_transfer_helper.c 
b/src/gallium/auxiliary/util/u_transfer_helper.c
index 14c4d56392d..a5c3c026e71 100644
--- a/src/gallium/auxiliary/util/u_transfer_helper.c
+++ b/src/gallium/auxiliary/util/u_transfer_helper.c
@@ -182,7 +182,7 @@ transfer_map_msaa(struct pipe_context *pctx,
  .depth0 = 1,
  .array_size = 1,
};
-   trans->ss = pscreen->resource_create(pscreen, );
+   trans->ss = u_transfer_helper_resource_create(pscreen, );
if (!trans->ss) {
   free(trans);
   return NULL;
-- 
2.20.1

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

Re: [Mesa-dev] [PATCH] panfrost: List primitive restart enable bit

2019-02-27 Thread Christian Gmeiner
Am Mi., 27. Feb. 2019 um 05:48 Uhr schrieb Alyssa Rosenzweig
:
>
> Signed-off-by: Alyssa Rosenzweig 
> ---
>  src/gallium/drivers/panfrost/include/panfrost-job.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/drivers/panfrost/include/panfrost-job.h 
> b/src/gallium/drivers/panfrost/include/panfrost-job.h
> index 1d738486617..d719325d07b 100644
> --- a/src/gallium/drivers/panfrost/include/panfrost-job.h
> +++ b/src/gallium/drivers/panfrost/include/panfrost-job.h
> @@ -820,10 +820,12 @@ struct mali_uniform_buffer_meta {
>   */
>
>  /* Applies to unknown_draw */
> +
>  #define MALI_DRAW_INDEXED_UINT8  (0x10)
>  #define MALI_DRAW_INDEXED_UINT16 (0x20)
>  #define MALI_DRAW_INDEXED_UINT32 (0x30)
>  #define MALI_DRAW_VARYING_SIZE   (0x100)
> +#define MALI_DRAW_PRIMITIVE_RESTART_FIXED_INDEX (0x1)
>
>  struct mali_vertex_tiler_prefix {
>  /* This is a dynamic bitfield containing the following things in 
> this order:

super nitpicking: What is the purpose of this change? Should this
define be added when it really gets used?

-- 
greets
--
Christian Gmeiner, MSc

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

Re: [Mesa-dev] [PATCH v5] etnaviv: fix resource usage tracking across different pipe_context's

2019-02-22 Thread Christian Gmeiner
Hi Boris,

Am Fr., 22. Feb. 2019 um 10:30 Uhr schrieb Boris Brezillon
:
>
> On Thu, 21 Feb 2019 23:29:53 +0100
> Boris Brezillon  wrote:
>
> > Christian, Marek,
> >
> > On Wed, 30 Jan 2019 05:28:14 +0100
> > Marek Vasut  wrote:
> >
> > > From: Christian Gmeiner 
> > >
> > > A pipe_resource can be shared by all the pipe_context's hanging off the
> > > same pipe_screen.
> >
> > We seem to be impacted by the problem you're fixing here, but, while
> > this patch definitely make things much better, the problem does not
> > seem to be entirely fixed (at least in our case).
> >

I also got some (private) reports about problems with QtWebEngine but had no
time yet to look more deeply into the issue.

>
> --->8---
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> index fc4f65dbeee1..b8c8b96a6f72 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
> @@ -729,6 +729,7 @@ etna_try_rs_blit(struct pipe_context *pctx,
>
> etna_submit_rs_state(ctx, _to_screen);
> resource_written(ctx, >base);
> +   resource_read(ctx, >base);
> dst->seqno++;
> dst->levels[blit_info->dst.level].ts_valid = false;
> ctx->dirty |= ETNA_DIRTY_DERIVE_TS;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index a3013e624ead..e4b2ac605e63 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -356,6 +356,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>  * transfers without a temporary resource.
>  */
> if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
> +  struct etna_screen *screen = ctx->screen;
>uint32_t prep_flags = 0;
>
>/*
> @@ -364,11 +365,13 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
> * current GPU usage (reads must wait for GPU writes, writes must have
> * exclusive access to the buffer).
> */
> +  mtx_lock(>lock);
>if ((trans->rsc && (etna_resource(trans->rsc)->status & 
> ETNA_PENDING_WRITE)) ||
>(!trans->rsc &&
> (((usage & PIPE_TRANSFER_READ) && (rsc->status & 
> ETNA_PENDING_WRITE)) ||
> ((usage & PIPE_TRANSFER_WRITE) && rsc->status
>   pctx->flush(pctx, NULL, 0);
> +  mtx_unlock(>lock);
>
>if (usage & PIPE_TRANSFER_READ)
>   prep_flags |= DRM_ETNA_PREP_READ;
>

Looks good to me - will prepare a v6 of this patch with your changes
incorporated.

Thanks a lot!

-- 
greets
--
Christian Gmeiner, MSc

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

[Mesa-dev] [PATCH 4/4] etnaviv: enable ETC2 texture compression support for HALTI0 GPUs

2019-02-22 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index de822fc85ca..ee32a499fb5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -518,19 +518,9 @@ gpu_supports_texure_format(struct etna_screen *screen, 
uint32_t fmt,
if (util_format_is_srgb(format))
   supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
 
-   if (fmt & EXT_FORMAT) {
+   if (fmt & EXT_FORMAT)
   supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
 
-  /* ETC1 is checked above, as it has its own feature bit. ETC2 is
-   * supported with HALTI0, however that implementation is buggy in 
hardware.
-   * The blob driver does per-block patching to work around this. As this
-   * is currently not implemented by etnaviv, enable it for HALTI1 (GC3000)
-   * only.
-   */
-  if (util_format_is_etc(format))
- supported = VIV_FEATURE(screen, chipMinorFeatures2, HALTI1);
-   }
-
if (fmt & ASTC_FORMAT) {
   supported = screen->specs.tex_astc;
}
-- 
2.20.1

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

[Mesa-dev] [PATCH 2/4] etnaviv: keep track of mapped bo address

2019-02-22 Thread Christian Gmeiner
Saves us from calling etna_bo_map(..) and saves us from doing the
same offset calcs for map() and unmap() operations.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_context.h |  1 +
 .../drivers/etnaviv/etnaviv_transfer.c| 19 ++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
b/src/gallium/drivers/etnaviv/etnaviv_context.h
index 6ad9f3431e1..45b3954c7cb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
@@ -70,6 +70,7 @@ struct etna_transfer {
struct pipe_transfer base;
struct pipe_resource *rsc;
void *staging;
+   void *mapped;
 };
 
 struct etna_vertexbuf_state {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index 0b7411b47ef..01da393d211 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -91,16 +91,15 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
pipe_transfer *ptrans)
   } else if (trans->staging) {
  /* map buffer object */
  struct etna_resource_level *res_level = >levels[ptrans->level];
- void *mapped = etna_bo_map(rsc->bo) + res_level->offset;
 
  if (rsc->layout == ETNA_LAYOUT_TILED) {
 etna_texture_tile(
-   mapped + ptrans->box.z * res_level->layer_stride,
+   trans->mapped + ptrans->box.z * res_level->layer_stride,
trans->staging, ptrans->box.x, ptrans->box.y,
res_level->stride, ptrans->box.width, ptrans->box.height,
ptrans->stride, util_format_get_blocksize(rsc->base.format));
  } else if (rsc->layout == ETNA_LAYOUT_LINEAR) {
-util_copy_box(mapped, rsc->base.format, res_level->stride,
+util_copy_box(trans->mapped, rsc->base.format, res_level->stride,
   res_level->layer_stride, ptrans->box.x,
   ptrans->box.y, ptrans->box.z, ptrans->box.width,
   ptrans->box.height, ptrans->box.depth,
@@ -327,8 +326,8 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
}
 
/* map buffer object */
-   void *mapped = etna_bo_map(rsc->bo);
-   if (!mapped)
+   trans->mapped = etna_bo_map(rsc->bo);
+   if (!trans->mapped)
   goto fail;
 
*out_transfer = ptrans;
@@ -337,9 +336,11 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
   ptrans->stride = res_level->stride;
   ptrans->layer_stride = res_level->layer_stride;
 
-  return mapped + res_level->offset +
+  trans->mapped += res_level->offset +
  etna_compute_offset(prsc->format, box, res_level->stride,
  res_level->layer_stride);
+
+  return trans->mapped;
} else {
   unsigned divSizeX = util_format_get_blockwidth(format);
   unsigned divSizeY = util_format_get_blockheight(format);
@@ -350,7 +351,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
   if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
  goto fail;
 
-  mapped += res_level->offset;
+  trans->mapped += res_level->offset;
   ptrans->stride = align(box->width, divSizeX) * 
util_format_get_blocksize(format); /* row stride in bytes */
   ptrans->layer_stride = align(box->height, divSizeY) * ptrans->stride;
   size_t size = ptrans->layer_stride * box->depth;
@@ -362,7 +363,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
   if (usage & PIPE_TRANSFER_READ) {
  if (rsc->layout == ETNA_LAYOUT_TILED) {
 etna_texture_untile(trans->staging,
-mapped + ptrans->box.z * 
res_level->layer_stride,
+trans->mapped + ptrans->box.z * 
res_level->layer_stride,
 ptrans->box.x, ptrans->box.y, 
res_level->stride,
 ptrans->box.width, ptrans->box.height, 
ptrans->stride,
 util_format_get_blocksize(rsc->base.format));
@@ -370,7 +371,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
 util_copy_box(trans->staging, rsc->base.format, ptrans->stride,
   ptrans->layer_stride, 0, 0, 0, /* dst x,y,z */
   ptrans->box.width, ptrans->box.height,
-  ptrans->box.depth, mapped, res_level->stride,
+  ptrans->box.depth, trans->mapped, res_level->stride,
   res_level->layer_stride, ptrans->box.x,
   ptrans->box.y, ptrans->box.z);
  } else {
-- 
2.20.1

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

[Mesa-dev] [PATCH 3/4] etnaviv: hook-up etc2 patching

2019-02-22 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 .../drivers/etnaviv/etnaviv_resource.c|  3 ++
 .../drivers/etnaviv/etnaviv_resource.h|  5 ++
 .../drivers/etnaviv/etnaviv_transfer.c| 49 +++
 3 files changed, 57 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index db5ead4d0ba..45d5f69169e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -478,6 +478,9 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct 
pipe_resource *prsc)
pipe_resource_reference(>texture, NULL);
pipe_resource_reference(>external, NULL);
 
+   for (unsigned i = 0; i < ETNA_NUM_LOD; i++)
+  FREE(rsc->levels[i].patch_offsets);
+
FREE(rsc);
 }
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h 
b/src/gallium/drivers/etnaviv/etnaviv_resource.h
index 75aa80b3d7a..c45ff7586d1 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
@@ -33,6 +33,7 @@
 #include "util/list.h"
 
 struct pipe_screen;
+struct util_dynarray;
 
 struct etna_resource_level {
unsigned width, padded_width; /* in pixels */
@@ -47,6 +48,10 @@ struct etna_resource_level {
uint32_t ts_size;
uint32_t clear_value; /* clear value of resource level (mainly for TS) */
bool ts_valid;
+
+   /* keep track if we have done some per block patching */
+   bool patched;
+   struct util_dynarray *patch_offsets;
 };
 
 enum etna_resource_addressing_mode {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index 01da393d211..119820d52b5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -28,6 +28,7 @@
 #include "etnaviv_clear_blit.h"
 #include "etnaviv_context.h"
 #include "etnaviv_debug.h"
+#include "etnaviv_etc2.h"
 #include "etnaviv_screen.h"
 
 #include "pipe/p_defines.h"
@@ -57,6 +58,46 @@ etna_compute_offset(enum pipe_format format, const struct 
pipe_box *box,
  util_format_get_blocksize(format);
 }
 
+static void etna_patch_data(void *buffer, const struct pipe_transfer *ptrans)
+{
+   struct pipe_resource *prsc = ptrans->resource;
+   struct etna_resource *rsc = etna_resource(prsc);
+   struct etna_resource_level *level = >levels[ptrans->level];
+
+   if (!etna_etc2_needs_patching(prsc))
+  return;
+
+   if (level->patched)
+  return;
+
+   /* do have the offsets of blocks to patch? */
+   if (!level->patch_offsets) {
+  level->patch_offsets = CALLOC_STRUCT(util_dynarray);
+
+  etna_etc2_calculate_blocks(buffer, ptrans->stride,
+ ptrans->box.width, ptrans->box.height,
+ prsc->format, level->patch_offsets);
+   }
+
+   etna_etc2_patch(buffer, level->patch_offsets);
+
+   level->patched = true;
+}
+
+static void etna_unpatch_data(void *buffer, const struct pipe_transfer *ptrans)
+{
+   struct pipe_resource *prsc = ptrans->resource;
+   struct etna_resource *rsc = etna_resource(prsc);
+   struct etna_resource_level *level = >levels[ptrans->level];
+
+   if (!level->patched)
+  return;
+
+   etna_etc2_patch(buffer, level->patch_offsets);
+
+   level->patched = false;
+}
+
 static void
 etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans)
 {
@@ -119,6 +160,10 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
pipe_transfer *ptrans)
   }
}
 
+   /* We need to have the patched data ready for the GPU. */
+   if (rsc->layout == ETNA_LAYOUT_LINEAR)
+  etna_patch_data(trans->mapped, ptrans);
+
/*
 * Transfers without a temporary are only pulled into the CPU domain if they
 * are not mapped unsynchronized. If they are, must push them back into GPU
@@ -340,6 +385,10 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
  etna_compute_offset(prsc->format, box, res_level->stride,
  res_level->layer_stride);
 
+  /* We need to have the unpatched data ready for the gfx stack. */
+  if (usage & PIPE_TRANSFER_READ)
+ etna_unpatch_data(trans->mapped, ptrans);
+
   return trans->mapped;
} else {
   unsigned divSizeX = util_format_get_blockwidth(format);
-- 
2.20.1

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

[Mesa-dev] [PATCH 1/4] etnaviv: implement ETC2 block patching for HALTI0

2019-02-22 Thread Christian Gmeiner
ETC2 is supported with HALTI0, however that implementation is buggy
in hardware. The blob driver does per-block patching to work around
this. We need to swap colors for t-mode etc2 blocks.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/Makefile.sources |   2 +
 src/gallium/drivers/etnaviv/etnaviv_etc2.c   | 149 +++
 src/gallium/drivers/etnaviv/etnaviv_etc2.h   |  51 +++
 src/gallium/drivers/etnaviv/meson.build  |   2 +
 4 files changed, 204 insertions(+)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_etc2.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_etc2.h

diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 0b208122999..01e7e49a38a 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -25,6 +25,8 @@ C_SOURCES :=  \
etnaviv_disasm.h \
etnaviv_emit.c \
etnaviv_emit.h \
+   etnaviv_etc2.c \
+   etnaviv_etc2.h \
etnaviv_fence.c \
etnaviv_fence.h \
etnaviv_format.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_etc2.c 
b/src/gallium/drivers/etnaviv/etnaviv_etc2.c
new file mode 100644
index 000..64811c3038d
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_etc2.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2019 Etnaviv Project
+ * Copyright (C) 2019 Zodiac Inflight Innovations
+ *
+ * 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:
+ *    Christian Gmeiner 
+ */
+
+#include "etnaviv_etc2.h"
+#include "etnaviv_resource.h"
+#include "etnaviv_screen.h"
+#include "hw/common.xml.h"
+#include "util/u_format.h"
+
+bool
+etna_etc2_needs_patching(const struct pipe_resource *prsc)
+{
+   const struct etna_screen *screen = etna_screen(prsc->screen);
+
+   if (!util_format_is_etc(prsc->format))
+  return false;
+
+   if (prsc->format == PIPE_FORMAT_ETC1_RGB8)
+  return false;
+
+   if (VIV_FEATURE(screen, chipMinorFeatures2, HALTI1))
+  return false;
+
+   switch (prsc->format) {
+   case PIPE_FORMAT_ETC2_RGB8:
+   case PIPE_FORMAT_ETC2_SRGB8:
+   case PIPE_FORMAT_ETC2_RGB8A1:
+   case PIPE_FORMAT_ETC2_SRGB8A1:
+   case PIPE_FORMAT_ETC2_RGBA8:
+   case PIPE_FORMAT_ETC2_SRGBA8:
+  return true;
+  break;
+
+   default:
+  return false;
+   }
+}
+
+static inline bool
+needs_patching(uint8_t *buffer, bool punchthrough_alpha)
+{
+   /* punchthrough_alpha or etc2 individual mode? */
+   if (!punchthrough_alpha && !(buffer[3] & 0x2))
+ return false;
+
+   /* etc2 t-mode? */
+   static const int lookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
+   const int R_plus_dR = (buffer[0] >> 3) + lookup[buffer[0] & 0x7];
+
+   if (R_plus_dR < 0 || R_plus_dR > 31)
+  return true;
+
+   return false;
+}
+
+void
+etna_etc2_calculate_blocks(uint8_t *buffer, unsigned stride,
+   unsigned width, unsigned height,
+   enum pipe_format format,
+   struct util_dynarray *offsets)
+{
+   const unsigned bw = util_format_get_blockwidth(format);
+   const unsigned bh = util_format_get_blockheight(format);
+   const unsigned bs = util_format_get_blocksize(format);
+   bool punchthrough_alpha = false;
+   unsigned offset = 0;
+   const uint8_t *base = buffer;
+
+   if (format == PIPE_FORMAT_ETC2_RGB8A1 ||
+   format == PIPE_FORMAT_ETC2_SRGB8A1)
+  punchthrough_alpha = true;
+
+   if (format == PIPE_FORMAT_ETC2_RGBA8 ||
+   format == PIPE_FORMAT_ETC2_SRGBA8 ||
+   format == PIPE_FORMAT_ETC2_SRGB8A1)
+  offset = 8;
+
+   for (unsigned y = 0; y < height; y += bh) {
+  uint8_t *src = buffer;
+
+  for (unsigned x = 0; x < width; x+= bw) {
+ if (needs_patching(src + offset, p

<    1   2   3   4   5   >