From 79b92af9da9c4de758e01d2aebdd758b5b4c07a2 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 12 May 2021 16:07:37 +0200 Subject: [PATCH] gallium: Add PIPE_CAP_QUERY_TIMESTAMP_BITS For those drivers that don't make full use of the 64 bits in pipe_query_result.u64. Applications will make use of it via GL_QUERY_COUNTER_BITS to handle when the value rolls over. Signed-off-by: Tomeu Vizoso Reviewed-by: Lionel Landwerlin Reviewed-By: Mike Blumenkrantz Reviewed-by: Emma Anholt Part-of: --- docs/gallium/screen.rst | 2 ++ src/gallium/auxiliary/util/u_screen.c | 3 +++ src/gallium/drivers/iris/iris_screen.c | 3 +++ src/gallium/drivers/zink/zink_screen.c | 3 +++ src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_context.c | 3 +++ 6 files changed, 15 insertions(+) diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 2b6bf438d74..9540ca4daf9 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -153,6 +153,8 @@ The integer capabilities: pipe_draw_info::start_instance. * ``PIPE_CAP_QUERY_TIMESTAMP``: Whether PIPE_QUERY_TIMESTAMP and the pipe_screen::get_timestamp hook are implemented. +* ``PIPE_CAP_QUERY_TIMESTAMP_BITS``: How many bits the driver uses for the + results of GL_TIMESTAMP queries. * ``PIPE_CAP_TEXTURE_MULTISAMPLE``: Whether all MSAA resources supported for rendering are also supported for texturing. * ``PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT``: The minimum alignment that should be diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 914ffc45833..d880d2a66d9 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -515,6 +515,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS); } + case PIPE_CAP_QUERY_TIMESTAMP_BITS: + return 64; + default: unreachable("bad PIPE_CAP_*"); } diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 177567b3871..5bf2ec91638 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -407,6 +407,9 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param) */ return devinfo->ver >= 11; + case PIPE_CAP_QUERY_TIMESTAMP_BITS: + return TIMESTAMP_BITS; + default: return u_pipe_screen_get_param_defaults(pscreen, param); } diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 9cc2c54ddf1..7078f3115d5 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -676,6 +676,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_QUERY_TIMESTAMP: return screen->timestamp_valid_bits > 0; + case PIPE_CAP_QUERY_TIMESTAMP_BITS: + return screen->timestamp_valid_bits; + case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: return 1 << MIN_SLAB_ORDER; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index f0b60e3ef35..f8c89341263 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -1001,6 +1001,7 @@ enum pipe_cap PIPE_CAP_DITHERING, PIPE_CAP_FBFETCH_ZS, PIPE_CAP_TIMELINE_SEMAPHORE_IMPORT, + PIPE_CAP_QUERY_TIMESTAMP_BITS, PIPE_CAP_LAST, /* XXX do not add caps after PIPE_CAP_LAST! */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 9935376ad97..a734c93a0d5 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -559,6 +559,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW); + ctx->Const.QueryCounterBits.Timestamp = + screen->get_param(screen, PIPE_CAP_QUERY_TIMESTAMP_BITS); + st->has_stencil_export = screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT); st->has_etc1 = screen->is_format_supported(screen, PIPE_FORMAT_ETC1_RGB8,