static void r300_destroy_query(struct pipe_context* pipe, struct pipe_query* query) { struct r300_query* q = r300_query(query); pb_reference(&q->buf, NULL); FREE(query); }
static boolean r300_get_query_result(struct pipe_context* pipe, struct pipe_query* query, boolean wait, union pipe_query_result *vresult) { struct r300_context* r300 = r300_context(pipe); struct r300_query *q = r300_query(query); unsigned i; uint32_t temp, *map; if (q->type == PIPE_QUERY_GPU_FINISHED) { if (wait) { r300->rws->buffer_wait(q->buf, RADEON_USAGE_READWRITE); vresult->b = TRUE; } else { vresult->b = !r300->rws->buffer_is_busy(q->buf, RADEON_USAGE_READWRITE); } return vresult->b; } map = r300->rws->buffer_map(q->cs_buf, r300->cs, PIPE_TRANSFER_READ | (!wait ? PIPE_TRANSFER_DONTBLOCK : 0)); if (!map) return FALSE; /* Sum up the results. */ temp = 0; for (i = 0; i < q->num_results; i++) { /* Convert little endian values written by GPU to CPU byte order */ temp += util_le32_to_cpu(*map); map++; } r300->rws->buffer_unmap(q->cs_buf); if (q->type == PIPE_QUERY_OCCLUSION_PREDICATE) { vresult->b = temp != 0; } else { vresult->u64 = temp; } return TRUE; }
static void r300_begin_query(struct pipe_context* pipe, struct pipe_query* query) { struct r300_context* r300 = r300_context(pipe); struct r300_query* q = r300_query(query); if (q->type == PIPE_QUERY_GPU_FINISHED) return; if (r300->query_current != NULL) { fprintf(stderr, "r300: begin_query: " "Some other query has already been started.\n"); assert(0); return; } q->num_results = 0; r300_resume_query(r300, q); }
static void r300_end_query(struct pipe_context* pipe, struct pipe_query* query) { struct r300_context* r300 = r300_context(pipe); struct r300_query *q = r300_query(query); if (q->type == PIPE_QUERY_GPU_FINISHED) { pb_reference(&q->buf, NULL); r300_flush(pipe, RADEON_FLUSH_ASYNC, (struct pipe_fence_handle**)&q->buf); return; } if (q != r300->query_current) { fprintf(stderr, "r300: end_query: Got invalid query.\n"); assert(0); return; } r300_stop_query(r300); }
static void r300_render_condition(struct pipe_context *pipe, struct pipe_query *query, uint mode) { struct r300_context *r300 = r300_context(pipe); union pipe_query_result result; boolean wait; r300->skip_rendering = FALSE; if (query) { wait = mode == PIPE_RENDER_COND_WAIT || mode == PIPE_RENDER_COND_BY_REGION_WAIT; if (r300_get_query_result(pipe, query, wait, &result)) { if (r300_query(query)->type == PIPE_QUERY_OCCLUSION_PREDICATE) { r300->skip_rendering = !result.b; } else { r300->skip_rendering = !result.u64; } } } }