1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (c) 2017-2019 Lima Project
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
12bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
13bf215546Sopenharmony_ci * of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci/**
26bf215546Sopenharmony_ci * Stub support for occlusion queries.
27bf215546Sopenharmony_ci *
28bf215546Sopenharmony_ci * Since we expose support for GL 2.0, we have to expose occlusion queries,
29bf215546Sopenharmony_ci * but the spec allows you to expose 0 query counter bits, so we just return 0
30bf215546Sopenharmony_ci * as the result of all our queries.
31bf215546Sopenharmony_ci */
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "util/u_debug.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#include "lima_context.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistruct lima_query
38bf215546Sopenharmony_ci{
39bf215546Sopenharmony_ci   uint8_t pad;
40bf215546Sopenharmony_ci};
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_cistatic struct pipe_query *
43bf215546Sopenharmony_cilima_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
44bf215546Sopenharmony_ci{
45bf215546Sopenharmony_ci   struct lima_query *query = calloc(1, sizeof(*query));
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci   /* Note that struct pipe_query isn't actually defined anywhere. */
48bf215546Sopenharmony_ci   return (struct pipe_query *)query;
49bf215546Sopenharmony_ci}
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_cistatic void
52bf215546Sopenharmony_cilima_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
53bf215546Sopenharmony_ci{
54bf215546Sopenharmony_ci   free(query);
55bf215546Sopenharmony_ci}
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_cistatic bool
58bf215546Sopenharmony_cilima_begin_query(struct pipe_context *ctx, struct pipe_query *query)
59bf215546Sopenharmony_ci{
60bf215546Sopenharmony_ci   return true;
61bf215546Sopenharmony_ci}
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_cistatic bool
64bf215546Sopenharmony_cilima_end_query(struct pipe_context *ctx, struct pipe_query *query)
65bf215546Sopenharmony_ci{
66bf215546Sopenharmony_ci   return true;
67bf215546Sopenharmony_ci}
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_cistatic bool
70bf215546Sopenharmony_cilima_get_query_result(struct pipe_context *ctx, struct pipe_query *query,
71bf215546Sopenharmony_ci                     bool wait, union pipe_query_result *vresult)
72bf215546Sopenharmony_ci{
73bf215546Sopenharmony_ci   uint64_t *result = &vresult->u64;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   *result = 0;
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci   return true;
78bf215546Sopenharmony_ci}
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_cistatic void
81bf215546Sopenharmony_cilima_set_active_query_state(struct pipe_context *pipe, bool enable)
82bf215546Sopenharmony_ci{
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci}
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_civoid
87bf215546Sopenharmony_cilima_query_init(struct lima_context *pctx)
88bf215546Sopenharmony_ci{
89bf215546Sopenharmony_ci   pctx->base.create_query = lima_create_query;
90bf215546Sopenharmony_ci   pctx->base.destroy_query = lima_destroy_query;
91bf215546Sopenharmony_ci   pctx->base.begin_query = lima_begin_query;
92bf215546Sopenharmony_ci   pctx->base.end_query = lima_end_query;
93bf215546Sopenharmony_ci   pctx->base.get_query_result = lima_get_query_result;
94bf215546Sopenharmony_ci   pctx->base.set_active_query_state = lima_set_active_query_state;
95bf215546Sopenharmony_ci}
96bf215546Sopenharmony_ci
97