From: Andrew Wesie Subject: Re: [PATCH] wined3d: Use query buffer objects for occlusion queries. Message-Id: Date: Thu, 6 Sep 2018 11:07:18 -0500 In-Reply-To: References: <1535933403-23092-1-git-send-email-awesie@gmail.com> On Thu, Sep 6, 2018 at 9:46 AM, Henri Verbeet wrote: > > While at least for occlusion queries this would be a very unlikely > result, it's not in general an invalid query result. I think ideally > we'd write QUERY_RESULT_AVAILABLE to the buffer object as well, but > based on the language in the extension spec, I don't see the > requirement that that should flush lifted. On the other hand, based on > a quick look at the Mesa source, it's not obvious to me that it > actually does flush. Perhaps this is ok in practice, and just an > oversight in the spec language. > > We could do something closer to "Example 2" in ARB_query_buffer_object spec. At a high level: - after glEndQuery, query on both GL_QUERY_RESULT_AVAILABLE and GL_QUERY_RESULT_NO_WAIT - in wined3d_query_buffer_poll, if available flag in the query buffer is set, return the result - else: emit WINED3D_CS_OP_QUERY_RESULT to cs thread, return result not available - in wined3d_cs_exec_query_result, query on both GL_QUERY_RESULT_AVAILABLE and GL_QUERY_RESULT_NO_WAIT This avoids the default value problem and also avoids the main thread directly blocking on the cs thread and a GPU flush. It may result in a lot more work on the CPU side, though, compared to the current implementation. I will not be near my testing machine for a while, so I can't easily benchmark and compare the performance.
On Thu, Sep 6, 2018 at 9:46 AM, Henri Verbeet <hverbeet@gmail.com> wrote:
While at least for occlusion queries this would be a very unlikely
result, it's not in general an invalid query result. I think ideally
we'd write QUERY_RESULT_AVAILABLE to the buffer object as well, but
based on the language in the extension spec, I don't see the
requirement that that should flush lifted. On the other hand, based on
a quick look at the Mesa source, it's not obvious to me that it
actually does flush. Perhaps this is ok in practice, and just an
oversight in the spec language.


We could do something closer to "Example 2" in ARB_query_buffer_object spec.  At a high level:
 - after glEndQuery, query on both GL_QUERY_RESULT_AVAILABLE and GL_QUERY_RESULT_NO_WAIT
 - in wined3d_query_buffer_poll, if available flag in the query buffer is set, return the result
 - else: emit WINED3D_CS_OP_QUERY_RESULT to cs thread, return result not available
 - in wined3d_cs_exec_query_result, query on both GL_QUERY_RESULT_AVAILABLE and GL_QUERY_RESULT_NO_WAIT

This avoids the default value problem and also avoids the main thread directly blocking on the cs thread and a GPU flush. It may result in a lot more work on the CPU side, though, compared to the current implementation.

I will not be near my testing machine for a while, so I can't easily benchmark and compare the performance.