From 99d8fe20abe1fe55ea357bfc6f8d9a7af946cfc5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Aug 2016 10:15:46 -0600 Subject: [PATCH] svga: fix vgpu10 query fencing We don't want to flush the command buffer or sync on the fence when ending a query (that kind of defeats the whole purpose of async queries). Do that instead in get_query_result(). Tested with Piglit, arbocclude, Sauerbraten game, Nobel Clinician Viewer, ETQW. Reviewed-by: Charmaine Lee --- src/gallium/drivers/svga/svga_pipe_query.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 33822e6e5ca..f09590aa0ee 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -610,7 +610,6 @@ begin_query_vgpu10(struct svga_context *svga, struct svga_query *sq) static enum pipe_error end_query_vgpu10(struct svga_context *svga, struct svga_query *sq) { - struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws; enum pipe_error ret = PIPE_OK; if (svga->rebind.flags.query) { @@ -623,15 +622,6 @@ end_query_vgpu10(struct svga_context *svga, struct svga_query *sq) ret = SVGA3D_vgpu10_EndQuery(svga->swc, sq->id); } - /* Finish fence is copied here from get_query_result_vgpu10. This helps - * with cases where svga_begin_query might be called again before - * svga_get_query_result, such as GL_TIME_ELAPSED. - */ - if (!sq->fence) { - svga_context_flush(svga, &sq->fence); - } - sws->fence_finish(sws, sq->fence, SVGA_FENCE_FLAG_QUERY); - return ret; } @@ -648,7 +638,17 @@ get_query_result_vgpu10(struct svga_context *svga, struct svga_query *sq, sws->query_get_result(sws, sq->gb_query, sq->offset, &queryState, result, resultLen); - if (queryState == SVGA3D_QUERYSTATE_PENDING) { + if (queryState == SVGA3D_QUERYSTATE_NEW && !sq->fence) { + /* The query hasn't been submitted yet. We need to submit it now + * since the GL spec says "Querying the state for a given occlusion + * query forces that occlusion query to complete within a finite amount + * of time." + */ + svga_context_flush(svga, &sq->fence); + } + + if (queryState == SVGA3D_QUERYSTATE_PENDING || + queryState == SVGA3D_QUERYSTATE_NEW) { if (!wait) return FALSE; sws->fence_finish(sws, sq->fence, SVGA_FENCE_FLAG_QUERY); -- 2.30.2