Module: Mesa
Branch: main
Commit: 5b45304624470bc36211b2e54590d7136ac4da45
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b45304624470bc36211b2e54590d7136ac4da45

Author: Mary Guillemard <[email protected]>
Date:   Tue Nov 21 19:26:49 2023 +0100

nvk: Implement VK_EXT_primitives_generated_query

Signed-off-by: Mary Guillemard <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26324>

---

 docs/features.txt                        |  2 +-
 src/nouveau/vulkan/nvk_physical_device.c |  6 ++++++
 src/nouveau/vulkan/nvk_query_pool.c      | 23 ++++++++++++++++++++++-
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 206cceed6ca..9bc0718d591 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -593,7 +593,7 @@ Khronos extensions that are not part of any Vulkan version:
   VK_EXT_pipeline_robustness                            DONE (anv, radv, v3dv)
   VK_EXT_post_depth_coverage                            DONE (anv/gfx10+, lvp, 
radv/gfx10+)
   VK_EXT_primitive_topology_list_restart                DONE (anv, hasvk, lvp, 
nvk, radv, tu, v3dv, vn)
-  VK_EXT_primitives_generated_query                     DONE (anv, hasvk, lvp, 
radv, tu, vn)
+  VK_EXT_primitives_generated_query                     DONE (anv, hasvk, lvp, 
nvk, radv, tu, vn)
   VK_EXT_provoking_vertex                               DONE (anv, hasvk, lvp, 
nvk, radv, tu, v3dv, vn)
   VK_EXT_queue_family_foreign                           DONE (anv, hasvk, 
radv, tu, vn)
   VK_EXT_rasterization_order_attachment_access          DONE (lvp, tu, vn)
diff --git a/src/nouveau/vulkan/nvk_physical_device.c 
b/src/nouveau/vulkan/nvk_physical_device.c
index 1ccf1039c60..da426adce04 100644
--- a/src/nouveau/vulkan/nvk_physical_device.c
+++ b/src/nouveau/vulkan/nvk_physical_device.c
@@ -127,6 +127,7 @@ nvk_get_device_extensions(const struct nv_device_info *info,
       .EXT_physical_device_drm = true,
       .EXT_primitive_topology_list_restart = true,
       .EXT_private_data = true,
+      .EXT_primitives_generated_query = true,
       .EXT_provoking_vertex = true,
       .EXT_robustness2 = true,
       .EXT_sample_locations = info->cls_eng3d >= MAXWELL_B,
@@ -379,6 +380,11 @@ nvk_get_device_features(const struct nv_device_info *info,
       .primitiveTopologyListRestart = true,
       .primitiveTopologyPatchListRestart = true,
 
+      /* VK_EXT_primitives_generated_query */
+      .primitivesGeneratedQuery = true,
+      .primitivesGeneratedQueryWithNonZeroStreams = true,
+      .primitivesGeneratedQueryWithRasterizerDiscard = true,
+
       /* VK_EXT_provoking_vertex */
       .provokingVertexLast = true,
       .transformFeedbackPreservesProvokingVertex = true,
diff --git a/src/nouveau/vulkan/nvk_query_pool.c 
b/src/nouveau/vulkan/nvk_query_pool.c
index 518233a1b8c..e9c6cf40e8b 100644
--- a/src/nouveau/vulkan/nvk_query_pool.c
+++ b/src/nouveau/vulkan/nvk_query_pool.c
@@ -55,6 +55,7 @@ nvk_CreateQueryPool(VkDevice device,
    uint32_t reports_per_query;
    switch (pCreateInfo->queryType) {
    case VK_QUERY_TYPE_OCCLUSION:
+   case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
       reports_per_query = 2;
       break;
    case VK_QUERY_TYPE_TIMESTAMP:
@@ -174,7 +175,8 @@ emit_zero_queries(struct nvk_cmd_buffer *cmd, struct 
nvk_query_pool *pool,
    switch (pool->vk.query_type) {
    case VK_QUERY_TYPE_OCCLUSION:
    case VK_QUERY_TYPE_TIMESTAMP:
-   case VK_QUERY_TYPE_PIPELINE_STATISTICS: {
+   case VK_QUERY_TYPE_PIPELINE_STATISTICS:
+   case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT: {
       for (uint32_t i = 0; i < num_queries; i++) {
          uint64_t addr = nvk_query_available_addr(pool, first_index + i);
 
@@ -483,6 +485,24 @@ nvk_cmd_begin_end_query(struct nvk_cmd_buffer *cmd,
       }
       break;
    }
+
+   case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
+      p = nvk_cmd_buffer_push(cmd, 5 + end_size);
+
+      P_MTHD(p, NV9097, SET_REPORT_SEMAPHORE_A);
+      P_NV9097_SET_REPORT_SEMAPHORE_A(p, report_addr >> 32);
+      P_NV9097_SET_REPORT_SEMAPHORE_B(p, report_addr);
+      P_NV9097_SET_REPORT_SEMAPHORE_C(p, 1);
+      P_NV9097_SET_REPORT_SEMAPHORE_D(p, {
+         .operation = OPERATION_REPORT_ONLY,
+         .pipeline_location = PIPELINE_LOCATION_STREAMING_OUTPUT,
+         .report = REPORT_VTG_PRIMITIVES_OUT,
+         .sub_report = index,
+         .structure_size = STRUCTURE_SIZE_FOUR_WORDS,
+         .flush_disable = true,
+      });
+      break;
+
    default:
       unreachable("Unsupported query type");
    }
@@ -637,6 +657,7 @@ nvk_GetQueryPoolResults(VkDevice device,
       uint32_t available_dst_idx = 1;
       switch (pool->vk.query_type) {
       case VK_QUERY_TYPE_OCCLUSION:
+      case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
          if (write_results)
             cpu_get_query_delta(dst, src, 0, flags);
          break;

Reply via email to