nv50: add a header file for nv50_query
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 16 Oct 2015 22:14:28 +0000 (00:14 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 30 Oct 2015 16:57:15 +0000 (17:57 +0100)
Like for nvc0, this will allow to split different types of queries and
to prepare the way for both global performance counters and MP counters.

While we are at it, make use of nv50_query struct instead of pipe_query.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/drivers/nouveau/Makefile.sources
src/gallium/drivers/nouveau/nv50/nv50_context.h
src/gallium/drivers/nouveau/nv50/nv50_query.c
src/gallium/drivers/nouveau/nv50/nv50_query.h [new file with mode: 0644]
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
src/gallium/drivers/nouveau/nv50/nv50_vbo.c

index c18e9f5b435b5f18b7d7a720b4c74a60ae6e1fd4..06d9d979e34dbfc117f488e285281be0e88daab6 100644 (file)
@@ -73,6 +73,7 @@ NV50_C_SOURCES := \
        nv50/nv50_program.h \
        nv50/nv50_push.c \
        nv50/nv50_query.c \
+       nv50/nv50_query.h \
        nv50/nv50_resource.c \
        nv50/nv50_resource.h \
        nv50/nv50_screen.c \
index 69c121274a91109343f182a3191e90b68ba0ad93..fb74a9748a3f5f61c61bc6c8de0469ff3119ff13 100644 (file)
@@ -16,6 +16,7 @@
 #include "nv50/nv50_program.h"
 #include "nv50/nv50_resource.h"
 #include "nv50/nv50_transfer.h"
+#include "nv50/nv50_query.h"
 
 #include "nouveau_context.h"
 #include "nouveau_debug.h"
@@ -195,17 +196,6 @@ void nv50_default_kick_notify(struct nouveau_pushbuf *);
 /* nv50_draw.c */
 extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *);
 
-/* nv50_query.c */
-void nv50_init_query_functions(struct nv50_context *);
-void nv50_query_pushbuf_submit(struct nouveau_pushbuf *, uint16_t method,
-                               struct pipe_query *, unsigned result_offset);
-void nv84_query_fifo_wait(struct nouveau_pushbuf *, struct pipe_query *);
-void nva0_so_target_save_offset(struct pipe_context *,
-                                struct pipe_stream_output_target *,
-                                unsigned index, bool seralize);
-
-#define NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET (PIPE_QUERY_TYPES + 0)
-
 /* nv50_shader_state.c */
 void nv50_vertprog_validate(struct nv50_context *);
 void nv50_gmtyprog_validate(struct nv50_context *);
index 5368ee73750aed629cc200d6d1c3db2bfbeffce5..7718d69b308d4e92b9f904ff0a3d8218293cafec 100644 (file)
@@ -25,6 +25,7 @@
 #define NV50_PUSH_EXPLICIT_SPACE_CHECKING
 
 #include "nv50/nv50_context.h"
+#include "nv50/nv50_query.h"
 #include "nv_object.xml.h"
 
 #define NV50_QUERY_STATE_READY   0
  * queries anyway.
  */
 
-struct nv50_query {
-   uint32_t *data;
-   uint16_t type;
-   uint16_t index;
-   uint32_t sequence;
-   struct nouveau_bo *bo;
-   uint32_t base;
-   uint32_t offset; /* base + i * 32 */
-   uint8_t state;
-   bool is64bit;
-   int nesting; /* only used for occlusion queries */
-   struct nouveau_mm_allocation *mm;
-   struct nouveau_fence *fence;
-};
-
 #define NV50_QUERY_ALLOC_SPACE 256
 
-static inline struct nv50_query *
-nv50_query(struct pipe_query *pipe)
-{
-   return (struct nv50_query *)pipe;
-}
-
 static bool
 nv50_query_allocate(struct nv50_context *nv50, struct nv50_query *q, int size)
 {
@@ -363,9 +343,8 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq,
 }
 
 void
-nv84_query_fifo_wait(struct nouveau_pushbuf *push, struct pipe_query *pq)
+nv84_query_fifo_wait(struct nouveau_pushbuf *push, struct nv50_query *q)
 {
-   struct nv50_query *q = nv50_query(pq);
    unsigned offset = q->offset;
 
    PUSH_SPACE(push, 5);
@@ -453,10 +432,8 @@ nv50_render_condition(struct pipe_context *pipe,
 
 void
 nv50_query_pushbuf_submit(struct nouveau_pushbuf *push, uint16_t method,
-                          struct pipe_query *pq, unsigned result_offset)
+                          struct nv50_query *q, unsigned result_offset)
 {
-   struct nv50_query *q = nv50_query(pq);
-
    nv50_query_update(q);
    if (q->state != NV50_QUERY_STATE_READY)
       nouveau_bo_wait(q->bo, NOUVEAU_BO_RD, push->client);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.h b/src/gallium/drivers/nouveau/nv50/nv50_query.h
new file mode 100644 (file)
index 0000000..722af0c
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef __NV50_QUERY_H__
+#define __NV50_QUERY_H__
+
+#include "pipe/p_context.h"
+
+#include "nouveau_context.h"
+#include "nouveau_mm.h"
+
+#define NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET (PIPE_QUERY_TYPES + 0)
+
+struct nv50_query {
+   uint32_t *data;
+   uint16_t type;
+   uint16_t index;
+   uint32_t sequence;
+   struct nouveau_bo *bo;
+   uint32_t base;
+   uint32_t offset; /* base + i * 32 */
+   uint8_t state;
+   bool is64bit;
+   int nesting; /* only used for occlusion queries */
+   struct nouveau_mm_allocation *mm;
+   struct nouveau_fence *fence;
+};
+
+static inline struct nv50_query *
+nv50_query(struct pipe_query *pipe)
+{
+   return (struct nv50_query *)pipe;
+}
+
+void nv50_init_query_functions(struct nv50_context *);
+void nv50_query_pushbuf_submit(struct nouveau_pushbuf *, uint16_t,
+                               struct nv50_query *, unsigned result_offset);
+void nv84_query_fifo_wait(struct nouveau_pushbuf *, struct nv50_query *);
+void nva0_so_target_save_offset(struct pipe_context *,
+                                struct pipe_stream_output_target *,
+                                unsigned, bool);
+
+#endif
index b3fece07c3f316df711c8025144ccfc60e376271..6b3ecbf37713d0cc2e64e7285e57c5a700810ab6 100644 (file)
@@ -641,7 +641,7 @@ nv50_stream_output_validate(struct nv50_context *nv50)
       const unsigned n = nv50->screen->base.class_3d >= NVA0_3D_CLASS ? 4 : 3;
 
       if (n == 4 && !targ->clean)
-         nv84_query_fifo_wait(push, targ->pq);
+         nv84_query_fifo_wait(push, nv50_query(targ->pq));
       BEGIN_NV04(push, NV50_3D(STRMOUT_ADDRESS_HIGH(i)), n);
       PUSH_DATAh(push, buf->address + targ->pipe.buffer_offset);
       PUSH_DATA (push, buf->address + targ->pipe.buffer_offset);
@@ -651,7 +651,7 @@ nv50_stream_output_validate(struct nv50_context *nv50)
          if (!targ->clean) {
             assert(targ->pq);
             nv50_query_pushbuf_submit(push, NVA0_3D_STRMOUT_OFFSET(i),
-                                      targ->pq, 0x4);
+                                      nv50_query(targ->pq), 0x4);
          } else {
             BEGIN_NV04(push, NVA0_3D(STRMOUT_OFFSET(i)), 1);
             PUSH_DATA(push, 0);
index f5f47087bef3b1644ff66df381e08c9fce93de62..dbc6632c248b422bb8fa5f844014623a3c942e70 100644 (file)
@@ -745,7 +745,8 @@ nva0_draw_stream_output(struct nv50_context *nv50,
       PUSH_DATA (push, 0);
       BEGIN_NV04(push, NVA0_3D(DRAW_TFB_STRIDE), 1);
       PUSH_DATA (push, so->stride);
-      nv50_query_pushbuf_submit(push, NVA0_3D_DRAW_TFB_BYTES, so->pq, 0x4);
+      nv50_query_pushbuf_submit(push, NVA0_3D_DRAW_TFB_BYTES,
+                                nv50_query(so->pq), 0x4);
       BEGIN_NV04(push, NV50_3D(VERTEX_END_GL), 1);
       PUSH_DATA (push, 0);