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)42 static struct pipe_query *i915_create_query(struct pipe_context *ctx,
43                                             unsigned query_type)
44 {
45    struct i915_query *query = CALLOC_STRUCT( i915_query );
46 
47    return (struct pipe_query *)query;
48 }
49 
i915_destroy_query(struct pipe_context * ctx,struct pipe_query * query)50 static void i915_destroy_query(struct pipe_context *ctx,
51                                struct pipe_query *query)
52 {
53    FREE(query);
54 }
55 
i915_begin_query(struct pipe_context * ctx,struct pipe_query * query)56 static void i915_begin_query(struct pipe_context *ctx,
57                              struct pipe_query *query)
58 {
59 }
60 
i915_end_query(struct pipe_context * ctx,struct pipe_query * query)61 static void i915_end_query(struct pipe_context *ctx, struct pipe_query *query)
62 {
63 }
64 
i915_get_query_result(struct pipe_context * ctx,struct pipe_query * query,boolean wait,union pipe_query_result * vresult)65 static boolean i915_get_query_result(struct pipe_context *ctx,
66                                      struct pipe_query *query,
67                                      boolean wait,
68                                      union pipe_query_result *vresult)
69 {
70    uint64_t *result = (uint64_t*)vresult;
71 
72    /* 2* viewport Max */
73    *result = 512*1024*1024;
74    return TRUE;
75 }
76 
77 void
i915_init_query_functions(struct i915_context * i915)78 i915_init_query_functions(struct i915_context *i915)
79 {
80    i915->base.create_query = i915_create_query;
81    i915->base.destroy_query = i915_destroy_query;
82    i915->base.begin_query = i915_begin_query;
83    i915->base.end_query = i915_end_query;
84    i915->base.get_query_result = i915_get_query_result;
85 }
86 
87