[PATCH v2] wined3d: Make use of VK_EXT_host_query_reset if available.

Jan Sikorski jsikorski at codeweavers.com
Fri Jul 30 03:17:49 CDT 2021


Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
---
v2: add it to supported extensions table and check that
---
 dlls/wined3d/adapter_vk.c | 10 +++++++++-
 dlls/wined3d/context_vk.c | 14 +++++++++++---
 dlls/wined3d/query.c      | 26 ++++++++++++++++++++------
 dlls/wined3d/wined3d_vk.h |  5 ++++-
 4 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index 850e2a6dfdb..c7da02865ea 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -313,6 +313,7 @@ struct wined3d_physical_device_info
 {
     VkPhysicalDeviceTransformFeedbackFeaturesEXT xfb_features;
     VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT vertex_divisor_features;
+    VkPhysicalDeviceHostQueryResetFeatures host_query_reset_features;
 
     VkPhysicalDeviceFeatures2 features2;
 };
@@ -403,6 +404,7 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
 {
     const struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk_const(adapter);
     VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *vertex_divisor_features;
+    VkPhysicalDeviceHostQueryResetFeatures *host_query_reset_features;
     const struct wined3d_vk_info *vk_info = &adapter_vk->vk_info;
     VkPhysicalDeviceTransformFeedbackFeaturesEXT *xfb_features;
     struct wined3d_physical_device_info physical_device_info;
@@ -435,9 +437,13 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
     vertex_divisor_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT;
     vertex_divisor_features->pNext = xfb_features;
 
+    host_query_reset_features = &physical_device_info.host_query_reset_features;
+    host_query_reset_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES;
+    host_query_reset_features->pNext = vertex_divisor_features;
+
     features2 = &physical_device_info.features2;
     features2->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
-    features2->pNext = vertex_divisor_features;
+    features2->pNext = host_query_reset_features;
 
     if (vk_info->vk_ops.vkGetPhysicalDeviceFeatures2)
         VK_CALL(vkGetPhysicalDeviceFeatures2(physical_device, features2));
@@ -2195,6 +2201,7 @@ static bool wined3d_adapter_vk_init_device_extensions(struct wined3d_adapter_vk
         {VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME,VK_API_VERSION_1_2},
         {VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME,      VK_API_VERSION_1_1, true},
         {VK_KHR_SWAPCHAIN_EXTENSION_NAME,                   ~0u,                true},
+        {VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME,            VK_API_VERSION_1_2},
     };
 
     static const struct
@@ -2206,6 +2213,7 @@ static bool wined3d_adapter_vk_init_device_extensions(struct wined3d_adapter_vk
     {
         {VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,           WINED3D_VK_EXT_TRANSFORM_FEEDBACK},
         {VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE},
+        {VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME,             WINED3D_VK_EXT_HOST_QUERY_RESET},
     };
 
     if ((vr = VK_CALL(vkEnumerateDeviceExtensionProperties(physical_device, NULL, &count, NULL))) < 0)
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index c718f3facd5..eac4eacff5a 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -1398,9 +1398,17 @@ bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk,
         return false;
     }
 
-    wined3d_context_vk_end_current_render_pass(context_vk);
-    VK_CALL(vkCmdResetQueryPool(wined3d_context_vk_get_command_buffer(context_vk),
-            pool_vk->vk_query_pool, 0, WINED3D_QUERY_POOL_SIZE));
+    if (vk_info->supported[WINED3D_VK_EXT_HOST_QUERY_RESET])
+    {
+        VK_CALL(vkResetQueryPoolEXT(wined3d_device_vk(context_vk->c.device)->vk_device,
+                pool_vk->vk_query_pool, 0, WINED3D_QUERY_POOL_SIZE));
+    }
+    else
+    {
+        wined3d_context_vk_end_current_render_pass(context_vk);
+        VK_CALL(vkCmdResetQueryPool(wined3d_context_vk_get_command_buffer(context_vk),
+                pool_vk->vk_query_pool, 0, WINED3D_QUERY_POOL_SIZE));
+    }
 
     if (!wined3d_query_pool_vk_allocate_query(pool_vk, &idx))
     {
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 4628cb98cdc..527d5f6c809 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -1351,12 +1351,26 @@ HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_quer
 static void wined3d_query_pool_vk_mark_complete(struct wined3d_query_pool_vk *pool_vk, size_t idx,
         struct wined3d_context_vk *context_vk)
 {
-    /* Don't reset completed queries right away, as vkCmdResetQueryPool() needs to happen
-     * outside of a render pass. Queue the query to be reset in wined3d_query_pool_vk_reset()
-     * instead, which is called when the render pass ends. */
-    wined3d_bitmap_set(pool_vk->completed, idx);
-    if (list_empty(&pool_vk->completed_entry))
-        list_add_tail(&context_vk->completed_query_pools, &pool_vk->completed_entry);
+    const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+
+    if (vk_info->supported[WINED3D_VK_EXT_HOST_QUERY_RESET])
+    {
+        VK_CALL(vkResetQueryPoolEXT(wined3d_device_vk(context_vk->c.device)->vk_device,
+                pool_vk->vk_query_pool, idx, 1));
+
+        wined3d_bitmap_clear(pool_vk->allocated, idx);
+        if (list_empty(&pool_vk->entry))
+            list_add_tail(pool_vk->free_list, &pool_vk->entry);
+    }
+    else
+    {
+        /* Don't reset completed queries right away, as vkCmdResetQueryPool() needs to happen
+         * outside of a render pass. Queue the query to be reset in wined3d_query_pool_vk_reset()
+         * instead, which is called when the render pass ends. */
+        wined3d_bitmap_set(pool_vk->completed, idx);
+        if (list_empty(&pool_vk->completed_entry))
+            list_add_tail(&context_vk->completed_query_pools, &pool_vk->completed_entry);
+    }
 }
 
 bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx)
diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h
index a417a795901..91ef8c816cd 100644
--- a/dlls/wined3d/wined3d_vk.h
+++ b/dlls/wined3d/wined3d_vk.h
@@ -49,7 +49,9 @@
     VK_INSTANCE_PFN(vkGetPhysicalDeviceSurfacePresentModesKHR) \
     VK_INSTANCE_PFN(vkGetPhysicalDeviceSurfaceSupportKHR) \
     /* VK_KHR_win32_surface */ \
-    VK_INSTANCE_PFN(vkCreateWin32SurfaceKHR)
+    VK_INSTANCE_PFN(vkCreateWin32SurfaceKHR) \
+    /* VK_EXT_host_query_reset */ \
+    VK_INSTANCE_EXT_PFN(vkResetQueryPoolEXT)
 
 #define VK_DEVICE_FUNCS() \
     VK_DEVICE_PFN(vkAllocateCommandBuffers) \
@@ -210,6 +212,7 @@ enum wined3d_vk_extension
 
     WINED3D_VK_EXT_TRANSFORM_FEEDBACK,
     WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE,
+    WINED3D_VK_EXT_HOST_QUERY_RESET,
 
     WINED3D_VK_EXT_COUNT,
 };
-- 
2.30.2




More information about the wine-devel mailing list