0335189297817344cf768cc293d41667e017cbe8
[mesa.git] / src / gallium / drivers / r600 / r600_query.c
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include "r600_pipe.h"
24 #include "r600d.h"
25 #include "util/u_memory.h"
26
27 static bool r600_is_timer_query(unsigned type)
28 {
29 return type == PIPE_QUERY_TIME_ELAPSED ||
30 type == PIPE_QUERY_TIMESTAMP ||
31 type == PIPE_QUERY_TIMESTAMP_DISJOINT;
32 }
33
34 static bool r600_query_needs_begin(unsigned type)
35 {
36 return type != PIPE_QUERY_GPU_FINISHED &&
37 type != PIPE_QUERY_TIMESTAMP;
38 }
39
40 static struct r600_resource *r600_new_query_buffer(struct r600_context *ctx, unsigned type)
41 {
42 unsigned j, i, num_results, buf_size = 4096;
43 uint32_t *results;
44 /* Queries are normally read by the CPU after
45 * being written by the gpu, hence staging is probably a good
46 * usage pattern.
47 */
48 struct r600_resource *buf = (struct r600_resource*)
49 pipe_buffer_create(&ctx->screen->screen, PIPE_BIND_CUSTOM,
50 PIPE_USAGE_STAGING, buf_size);
51
52 switch (type) {
53 case PIPE_QUERY_OCCLUSION_COUNTER:
54 case PIPE_QUERY_OCCLUSION_PREDICATE:
55 results = r600_buffer_mmap_sync_with_rings(ctx, buf, PIPE_TRANSFER_WRITE);
56 memset(results, 0, buf_size);
57
58 /* Set top bits for unused backends. */
59 num_results = buf_size / (16 * ctx->max_db);
60 for (j = 0; j < num_results; j++) {
61 for (i = 0; i < ctx->max_db; i++) {
62 if (!(ctx->backend_mask & (1<<i))) {
63 results[(i * 4)+1] = 0x80000000;
64 results[(i * 4)+3] = 0x80000000;
65 }
66 }
67 results += 4 * ctx->max_db;
68 }
69 ctx->ws->buffer_unmap(buf->cs_buf);
70 break;
71 case PIPE_QUERY_TIME_ELAPSED:
72 case PIPE_QUERY_TIMESTAMP:
73 break;
74 case PIPE_QUERY_PRIMITIVES_EMITTED:
75 case PIPE_QUERY_PRIMITIVES_GENERATED:
76 case PIPE_QUERY_SO_STATISTICS:
77 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
78 results = r600_buffer_mmap_sync_with_rings(ctx, buf, PIPE_TRANSFER_WRITE);
79 memset(results, 0, buf_size);
80 ctx->ws->buffer_unmap(buf->cs_buf);
81 break;
82 default:
83 assert(0);
84 }
85 return buf;
86 }
87
88 static void r600_update_occlusion_query_state(struct r600_context *rctx,
89 unsigned type, int diff)
90 {
91 if (type == PIPE_QUERY_OCCLUSION_COUNTER ||
92 type == PIPE_QUERY_OCCLUSION_PREDICATE) {
93 bool enable;
94
95 rctx->num_occlusion_queries += diff;
96 assert(rctx->num_occlusion_queries >= 0);
97
98 enable = rctx->num_occlusion_queries != 0;
99
100 if (rctx->db_misc_state.occlusion_query_enabled != enable) {
101 rctx->db_misc_state.occlusion_query_enabled = enable;
102 rctx->db_misc_state.atom.dirty = true;
103 }
104 }
105 }
106
107 static void r600_emit_query_begin(struct r600_context *ctx, struct r600_query *query)
108 {
109 struct radeon_winsys_cs *cs = ctx->rings.gfx.cs;
110 uint64_t va;
111
112 r600_update_occlusion_query_state(ctx, query->type, 1);
113 r600_need_cs_space(ctx, query->num_cs_dw * 2, TRUE);
114
115 /* Get a new query buffer if needed. */
116 if (query->buffer.results_end + query->result_size > query->buffer.buf->b.b.width0) {
117 struct r600_query_buffer *qbuf = MALLOC_STRUCT(r600_query_buffer);
118 *qbuf = query->buffer;
119 query->buffer.buf = r600_new_query_buffer(ctx, query->type);
120 query->buffer.results_end = 0;
121 query->buffer.previous = qbuf;
122 }
123
124 /* emit begin query */
125 va = r600_resource_va(&ctx->screen->screen, (void*)query->buffer.buf);
126 va += query->buffer.results_end;
127
128 switch (query->type) {
129 case PIPE_QUERY_OCCLUSION_COUNTER:
130 case PIPE_QUERY_OCCLUSION_PREDICATE:
131 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
132 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | EVENT_INDEX(1);
133 cs->buf[cs->cdw++] = va;
134 cs->buf[cs->cdw++] = (va >> 32UL) & 0xFF;
135 break;
136 case PIPE_QUERY_PRIMITIVES_EMITTED:
137 case PIPE_QUERY_PRIMITIVES_GENERATED:
138 case PIPE_QUERY_SO_STATISTICS:
139 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
140 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
141 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_SAMPLE_STREAMOUTSTATS) | EVENT_INDEX(3);
142 cs->buf[cs->cdw++] = va;
143 cs->buf[cs->cdw++] = (va >> 32UL) & 0xFF;
144 break;
145 case PIPE_QUERY_TIME_ELAPSED:
146 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE_EOP, 4, 0);
147 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5);
148 cs->buf[cs->cdw++] = va;
149 cs->buf[cs->cdw++] = (3 << 29) | ((va >> 32UL) & 0xFF);
150 cs->buf[cs->cdw++] = 0;
151 cs->buf[cs->cdw++] = 0;
152 break;
153 default:
154 assert(0);
155 }
156 cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0);
157 cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, &ctx->rings.gfx, query->buffer.buf, RADEON_USAGE_WRITE);
158
159 if (!r600_is_timer_query(query->type)) {
160 ctx->num_cs_dw_nontimer_queries_suspend += query->num_cs_dw;
161 }
162 }
163
164 static void r600_emit_query_end(struct r600_context *ctx, struct r600_query *query)
165 {
166 struct radeon_winsys_cs *cs = ctx->rings.gfx.cs;
167 uint64_t va;
168
169 /* The queries which need begin already called this in begin_query. */
170 if (!r600_query_needs_begin(query->type)) {
171 r600_need_cs_space(ctx, query->num_cs_dw, FALSE);
172 }
173
174 va = r600_resource_va(&ctx->screen->screen, (void*)query->buffer.buf);
175 /* emit end query */
176 switch (query->type) {
177 case PIPE_QUERY_OCCLUSION_COUNTER:
178 case PIPE_QUERY_OCCLUSION_PREDICATE:
179 va += query->buffer.results_end + 8;
180 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
181 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | EVENT_INDEX(1);
182 cs->buf[cs->cdw++] = va;
183 cs->buf[cs->cdw++] = (va >> 32UL) & 0xFF;
184 break;
185 case PIPE_QUERY_PRIMITIVES_EMITTED:
186 case PIPE_QUERY_PRIMITIVES_GENERATED:
187 case PIPE_QUERY_SO_STATISTICS:
188 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
189 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
190 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_SAMPLE_STREAMOUTSTATS) | EVENT_INDEX(3);
191 cs->buf[cs->cdw++] = query->buffer.results_end + query->result_size/2;
192 cs->buf[cs->cdw++] = 0;
193 break;
194 case PIPE_QUERY_TIME_ELAPSED:
195 va += query->buffer.results_end + query->result_size/2;
196 /* fall through */
197 case PIPE_QUERY_TIMESTAMP:
198 cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE_EOP, 4, 0);
199 cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5);
200 cs->buf[cs->cdw++] = va;
201 cs->buf[cs->cdw++] = (3 << 29) | ((va >> 32UL) & 0xFF);
202 cs->buf[cs->cdw++] = 0;
203 cs->buf[cs->cdw++] = 0;
204 break;
205 default:
206 assert(0);
207 }
208 cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0);
209 cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, &ctx->rings.gfx, query->buffer.buf, RADEON_USAGE_WRITE);
210
211 query->buffer.results_end += query->result_size;
212
213 if (r600_query_needs_begin(query->type)) {
214 if (!r600_is_timer_query(query->type)) {
215 ctx->num_cs_dw_nontimer_queries_suspend -= query->num_cs_dw;
216 }
217 }
218
219 r600_update_occlusion_query_state(ctx, query->type, -1);
220 }
221
222 static void r600_emit_query_predication(struct r600_context *ctx, struct r600_query *query,
223 int operation, bool flag_wait)
224 {
225 struct radeon_winsys_cs *cs = ctx->rings.gfx.cs;
226
227 if (operation == PREDICATION_OP_CLEAR) {
228 r600_need_cs_space(ctx, 3, FALSE);
229
230 cs->buf[cs->cdw++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
231 cs->buf[cs->cdw++] = 0;
232 cs->buf[cs->cdw++] = PRED_OP(PREDICATION_OP_CLEAR);
233 } else {
234 struct r600_query_buffer *qbuf;
235 unsigned count;
236 uint32_t op;
237
238 /* Find how many results there are. */
239 count = 0;
240 for (qbuf = &query->buffer; qbuf; qbuf = qbuf->previous) {
241 count += qbuf->results_end / query->result_size;
242 }
243
244 r600_need_cs_space(ctx, 5 * count, TRUE);
245
246 op = PRED_OP(operation) | PREDICATION_DRAW_VISIBLE |
247 (flag_wait ? PREDICATION_HINT_WAIT : PREDICATION_HINT_NOWAIT_DRAW);
248
249 /* emit predicate packets for all data blocks */
250 for (qbuf = &query->buffer; qbuf; qbuf = qbuf->previous) {
251 unsigned results_base = 0;
252 uint64_t va = r600_resource_va(&ctx->screen->screen, &qbuf->buf->b.b);
253
254 while (results_base < qbuf->results_end) {
255 cs->buf[cs->cdw++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
256 cs->buf[cs->cdw++] = (va + results_base) & 0xFFFFFFFFUL;
257 cs->buf[cs->cdw++] = op | (((va + results_base) >> 32UL) & 0xFF);
258 cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0);
259 cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, &ctx->rings.gfx, qbuf->buf, RADEON_USAGE_READ);
260 results_base += query->result_size;
261
262 /* set CONTINUE bit for all packets except the first */
263 op |= PREDICATION_CONTINUE;
264 }
265 } while (qbuf);
266 }
267 }
268
269 static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned query_type)
270 {
271 struct r600_context *rctx = (struct r600_context *)ctx;
272
273 struct r600_query *query;
274
275 query = CALLOC_STRUCT(r600_query);
276 if (query == NULL)
277 return NULL;
278
279 query->type = query_type;
280
281 switch (query_type) {
282 case PIPE_QUERY_OCCLUSION_COUNTER:
283 case PIPE_QUERY_OCCLUSION_PREDICATE:
284 query->result_size = 16 * rctx->max_db;
285 query->num_cs_dw = 6;
286 break;
287 case PIPE_QUERY_TIME_ELAPSED:
288 query->result_size = 16;
289 query->num_cs_dw = 8;
290 break;
291 case PIPE_QUERY_TIMESTAMP:
292 query->result_size = 8;
293 query->num_cs_dw = 8;
294 break;
295 case PIPE_QUERY_PRIMITIVES_EMITTED:
296 case PIPE_QUERY_PRIMITIVES_GENERATED:
297 case PIPE_QUERY_SO_STATISTICS:
298 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
299 /* NumPrimitivesWritten, PrimitiveStorageNeeded. */
300 query->result_size = 32;
301 query->num_cs_dw = 6;
302 break;
303 default:
304 assert(0);
305 FREE(query);
306 return NULL;
307 }
308
309 query->buffer.buf = r600_new_query_buffer(rctx, query_type);
310 if (!query->buffer.buf) {
311 FREE(query);
312 return NULL;
313 }
314 return (struct pipe_query*)query;
315 }
316
317 static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
318 {
319 struct r600_query *rquery = (struct r600_query*)query;
320 struct r600_query_buffer *prev = rquery->buffer.previous;
321
322 /* Release all query buffers. */
323 while (prev) {
324 struct r600_query_buffer *qbuf = prev;
325 prev = prev->previous;
326 pipe_resource_reference((struct pipe_resource**)&qbuf->buf, NULL);
327 FREE(qbuf);
328 }
329
330 pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL);
331 FREE(query);
332 }
333
334 static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
335 {
336 struct r600_context *rctx = (struct r600_context *)ctx;
337 struct r600_query *rquery = (struct r600_query *)query;
338 struct r600_query_buffer *prev = rquery->buffer.previous;
339
340 if (!r600_query_needs_begin(rquery->type)) {
341 assert(0);
342 return;
343 }
344
345 /* Discard the old query buffers. */
346 while (prev) {
347 struct r600_query_buffer *qbuf = prev;
348 prev = prev->previous;
349 pipe_resource_reference((struct pipe_resource**)&qbuf->buf, NULL);
350 FREE(qbuf);
351 }
352
353 /* Obtain a new buffer if the current one can't be mapped without a stall. */
354 if (r600_rings_is_buffer_referenced(rctx, rquery->buffer.buf->cs_buf, RADEON_USAGE_READWRITE) ||
355 rctx->ws->buffer_is_busy(rquery->buffer.buf->buf, RADEON_USAGE_READWRITE)) {
356 pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL);
357 rquery->buffer.buf = r600_new_query_buffer(rctx, rquery->type);
358 }
359
360 rquery->buffer.results_end = 0;
361 rquery->buffer.previous = NULL;
362
363 r600_emit_query_begin(rctx, rquery);
364
365 if (!r600_is_timer_query(rquery->type)) {
366 LIST_ADDTAIL(&rquery->list, &rctx->active_nontimer_queries);
367 }
368 }
369
370 static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
371 {
372 struct r600_context *rctx = (struct r600_context *)ctx;
373 struct r600_query *rquery = (struct r600_query *)query;
374
375 r600_emit_query_end(rctx, rquery);
376
377 if (r600_query_needs_begin(rquery->type) && !r600_is_timer_query(rquery->type)) {
378 LIST_DELINIT(&rquery->list);
379 }
380 }
381
382 static unsigned r600_query_read_result(char *map, unsigned start_index, unsigned end_index,
383 bool test_status_bit)
384 {
385 uint32_t *current_result = (uint32_t*)map;
386 uint64_t start, end;
387
388 start = (uint64_t)current_result[start_index] |
389 (uint64_t)current_result[start_index+1] << 32;
390 end = (uint64_t)current_result[end_index] |
391 (uint64_t)current_result[end_index+1] << 32;
392
393 if (!test_status_bit ||
394 ((start & 0x8000000000000000UL) && (end & 0x8000000000000000UL))) {
395 return end - start;
396 }
397 return 0;
398 }
399
400 static boolean r600_get_query_buffer_result(struct r600_context *ctx,
401 struct r600_query *query,
402 struct r600_query_buffer *qbuf,
403 boolean wait,
404 union pipe_query_result *result)
405 {
406 unsigned results_base = 0;
407 char *map;
408
409 map = r600_buffer_mmap_sync_with_rings(ctx, qbuf->buf,
410 PIPE_TRANSFER_READ |
411 (wait ? 0 : PIPE_TRANSFER_DONTBLOCK));
412 if (!map)
413 return FALSE;
414
415 /* count all results across all data blocks */
416 switch (query->type) {
417 case PIPE_QUERY_OCCLUSION_COUNTER:
418 while (results_base != qbuf->results_end) {
419 result->u64 +=
420 r600_query_read_result(map + results_base, 0, 2, true);
421 results_base += 16;
422 }
423 break;
424 case PIPE_QUERY_OCCLUSION_PREDICATE:
425 while (results_base != qbuf->results_end) {
426 result->b = result->b ||
427 r600_query_read_result(map + results_base, 0, 2, true) != 0;
428 results_base += 16;
429 }
430 break;
431 case PIPE_QUERY_TIME_ELAPSED:
432 while (results_base != qbuf->results_end) {
433 result->u64 +=
434 r600_query_read_result(map + results_base, 0, 2, false);
435 results_base += query->result_size;
436 }
437 break;
438 case PIPE_QUERY_TIMESTAMP:
439 {
440 uint32_t *current_result = (uint32_t*)map;
441 result->u64 = (uint64_t)current_result[0] |
442 (uint64_t)current_result[1] << 32;
443 break;
444 }
445 case PIPE_QUERY_PRIMITIVES_EMITTED:
446 /* SAMPLE_STREAMOUTSTATS stores this structure:
447 * {
448 * u64 NumPrimitivesWritten;
449 * u64 PrimitiveStorageNeeded;
450 * }
451 * We only need NumPrimitivesWritten here. */
452 while (results_base != qbuf->results_end) {
453 result->u64 +=
454 r600_query_read_result(map + results_base, 2, 6, true);
455 results_base += query->result_size;
456 }
457 break;
458 case PIPE_QUERY_PRIMITIVES_GENERATED:
459 /* Here we read PrimitiveStorageNeeded. */
460 while (results_base != qbuf->results_end) {
461 result->u64 +=
462 r600_query_read_result(map + results_base, 0, 4, true);
463 results_base += query->result_size;
464 }
465 break;
466 case PIPE_QUERY_SO_STATISTICS:
467 while (results_base != qbuf->results_end) {
468 result->so_statistics.num_primitives_written +=
469 r600_query_read_result(map + results_base, 2, 6, true);
470 result->so_statistics.primitives_storage_needed +=
471 r600_query_read_result(map + results_base, 0, 4, true);
472 results_base += query->result_size;
473 }
474 break;
475 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
476 while (results_base != qbuf->results_end) {
477 result->b = result->b ||
478 r600_query_read_result(map + results_base, 2, 6, true) !=
479 r600_query_read_result(map + results_base, 0, 4, true);
480 results_base += query->result_size;
481 }
482 break;
483 default:
484 assert(0);
485 }
486
487 ctx->ws->buffer_unmap(qbuf->buf->cs_buf);
488 return TRUE;
489 }
490
491 static boolean r600_get_query_result(struct pipe_context *ctx,
492 struct pipe_query *query,
493 boolean wait, union pipe_query_result *result)
494 {
495 struct r600_context *rctx = (struct r600_context *)ctx;
496 struct r600_query *rquery = (struct r600_query *)query;
497 struct r600_query_buffer *qbuf;
498
499 util_query_clear_result(result, rquery->type);
500
501 for (qbuf = &rquery->buffer; qbuf; qbuf = qbuf->previous) {
502 if (!r600_get_query_buffer_result(rctx, rquery, qbuf, wait, result)) {
503 return FALSE;
504 }
505 }
506
507 /* Convert the time to expected units. */
508 if (rquery->type == PIPE_QUERY_TIME_ELAPSED ||
509 rquery->type == PIPE_QUERY_TIMESTAMP) {
510 result->u64 = (1000000 * result->u64) / rctx->screen->info.r600_clock_crystal_freq;
511 }
512 return TRUE;
513 }
514
515 static void r600_render_condition(struct pipe_context *ctx,
516 struct pipe_query *query,
517 uint mode)
518 {
519 struct r600_context *rctx = (struct r600_context *)ctx;
520 struct r600_query *rquery = (struct r600_query *)query;
521 bool wait_flag = false;
522
523 rctx->current_render_cond = query;
524 rctx->current_render_cond_mode = mode;
525
526 if (query == NULL) {
527 if (rctx->predicate_drawing) {
528 rctx->predicate_drawing = false;
529 r600_emit_query_predication(rctx, NULL, PREDICATION_OP_CLEAR, false);
530 }
531 return;
532 }
533
534 if (mode == PIPE_RENDER_COND_WAIT ||
535 mode == PIPE_RENDER_COND_BY_REGION_WAIT) {
536 wait_flag = true;
537 }
538
539 rctx->predicate_drawing = true;
540
541 switch (rquery->type) {
542 case PIPE_QUERY_OCCLUSION_COUNTER:
543 case PIPE_QUERY_OCCLUSION_PREDICATE:
544 r600_emit_query_predication(rctx, rquery, PREDICATION_OP_ZPASS, wait_flag);
545 break;
546 case PIPE_QUERY_PRIMITIVES_EMITTED:
547 case PIPE_QUERY_PRIMITIVES_GENERATED:
548 case PIPE_QUERY_SO_STATISTICS:
549 case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
550 r600_emit_query_predication(rctx, rquery, PREDICATION_OP_PRIMCOUNT, wait_flag);
551 break;
552 default:
553 assert(0);
554 }
555 }
556
557 void r600_suspend_nontimer_queries(struct r600_context *ctx)
558 {
559 struct r600_query *query;
560
561 LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_queries, list) {
562 r600_emit_query_end(ctx, query);
563 }
564 assert(ctx->num_cs_dw_nontimer_queries_suspend == 0);
565 }
566
567 void r600_resume_nontimer_queries(struct r600_context *ctx)
568 {
569 struct r600_query *query;
570
571 assert(ctx->num_cs_dw_nontimer_queries_suspend == 0);
572
573 LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_queries, list) {
574 r600_emit_query_begin(ctx, query);
575 }
576 }
577
578 void r600_init_query_functions(struct r600_context *rctx)
579 {
580 rctx->context.create_query = r600_create_query;
581 rctx->context.destroy_query = r600_destroy_query;
582 rctx->context.begin_query = r600_begin_query;
583 rctx->context.end_query = r600_end_query;
584 rctx->context.get_query_result = r600_get_query_result;
585
586 if (rctx->screen->info.r600_num_backends > 0)
587 rctx->context.render_condition = r600_render_condition;
588 }