Re: [Mesa-dev] [PATCH 2/5] etnaviv: add basic infrastructure for hw queries

2017-10-19 Thread Wladimir J. van der Laan
On Tue, Oct 17, 2017 at 10:38:14PM +0200, Christian Gmeiner wrote:
> No hardware query is supported yet.
> 
> Signed-off-by: Christian Gmeiner 

Reviewed-by: Wladimir J. van der Laan 

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


[Mesa-dev] [PATCH 2/5] etnaviv: add basic infrastructure for hw queries

2017-10-17 Thread Christian Gmeiner
No hardware query is supported yet.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_context.c  |  11 ++
 src/gallium/drivers/etnaviv/etnaviv_context.h  |   3 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|   3 +
 src/gallium/drivers/etnaviv/etnaviv_query_hw.c | 185 +
 src/gallium/drivers/etnaviv/etnaviv_query_hw.h |  90 
 6 files changed, 294 insertions(+)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.h

diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 60275c949d..ea8df807f6 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -27,6 +27,8 @@ C_SOURCES :=  \
etnaviv_internal.h \
etnaviv_query.c \
etnaviv_query.h \
+   etnaviv_query_hw.c \
+   etnaviv_query_hw.h \
etnaviv_query_sw.c \
etnaviv_query_sw.h \
etnaviv_rasterizer.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 67aab6a68c..65c20d2f83 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -34,6 +34,7 @@
 #include "etnaviv_emit.h"
 #include "etnaviv_fence.h"
 #include "etnaviv_query.h"
+#include "etnaviv_query_hw.h"
 #include "etnaviv_rasterizer.h"
 #include "etnaviv_screen.h"
 #include "etnaviv_shader.h"
@@ -260,6 +261,9 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
pipe_draw_info *info)
   if (ctx->sampler_view[i])
  resource_read(ctx, ctx->sampler_view[i]->texture);
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  resource_written(ctx, hq->prsc);
+
ctx->stats.prims_emitted += u_reduced_prims_for_vertices(info->mode, 
info->count);
ctx->stats.draw_calls++;
 
@@ -299,10 +303,16 @@ etna_flush(struct pipe_context *pctx, struct 
pipe_fence_handle **fence,
struct etna_context *ctx = etna_context(pctx);
int out_fence_fd = -1;
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  etna_hw_query_suspend(hq, ctx);
+
etna_cmd_stream_flush2(ctx->stream, ctx->in_fence_fd,
  (flags & PIPE_FLUSH_FENCE_FD) ? _fence_fd :
  NULL);
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  etna_hw_query_resume(hq, ctx);
+
if (fence)
   *fence = etna_fence_create(pctx, out_fence_fd);
 }
@@ -436,6 +446,7 @@ etna_context_create(struct pipe_screen *pscreen, void 
*priv, unsigned flags)
   goto fail;
 
slab_create_child(>transfer_pool, >transfer_pool);
+   list_inithead(>active_hw_queries);
 
return pctx;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
b/src/gallium/drivers/etnaviv/etnaviv_context.h
index bf2b265f5e..2903e0963d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
@@ -180,6 +180,9 @@ struct etna_context {
 
struct pipe_debug_callback debug;
int in_fence_fd;
+
+   /* list of active hardware queries */
+   struct list_head active_hw_queries;
 };
 
 static inline struct etna_context *
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index a416a7cb0f..9e897cd75a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -30,6 +30,7 @@
 
 #include "etnaviv_context.h"
 #include "etnaviv_query.h"
+#include "etnaviv_query_hw.h"
 #include "etnaviv_query_sw.h"
 
 static struct pipe_query *
@@ -40,6 +41,8 @@ etna_create_query(struct pipe_context *pctx, unsigned 
query_type,
struct etna_query *q;
 
q = etna_sw_create_query(ctx, query_type);
+   if (!q)
+  q = etna_hw_create_query(ctx, query_type);
 
return (struct pipe_query *)q;
 }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_hw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
new file mode 100644
index 00..a1dead335c
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
@@ -0,0 +1,185 @@
+/*
+ * 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, 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