From 895ec843d33e48e148cdc978f08dc42a55b08426 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 29 Nov 2022 12:32:29 -0800 Subject: [PATCH] egl: Collapse a bunch of renderer queries into pipe cap queries. Now that we can access the pipe screen through the dri_screen, we can skip some indirection. Reviewed-by: Adam Jackson Acked-by: Eric Engestrom Part-of: --- include/GL/internal/dri_interface.h | 12 --------- src/egl/drivers/dri2/egl_dri2.c | 24 ++++++++++------- .../frontends/dri/dri_query_renderer.c | 27 ------------------- src/gallium/include/pipe/p_defines.h | 2 +- 4 files changed, 15 insertions(+), 50 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 4dafb5879ff..fa0f7432342 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1926,26 +1926,14 @@ typedef struct __DRIconfigOptionsExtensionRec { #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a -#define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b /* Whether there is an sRGB format support for every supported 32-bit UNORM * color format. */ #define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c -/* Bitmaks of supported/available context priorities - must match - * __EGL_CONTEXT_PRIORITY_LOW_BIT et al - */ -#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d -#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0) -#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1) -#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2) - -#define __DRI2_RENDERER_HAS_PROTECTED_SURFACE 0x000e #define __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE 0x000f #define __DRI2_RENDERER_HAS_NO_ERROR_CONTEXT 0x0010 -#define __DRI2_RENDERER_HAS_PROTECTED_CONTEXT 0x0020 - typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension; struct __DRI2rendererQueryExtensionRec { __DRIextension base; diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index fb1aa9689f7..55e0642ef5c 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -72,6 +72,7 @@ #include "util/bitscan.h" #include "util/driconf.h" #include "util/u_math.h" +#include "pipe/p_screen.h" #define NUM_ATTRIBS 12 @@ -835,6 +836,13 @@ dri2_query_driver_config(_EGLDisplay *disp) return ret; } +static int +get_screen_param(_EGLDisplay *disp, enum pipe_cap param) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri_screen *screen = dri_screen(dri2_dpy->dri_screen); + return screen->base.screen->get_param(screen->base.screen, param); +} void dri2_setup_screen(_EGLDisplay *disp) @@ -875,9 +883,7 @@ dri2_setup_screen(_EGLDisplay *disp) } /* Report back to EGL the bitmask of priorities supported */ - disp->Extensions.IMG_context_priority = - dri2_renderer_query_integer(dri2_dpy, - __DRI2_RENDERER_HAS_CONTEXT_PRIORITY); + disp->Extensions.IMG_context_priority = get_screen_param(disp, PIPE_CAP_CONTEXT_PRIORITY_MASK); disp->Extensions.EXT_pixel_format_float = EGL_TRUE; @@ -929,9 +935,9 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE; disp->Extensions.KHR_gl_texture_cubemap_image = EGL_TRUE; - if (dri2_renderer_query_integer(dri2_dpy, - __DRI2_RENDERER_HAS_TEXTURE_3D)) - disp->Extensions.KHR_gl_texture_3D_image = EGL_TRUE; + if (get_screen_param(disp, PIPE_CAP_MAX_TEXTURE_3D_LEVELS) != 0) + disp->Extensions.KHR_gl_texture_3D_image = EGL_TRUE; + #ifdef HAVE_LIBDRM if (dri2_dpy->image->base.version >= 8 && dri2_dpy->image->createImageFromDmaBufs) { @@ -948,11 +954,9 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.KHR_partial_update = EGL_TRUE; disp->Extensions.EXT_protected_surface = - dri2_renderer_query_integer(dri2_dpy, - __DRI2_RENDERER_HAS_PROTECTED_SURFACE); + get_screen_param(disp, PIPE_CAP_DEVICE_PROTECTED_SURFACE) != 0; disp->Extensions.EXT_protected_content = - dri2_renderer_query_integer(dri2_dpy, - __DRI2_RENDERER_HAS_PROTECTED_CONTEXT); + get_screen_param(disp, PIPE_CAP_DEVICE_PROTECTED_CONTEXT) != 0; } void diff --git a/src/gallium/frontends/dri/dri_query_renderer.c b/src/gallium/frontends/dri/dri_query_renderer.c index 9d6ee4356db..7a9bce33a91 100644 --- a/src/gallium/frontends/dri/dri_query_renderer.c +++ b/src/gallium/frontends/dri/dri_query_renderer.c @@ -118,12 +118,6 @@ dri2_query_renderer_integer(__DRIscreen *_screen, int param, PIPE_CAP_UMA); return 0; - case __DRI2_RENDERER_HAS_TEXTURE_3D: - value[0] = - screen->base.screen->get_param(screen->base.screen, - PIPE_CAP_MAX_TEXTURE_3D_LEVELS) != 0; - return 0; - case __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB: value[0] = screen->base.screen->is_format_supported(screen->base.screen, @@ -131,32 +125,11 @@ dri2_query_renderer_integer(__DRIscreen *_screen, int param, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_RENDER_TARGET); return 0; - case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY: - value[0] = - screen->base.screen->get_param(screen->base.screen, - PIPE_CAP_CONTEXT_PRIORITY_MASK); - if (!value[0]) - return -1; - return 0; - case __DRI2_RENDERER_HAS_PROTECTED_SURFACE: - value[0] = - screen->base.screen->get_param(screen->base.screen, - PIPE_CAP_DEVICE_PROTECTED_SURFACE); - if (!value[0]) - return -1; - return 0; case __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE: value[0] = screen->base.screen->get_param(screen->base.screen, PIPE_CAP_PREFER_BACK_BUFFER_REUSE); return 0; - case __DRI2_RENDERER_HAS_PROTECTED_CONTEXT: - value[0] = - screen->base.screen->get_param(screen->base.screen, - PIPE_CAP_DEVICE_PROTECTED_CONTEXT); - if (!value[0]) - return -1; - return 0; default: return driQueryRendererIntegerCommon(screen, param, value); } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 76d01dd25e2..b97b546e555 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -1028,7 +1028,7 @@ enum pipe_texture_transfer_mode { * return a bitmask of the supported priorities. If the driver does not * support prioritized contexts, it can return 0. * - * Note that these match __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_* + * Note that these match __EGL_CONTEXT_PRIORITY_*_BIT. */ #define PIPE_CONTEXT_PRIORITY_LOW (1 << 0) #define PIPE_CONTEXT_PRIORITY_MEDIUM (1 << 1)