1 /* -*- mode: C; c-file-style: "k&r"; ttxab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
29 #include "pipe/p_state.h"
30 #include "util/u_memory.h"
32 #include "freedreno_query.h"
33 #include "freedreno_query_sw.h"
34 #include "freedreno_query_hw.h"
35 #include "freedreno_context.h"
36 #include "freedreno_util.h"
39 * Pipe Query interface:
42 static struct pipe_query
*
43 fd_create_query(struct pipe_context
*pctx
, unsigned query_type
)
45 struct fd_context
*ctx
= fd_context(pctx
);
48 q
= fd_sw_create_query(ctx
, query_type
);
50 q
= fd_hw_create_query(ctx
, query_type
);
52 return (struct pipe_query
*) q
;
56 fd_destroy_query(struct pipe_context
*pctx
, struct pipe_query
*pq
)
58 struct fd_query
*q
= fd_query(pq
);
59 q
->funcs
->destroy_query(fd_context(pctx
), q
);
63 fd_begin_query(struct pipe_context
*pctx
, struct pipe_query
*pq
)
65 struct fd_query
*q
= fd_query(pq
);
66 q
->funcs
->begin_query(fd_context(pctx
), q
);
70 fd_end_query(struct pipe_context
*pctx
, struct pipe_query
*pq
)
72 struct fd_query
*q
= fd_query(pq
);
73 q
->funcs
->end_query(fd_context(pctx
), q
);
77 fd_get_query_result(struct pipe_context
*pctx
, struct pipe_query
*pq
,
78 boolean wait
, union pipe_query_result
*result
)
80 struct fd_query
*q
= fd_query(pq
);
81 return q
->funcs
->get_query_result(fd_context(pctx
), q
, wait
, result
);
85 fd_get_driver_query_info(struct pipe_screen
*pscreen
,
86 unsigned index
, struct pipe_driver_query_info
*info
)
88 struct pipe_driver_query_info list
[] = {
89 {"draw-calls", FD_QUERY_DRAW_CALLS
, 0},
90 {"batches", FD_QUERY_BATCH_TOTAL
, 0},
91 {"batches-sysmem", FD_QUERY_BATCH_SYSMEM
, 0},
92 {"batches-gmem", FD_QUERY_BATCH_GMEM
, 0},
93 {"restores", FD_QUERY_BATCH_RESTORE
, 0},
94 {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED
, 0},
98 return ARRAY_SIZE(list
);
100 if (index
>= ARRAY_SIZE(list
))
108 fd_query_screen_init(struct pipe_screen
*pscreen
)
110 pscreen
->get_driver_query_info
= fd_get_driver_query_info
;
114 fd_query_context_init(struct pipe_context
*pctx
)
116 pctx
->create_query
= fd_create_query
;
117 pctx
->destroy_query
= fd_destroy_query
;
118 pctx
->begin_query
= fd_begin_query
;
119 pctx
->end_query
= fd_end_query
;
120 pctx
->get_query_result
= fd_get_query_result
;