anv: implement VK_EXT_primitives_generated_query
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15638>
This commit is contained in:
@@ -286,6 +286,7 @@ get_device_extensions(const struct anv_physical_device *device,
|
||||
.EXT_pipeline_creation_cache_control = true,
|
||||
.EXT_pipeline_creation_feedback = true,
|
||||
.EXT_post_depth_coverage = device->info.ver >= 9,
|
||||
.EXT_primitives_generated_query = true,
|
||||
.EXT_primitive_topology_list_restart = true,
|
||||
.EXT_private_data = true,
|
||||
.EXT_provoking_vertex = true,
|
||||
@@ -1647,6 +1648,15 @@ void anv_GetPhysicalDeviceFeatures2(
|
||||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT: {
|
||||
VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT *features =
|
||||
(VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT *)ext;
|
||||
features->primitivesGeneratedQuery = true;
|
||||
features->primitivesGeneratedQueryWithRasterizerDiscard = false;
|
||||
features->primitivesGeneratedQueryWithNonZeroStreams = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT: {
|
||||
VkPhysicalDeviceProvokingVertexFeaturesEXT *features =
|
||||
(VkPhysicalDeviceProvokingVertexFeaturesEXT *)ext;
|
||||
|
@@ -159,6 +159,10 @@ VkResult genX(CreateQueryPool)(
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
|
||||
/* Query has two values: begin and end. */
|
||||
uint64s_per_slot = 1 + 2;
|
||||
break;
|
||||
default:
|
||||
assert(!"Invalid query type");
|
||||
}
|
||||
@@ -448,7 +452,8 @@ VkResult genX(GetQueryPoolResults)(
|
||||
pool->type == VK_QUERY_TYPE_TIMESTAMP ||
|
||||
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_PERFORMANCE_QUERY_INTEL ||
|
||||
pool->type == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT);
|
||||
|
||||
if (vk_device_is_lost(&device->vk))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
@@ -490,7 +495,8 @@ VkResult genX(GetQueryPoolResults)(
|
||||
|
||||
uint32_t idx = 0;
|
||||
switch (pool->type) {
|
||||
case VK_QUERY_TYPE_OCCLUSION: {
|
||||
case VK_QUERY_TYPE_OCCLUSION:
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT: {
|
||||
uint64_t *slot = query_slot(pool, firstQuery + i);
|
||||
if (write_results) {
|
||||
/* From the Vulkan 1.2.132 spec:
|
||||
@@ -675,6 +681,7 @@ emit_zero_queries(struct anv_cmd_buffer *cmd_buffer,
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
|
||||
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
|
||||
case VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT:
|
||||
for (uint32_t i = 0; i < num_queries; i++) {
|
||||
@@ -750,7 +757,8 @@ void genX(CmdResetQueryPool)(
|
||||
}
|
||||
|
||||
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
|
||||
case VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT: {
|
||||
case VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT:
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT: {
|
||||
struct mi_builder b;
|
||||
mi_builder_init(&b, &cmd_buffer->device->info, &cmd_buffer->batch);
|
||||
|
||||
@@ -923,6 +931,11 @@ void genX(CmdBeginQueryIndexedEXT)(
|
||||
emit_ps_depth_count(cmd_buffer, anv_address_add(query_addr, 8));
|
||||
break;
|
||||
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
|
||||
mi_store(&b, mi_mem64(anv_address_add(query_addr, 8)),
|
||||
mi_reg64(GENX(CL_INVOCATION_COUNT_num)));
|
||||
break;
|
||||
|
||||
case VK_QUERY_TYPE_PIPELINE_STATISTICS: {
|
||||
/* TODO: This might only be necessary for certain stats */
|
||||
anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
|
||||
@@ -1101,6 +1114,20 @@ void genX(CmdEndQueryIndexedEXT)(
|
||||
emit_query_pc_availability(cmd_buffer, query_addr, true);
|
||||
break;
|
||||
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
|
||||
/* Ensure previous commands have completed before capturing the register
|
||||
* value.
|
||||
*/
|
||||
anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
|
||||
pc.CommandStreamerStallEnable = true;
|
||||
pc.StallAtPixelScoreboard = true;
|
||||
}
|
||||
|
||||
mi_store(&b, mi_mem64(anv_address_add(query_addr, 16)),
|
||||
mi_reg64(GENX(CL_INVOCATION_COUNT_num)));
|
||||
emit_query_mi_availability(&b, query_addr, true);
|
||||
break;
|
||||
|
||||
case VK_QUERY_TYPE_PIPELINE_STATISTICS: {
|
||||
/* TODO: This might only be necessary for certain stats */
|
||||
anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
|
||||
@@ -1412,6 +1439,7 @@ void genX(CmdCopyQueryPoolResults)(
|
||||
uint32_t idx = 0;
|
||||
switch (pool->type) {
|
||||
case VK_QUERY_TYPE_OCCLUSION:
|
||||
case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT:
|
||||
result = compute_query_result(&b, anv_address_add(query_addr, 8));
|
||||
/* Like in the case of vkGetQueryPoolResults, if the query is
|
||||
* unavailable and the VK_QUERY_RESULT_PARTIAL_BIT flag is set,
|
||||
|
Reference in New Issue
Block a user