GPUOpen-Archive / Anvil

Anvil is a cross-platform framework for Vulkan
MIT License
594 stars 62 forks source link

QueryPool::get_query_pool_results calculates query size incorrectly #148

Open Silverlan opened 5 years ago

Silverlan commented 5 years ago

The query size is calculated in _QueryPool::get_query_pool_resultsinternal like so:

if (in_should_return_uint64)
{
    flags             |= VK_QUERY_RESULT_64_BIT;
    result_query_size  = sizeof(uint64_t);
}
else
{
    result_query_size = sizeof(uint32_t);
}

While this is fine for occlusion and timestamp queries, this is incorrect for pipeline statistics queries if more than one statistics-flag was set for the query pool. According to the specification, the size of the data for a statistics query is calculated like this:

Pipeline statistics queries write one integer value for each bit that is enabled in the pipelineStatistics when the pool is created, and the statistics values are written in bit order starting from the least significant bit.

(+ one integer for the availability if the flag was set.)

I've created a pull request for a fix here: #149