anv: Properly fetch the results of unavailable occlusion queries
This patch series fixes fetching occlusion query results via vkCmdCopyQueryPoolResults
and vkGetQueryPoolResults
when the query is not yet available.
- For
vkGetQueryPoolResults
, the Vulkan spec states that the return value for an unavailable query with thePARTIAL_BIT
flag set should be an "intermediate result value between zero and the final result value". Currently, anv returnsslot.end - slot.begin
, but in the case of unavailable queries,slot.end
is still at the initial value of 0. Ifslot.begin
is non-zero, the occlusion count underflows to a value that is likely outside the acceptable range of the partial result. - For
vkCmdCopyQueryPoolResults
, there is no special handling of unavailable queries at all, so anv always writesslot.end - slot.begin
into the output buffer. According to the Vulkan spec, we should return an intermediate value if thePARTIAL_BIT
flag is set and if not, skip writing into the buffer altogether.
In this fix, I use MI_PREDIACTE
with MI_STORE_REGISTER_MEM
to store the results of a query predicated by its availability status. I'm not too familiar with Intel, but is there a cleaner way of conditionally executing a store that doesn't require Haswell+?