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

Author: Marek Olšák <marek.ol...@amd.com>
Date:   Fri Nov 17 16:01:46 2023 -0500

gallium: add PIPE_CAP_PERFORMANCE_MONITOR for GL_AMD_performance_monitor

Use a CAP instead of guessing it. radeonsi won't expose it.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-pra...@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26262>

---

 docs/gallium/screen.rst                |  2 ++
 src/gallium/auxiliary/util/u_screen.c  |  4 ++++
 src/gallium/include/pipe/p_defines.h   |  1 +
 src/mesa/state_tracker/st_context.c    | 15 ---------------
 src/mesa/state_tracker/st_extensions.c |  1 +
 5 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst
index f66d9f26cfc..5c668aec4f1 100644
--- a/docs/gallium/screen.rst
+++ b/docs/gallium/screen.rst
@@ -647,6 +647,8 @@ The integer capabilities:
 * ``PIPE_CAP_ASTC_VOID_EXTENTS_NEED_DENORM_FLUSH`` : True if the 
driver/hardware needs denormalized values in ASTC void extent blocks flushed to 
zero.
 * ``PIPE_CAP_VALIDATE_ALL_DIRTY_STATES`` : Whether state validation must also 
validate the state changes for resources types used in the previous shader but 
not in the current shader.
 * ``PIPE_CAP_HAS_CONST_BW``: Whether the driver only supports 
non-data-dependent layouts (ie. not bandwidth compressed formats like AFBC, 
UBWC, etc), or supports ``PIPE_BIND_CONST_BW`` to disable data-dependent 
layouts on requested resources.
+* ``PIPE_CAP_PERFORMANCE_MONITOR``: Whether GL_AMD_performance_monitor should 
be exposed.
+
 
 .. _pipe_capf:
 
diff --git a/src/gallium/auxiliary/util/u_screen.c 
b/src/gallium/auxiliary/util/u_screen.c
index 66efbddf04c..df9a7c0ab7f 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -550,6 +550,10 @@ u_pipe_screen_get_param_defaults(struct pipe_screen 
*pscreen,
    case PIPE_CAP_HAS_CONST_BW:
       return 0;
 
+   case PIPE_CAP_PERFORMANCE_MONITOR:
+      return pscreen->get_driver_query_info && 
pscreen->get_driver_query_group_info &&
+             pscreen->get_driver_query_group_info(pscreen, 0, NULL) != 0;
+
    default:
       unreachable("bad PIPE_CAP_*");
    }
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 9ea8dcc49ae..27056cf2281 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -934,6 +934,7 @@ enum pipe_cap
    PIPE_CAP_ASTC_VOID_EXTENTS_NEED_DENORM_FLUSH,
    PIPE_CAP_VALIDATE_ALL_DIRTY_STATES,
    PIPE_CAP_HAS_CONST_BW,
+   PIPE_CAP_PERFORMANCE_MONITOR,
    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 4f16fe9bcff..2d7b8279aa4 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -431,17 +431,6 @@ st_init_driver_flags(struct st_context *st)
       f->NewAtomicBuffer |= ST_NEW_CONSTANTS;
 }
 
-static bool
-st_have_perfmon(struct st_context *st)
-{
-   struct pipe_screen *screen = st->screen;
-
-   if (!screen->get_driver_query_info || !screen->get_driver_query_group_info)
-      return false;
-
-   return screen->get_driver_query_group_info(screen, 0, NULL) != 0;
-}
-
 static bool
 st_have_perfquery(struct st_context *ctx)
 {
@@ -663,10 +652,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
    st_init_extensions(screen, &ctx->Const,
                       &ctx->Extensions, &st->options, ctx->API);
 
-   if (st_have_perfmon(st)) {
-      ctx->Extensions.AMD_performance_monitor = GL_TRUE;
-   }
-
    if (st_have_perfquery(st)) {
       ctx->Extensions.INTEL_performance_query = GL_TRUE;
    }
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 0abc9a7ca88..b0521fafcf7 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -846,6 +846,7 @@ void st_init_extensions(struct pipe_screen *screen,
 
       { o(AMD_depth_clamp_separate),         
PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE      },
       { o(AMD_framebuffer_multisample_advanced), 
PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS },
+      { o(AMD_performance_monitor),          PIPE_CAP_PERFORMANCE_MONITOR      
        },
       { o(AMD_pinned_memory),                
PIPE_CAP_RESOURCE_FROM_USER_MEMORY        },
       { o(ATI_meminfo),                      PIPE_CAP_QUERY_MEMORY_INFO        
        },
       { o(AMD_seamless_cubemap_per_texture), 
PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE    },

Reply via email to