1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci/* Author:
29bf215546Sopenharmony_ci *    Keith Whitwell <keithw@vmware.com>
30bf215546Sopenharmony_ci */
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#include "draw/draw_context.h"
33bf215546Sopenharmony_ci#include "util/os_time.h"
34bf215546Sopenharmony_ci#include "pipe/p_defines.h"
35bf215546Sopenharmony_ci#include "util/u_memory.h"
36bf215546Sopenharmony_ci#include "sp_context.h"
37bf215546Sopenharmony_ci#include "sp_query.h"
38bf215546Sopenharmony_ci#include "sp_state.h"
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_cistruct softpipe_query {
41bf215546Sopenharmony_ci   unsigned type;
42bf215546Sopenharmony_ci   unsigned index;
43bf215546Sopenharmony_ci   uint64_t start;
44bf215546Sopenharmony_ci   uint64_t end;
45bf215546Sopenharmony_ci   struct pipe_query_data_so_statistics so[PIPE_MAX_VERTEX_STREAMS];
46bf215546Sopenharmony_ci   struct pipe_query_data_pipeline_statistics stats;
47bf215546Sopenharmony_ci};
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_cistatic struct softpipe_query *softpipe_query( struct pipe_query *p )
51bf215546Sopenharmony_ci{
52bf215546Sopenharmony_ci   return (struct softpipe_query *)p;
53bf215546Sopenharmony_ci}
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_cistatic struct pipe_query *
56bf215546Sopenharmony_cisoftpipe_create_query(struct pipe_context *pipe,
57bf215546Sopenharmony_ci		      unsigned type,
58bf215546Sopenharmony_ci		      unsigned index)
59bf215546Sopenharmony_ci{
60bf215546Sopenharmony_ci   struct softpipe_query* sq;
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci   assert(type == PIPE_QUERY_OCCLUSION_COUNTER ||
63bf215546Sopenharmony_ci          type == PIPE_QUERY_OCCLUSION_PREDICATE ||
64bf215546Sopenharmony_ci          type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE ||
65bf215546Sopenharmony_ci          type == PIPE_QUERY_TIME_ELAPSED ||
66bf215546Sopenharmony_ci          type == PIPE_QUERY_SO_STATISTICS ||
67bf215546Sopenharmony_ci          type == PIPE_QUERY_SO_OVERFLOW_PREDICATE ||
68bf215546Sopenharmony_ci          type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE ||
69bf215546Sopenharmony_ci          type == PIPE_QUERY_PRIMITIVES_EMITTED ||
70bf215546Sopenharmony_ci          type == PIPE_QUERY_PRIMITIVES_GENERATED ||
71bf215546Sopenharmony_ci          type == PIPE_QUERY_PIPELINE_STATISTICS ||
72bf215546Sopenharmony_ci          type == PIPE_QUERY_GPU_FINISHED ||
73bf215546Sopenharmony_ci          type == PIPE_QUERY_TIMESTAMP ||
74bf215546Sopenharmony_ci          type == PIPE_QUERY_TIMESTAMP_DISJOINT);
75bf215546Sopenharmony_ci   sq = CALLOC_STRUCT( softpipe_query );
76bf215546Sopenharmony_ci   sq->type = type;
77bf215546Sopenharmony_ci   sq->index = index;
78bf215546Sopenharmony_ci   return (struct pipe_query *)sq;
79bf215546Sopenharmony_ci}
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_cistatic void
83bf215546Sopenharmony_cisoftpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
84bf215546Sopenharmony_ci{
85bf215546Sopenharmony_ci   FREE(q);
86bf215546Sopenharmony_ci}
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_cistatic bool
90bf215546Sopenharmony_cisoftpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
91bf215546Sopenharmony_ci{
92bf215546Sopenharmony_ci   struct softpipe_context *softpipe = softpipe_context( pipe );
93bf215546Sopenharmony_ci   struct softpipe_query *sq = softpipe_query(q);
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci   switch (sq->type) {
96bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_COUNTER:
97bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE:
98bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
99bf215546Sopenharmony_ci      sq->start = softpipe->occlusion_count;
100bf215546Sopenharmony_ci      break;
101bf215546Sopenharmony_ci   case PIPE_QUERY_TIME_ELAPSED:
102bf215546Sopenharmony_ci      sq->start = os_time_get_nano();
103bf215546Sopenharmony_ci      break;
104bf215546Sopenharmony_ci   case PIPE_QUERY_SO_STATISTICS:
105bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written = softpipe->so_stats[sq->index].num_primitives_written;
106bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed = softpipe->so_stats[sq->index].primitives_storage_needed;
107bf215546Sopenharmony_ci      break;
108bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
109bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written = softpipe->so_stats[sq->index].num_primitives_written;
110bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed = softpipe->so_stats[sq->index].primitives_storage_needed;
111bf215546Sopenharmony_ci      break;
112bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
113bf215546Sopenharmony_ci      for (unsigned i = 0; i < PIPE_MAX_VERTEX_STREAMS; i++) {
114bf215546Sopenharmony_ci         sq->so[i].num_primitives_written = softpipe->so_stats[i].num_primitives_written;
115bf215546Sopenharmony_ci         sq->so[i].primitives_storage_needed = softpipe->so_stats[i].primitives_storage_needed;
116bf215546Sopenharmony_ci      }
117bf215546Sopenharmony_ci      break;
118bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_EMITTED:
119bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written = softpipe->so_stats[sq->index].num_primitives_written;
120bf215546Sopenharmony_ci      break;
121bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_GENERATED:
122bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed = softpipe->so_stats[sq->index].primitives_storage_needed;
123bf215546Sopenharmony_ci      break;
124bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP:
125bf215546Sopenharmony_ci   case PIPE_QUERY_GPU_FINISHED:
126bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP_DISJOINT:
127bf215546Sopenharmony_ci      break;
128bf215546Sopenharmony_ci   case PIPE_QUERY_PIPELINE_STATISTICS:
129bf215546Sopenharmony_ci      /* reset our cache */
130bf215546Sopenharmony_ci      if (softpipe->active_statistics_queries == 0) {
131bf215546Sopenharmony_ci         memset(&softpipe->pipeline_statistics, 0,
132bf215546Sopenharmony_ci                sizeof(softpipe->pipeline_statistics));
133bf215546Sopenharmony_ci      }
134bf215546Sopenharmony_ci      memcpy(&sq->stats, &softpipe->pipeline_statistics,
135bf215546Sopenharmony_ci             sizeof(sq->stats));
136bf215546Sopenharmony_ci      softpipe->active_statistics_queries++;
137bf215546Sopenharmony_ci      break;
138bf215546Sopenharmony_ci   default:
139bf215546Sopenharmony_ci      assert(0);
140bf215546Sopenharmony_ci      break;
141bf215546Sopenharmony_ci   }
142bf215546Sopenharmony_ci   softpipe->active_query_count++;
143bf215546Sopenharmony_ci   softpipe->dirty |= SP_NEW_QUERY;
144bf215546Sopenharmony_ci   return true;
145bf215546Sopenharmony_ci}
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_cistatic bool
149bf215546Sopenharmony_cisoftpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
150bf215546Sopenharmony_ci{
151bf215546Sopenharmony_ci   struct softpipe_context *softpipe = softpipe_context( pipe );
152bf215546Sopenharmony_ci   struct softpipe_query *sq = softpipe_query(q);
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci   softpipe->active_query_count--;
155bf215546Sopenharmony_ci   switch (sq->type) {
156bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_COUNTER:
157bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE:
158bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
159bf215546Sopenharmony_ci      sq->end = softpipe->occlusion_count;
160bf215546Sopenharmony_ci      break;
161bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP:
162bf215546Sopenharmony_ci      sq->start = 0;
163bf215546Sopenharmony_ci      FALLTHROUGH;
164bf215546Sopenharmony_ci   case PIPE_QUERY_TIME_ELAPSED:
165bf215546Sopenharmony_ci      sq->end = os_time_get_nano();
166bf215546Sopenharmony_ci      break;
167bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
168bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written =
169bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].num_primitives_written - sq->so[sq->index].num_primitives_written;
170bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed =
171bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].primitives_storage_needed - sq->so[sq->index].primitives_storage_needed;
172bf215546Sopenharmony_ci      sq->end = sq->so[sq->index].primitives_storage_needed > sq->so[sq->index].num_primitives_written;
173bf215546Sopenharmony_ci      break;
174bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
175bf215546Sopenharmony_ci      sq->end = 0;
176bf215546Sopenharmony_ci      for (unsigned i = 0; i < PIPE_MAX_VERTEX_STREAMS; i++) {
177bf215546Sopenharmony_ci         sq->so[i].num_primitives_written =
178bf215546Sopenharmony_ci            softpipe->so_stats[i].num_primitives_written - sq->so[i].num_primitives_written;
179bf215546Sopenharmony_ci         sq->so[i].primitives_storage_needed =
180bf215546Sopenharmony_ci            softpipe->so_stats[i].primitives_storage_needed - sq->so[i].primitives_storage_needed;
181bf215546Sopenharmony_ci         sq->end |= sq->so[i].primitives_storage_needed > sq->so[i].num_primitives_written;
182bf215546Sopenharmony_ci      }
183bf215546Sopenharmony_ci      break;
184bf215546Sopenharmony_ci   case PIPE_QUERY_SO_STATISTICS:
185bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written =
186bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].num_primitives_written - sq->so[sq->index].num_primitives_written;
187bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed =
188bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].primitives_storage_needed - sq->so[sq->index].primitives_storage_needed;
189bf215546Sopenharmony_ci      break;
190bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_EMITTED:
191bf215546Sopenharmony_ci      sq->so[sq->index].num_primitives_written =
192bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].num_primitives_written - sq->so[sq->index].num_primitives_written;
193bf215546Sopenharmony_ci      break;
194bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_GENERATED:
195bf215546Sopenharmony_ci      sq->so[sq->index].primitives_storage_needed =
196bf215546Sopenharmony_ci         softpipe->so_stats[sq->index].primitives_storage_needed - sq->so[sq->index].primitives_storage_needed;
197bf215546Sopenharmony_ci      break;
198bf215546Sopenharmony_ci   case PIPE_QUERY_GPU_FINISHED:
199bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP_DISJOINT:
200bf215546Sopenharmony_ci      break;
201bf215546Sopenharmony_ci   case PIPE_QUERY_PIPELINE_STATISTICS:
202bf215546Sopenharmony_ci      sq->stats.ia_vertices =
203bf215546Sopenharmony_ci         softpipe->pipeline_statistics.ia_vertices - sq->stats.ia_vertices;
204bf215546Sopenharmony_ci      sq->stats.ia_primitives =
205bf215546Sopenharmony_ci         softpipe->pipeline_statistics.ia_primitives - sq->stats.ia_primitives;
206bf215546Sopenharmony_ci      sq->stats.vs_invocations =
207bf215546Sopenharmony_ci         softpipe->pipeline_statistics.vs_invocations - sq->stats.vs_invocations;
208bf215546Sopenharmony_ci      sq->stats.gs_invocations =
209bf215546Sopenharmony_ci         softpipe->pipeline_statistics.gs_invocations - sq->stats.gs_invocations;
210bf215546Sopenharmony_ci      sq->stats.gs_primitives =
211bf215546Sopenharmony_ci         softpipe->pipeline_statistics.gs_primitives - sq->stats.gs_primitives;
212bf215546Sopenharmony_ci      sq->stats.c_invocations =
213bf215546Sopenharmony_ci         softpipe->pipeline_statistics.c_invocations - sq->stats.c_invocations;
214bf215546Sopenharmony_ci      sq->stats.c_primitives =
215bf215546Sopenharmony_ci         softpipe->pipeline_statistics.c_primitives - sq->stats.c_primitives;
216bf215546Sopenharmony_ci      sq->stats.ps_invocations =
217bf215546Sopenharmony_ci         softpipe->pipeline_statistics.ps_invocations - sq->stats.ps_invocations;
218bf215546Sopenharmony_ci      sq->stats.cs_invocations =
219bf215546Sopenharmony_ci         softpipe->pipeline_statistics.cs_invocations - sq->stats.cs_invocations;
220bf215546Sopenharmony_ci
221bf215546Sopenharmony_ci      softpipe->active_statistics_queries--;
222bf215546Sopenharmony_ci      break;
223bf215546Sopenharmony_ci   default:
224bf215546Sopenharmony_ci      assert(0);
225bf215546Sopenharmony_ci      break;
226bf215546Sopenharmony_ci   }
227bf215546Sopenharmony_ci   softpipe->dirty |= SP_NEW_QUERY;
228bf215546Sopenharmony_ci   return true;
229bf215546Sopenharmony_ci}
230bf215546Sopenharmony_ci
231bf215546Sopenharmony_ci
232bf215546Sopenharmony_cistatic bool
233bf215546Sopenharmony_cisoftpipe_get_query_result(struct pipe_context *pipe,
234bf215546Sopenharmony_ci                          struct pipe_query *q,
235bf215546Sopenharmony_ci                          bool wait,
236bf215546Sopenharmony_ci                          union pipe_query_result *vresult)
237bf215546Sopenharmony_ci{
238bf215546Sopenharmony_ci   struct softpipe_query *sq = softpipe_query(q);
239bf215546Sopenharmony_ci   uint64_t *result = (uint64_t*)vresult;
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ci   switch (sq->type) {
242bf215546Sopenharmony_ci   case PIPE_QUERY_SO_STATISTICS: {
243bf215546Sopenharmony_ci      struct pipe_query_data_so_statistics *stats =
244bf215546Sopenharmony_ci         (struct pipe_query_data_so_statistics *)vresult;
245bf215546Sopenharmony_ci      stats->num_primitives_written = sq->so[sq->index].num_primitives_written;
246bf215546Sopenharmony_ci      stats->primitives_storage_needed = sq->so[sq->index].primitives_storage_needed;
247bf215546Sopenharmony_ci   }
248bf215546Sopenharmony_ci      break;
249bf215546Sopenharmony_ci   case PIPE_QUERY_PIPELINE_STATISTICS:
250bf215546Sopenharmony_ci      memcpy(vresult, &sq->stats,
251bf215546Sopenharmony_ci             sizeof(struct pipe_query_data_pipeline_statistics));
252bf215546Sopenharmony_ci      break;
253bf215546Sopenharmony_ci   case PIPE_QUERY_GPU_FINISHED:
254bf215546Sopenharmony_ci      vresult->b = true;
255bf215546Sopenharmony_ci      break;
256bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
257bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
258bf215546Sopenharmony_ci      vresult->b = sq->end != 0;
259bf215546Sopenharmony_ci      break;
260bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP_DISJOINT: {
261bf215546Sopenharmony_ci      struct pipe_query_data_timestamp_disjoint *td =
262bf215546Sopenharmony_ci          (struct pipe_query_data_timestamp_disjoint *)vresult;
263bf215546Sopenharmony_ci      /* os_get_time_nano return nanoseconds */
264bf215546Sopenharmony_ci      td->frequency = UINT64_C(1000000000);
265bf215546Sopenharmony_ci      td->disjoint = false;
266bf215546Sopenharmony_ci   }
267bf215546Sopenharmony_ci      break;
268bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_EMITTED:
269bf215546Sopenharmony_ci      *result = sq->so[sq->index].num_primitives_written;
270bf215546Sopenharmony_ci      break;
271bf215546Sopenharmony_ci   case PIPE_QUERY_PRIMITIVES_GENERATED:
272bf215546Sopenharmony_ci      *result = sq->so[sq->index].primitives_storage_needed;
273bf215546Sopenharmony_ci      break;
274bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE:
275bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
276bf215546Sopenharmony_ci      vresult->b = sq->end - sq->start != 0;
277bf215546Sopenharmony_ci      break;
278bf215546Sopenharmony_ci   default:
279bf215546Sopenharmony_ci      *result = sq->end - sq->start;
280bf215546Sopenharmony_ci      break;
281bf215546Sopenharmony_ci   }
282bf215546Sopenharmony_ci   return true;
283bf215546Sopenharmony_ci}
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_cistatic bool
286bf215546Sopenharmony_ciis_result_nonzero(struct pipe_query *q,
287bf215546Sopenharmony_ci                  union pipe_query_result *vresult)
288bf215546Sopenharmony_ci{
289bf215546Sopenharmony_ci   struct softpipe_query *sq = softpipe_query(q);
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ci   switch (sq->type) {
292bf215546Sopenharmony_ci   case PIPE_QUERY_TIMESTAMP_DISJOINT:
293bf215546Sopenharmony_ci   case PIPE_QUERY_SO_STATISTICS:
294bf215546Sopenharmony_ci   case PIPE_QUERY_PIPELINE_STATISTICS:
295bf215546Sopenharmony_ci      unreachable("unpossible");
296bf215546Sopenharmony_ci      break;
297bf215546Sopenharmony_ci   case PIPE_QUERY_GPU_FINISHED:
298bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE:
299bf215546Sopenharmony_ci   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
300bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
301bf215546Sopenharmony_ci   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
302bf215546Sopenharmony_ci      return vresult->b;
303bf215546Sopenharmony_ci   default:
304bf215546Sopenharmony_ci      return !!vresult->u64;
305bf215546Sopenharmony_ci   }
306bf215546Sopenharmony_ci   return false;
307bf215546Sopenharmony_ci}
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci/**
310bf215546Sopenharmony_ci * Called by rendering function to check rendering is conditional.
311bf215546Sopenharmony_ci * \return TRUE if we should render, FALSE if we should skip rendering
312bf215546Sopenharmony_ci */
313bf215546Sopenharmony_ciboolean
314bf215546Sopenharmony_cisoftpipe_check_render_cond(struct softpipe_context *sp)
315bf215546Sopenharmony_ci{
316bf215546Sopenharmony_ci   struct pipe_context *pipe = &sp->pipe;
317bf215546Sopenharmony_ci   boolean b, wait;
318bf215546Sopenharmony_ci   union pipe_query_result result;
319bf215546Sopenharmony_ci   memset(&result, 0, sizeof(union pipe_query_result));
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ci   if (!sp->render_cond_query) {
322bf215546Sopenharmony_ci      return TRUE;  /* no query predicate, draw normally */
323bf215546Sopenharmony_ci   }
324bf215546Sopenharmony_ci
325bf215546Sopenharmony_ci   wait = (sp->render_cond_mode == PIPE_RENDER_COND_WAIT ||
326bf215546Sopenharmony_ci           sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_ci   b = pipe->get_query_result(pipe, sp->render_cond_query, wait,
329bf215546Sopenharmony_ci                              &result);
330bf215546Sopenharmony_ci   if (b)
331bf215546Sopenharmony_ci      return !is_result_nonzero(sp->render_cond_query, &result) == sp->render_cond_cond;
332bf215546Sopenharmony_ci   else
333bf215546Sopenharmony_ci      return TRUE;
334bf215546Sopenharmony_ci}
335bf215546Sopenharmony_ci
336bf215546Sopenharmony_ci
337bf215546Sopenharmony_cistatic void
338bf215546Sopenharmony_cisoftpipe_set_active_query_state(struct pipe_context *pipe, bool enable)
339bf215546Sopenharmony_ci{
340bf215546Sopenharmony_ci}
341bf215546Sopenharmony_ci
342bf215546Sopenharmony_ci
343bf215546Sopenharmony_civoid softpipe_init_query_funcs(struct softpipe_context *softpipe )
344bf215546Sopenharmony_ci{
345bf215546Sopenharmony_ci   softpipe->pipe.create_query = softpipe_create_query;
346bf215546Sopenharmony_ci   softpipe->pipe.destroy_query = softpipe_destroy_query;
347bf215546Sopenharmony_ci   softpipe->pipe.begin_query = softpipe_begin_query;
348bf215546Sopenharmony_ci   softpipe->pipe.end_query = softpipe_end_query;
349bf215546Sopenharmony_ci   softpipe->pipe.get_query_result = softpipe_get_query_result;
350bf215546Sopenharmony_ci   softpipe->pipe.set_active_query_state = softpipe_set_active_query_state;
351bf215546Sopenharmony_ci}
352bf215546Sopenharmony_ci
353bf215546Sopenharmony_ci
354