radeonsi: move VS_STATE.LS_OUT_PATCH_SIZE a few bits higher to make space there
[mesa.git] / src / gallium / drivers / radeonsi / si_query.h
index ebd965a004f42d9d30518142b9d05ef944c40c36..dc219f8551c076069104f4e1d9c6f7f4e7301869 100644 (file)
@@ -34,8 +34,11 @@ struct pipe_resource;
 struct si_screen;
 struct si_context;
 struct si_query;
+struct si_query_buffer;
 struct si_query_hw;
-struct r600_resource;
+struct si_resource;
+
+#define SI_MAX_STREAMS 4
 
 enum {
        SI_QUERY_DRAW_CALLS = PIPE_QUERY_DRIVER_SPECIFIC,
@@ -111,6 +114,9 @@ enum {
        SI_QUERY_GPIN_NUM_SE,
        SI_QUERY_TIME_ELAPSED_SDMA,
        SI_QUERY_TIME_ELAPSED_SDMA_SI, /* emulated, measured on the CPU */
+       SI_QUERY_PD_NUM_PRIMS_ACCEPTED,
+       SI_QUERY_PD_NUM_PRIMS_REJECTED,
+       SI_QUERY_PD_NUM_PRIMS_INELIGIBLE,
 
        SI_QUERY_FIRST_PERFCOUNTER = PIPE_QUERY_DRIVER_SPECIFIC + 100,
 };
@@ -121,7 +127,7 @@ enum {
 };
 
 struct si_query_ops {
-       void (*destroy)(struct si_screen *, struct si_query *);
+       void (*destroy)(struct si_context *, struct si_query *);
        bool (*begin)(struct si_context *, struct si_query *);
        bool (*end)(struct si_context *, struct si_query *);
        bool (*get_result)(struct si_context *,
@@ -140,7 +146,7 @@ struct si_query_ops {
 
 struct si_query {
        struct threaded_query b;
-       struct si_query_ops *ops;
+       const struct si_query_ops *ops;
 
        /* The PIPE_QUERY_xxx type of query */
        unsigned type;
@@ -160,15 +166,13 @@ enum {
 };
 
 struct si_query_hw_ops {
-       bool (*prepare_buffer)(struct si_screen *,
-                              struct si_query_hw *,
-                              struct r600_resource *);
+       bool (*prepare_buffer)(struct si_context *, struct si_query_buffer *);
        void (*emit_start)(struct si_context *,
                           struct si_query_hw *,
-                          struct r600_resource *buffer, uint64_t va);
+                          struct si_resource *buffer, uint64_t va);
        void (*emit_stop)(struct si_context *,
                          struct si_query_hw *,
-                         struct r600_resource *buffer, uint64_t va);
+                         struct si_resource *buffer, uint64_t va);
        void (*clear_result)(struct si_query_hw *, union pipe_query_result *);
        void (*add_result)(struct si_screen *screen,
                           struct si_query_hw *, void *buffer,
@@ -177,15 +181,23 @@ struct si_query_hw_ops {
 
 struct si_query_buffer {
        /* The buffer where query results are stored. */
-       struct r600_resource            *buf;
-       /* Offset of the next free result after current query data */
-       unsigned                        results_end;
+       struct si_resource              *buf;
        /* If a query buffer is full, a new buffer is created and the old one
         * is put in here. When we calculate the result, we sum up the samples
         * from all buffers. */
        struct si_query_buffer  *previous;
+       /* Offset of the next free result after current query data */
+       unsigned                        results_end;
+       bool unprepared;
 };
 
+void si_query_buffer_destroy(struct si_screen *sctx, struct si_query_buffer *buffer);
+void si_query_buffer_reset(struct si_context *sctx, struct si_query_buffer *buffer);
+bool si_query_buffer_alloc(struct si_context *sctx, struct si_query_buffer *buffer,
+                          bool (*prepare_buffer)(struct si_context *, struct si_query_buffer*),
+                          unsigned size);
+
+
 struct si_query_hw {
        struct si_query b;
        struct si_query_hw_ops *ops;
@@ -200,26 +212,30 @@ struct si_query_hw {
        unsigned stream;
 
        /* Workaround via compute shader */
-       struct r600_resource *workaround_buf;
+       struct si_resource *workaround_buf;
        unsigned workaround_offset;
 };
 
-bool si_query_hw_init(struct si_screen *sscreen,
-                     struct si_query_hw *query);
-void si_query_hw_destroy(struct si_screen *sscreen,
-                        struct si_query *rquery);
+void si_query_hw_destroy(struct si_context *sctx,
+                        struct si_query *squery);
 bool si_query_hw_begin(struct si_context *sctx,
-                      struct si_query *rquery);
+                      struct si_query *squery);
 bool si_query_hw_end(struct si_context *sctx,
-                    struct si_query *rquery);
+                    struct si_query *squery);
 bool si_query_hw_get_result(struct si_context *sctx,
-                           struct si_query *rquery,
+                           struct si_query *squery,
                            bool wait,
                            union pipe_query_result *result);
 void si_query_hw_suspend(struct si_context *sctx, struct si_query *query);
 void si_query_hw_resume(struct si_context *sctx, struct si_query *query);
 
 
+/* Shader-based queries */
+struct pipe_query *gfx10_sh_query_create(struct si_screen *screen,
+                                        enum pipe_query_type query_type,
+                                        unsigned index);
+
+
 /* Performance counters */
 struct si_perfcounters {
        unsigned num_groups;
@@ -244,13 +260,11 @@ int si_get_perfcounter_group_info(struct si_screen *,
                                  unsigned index,
                                  struct pipe_driver_query_group_info *info);
 
-void si_query_hw_reset_buffers(struct si_context *sctx,
-                              struct si_query_hw *query);
-
 struct si_qbo_state {
        void *saved_compute;
        struct pipe_constant_buffer saved_const0;
        struct pipe_shader_buffer saved_ssbo[3];
+       unsigned saved_ssbo_writable_mask;
 };
 
 #endif /* SI_QUERY_H */