From 3a06bb4fc2178956b0c3a2823d084d8ce1108ef1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 8 Feb 2023 13:32:36 +1000 Subject: [PATCH] hasvk/query: add query status report --- src/intel/vulkan_hasvk/anv_device.c | 7 +++++- src/intel/vulkan_hasvk/genX_query.c | 38 +++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index ed3ca5a..a188943 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -2099,7 +2099,12 @@ void anv_GetPhysicalDeviceQueueFamilyProperties2( properties->priorityCount = count; break; } - + case VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR: { + VkQueueFamilyQueryResultStatusPropertiesKHR *prop = + (VkQueueFamilyQueryResultStatusPropertiesKHR *)ext; + prop->queryResultStatusSupport = VK_TRUE; + break; + } default: vk_debug_ignored_stype(ext->sType); } diff --git a/src/intel/vulkan_hasvk/genX_query.c b/src/intel/vulkan_hasvk/genX_query.c index 1728b15..44e6edd 100644 --- a/src/intel/vulkan_hasvk/genX_query.c +++ b/src/intel/vulkan_hasvk/genX_query.c @@ -59,6 +59,18 @@ anv_query_address(struct anv_query_pool *pool, uint32_t query) }; } +static void +emit_query_mi_flush_availability(struct anv_cmd_buffer *cmd_buffer, + struct anv_address addr, + bool available) +{ + anv_batch_emit(&cmd_buffer->batch, GENX(MI_FLUSH_DW), flush) { + flush.PostSyncOperation = WriteImmediateData; + flush.Address = addr; + flush.ImmediateData = available; + } +} + VkResult genX(CreateQueryPool)( VkDevice _device, const VkQueryPoolCreateInfo* pCreateInfo, @@ -163,6 +175,9 @@ VkResult genX(CreateQueryPool)( /* Query has two values: begin and end. */ uint64s_per_slot = 1 + 2; break; + case VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR: + uint64s_per_slot = 1; + break; default: UNREACHABLE("Invalid query type"); } @@ -453,7 +468,8 @@ VkResult genX(GetQueryPoolResults)( pool->type == VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT || pool->type == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR || pool->type == VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL || - pool->type == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT); + pool->type == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT || + pool->type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR); if (vk_device_is_lost(&device->vk)) return VK_ERROR_DEVICE_LOST; @@ -591,6 +607,14 @@ VkResult genX(GetQueryPoolResults)( break; } + case VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR: + if (!write_results) + break; + const uint32_t *query_data = query_slot(pool, firstQuery + i); + uint32_t result = available ? *query_data : 0; + cpu_write_query_result(pData, flags, idx, result); + break; + default: UNREACHABLE("invalid pool type"); } @@ -713,6 +737,11 @@ emit_zero_queries(struct anv_cmd_buffer *cmd_buffer, } break; + case VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR: + for (uint32_t i = 0; i < num_queries; i++) + emit_query_mi_flush_availability(cmd_buffer, anv_query_address(pool, first_index + i), false); + break; + default: UNREACHABLE("Unsupported query type"); } @@ -1088,7 +1117,9 @@ void genX(CmdBeginQueryIndexedEXT)( emit_perf_intel_query(cmd_buffer, pool, &b, query_addr, false); break; } - + case VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR: + emit_query_mi_flush_availability(cmd_buffer, query_addr, false); + break; default: UNREACHABLE(""); } @@ -1256,6 +1287,9 @@ void genX(CmdEndQueryIndexedEXT)( emit_query_mi_availability(&b, query_addr, true); break; } + case VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR: + emit_query_mi_flush_availability(cmd_buffer, query_addr, true); + break; default: UNREACHABLE("");