diff --git a/src/gallium/state_trackers/nine/query9.c b/src/gallium/state_trackers/nine/query9.c index 466b4ba..a8ec4ec 100644 --- a/src/gallium/state_trackers/nine/query9.c +++ b/src/gallium/state_trackers/nine/query9.c @@ -183,7 +183,12 @@ NineQuery9_Issue( struct NineQuery9 *This, This->type != D3DQUERYTYPE_EVENT && This->type != D3DQUERYTYPE_TIMESTAMP) pipe->begin_query(pipe, This->pq); - pipe->end_query(pipe, This->pq); + if (This->type != D3DQUERYTYPE_EVENT) + pipe->end_query(pipe, This->pq); + if (This->type == D3DQUERYTYPE_EVENT && This->fence) + This->base.device->screen->fence_reference(This->base.device->screen, &This->fence, NULL); + if (This->type == D3DQUERYTYPE_EVENT) + pipe->flush(pipe, &This->fence, NULL); This->state = NINE_QUERY_STATE_ENDED; } return D3D_OK; @@ -204,6 +209,7 @@ NineQuery9_GetData( struct NineQuery9 *This, DWORD dwGetDataFlags ) { struct pipe_context *pipe = This->base.device->pipe; + struct pipe_screen *screen = This->base.device->screen; boolean ok, wait_query_result = FALSE; union pipe_query_result presult; union nine_query_result nresult; @@ -230,11 +236,20 @@ NineQuery9_GetData( struct NineQuery9 *This, /* Wine tests: D3DQUERYTYPE_TIMESTAMP always succeeds */ wait_query_result |= This->type == D3DQUERYTYPE_TIMESTAMP; + if (This->type == D3DQUERYTYPE_EVENT) { + if (wait_query_result) { + ok = TRUE; + screen->fence_finish(screen, This->fence, PIPE_TIMEOUT_INFINITE); + } else { + ok = screen->fence_signalled(screen, This->fence); + } + } else { + /* Note: We ignore dwGetDataFlags, because get_query_result will * flush automatically if needed */ ok = pipe->get_query_result(pipe, This->pq, wait_query_result, &presult); - + } if (!ok) return S_FALSE; if (!dwSize) diff --git a/src/gallium/state_trackers/nine/query9.h b/src/gallium/state_trackers/nine/query9.h index ad1ca50..83fd4c6 100644 --- a/src/gallium/state_trackers/nine/query9.h +++ b/src/gallium/state_trackers/nine/query9.h @@ -39,6 +39,7 @@ struct NineQuery9 DWORD result_size; D3DQUERYTYPE type; enum nine_query_state state; + struct pipe_fence_handle *fence; boolean instant; /* true if D3DISSUE_BEGIN is not needed / invalid */ }; static INLINE struct NineQuery9 *