[PATCH vkd3d 4/9] vkd3d: Try to call vkCmdCopyQueryPoolResults() for multiple queries.

Józef Kucia joseph.kucia at gmail.com
Thu Aug 23 11:33:03 CDT 2018


From: Józef Kucia <jkucia at codeweavers.com>

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 libs/vkd3d/command.c | 47 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 793417eaddff..aa77c6c79f21 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -3885,8 +3885,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12Graphics
     struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
     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;
+    VkDeviceSize offset, stride = sizeof(uint64_t);
+    unsigned int i, first, count;
 
     TRACE("iface %p, heap %p, type %#x, start_index %u, query_count %u, "
             "dst_buffer %p, aligned_dst_buffer_offset %#"PRIx64".\n",
@@ -3914,26 +3914,45 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12Graphics
     if (type == D3D12_QUERY_TYPE_PIPELINE_STATISTICS)
         stride = sizeof(struct D3D12_QUERY_DATA_PIPELINE_STATISTICS);
 
-    /* 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."
-     */
+    count = 0;
+    first = start_index;
+    offset = aligned_dst_buffer_offset;
     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))
+        if (d3d12_query_heap_is_result_available(query_heap, start_index + i))
+        {
+            ++count;
+        }
+        else
         {
+            if (count)
+            {
+                VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
+                        query_heap->vk_query_pool, first, count, buffer->u.vk_buffer,
+                        offset, stride, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
+            }
+            count = 0;
+            first = start_index + i;
+            offset = aligned_dst_buffer_offset + i * stride;
+
+            /* 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."
+             */
             VK_CALL(vkCmdFillBuffer(list->vk_command_buffer,
                     buffer->u.vk_buffer, offset, stride, 0x00000000));
-            continue;
+
+            ++first;
+            offset += stride;
         }
+    }
 
+    if (count)
+    {
         VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
-                query_heap->vk_query_pool, query_index, 1, buffer->u.vk_buffer,
+                query_heap->vk_query_pool, first, count, buffer->u.vk_buffer,
                 offset, stride, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
     }
 }
-- 
2.16.4




More information about the wine-devel mailing list