wined3d: Implement pipeline statistics queries for the Vulkan adapter.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2020-05-27 20:25:34 +04:30 committed by Alexandre Julliard
parent 8f70aad2d5
commit 7a03ccfbe9
3 changed files with 45 additions and 0 deletions

View File

@ -1231,6 +1231,10 @@ bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk,
free_pools = &context_vk->free_timestamp_query_pools;
break;
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
free_pools = &context_vk->free_pipeline_statistics_query_pools;
break;
default:
FIXME("Unhandled query type %#x.\n", type);
return false;
@ -1291,6 +1295,7 @@ void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk)
wined3d_context_vk_cleanup_resources(context_vk);
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_occlusion_query_pools);
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_timestamp_query_pools);
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_pipeline_statistics_query_pools);
wine_rb_destroy(&context_vk->bo_slab_available, wined3d_context_vk_destroy_bo_slab, context_vk);
heap_free(context_vk->pending_queries.queries);
heap_free(context_vk->submitted.buffers);
@ -3063,6 +3068,7 @@ HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, struct wi
list_init(&context_vk->active_queries);
list_init(&context_vk->free_occlusion_query_pools);
list_init(&context_vk->free_timestamp_query_pools);
list_init(&context_vk->free_pipeline_statistics_query_pools);
wine_rb_init(&context_vk->render_passes, wined3d_render_pass_vk_compare);
wine_rb_init(&context_vk->pipeline_layouts, wined3d_pipeline_layout_vk_compare);

View File

@ -1408,6 +1408,21 @@ bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk,
pool_info.pipelineStatistics = 0;
break;
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
pool_info.queryType = VK_QUERY_TYPE_PIPELINE_STATISTICS;
pool_info.pipelineStatistics = VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
| VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
| VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
break;
default:
FIXME("Unhandled query type %#x.\n", type);
return false;
@ -1428,12 +1443,15 @@ bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk,
struct wined3d_context_vk *context_vk, const struct wined3d_query_pool_idx_vk *pool_idx)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
const struct wined3d_query_data_pipeline_statistics *ps_tmp;
const struct wined3d_vk_info *vk_info = context_vk->vk_info;
struct wined3d_query_data_pipeline_statistics *ps_result;
VkResult vr;
union
{
uint64_t occlusion;
uint64_t timestamp;
struct wined3d_query_data_pipeline_statistics pipeline_statistics;
} tmp, *result;
if ((vr = VK_CALL(vkGetQueryPoolResults(device_vk->vk_device, pool_idx->pool_vk->vk_query_pool,
@ -1457,6 +1475,22 @@ bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk,
result->timestamp = tmp.timestamp;
break;
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
ps_result = &result->pipeline_statistics;
ps_tmp = &tmp.pipeline_statistics;
ps_result->vertices_submitted += ps_tmp->vertices_submitted;
ps_result->primitives_submitted += ps_tmp->primitives_submitted;
ps_result->vs_invocations += ps_tmp->vs_invocations;
ps_result->gs_invocations += ps_tmp->gs_invocations;
ps_result->gs_primitives += ps_tmp->gs_primitives;
ps_result->clipping_input_primitives += ps_tmp->clipping_input_primitives;
ps_result->clipping_output_primitives += ps_tmp->clipping_output_primitives;
ps_result->ps_invocations += ps_tmp->ps_invocations;
ps_result->hs_invocations += ps_tmp->hs_invocations;
ps_result->ds_invocations += ps_tmp->ds_invocations;
ps_result->cs_invocations += ps_tmp->cs_invocations;
break;
default:
FIXME("Unhandled query type %#x.\n", query_vk->q.type);
return false;
@ -1763,6 +1797,10 @@ HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_quer
data_size = sizeof(struct wined3d_query_data_timestamp_disjoint);
break;
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
data_size = sizeof(struct wined3d_query_data_pipeline_statistics);
break;
default:
FIXME("Unhandled query type %#x.\n", type);
return WINED3DERR_NOTAVAILABLE;

View File

@ -2496,6 +2496,7 @@ struct wined3d_context_vk
struct wined3d_pending_queries_vk pending_queries;
struct list free_occlusion_query_pools;
struct list free_timestamp_query_pools;
struct list free_pipeline_statistics_query_pools;
struct wined3d_retired_objects_vk retired;
struct wine_rb_tree render_passes;