vc4_query.c revision 32214e0c6837a24ad82152e9971baa3926992498
1/*
2 * Copyright © 2014 Broadcom
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24/**
25 * Stub support for occlusion queries.
26 *
27 * Since we expose support for GL 2.0, we have to expose occlusion queries,
28 * but the spec allows you to expose 0 query counter bits, so we just return 0
29 * as the result of all our queries.
30 */
31#include "vc4_context.h"
32
33struct vc4_query
34{
35        uint8_t pad;
36};
37
38static struct pipe_query *
39vc4_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
40{
41        struct vc4_query *query = calloc(1, sizeof(*query));
42
43        /* Note that struct pipe_query isn't actually defined anywhere. */
44        return (struct pipe_query *)query;
45}
46
47static void
48vc4_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
49{
50        free(query);
51}
52
53static boolean
54vc4_begin_query(struct pipe_context *ctx, struct pipe_query *query)
55{
56        return true;
57}
58
59static bool
60vc4_end_query(struct pipe_context *ctx, struct pipe_query *query)
61{
62        return true;
63}
64
65static boolean
66vc4_get_query_result(struct pipe_context *ctx, struct pipe_query *query,
67                     boolean wait, union pipe_query_result *vresult)
68{
69        uint64_t *result = &vresult->u64;
70
71        *result = 0;
72
73        return true;
74}
75
76static void
77vc4_set_active_query_state(struct pipe_context *pipe, boolean enable)
78{
79}
80
81void
82vc4_query_init(struct pipe_context *pctx)
83{
84        pctx->create_query = vc4_create_query;
85        pctx->destroy_query = vc4_destroy_query;
86        pctx->begin_query = vc4_begin_query;
87        pctx->end_query = vc4_end_query;
88        pctx->get_query_result = vc4_get_query_result;
89	pctx->set_active_query_state = vc4_set_active_query_state;
90}
91
92