v3d_query.c 3.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright © 2014 Broadcom
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

24
#include "v3d_query.h"
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
int
v3d_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
                                struct pipe_driver_query_group_info *info)
{
        struct v3d_screen *screen = v3d_screen(pscreen);

        return v3d_get_driver_query_group_info_perfcnt(screen, index, info);
}

int
v3d_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
                          struct pipe_driver_query_info *info)
{
        struct v3d_screen *screen = v3d_screen(pscreen);

        return v3d_get_driver_query_info_perfcnt(screen, index, info);
}

44
static struct pipe_query *
45
v3d_create_query(struct pipe_context *pctx, unsigned query_type, unsigned index)
46
{
47
48
49
50
51
52
53
54
55
56
57
58
        struct v3d_context *v3d = v3d_context(pctx);

        return v3d_create_query_pipe(v3d, query_type, index);
}

static struct pipe_query *
v3d_create_batch_query(struct pipe_context *pctx, unsigned num_queries,
                       unsigned *query_types)
{
        return v3d_create_batch_query_perfcnt(v3d_context(pctx),
                                              num_queries,
                                              query_types);
59
60
61
}

static void
62
v3d_destroy_query(struct pipe_context *pctx, struct pipe_query *query)
63
{
64
        struct v3d_context *v3d = v3d_context(pctx);
65
        struct v3d_query *q = (struct v3d_query *)query;
66

67
        q->funcs->destroy_query(v3d, q);
68
69
}

70
static bool
71
v3d_begin_query(struct pipe_context *pctx, struct pipe_query *query)
72
{
73
74
        struct v3d_context *v3d = v3d_context(pctx);
        struct v3d_query *q = (struct v3d_query *)query;
75

76
        return q->funcs->begin_query(v3d, q);
77
78
79
}

static bool
80
v3d_end_query(struct pipe_context *pctx, struct pipe_query *query)
81
{
82
83
        struct v3d_context *v3d = v3d_context(pctx);
        struct v3d_query *q = (struct v3d_query *)query;
84

85
        return q->funcs->end_query(v3d, q);
86
87
}

88
static bool
89
v3d_get_query_result(struct pipe_context *pctx, struct pipe_query *query,
90
                     bool wait, union pipe_query_result *vresult)
91
{
92
        struct v3d_context *v3d = v3d_context(pctx);
93
        struct v3d_query *q = (struct v3d_query *)query;
94

95
        return q->funcs->get_query_result(v3d, q, wait, vresult);
96
97
98
}

static void
99
v3d_set_active_query_state(struct pipe_context *pctx, bool enable)
100
{
101
        struct v3d_context *v3d = v3d_context(pctx);
102

103
        v3d->active_queries = enable;
104
105
        v3d->dirty |= V3D_DIRTY_OQ;
        v3d->dirty |= V3D_DIRTY_STREAMOUT;
106
107
108
}

void
109
v3d_query_init(struct pipe_context *pctx)
110
{
111
        pctx->create_query = v3d_create_query;
112
        pctx->create_batch_query = v3d_create_batch_query;
113
114
115
116
117
        pctx->destroy_query = v3d_destroy_query;
        pctx->begin_query = v3d_begin_query;
        pctx->end_query = v3d_end_query;
        pctx->get_query_result = v3d_get_query_result;
        pctx->set_active_query_state = v3d_set_active_query_state;
118
}