X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fllvmpipe%2Flp_query.c;h=20c0a1e0bcb8f95f0bbd7be3eee8640ce99673ab;hb=1b749dc34f8d83cf3dfa863279b1fe2b356d34b2;hp=02eeaf64871d5344aab458785f201939654a6331;hpb=3ed0a099c70e9d771e60e0ddf70bc0b5ba83a483;p=mesa.git diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 02eeaf64871..20c0a1e0bcb 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -35,9 +35,8 @@ #include "util/u_memory.h" #include "lp_context.h" #include "lp_flush.h" +#include "lp_fence.h" #include "lp_query.h" -#include "lp_rast.h" -#include "lp_rast_priv.h" #include "lp_state.h" @@ -55,9 +54,6 @@ llvmpipe_create_query(struct pipe_context *pipe, assert(type == PIPE_QUERY_OCCLUSION_COUNTER); pq = CALLOC_STRUCT( llvmpipe_query ); - if (pq) { - pipe_mutex_init(pq->mutex); - } return (struct pipe_query *) pq; } @@ -67,17 +63,20 @@ static void llvmpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q) { struct llvmpipe_query *pq = llvmpipe_query(q); - /* query might still be in process if we never waited for the result */ - if (!pq->done) { - struct pipe_fence_handle *fence = NULL; - llvmpipe_flush(pipe, 0, &fence); - if (fence) { - pipe->screen->fence_finish(pipe->screen, fence, 0); - pipe->screen->fence_reference(pipe->screen, &fence, NULL); - } + + /* Ideally we would refcount queries & not get destroyed until the + * last scene had finished with us. + */ + if (pq->fence) { + if (!lp_fence_issued(pq->fence)) + llvmpipe_flush(pipe, NULL, __FUNCTION__); + + if (!lp_fence_signalled(pq->fence)) + lp_fence_wait(pq->fence); + + lp_fence_reference(&pq->fence, NULL); } - pipe_mutex_destroy(pq->mutex); FREE(pq); } @@ -86,31 +85,36 @@ 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) { + /* 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, NULL, __FUNCTION__); + + if (!wait) + return FALSE; - if (!pq->done) { - if (wait) { - struct pipe_fence_handle *fence = NULL; - llvmpipe_flush(pipe, 0, &fence); - if (fence) { - pipe->screen->fence_finish(pipe->screen, fence, 0); - pipe->screen->fence_reference(pipe->screen, &fence, NULL); - } - } - /* this is a bit inconsequent but should be ok */ - else { - llvmpipe_flush(pipe, 0, NULL); - } + lp_fence_wait(pq->fence); } - if (pq->done) { - *result = pq->result; + /* Sum the results from each of the threads: + */ + *result = 0; + for (i = 0; i < LP_MAX_THREADS; i++) { + *result += pq->count[i]; } - return pq->done; + return TRUE; } @@ -124,15 +128,12 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) * flush the scene now. Real apps shouldn't re-use a query in a * frame of rendering. */ - if (pq->binned) { - struct pipe_fence_handle *fence; - llvmpipe_flush(pipe, 0, &fence); - if (fence) { - pipe->screen->fence_finish(pipe->screen, fence, 0); - pipe->screen->fence_reference(pipe->screen, &fence, NULL); - } + 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++; @@ -153,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 ) {