zink: add render-passes HUD query
Add a driver specific query to display the number of render passes per frame in the Gallium HUD. Suggested in https://gitlab.freedesktop.org/mesa/mesa/-/issues/7327 Signed-off-by: José Expósito <jexposit@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26518>
This commit is contained in:
@@ -2986,6 +2986,10 @@ zink_batch_rp(struct zink_context *ctx)
|
|||||||
else
|
else
|
||||||
clear_buffers = begin_rendering(ctx);
|
clear_buffers = begin_rendering(ctx);
|
||||||
assert(!ctx->rp_changed);
|
assert(!ctx->rp_changed);
|
||||||
|
|
||||||
|
/* update the render-passes HUD query */
|
||||||
|
ctx->hud.render_passes++;
|
||||||
|
|
||||||
if (!in_rp && ctx->batch.in_rp) {
|
if (!in_rp && ctx->batch.in_rp) {
|
||||||
/* only hit this for valid swapchain and new renderpass */
|
/* only hit this for valid swapchain and new renderpass */
|
||||||
if (ctx->render_condition.query)
|
if (ctx->render_condition.query)
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#define NUM_QUERIES 500
|
#define NUM_QUERIES 500
|
||||||
|
|
||||||
|
#define ZINK_QUERY_RENDER_PASSES (PIPE_QUERY_DRIVER_SPECIFIC + 0)
|
||||||
|
|
||||||
struct zink_query_pool {
|
struct zink_query_pool {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
VkQueryType vk_query_type;
|
VkQueryType vk_query_type;
|
||||||
@@ -86,6 +88,10 @@ struct zink_query {
|
|||||||
bool predicate_dirty;
|
bool predicate_dirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct pipe_driver_query_info zink_specific_queries[] = {
|
||||||
|
{"render-passes", ZINK_QUERY_RENDER_PASSES, { 0 }},
|
||||||
|
};
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
get_num_starts(struct zink_query *q)
|
get_num_starts(struct zink_query *q)
|
||||||
{
|
{
|
||||||
@@ -251,7 +257,8 @@ get_num_queries(struct zink_query *q)
|
|||||||
static inline unsigned
|
static inline unsigned
|
||||||
get_num_results(struct zink_query *q)
|
get_num_results(struct zink_query *q)
|
||||||
{
|
{
|
||||||
if (q->vkqtype == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT)
|
if (q->type < PIPE_QUERY_DRIVER_SPECIFIC &&
|
||||||
|
q->vkqtype == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT)
|
||||||
return 1;
|
return 1;
|
||||||
switch (q->type) {
|
switch (q->type) {
|
||||||
case PIPE_QUERY_OCCLUSION_COUNTER:
|
case PIPE_QUERY_OCCLUSION_COUNTER:
|
||||||
@@ -499,6 +506,10 @@ zink_create_query(struct pipe_context *pctx,
|
|||||||
|
|
||||||
query->index = index;
|
query->index = index;
|
||||||
query->type = query_type;
|
query->type = query_type;
|
||||||
|
|
||||||
|
if (query->type >= PIPE_QUERY_DRIVER_SPECIFIC)
|
||||||
|
return (struct pipe_query *)query;
|
||||||
|
|
||||||
if (query->type == PIPE_QUERY_GPU_FINISHED || query->type == PIPE_QUERY_TIMESTAMP_DISJOINT)
|
if (query->type == PIPE_QUERY_GPU_FINISHED || query->type == PIPE_QUERY_TIMESTAMP_DISJOINT)
|
||||||
return (struct pipe_query *)query;
|
return (struct pipe_query *)query;
|
||||||
query->vkqtype = convert_query_type(screen, query_type, &query->precise);
|
query->vkqtype = convert_query_type(screen, query_type, &query->precise);
|
||||||
@@ -872,7 +883,7 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
|
|||||||
{
|
{
|
||||||
VkQueryControlFlags flags = 0;
|
VkQueryControlFlags flags = 0;
|
||||||
|
|
||||||
if (q->type == PIPE_QUERY_TIMESTAMP_DISJOINT)
|
if (q->type == PIPE_QUERY_TIMESTAMP_DISJOINT || q->type >= PIPE_QUERY_DRIVER_SPECIFIC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (q->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && q->index == PIPE_STAT_QUERY_CS_INVOCATIONS && ctx->batch.in_rp) {
|
if (q->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && q->index == PIPE_STAT_QUERY_CS_INVOCATIONS && ctx->batch.in_rp) {
|
||||||
@@ -961,7 +972,7 @@ zink_begin_query(struct pipe_context *pctx,
|
|||||||
/* drop all past results */
|
/* drop all past results */
|
||||||
reset_qbo(query);
|
reset_qbo(query);
|
||||||
|
|
||||||
if (query->vkqtype == VK_QUERY_TYPE_OCCLUSION)
|
if (query->type < PIPE_QUERY_DRIVER_SPECIFIC && query->vkqtype == VK_QUERY_TYPE_OCCLUSION)
|
||||||
ctx->occlusion_query_active = true;
|
ctx->occlusion_query_active = true;
|
||||||
if (query->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && query->index == PIPE_STAT_QUERY_PS_INVOCATIONS)
|
if (query->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && query->index == PIPE_STAT_QUERY_PS_INVOCATIONS)
|
||||||
ctx->fs_query_active = true;
|
ctx->fs_query_active = true;
|
||||||
@@ -995,7 +1006,7 @@ update_query_id(struct zink_context *ctx, struct zink_query *q)
|
|||||||
static void
|
static void
|
||||||
end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query *q)
|
end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query *q)
|
||||||
{
|
{
|
||||||
if (q->type == PIPE_QUERY_TIMESTAMP_DISJOINT)
|
if (q->type == PIPE_QUERY_TIMESTAMP_DISJOINT || q->type >= PIPE_QUERY_DRIVER_SPECIFIC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zink_flush_dgc_if_enabled(ctx);
|
zink_flush_dgc_if_enabled(ctx);
|
||||||
@@ -1050,7 +1061,7 @@ zink_end_query(struct pipe_context *pctx,
|
|||||||
struct zink_query *query = (struct zink_query *)q;
|
struct zink_query *query = (struct zink_query *)q;
|
||||||
struct zink_batch *batch = &ctx->batch;
|
struct zink_batch *batch = &ctx->batch;
|
||||||
|
|
||||||
if (query->type == PIPE_QUERY_TIMESTAMP_DISJOINT)
|
if (query->type == PIPE_QUERY_TIMESTAMP_DISJOINT || query->type >= PIPE_QUERY_DRIVER_SPECIFIC)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (query->type == PIPE_QUERY_GPU_FINISHED) {
|
if (query->type == PIPE_QUERY_GPU_FINISHED) {
|
||||||
@@ -1123,6 +1134,12 @@ zink_get_query_result(struct pipe_context *pctx,
|
|||||||
return result->b;
|
return result->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query->type == ZINK_QUERY_RENDER_PASSES) {
|
||||||
|
result->u64 = ctx->hud.render_passes;
|
||||||
|
ctx->hud.render_passes = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (query->needs_update) {
|
if (query->needs_update) {
|
||||||
assert(!ctx->tc || !threaded_query(q)->flushed);
|
assert(!ctx->tc || !threaded_query(q)->flushed);
|
||||||
update_qbo(ctx, query);
|
update_qbo(ctx, query);
|
||||||
@@ -1508,3 +1525,31 @@ zink_context_query_init(struct pipe_context *pctx)
|
|||||||
pctx->set_active_query_state = zink_set_active_query_state;
|
pctx->set_active_query_state = zink_set_active_query_state;
|
||||||
pctx->render_condition = zink_render_condition;
|
pctx->render_condition = zink_render_condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
zink_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
|
||||||
|
struct pipe_driver_query_group_info *info)
|
||||||
|
{
|
||||||
|
if (!info)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
assert(index == 0);
|
||||||
|
info->name = "Zink counters";
|
||||||
|
info->max_active_queries = ARRAY_SIZE(zink_specific_queries);
|
||||||
|
info->num_queries = ARRAY_SIZE(zink_specific_queries);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
zink_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
|
||||||
|
struct pipe_driver_query_info *info)
|
||||||
|
{
|
||||||
|
if (!info)
|
||||||
|
return ARRAY_SIZE(zink_specific_queries);
|
||||||
|
|
||||||
|
assert(index < ARRAY_SIZE(zink_specific_queries));
|
||||||
|
*info = zink_specific_queries[index];
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -62,6 +62,15 @@ void
|
|||||||
zink_context_destroy_query_pools(struct zink_context *ctx);
|
zink_context_destroy_query_pools(struct zink_context *ctx);
|
||||||
uint64_t
|
uint64_t
|
||||||
zink_get_timestamp(struct pipe_screen *pscreen);
|
zink_get_timestamp(struct pipe_screen *pscreen);
|
||||||
|
|
||||||
|
int
|
||||||
|
zink_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
|
||||||
|
struct pipe_driver_query_group_info *info);
|
||||||
|
|
||||||
|
int
|
||||||
|
zink_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
|
||||||
|
struct pipe_driver_query_info *info);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -3380,6 +3380,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev
|
|||||||
screen->base.finalize_nir = zink_shader_finalize;
|
screen->base.finalize_nir = zink_shader_finalize;
|
||||||
screen->base.get_disk_shader_cache = zink_get_disk_shader_cache;
|
screen->base.get_disk_shader_cache = zink_get_disk_shader_cache;
|
||||||
screen->base.get_sparse_texture_virtual_page_size = zink_get_sparse_texture_virtual_page_size;
|
screen->base.get_sparse_texture_virtual_page_size = zink_get_sparse_texture_virtual_page_size;
|
||||||
|
screen->base.get_driver_query_group_info = zink_get_driver_query_group_info;
|
||||||
|
screen->base.get_driver_query_info = zink_get_driver_query_info;
|
||||||
|
|
||||||
if (screen->info.have_EXT_sample_locations) {
|
if (screen->info.have_EXT_sample_locations) {
|
||||||
VkMultisamplePropertiesEXT prop;
|
VkMultisamplePropertiesEXT prop;
|
||||||
|
@@ -1931,6 +1931,9 @@ struct zink_context {
|
|||||||
bool inverted;
|
bool inverted;
|
||||||
bool active; //this is the internal vk state
|
bool active; //this is the internal vk state
|
||||||
} render_condition;
|
} render_condition;
|
||||||
|
struct {
|
||||||
|
uint64_t render_passes;
|
||||||
|
} hud;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool valid;
|
bool valid;
|
||||||
|
Reference in New Issue
Block a user