1 /**************************************************************************
2 *
3 * Copyright 2011 The Chromium OS authors.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL GOOGLE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /* Fake occlusion queries which return 0, it's better than crashing */
29
30 #include "pipe/p_compiler.h"
31
32 #include "util/u_memory.h"
33
34 #include "i915_context.h"
35 #include "i915_query.h"
36
37 struct i915_query
38 {
39 unsigned query;
40 };
41
i915_create_query(struct pipe_context * ctx,unsigned query_type,unsigned index)42 static struct pipe_query *i915_create_query(struct pipe_context *ctx,
43 unsigned query_type,
44 unsigned index)
45 {
46 struct i915_query *query = CALLOC_STRUCT( i915_query );
47
48 return (struct pipe_query *)query;
49 }
50
i915_destroy_query(struct pipe_context * ctx,struct pipe_query * query)51 static void i915_destroy_query(struct pipe_context *ctx,
52 struct pipe_query *query)
53 {
54 FREE(query);
55 }
56
i915_begin_query(struct pipe_context * ctx,struct pipe_query * query)57 static boolean i915_begin_query(struct pipe_context *ctx,
58 struct pipe_query *query)
59 {
60 return true;
61 }
62
i915_end_query(struct pipe_context * ctx,struct pipe_query * query)63 static bool i915_end_query(struct pipe_context *ctx, struct pipe_query *query)
64 {
65 return true;
66 }
67
i915_get_query_result(struct pipe_context * ctx,struct pipe_query * query,boolean wait,union pipe_query_result * vresult)68 static boolean i915_get_query_result(struct pipe_context *ctx,
69 struct pipe_query *query,
70 boolean wait,
71 union pipe_query_result *vresult)
72 {
73 uint64_t *result = (uint64_t*)vresult;
74
75 /* 2* viewport Max */
76 *result = 512*1024*1024;
77 return TRUE;
78 }
79
80 static void
i915_set_active_query_state(struct pipe_context * pipe,boolean enable)81 i915_set_active_query_state(struct pipe_context *pipe, boolean enable)
82 {
83 }
84
85 void
i915_init_query_functions(struct i915_context * i915)86 i915_init_query_functions(struct i915_context *i915)
87 {
88 i915->base.create_query = i915_create_query;
89 i915->base.destroy_query = i915_destroy_query;
90 i915->base.begin_query = i915_begin_query;
91 i915->base.end_query = i915_end_query;
92 i915->base.get_query_result = i915_get_query_result;
93 i915->base.set_active_query_state = i915_set_active_query_state;
94 }
95
96