[PATCH 2/5] wined3d: Implement pipeline statistics queries for the Vulkan adapter.

Henri Verbeet hverbeet at codeweavers.com
Wed May 27 10:55:34 CDT 2020


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/context_vk.c      |  6 ++++++
 dlls/wined3d/query.c           | 38 ++++++++++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |  1 +
 3 files changed, 45 insertions(+)

diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index af29ef7e7a7..c5f2789f7fb 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -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);
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 91793501476..3af56499904 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -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;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9f8c212fbf3..ae78a60f2ab 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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;
-- 
2.20.1




More information about the wine-devel mailing list