X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fllvmpipe%2Flp_query.c;h=20c0a1e0bcb8f95f0bbd7be3eee8640ce99673ab;hb=1b749dc34f8d83cf3dfa863279b1fe2b356d34b2;hp=76d0231fd1cabd9da5b63d2ebd5ea36a1bfcb5df;hpb=18452c1e87f79327fbd5f27478028b481ee72a5d;p=mesa.git diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 76d0231fd1c..20c0a1e0bcb 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -69,7 +69,7 @@ llvmpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q) */ if (pq->fence) { if (!lp_fence_issued(pq->fence)) - llvmpipe_flush(pipe, 0, NULL, __FUNCTION__); + llvmpipe_flush(pipe, NULL, __FUNCTION__); if (!lp_fence_signalled(pq->fence)) lp_fence_wait(pq->fence); @@ -85,20 +85,21 @@ static boolean llvmpipe_get_query_result(struct pipe_context *pipe, struct pipe_query *q, boolean wait, - void *vresult) + union pipe_query_result *vresult) { struct llvmpipe_query *pq = llvmpipe_query(q); uint64_t *result = (uint64_t *)vresult; int i; if (!pq->fence) { - assert(0); /* query not in issued state */ - return FALSE; + /* no fence because there was no scene, so results is zero */ + *result = 0; + return TRUE; } if (!lp_fence_signalled(pq->fence)) { if (!lp_fence_issued(pq->fence)) - llvmpipe_flush(pipe, 0, NULL, __FUNCTION__); + llvmpipe_flush(pipe, NULL, __FUNCTION__); if (!wait) return FALSE; @@ -123,6 +124,16 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); struct llvmpipe_query *pq = llvmpipe_query(q); + /* Check if the query is already in the scene. If so, we need to + * flush the scene now. Real apps shouldn't re-use a query in a + * frame of rendering. + */ + if (pq->fence && !lp_fence_issued(pq->fence)) { + llvmpipe_finish(pipe, __FUNCTION__); + } + + + memset(pq->count, 0, sizeof(pq->count)); lp_setup_begin_query(llvmpipe->setup, pq); llvmpipe->active_query_count++; @@ -143,6 +154,24 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) llvmpipe->dirty |= LP_NEW_QUERY; } +boolean +llvmpipe_check_render_cond(struct llvmpipe_context *lp) +{ + struct pipe_context *pipe = &lp->pipe; + boolean b, wait; + uint64_t result; + + if (!lp->render_cond_query) + return TRUE; /* no query predicate, draw normally */ + wait = (lp->render_cond_mode == PIPE_RENDER_COND_WAIT || + lp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT); + + b = pipe->get_query_result(pipe, lp->render_cond_query, wait, (void*)&result); + if (b) + return result > 0; + else + return TRUE; +} void llvmpipe_init_query_funcs(struct llvmpipe_context *llvmpipe ) {