1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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 TUNGSTEN GRAPHICS 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.
26 **************************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
32 #include "draw/draw_context.h"
33 #include "pipe/p_defines.h"
34 #include "util/u_memory.h"
35 #include "lp_context.h"
39 struct llvmpipe_query
{
45 static struct llvmpipe_query
*llvmpipe_query( struct pipe_query
*p
)
47 return (struct llvmpipe_query
*)p
;
50 static struct pipe_query
*
51 llvmpipe_create_query(struct pipe_context
*pipe
,
54 assert(type
== PIPE_QUERY_OCCLUSION_COUNTER
);
55 return (struct pipe_query
*)CALLOC_STRUCT( llvmpipe_query
);
60 llvmpipe_destroy_query(struct pipe_context
*pipe
, struct pipe_query
*q
)
67 llvmpipe_begin_query(struct pipe_context
*pipe
, struct pipe_query
*q
)
69 struct llvmpipe_context
*llvmpipe
= llvmpipe_context( pipe
);
70 struct llvmpipe_query
*sq
= llvmpipe_query(q
);
72 sq
->start
= llvmpipe
->occlusion_count
;
73 llvmpipe
->active_query_count
++;
74 llvmpipe
->dirty
|= LP_NEW_QUERY
;
79 llvmpipe_end_query(struct pipe_context
*pipe
, struct pipe_query
*q
)
81 struct llvmpipe_context
*llvmpipe
= llvmpipe_context( pipe
);
82 struct llvmpipe_query
*sq
= llvmpipe_query(q
);
84 llvmpipe
->active_query_count
--;
85 sq
->end
= llvmpipe
->occlusion_count
;
86 llvmpipe
->dirty
|= LP_NEW_QUERY
;
91 llvmpipe_get_query_result(struct pipe_context
*pipe
,
96 struct llvmpipe_query
*sq
= llvmpipe_query(q
);
97 *result
= sq
->end
- sq
->start
;
102 void llvmpipe_init_query_funcs(struct llvmpipe_context
*llvmpipe
)
104 llvmpipe
->pipe
.create_query
= llvmpipe_create_query
;
105 llvmpipe
->pipe
.destroy_query
= llvmpipe_destroy_query
;
106 llvmpipe
->pipe
.begin_query
= llvmpipe_begin_query
;
107 llvmpipe
->pipe
.end_query
= llvmpipe_end_query
;
108 llvmpipe
->pipe
.get_query_result
= llvmpipe_get_query_result
;