1
0
Fork 0

cogl: Expose Renderer.get_proc_address

Allows to get rid of the cogl_get_proc_address

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3857>
This commit is contained in:
Bilal Elmoussaoui 2024-06-29 16:25:22 +02:00 committed by Marge Bot
parent b3ae934304
commit 9ee1a0fc34
24 changed files with 73 additions and 130 deletions

View file

@ -44,7 +44,6 @@
#include "cogl/cogl-rectangle-map.h"
#include "cogl/cogl-journal-private.h"
#include "cogl/cogl-atlas.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-sub-texture.h"
#include "cogl/driver/gl/cogl-texture-gl-private.h"

View file

@ -41,7 +41,6 @@
#include "cogl/cogl-texture-private.h"
#include "cogl/cogl-texture-2d-private.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl1-context.h"
static const CoglBlitMode *_cogl_blit_default_mode = NULL;

View file

@ -44,7 +44,6 @@
#include "cogl/cogl-private.h"
#include "cogl/cogl-attribute-private.h"
#include "cogl/cogl-primitive-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-offscreen.h"
#include "cogl/cogl-matrix-stack.h"
#include "mtk/mtk.h"

View file

@ -45,7 +45,6 @@
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl-onscreen-private.h"
#include "cogl/cogl-attribute-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/winsys/cogl-winsys-private.h"
#include <gio/gio.h>

View file

@ -35,7 +35,6 @@
#include "cogl/cogl-i18n-private.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl-debug.h"
#include "cogl/cogl1-context.h"
/* XXX: If you add a debug option, please also add an option
* definition to cogl-debug-options.h. This will enable us - for

View file

@ -143,7 +143,7 @@ _cogl_feature_check (CoglRenderer *renderer,
full_function_name = g_strconcat (data->functions[func_num].name,
suffix, NULL);
func = _cogl_renderer_get_proc_address (renderer,
func = cogl_renderer_get_proc_address (renderer,
full_function_name);
g_free (full_function_name);

View file

@ -46,7 +46,6 @@
#include "cogl/cogl-pipeline-state-private.h"
#include "cogl/cogl-primitive-private.h"
#include "cogl/cogl-offscreen.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl-primitives-private.h"
#include "cogl/cogl-trace.h"

View file

@ -43,7 +43,6 @@
#include "cogl/cogl-point-in-poly-private.h"
#include "cogl/cogl-trace.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl1-context.h"
#include <string.h>
#include <gmodule.h>

View file

@ -38,7 +38,6 @@
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl-onscreen-template-private.h"
#include "cogl/cogl-context-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-closure-list-private.h"
#include "cogl/cogl-poll-private.h"

View file

@ -46,7 +46,6 @@
#include "cogl/cogl-profile.h"
#include "cogl/cogl-depth-state-private.h"
#include "cogl/cogl-snippet-private.h"
#include "cogl/cogl1-context.h"
#include <glib.h>
#include <glib/gprintf.h>

View file

@ -40,7 +40,6 @@
#include "cogl/cogl-private.h"
#include "cogl/cogl-meta-texture.h"
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-primitives-private.h"
#include <string.h>

View file

@ -89,7 +89,3 @@ void
_cogl_renderer_remove_native_filter (CoglRenderer *renderer,
CoglNativeFilterFunc func,
void *data);
void *
_cogl_renderer_get_proc_address (CoglRenderer *renderer,
const char *name);

View file

@ -615,7 +615,7 @@ cogl_renderer_get_winsys_id (CoglRenderer *renderer)
}
void *
_cogl_renderer_get_proc_address (CoglRenderer *renderer,
cogl_renderer_get_proc_address (CoglRenderer *renderer,
const char *name)
{
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);

View file

@ -311,4 +311,24 @@ cogl_renderer_is_dma_buf_supported (CoglRenderer *renderer);
COGL_EXPORT void
cogl_renderer_bind_api (CoglRenderer *renderer);
/**
* cogl_renderer_get_proc_address:
* @renderer: A #CoglRenderer.
* @name: the name of the function.
*
* Gets a pointer to a given GL or GL ES extension function. This acts
* as a wrapper around glXGetProcAddress() or whatever is the
* appropriate function for the current backend.
*
* This function should not be used to query core opengl API
* symbols since eglGetProcAddress for example doesn't allow this and
* and may return a junk pointer if you do.
*
* Return value: a pointer to the requested function or %NULL if the
* function is not available.
*/
COGL_EXPORT void *
cogl_renderer_get_proc_address (CoglRenderer *renderer,
const char *name);
G_END_DECLS

View file

@ -53,7 +53,6 @@
#include "cogl/cogl-context-private.h"
#include "cogl/cogl-offscreen-private.h"
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-sub-texture.h"
#include "cogl/cogl-primitive-texture.h"

View file

@ -50,18 +50,9 @@
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl-renderer-private.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-offscreen.h"
#include "cogl/winsys/cogl-winsys-private.h"
GCallback
cogl_get_proc_address (const char* name)
{
_COGL_GET_CONTEXT (ctx, NULL);
return _cogl_renderer_get_proc_address (ctx->display->renderer, name);
}
gboolean
_cogl_check_extension (const char *name, char * const *ext)
{

View file

@ -45,7 +45,6 @@
#include "cogl/cogl-macros.h"
#include "cogl/cogl1-context.h"
#include "cogl/cogl-bitmap.h"
#include "cogl/cogl-color.h"
#include "cogl/cogl-dma-buf-handle.h"

View file

@ -1,66 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*
*/
#pragma once
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#include "cogl/cogl-types.h"
#include "cogl/cogl-texture.h"
#include "cogl/cogl-framebuffer.h"
#include "cogl/cogl-macros.h"
G_BEGIN_DECLS
/* Misc */
/**
* cogl_get_proc_address: (skip)
* @name: the name of the function.
*
* Gets a pointer to a given GL or GL ES extension function. This acts
* as a wrapper around glXGetProcAddress() or whatever is the
* appropriate function for the current backend.
*
* This function should not be used to query core opengl API
* symbols since eglGetProcAddress for example doesn't allow this and
* and may return a junk pointer if you do.
*
* Return value: a pointer to the requested function or %NULL if the
* function is not available.
*/
COGL_EXPORT GCallback
cogl_get_proc_address (const char *name);
G_END_DECLS

View file

@ -429,13 +429,13 @@ _cogl_driver_update_features (CoglContext *ctx,
functions because we need to use them to determine what functions
we can expect */
ctx->glGetString =
(void *) _cogl_renderer_get_proc_address (ctx->display->renderer,
(void *) cogl_renderer_get_proc_address (ctx->display->renderer,
"glGetString");
ctx->glGetStringi =
(void *) _cogl_renderer_get_proc_address (ctx->display->renderer,
(void *) cogl_renderer_get_proc_address (ctx->display->renderer,
"glGetStringi");
ctx->glGetIntegerv =
(void *) _cogl_renderer_get_proc_address (ctx->display->renderer,
(void *) cogl_renderer_get_proc_address (ctx->display->renderer,
"glGetIntegerv");
gl_extensions = _cogl_context_get_gl_extensions (ctx);

View file

@ -578,10 +578,10 @@ _cogl_driver_update_features (CoglContext *context,
function because we need to use it to determine what functions we
can expect */
context->glGetString =
(void *) _cogl_renderer_get_proc_address (context->display->renderer,
(void *) cogl_renderer_get_proc_address (context->display->renderer,
"glGetString");
context->glGetStringi =
(void *) _cogl_renderer_get_proc_address (context->display->renderer,
(void *) cogl_renderer_get_proc_address (context->display->renderer,
"glGetStringi");
gl_extensions = _cogl_context_get_gl_extensions (context);

View file

@ -25,7 +25,6 @@ cogl_headers = [
'cogl-attribute.h',
'cogl-bitmap.h',
'cogl-color.h',
'cogl1-context.h',
'cogl-context.h',
'cogl-depth-state.h',
'cogl-display.h',

View file

@ -133,6 +133,8 @@ meta_compositor_x11_manage (MetaCompositor *compositor,
MetaDisplay *display = meta_compositor_get_display (compositor);
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
MetaX11Display *x11_display = display->x11_display;
Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
int composite_version;
@ -186,7 +188,7 @@ meta_compositor_x11_manage (MetaCompositor *compositor,
*/
XMapWindow (xdisplay, compositor_x11->output);
compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay);
compositor_x11->have_x11_sync_object = meta_sync_ring_init (cogl_context, xdisplay);
return TRUE;
}
@ -332,6 +334,9 @@ maybe_do_sync (MetaCompositor *compositor)
if (compositor_x11->frame_has_updated_xsurfaces)
{
MetaDisplay *display = meta_compositor_get_display (compositor);
MetaBackend *backend = meta_compositor_get_backend (compositor);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
/*
* We need to make sure that any X drawing that happens before the
@ -354,7 +359,7 @@ maybe_do_sync (MetaCompositor *compositor)
* at this point is sufficient to flush the GLX buffers.
*/
if (compositor_x11->have_x11_sync_object)
compositor_x11->have_x11_sync_object = meta_sync_ring_insert_wait ();
compositor_x11->have_x11_sync_object = meta_sync_ring_insert_wait (cogl_context);
else
XSync (display->x11_display->xdisplay, False);
}
@ -379,8 +384,12 @@ on_after_update (ClutterStage *stage,
if (compositor_x11->frame_has_updated_xsurfaces)
{
MetaBackend *backend = meta_compositor_get_backend (compositor);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
if (compositor_x11->have_x11_sync_object)
compositor_x11->have_x11_sync_object = meta_sync_ring_after_frame ();
compositor_x11->have_x11_sync_object = meta_sync_ring_after_frame (cogl_context);
compositor_x11->frame_has_updated_xsurfaces = FALSE;
}

View file

@ -132,10 +132,11 @@ meta_sync_ring_get (void)
}
static gboolean
load_gl_symbol (const char *name,
load_gl_symbol (CoglContext *ctx,
const char *name,
void **func)
{
*func = cogl_get_proc_address (name);
*func = cogl_renderer_get_proc_address (ctx->display->renderer, name);
if (!*func)
{
meta_verbose ("MetaSyncRing: failed to resolve required GL symbol \"%s\"", name);
@ -187,7 +188,7 @@ check_gl_extensions (void)
}
static gboolean
load_required_symbols (void)
load_required_symbols (CoglContext *ctx)
{
static gboolean success = FALSE;
@ -199,11 +200,11 @@ load_required_symbols (void)
* and dynamically loaded libGL at this point.
*/
if (!load_gl_symbol ("glGetString", (void **) &meta_gl_get_string))
if (!load_gl_symbol (ctx, "glGetString", (void **) &meta_gl_get_string))
goto out;
if (!load_gl_symbol ("glGetIntegerv", (void **) &meta_gl_get_integerv))
if (!load_gl_symbol (ctx, "glGetIntegerv", (void **) &meta_gl_get_integerv))
goto out;
if (!load_gl_symbol ("glGetStringi", (void **) &meta_gl_get_stringi))
if (!load_gl_symbol (ctx, "glGetStringi", (void **) &meta_gl_get_stringi))
goto out;
if (!check_gl_extensions ())
@ -212,15 +213,15 @@ load_required_symbols (void)
goto out;
}
if (!load_gl_symbol ("glDeleteSync", (void **) &meta_gl_delete_sync))
if (!load_gl_symbol (ctx, "glDeleteSync", (void **) &meta_gl_delete_sync))
goto out;
if (!load_gl_symbol ("glClientWaitSync", (void **) &meta_gl_client_wait_sync))
if (!load_gl_symbol (ctx, "glClientWaitSync", (void **) &meta_gl_client_wait_sync))
goto out;
if (!load_gl_symbol ("glWaitSync", (void **) &meta_gl_wait_sync))
if (!load_gl_symbol (ctx, "glWaitSync", (void **) &meta_gl_wait_sync))
goto out;
if (!load_gl_symbol ("glImportSyncEXT", (void **) &meta_gl_import_sync))
if (!load_gl_symbol (ctx, "glImportSyncEXT", (void **) &meta_gl_import_sync))
goto out;
if (!load_gl_symbol ("glFenceSync", (void **) &meta_gl_fence_sync))
if (!load_gl_symbol (ctx, "glFenceSync", (void **) &meta_gl_fence_sync))
goto out;
success = TRUE;
@ -405,7 +406,8 @@ meta_sync_free (MetaSync *self)
}
gboolean
meta_sync_ring_init (Display *xdisplay)
meta_sync_ring_init (CoglContext *ctx,
Display *xdisplay)
{
gint major, minor;
guint i;
@ -417,7 +419,7 @@ meta_sync_ring_init (Display *xdisplay)
g_return_val_if_fail (xdisplay != NULL, FALSE);
g_return_val_if_fail (ring->xdisplay == NULL, FALSE);
if (!load_required_symbols ())
if (!load_required_symbols (ctx))
return FALSE;
if (!XSyncQueryExtension (xdisplay, &ring->xsync_event_base, &ring->xsync_error_base) ||
@ -477,7 +479,8 @@ meta_sync_ring_destroy (void)
}
static gboolean
meta_sync_ring_reboot (Display *xdisplay)
meta_sync_ring_reboot (CoglContext *ctx,
Display *xdisplay)
{
MetaSyncRing *ring = meta_sync_ring_get ();
@ -494,11 +497,11 @@ meta_sync_ring_reboot (Display *xdisplay)
return FALSE;
}
return meta_sync_ring_init (xdisplay);
return meta_sync_ring_init (ctx, xdisplay);
}
gboolean
meta_sync_ring_after_frame (void)
meta_sync_ring_after_frame (CoglContext *ctx)
{
MetaSyncRing *ring = meta_sync_ring_get ();
@ -522,7 +525,7 @@ meta_sync_ring_after_frame (void)
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
{
meta_warning ("MetaSyncRing: Timed out waiting for sync object.");
return meta_sync_ring_reboot (ring->xdisplay);
return meta_sync_ring_reboot (ctx, ring->xdisplay);
}
meta_sync_reset (sync_to_reset);
@ -541,7 +544,7 @@ meta_sync_ring_after_frame (void)
}
gboolean
meta_sync_ring_insert_wait (void)
meta_sync_ring_insert_wait (CoglContext *ctx)
{
MetaSyncRing *ring = meta_sync_ring_get ();
MetaSync *sync;
@ -562,7 +565,7 @@ meta_sync_ring_insert_wait (void)
else if (sync->state != META_SYNC_STATE_READY)
{
meta_warning ("MetaSyncRing: Sync object is not ready -- were events handled properly?");
if (!meta_sync_ring_reboot (ring->xdisplay))
if (!meta_sync_ring_reboot (ctx, ring->xdisplay))
return FALSE;
}

View file

@ -3,8 +3,11 @@
#include <glib.h>
#include <X11/Xlib.h>
gboolean meta_sync_ring_init (Display *dpy);
#include "cogl/cogl.h"
gboolean meta_sync_ring_init (CoglContext *ctx,
Display *dpy);
void meta_sync_ring_destroy (void);
gboolean meta_sync_ring_after_frame (void);
gboolean meta_sync_ring_insert_wait (void);
gboolean meta_sync_ring_after_frame (CoglContext *ctx);
gboolean meta_sync_ring_insert_wait (CoglContext *ctx);
void meta_sync_ring_handle_event (XEvent *event);