• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 Rob Clark <robclark@freedesktop.org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  *
23  * Authors:
24  *    Rob Clark <robclark@freedesktop.org>
25  */
26 
27 #ifndef FREEDRENO_QUERY_ACC_H_
28 #define FREEDRENO_QUERY_ACC_H_
29 
30 #include "util/list.h"
31 
32 #include "freedreno_context.h"
33 #include "freedreno_query.h"
34 
35 /*
36  * Accumulated HW Queries:
37  *
38  * Unlike the original HW Queries in earlier adreno generations (see
39  * freedreno_query_hw.[ch], later generations can accumulate the per-
40  * tile results of some (a4xx) or all (a5xx+?) queries in the cmdstream.
41  * But we still need to handle pausing/resuming the query across stage
42  * changes (in particular when switching between batches).
43  *
44  * fd_acc_sample_provider:
45  *   - one per accumulated query type, registered/implemented by gpu
46  *     generation specific code
47  *   - knows how to emit cmdstream to pause/resume a query instance
48  *
49  * fd_acc_query:
50  *   - one instance per query object
51  *   - each query object has it's own result buffer, which may
52  *     span multiple batches, etc.
53  */
54 
55 struct fd_acc_query;
56 
57 struct fd_acc_sample_provider {
58    unsigned query_type;
59 
60    /* Set if the provider should still count while !ctx->active_queries */
61    bool always;
62 
63    unsigned size;
64 
65    void (*resume)(struct fd_acc_query *aq, struct fd_batch *batch) dt;
66    void (*pause)(struct fd_acc_query *aq, struct fd_batch *batch) dt;
67 
68    void (*result)(struct fd_acc_query *aq, void *buf,
69                   union pipe_query_result *result);
70 };
71 
72 struct fd_acc_query {
73    struct fd_query base;
74 
75    const struct fd_acc_sample_provider *provider;
76 
77    struct pipe_resource *prsc;
78 
79    /* Pointer to the batch that our query has had resume() called on (if
80     * any).
81     */
82    struct fd_batch *batch;
83 
84    /* usually the same as provider->size but for batch queries we
85     * need to calculate the size dynamically when the query is
86     * allocated:
87     */
88    unsigned size;
89 
90    struct list_head node; /* list-node in ctx->active_acc_queries */
91 
92    void *query_data; /* query specific data */
93 };
94 
95 static inline struct fd_acc_query *
fd_acc_query(struct fd_query * q)96 fd_acc_query(struct fd_query *q)
97 {
98    return (struct fd_acc_query *)q;
99 }
100 
101 struct fd_query *fd_acc_create_query(struct fd_context *ctx,
102                                      unsigned query_type, unsigned index);
103 struct fd_query *
104 fd_acc_create_query2(struct fd_context *ctx, unsigned query_type,
105                      unsigned index,
106                      const struct fd_acc_sample_provider *provider);
107 void fd_acc_query_update_batch(struct fd_batch *batch,
108                                bool disable_all) assert_dt;
109 void
110 fd_acc_query_register_provider(struct pipe_context *pctx,
111                                const struct fd_acc_sample_provider *provider);
112 
113 #endif /* FREEDRENO_QUERY_ACC_H_ */
114