1 /*
2 * Copyright (c) 2017-2019 Lima Project
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, sub license,
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
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the 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 NON-INFRINGEMENT. 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
21 * DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 /**
26 * Stub support for occlusion queries.
27 *
28 * Since we expose support for GL 2.0, we have to expose occlusion queries,
29 * but the spec allows you to expose 0 query counter bits, so we just return 0
30 * as the result of all our queries.
31 */
32
33 #include "util/u_debug.h"
34
35 #include "lima_context.h"
36
37 struct lima_query
38 {
39 uint8_t pad;
40 };
41
42 static struct pipe_query *
lima_create_query(struct pipe_context * ctx,unsigned query_type,unsigned index)43 lima_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
44 {
45 struct lima_query *query = calloc(1, sizeof(*query));
46
47 /* Note that struct pipe_query isn't actually defined anywhere. */
48 return (struct pipe_query *)query;
49 }
50
51 static void
lima_destroy_query(struct pipe_context * ctx,struct pipe_query * query)52 lima_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
53 {
54 free(query);
55 }
56
57 static bool
lima_begin_query(struct pipe_context * ctx,struct pipe_query * query)58 lima_begin_query(struct pipe_context *ctx, struct pipe_query *query)
59 {
60 return true;
61 }
62
63 static bool
lima_end_query(struct pipe_context * ctx,struct pipe_query * query)64 lima_end_query(struct pipe_context *ctx, struct pipe_query *query)
65 {
66 return true;
67 }
68
69 static bool
lima_get_query_result(struct pipe_context * ctx,struct pipe_query * query,bool wait,union pipe_query_result * vresult)70 lima_get_query_result(struct pipe_context *ctx, struct pipe_query *query,
71 bool wait, union pipe_query_result *vresult)
72 {
73 uint64_t *result = &vresult->u64;
74
75 *result = 0;
76
77 return true;
78 }
79
80 static void
lima_set_active_query_state(struct pipe_context * pipe,bool enable)81 lima_set_active_query_state(struct pipe_context *pipe, bool enable)
82 {
83
84 }
85
86 void
lima_query_init(struct lima_context * pctx)87 lima_query_init(struct lima_context *pctx)
88 {
89 pctx->base.create_query = lima_create_query;
90 pctx->base.destroy_query = lima_destroy_query;
91 pctx->base.begin_query = lima_begin_query;
92 pctx->base.end_query = lima_end_query;
93 pctx->base.get_query_result = lima_get_query_result;
94 pctx->base.set_active_query_state = lima_set_active_query_state;
95 }
96
97