mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
libs/vkd3d: Avoid vkCmdCopyQueryPoolResults() for not issued queries.
The Vulkan spec states:
* "If the query does not become available in a finite amount of time
(e.g. due to not issuing a query since the last reset), a
VK_ERROR_DEVICE_LOST error may occur."
* "If queries will never finish (e.g. due to being reset but not
issued), then vkGetQueryPoolResults may not return in finite time."
This commit is contained in:
@@ -3305,6 +3305,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_EndQuery(ID3D12GraphicsCommandL
|
||||
|
||||
TRACE("iface %p, heap %p, type %#x, index %u.\n", iface, heap, type, index);
|
||||
|
||||
d3d12_query_heap_mark_result_as_available(query_heap, index);
|
||||
|
||||
if (type == D3D12_QUERY_TYPE_TIMESTAMP)
|
||||
{
|
||||
VK_CALL(vkCmdResetQueryPool(list->vk_command_buffer, query_heap->vk_query_pool, index, 1));
|
||||
@@ -3320,11 +3322,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12Graphics
|
||||
ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count,
|
||||
ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset)
|
||||
{
|
||||
const struct d3d12_query_heap *query_heap = unsafe_impl_from_ID3D12QueryHeap(heap);
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
struct d3d12_query_heap *query_heap = unsafe_impl_from_ID3D12QueryHeap(heap);
|
||||
struct d3d12_resource *buffer = unsafe_impl_from_ID3D12Resource(dst_buffer);
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
VkDeviceSize stride = sizeof(uint64_t);
|
||||
unsigned int i;
|
||||
|
||||
TRACE("iface %p, heap %p, type %#x, start_index %u, query_count %u, "
|
||||
"dst_buffer %p, aligned_dst_buffer_offset %#"PRIx64".\n",
|
||||
@@ -3350,9 +3353,28 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12Graphics
|
||||
if (type == D3D12_QUERY_TYPE_PIPELINE_STATISTICS)
|
||||
stride = sizeof(struct D3D12_QUERY_DATA_PIPELINE_STATISTICS);
|
||||
|
||||
VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer, query_heap->vk_query_pool,
|
||||
start_index, query_count, buffer->u.vk_buffer, aligned_dst_buffer_offset,
|
||||
stride, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
|
||||
/* We cannot copy query results if a query was not issued:
|
||||
*
|
||||
* "If the query does not become available in a finite amount of time
|
||||
* (e.g. due to not issuing a query since the last reset),
|
||||
* a VK_ERROR_DEVICE_LOST error may occur."
|
||||
*/
|
||||
for (i = 0; i < query_count; ++i)
|
||||
{
|
||||
const UINT64 offset = aligned_dst_buffer_offset + i * stride;
|
||||
const unsigned int query_index = start_index + i;
|
||||
|
||||
if (!d3d12_query_heap_is_result_available(query_heap, query_index))
|
||||
{
|
||||
VK_CALL(vkCmdFillBuffer(list->vk_command_buffer,
|
||||
buffer->u.vk_buffer, offset, stride, 0x00000000));
|
||||
continue;
|
||||
}
|
||||
|
||||
VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
|
||||
query_heap->vk_query_pool, query_index, 1, buffer->u.vk_buffer,
|
||||
offset, stride, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
|
||||
}
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_command_list_SetPredication(ID3D12GraphicsCommandList *iface,
|
||||
|
||||
Reference in New Issue
Block a user