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
33 struct vc4_query
34 {
35 uint8_t pad;
36 };
37
38 static struct pipe_query *
vc4_create_query(struct pipe_context * ctx,unsigned query_type,unsigned index)39 vc4_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
47 static void
vc4_destroy_query(struct pipe_context * ctx,struct pipe_query * query)48 vc4_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
49 {
50 free(query);
51 }
52
53 static boolean
vc4_begin_query(struct pipe_context * ctx,struct pipe_query * query)54 vc4_begin_query(struct pipe_context *ctx, struct pipe_query *query)
55 {
56 return true;
57 }
58
59 static bool
vc4_end_query(struct pipe_context * ctx,struct pipe_query * query)60 vc4_end_query(struct pipe_context *ctx, struct pipe_query *query)
61 {
62 return true;
63 }
64
65 static boolean
vc4_get_query_result(struct pipe_context * ctx,struct pipe_query * query,boolean wait,union pipe_query_result * vresult)66 vc4_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
76 static void
vc4_set_active_query_state(struct pipe_context * pipe,boolean enable)77 vc4_set_active_query_state(struct pipe_context *pipe, boolean enable)
78 {
79 }
80
81 void
vc4_query_init(struct pipe_context * pctx)82 vc4_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