1
0
Fork 0

cogl/context: Add test util function to get the GL/GLES driver vendor

Some tests sadly behaves differently depending on the driver in use.
While this shouldn't happen we can't block on these driver issues, so
add a test utils private function to get the driver information so that
we can adapt test behavior depending on this.

This will allow to disable / enable tests at runtime instead of failing
in all the implementations, which is still better for catching
regressions in the parts we may be ignoring otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
This commit is contained in:
Marco Trevisan (Treviño) 2024-06-02 19:28:34 +02:00 committed by Marge Bot
parent 615fe1e703
commit 03ef333937
10 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,37 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) Canonical Ltd.
*
* 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.
*
*
*/
#pragma once
#include "cogl-context.h"
COGL_EXPORT
const char *
_cogl_context_get_driver_vendor (CoglContext *context);

View file

@ -35,6 +35,7 @@
#include "cogl/cogl-profile.h"
#include "cogl/cogl-util.h"
#include "cogl/cogl-context-private.h"
#include "cogl/cogl-context-test-utils.h"
#include "cogl/cogl-display-private.h"
#include "cogl/cogl-renderer-private.h"
#include "cogl/cogl-journal-private.h"
@ -436,6 +437,12 @@ cogl_context_get_renderer (CoglContext *context)
return context->display->renderer;
}
const char *
_cogl_context_get_driver_vendor (CoglContext *context)
{
return context->driver_vtable->get_vendor (context);
}
gboolean
_cogl_context_update_features (CoglContext *context,
GError **error)

View file

@ -47,6 +47,9 @@ struct _CoglDriverVtable
void
(* context_deinit) (CoglContext *context);
const char *
(* get_vendor) (CoglContext *context);
gboolean
(* is_hardware_accelerated) (CoglContext *context);

View file

@ -132,6 +132,9 @@ _cogl_context_get_gl_extensions (CoglContext *context);
const char *
_cogl_context_get_gl_version (CoglContext *context);
const char *
_cogl_context_get_gl_vendor (CoglContext *context);
/* Parses a GL version number stored in a string. @version_string must
* point to the beginning of the version number (ie, it can't point to
* the "OpenGL ES" part on GLES). The version number can be followed

View file

@ -415,6 +415,12 @@ _cogl_context_get_gl_version (CoglContext *context)
}
const char *
_cogl_context_get_gl_vendor (CoglContext *context)
{
return (const char *) context->glGetString (GL_VENDOR);
}
gboolean
_cogl_gl_util_parse_gl_version (const char *version_string,
int *major_out,

View file

@ -563,6 +563,7 @@ _cogl_driver_gl =
{
_cogl_driver_gl_real_context_init,
_cogl_driver_gl_context_deinit,
_cogl_context_get_gl_vendor,
_cogl_driver_gl_is_hardware_accelerated,
_cogl_gl_get_graphics_reset_status,
_cogl_driver_pixel_format_to_gl,

View file

@ -768,6 +768,7 @@ _cogl_driver_gles =
{
_cogl_driver_gl_context_init,
_cogl_driver_gl_context_deinit,
_cogl_context_get_gl_vendor,
_cogl_driver_gl_is_hardware_accelerated,
_cogl_gl_get_graphics_reset_status,
_cogl_driver_pixel_format_to_gl,

View file

@ -67,6 +67,12 @@ _cogl_driver_nop_is_hardware_accelerated (CoglContext *context)
return FALSE;
}
static const char *
_cogl_driver_nop_get_renderer (CoglContext *context)
{
return "NOP";
}
static CoglFramebufferDriver *
_cogl_driver_nop_create_framebuffer_driver (CoglContext *context,
CoglFramebuffer *framebuffer,
@ -91,6 +97,7 @@ _cogl_driver_nop =
{
_cogl_driver_nop_context_init,
_cogl_driver_nop_context_deinit,
_cogl_driver_nop_get_renderer,
_cogl_driver_nop_is_hardware_accelerated,
NULL, /* get_graphics_reset_status */
NULL, /* pixel_format_to_gl */

View file

@ -21,6 +21,7 @@
#include "tests/cogl-test-utils.h"
#include "backends/meta-backend-private.h"
#include "cogl/cogl-context-test-utils.h"
static gboolean cogl_test_is_verbose;
CoglContext *test_ctx;
@ -370,6 +371,12 @@ on_before_tests (MetaContext *context)
0, 0, 0, 1);
}
const char *
test_utils_get_cogl_driver_vendor (CoglContext *context)
{
return _cogl_context_get_driver_vendor (context);
}
static void
on_after_tests (MetaContext *context)
{

View file

@ -295,3 +295,12 @@ test_utils_is_pot (unsigned int number)
/* Make sure there is only one bit set */
return (number & (number - 1)) == 0;
}
/*
* test_utils_get_cogl_gl3_vendor:
* @context: A #CoglContext
*
* Gets the GL driver vendor name or %NULL if gl driver is not in use.
*/
const char *
test_utils_get_cogl_driver_vendor (CoglContext *context);