wined3d: Make use of VK_EXT_host_query_reset if available.

Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jan Sikorski 2021-07-30 10:17:49 +02:00 committed by Alexandre Julliard
parent 6f095cea53
commit fed705e03f
4 changed files with 44 additions and 11 deletions

View File

@ -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)

View File

@ -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))
{

View File

@ -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)

View File

@ -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,
};