• 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_query.h"
33 #include "freedreno_context.h"
34 
35 
36 /*
37  * Accumulated HW Queries:
38  *
39  * Unlike the original HW Queries in earlier adreno generations (see
40  * freedreno_query_hw.[ch], later generations can accumulate the per-
41  * tile results of some (a4xx) or all (a5xx+?) queries in the cmdstream.
42  * But we still need to handle pausing/resuming the query across stage
43  * changes (in particular when switching between batches).
44  *
45  * fd_acc_sample_provider:
46  *   - one per accumulated query type, registered/implemented by gpu
47  *     generation specific code
48  *   - knows how to emit cmdstream to pause/resume a query instance
49  *
50  * fd_acc_query:
51  *   - one instance per query object
52  *   - each query object has it's own result buffer, which may
53  *     span multiple batches, etc.
54  */
55 
56 
57 struct fd_acc_query;
58 
59 struct fd_acc_sample_provider {
60 	unsigned query_type;
61 
62 	/* stages applicable to the query type: */
63 	enum fd_render_stage active;
64 
65 	unsigned size;
66 
67 	void (*resume)(struct fd_acc_query *aq, struct fd_batch *batch);
68 	void (*pause)(struct fd_acc_query *aq, struct fd_batch *batch);
69 
70 	void (*result)(struct fd_context *ctx, void *buf,
71 			union pipe_query_result *result);
72 };
73 
74 struct fd_acc_query {
75 	struct fd_query base;
76 
77 	const struct fd_acc_sample_provider *provider;
78 
79 	struct pipe_resource *prsc;
80 	unsigned offset;
81 
82 	struct list_head node;   /* list-node in ctx->active_acc_queries */
83 
84 	int no_wait_cnt;         /* see fd_acc_get_query_result() */
85 };
86 
87 static inline struct fd_acc_query *
fd_acc_query(struct fd_query * q)88 fd_acc_query(struct fd_query *q)
89 {
90 	return (struct fd_acc_query *)q;
91 }
92 
93 struct fd_query * fd_acc_create_query(struct fd_context *ctx, unsigned query_type);
94 void fd_acc_query_set_stage(struct fd_batch *batch, enum fd_render_stage stage);
95 void fd_acc_query_register_provider(struct pipe_context *pctx,
96 		const struct fd_acc_sample_provider *provider);
97 
98 #endif /* FREEDRENO_QUERY_ACC_H_ */
99