cogl: Create a common GL driver
Both the GL3 & GLES2 inherit from it to avoid overriding the same vfuncs multiple times. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4132>
This commit is contained in:
parent
2e36f80914
commit
71381c2e7f
44
cogl/cogl/driver/gl/cogl-driver-gl-private.h
Normal file
44
cogl/cogl/driver/gl/cogl-driver-gl-private.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Cogl
|
||||||
|
*
|
||||||
|
* A Low Level GPU Graphics and Utilities API
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 Red Hat.
|
||||||
|
*
|
||||||
|
* 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/cogl-driver-private.h"
|
||||||
|
|
||||||
|
struct _CoglDriverGLClass
|
||||||
|
{
|
||||||
|
CoglDriverClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (CoglDriverGL,
|
||||||
|
cogl_driver_gl,
|
||||||
|
COGL,
|
||||||
|
DRIVER_GL,
|
||||||
|
CoglDriver);
|
||||||
|
|
||||||
|
#define COGL_TYPE_DRIVER_GL (cogl_driver_gl_get_type ())
|
69
cogl/cogl/driver/gl/cogl-driver-gl.c
Normal file
69
cogl/cogl/driver/gl/cogl-driver-gl.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Cogl
|
||||||
|
*
|
||||||
|
* A Low Level GPU Graphics and Utilities API
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 Red Hat.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cogl/driver/gl/cogl-driver-gl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-pipeline-opengl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-buffer-gl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-clip-stack-gl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-attribute-gl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-texture-2d-gl-private.h"
|
||||||
|
#include "cogl/driver/gl/cogl-util-gl-private.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (CoglDriverGL, cogl_driver_gl, COGL_TYPE_DRIVER);
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_driver_gl_class_init (CoglDriverGLClass *klass)
|
||||||
|
{
|
||||||
|
CoglDriverClass *driver_klass = COGL_DRIVER_CLASS (klass);
|
||||||
|
|
||||||
|
driver_klass->context_deinit = _cogl_driver_gl_context_deinit;
|
||||||
|
driver_klass->get_vendor = _cogl_context_get_gl_vendor;
|
||||||
|
driver_klass->is_hardware_accelerated = _cogl_driver_gl_is_hardware_accelerated;
|
||||||
|
driver_klass->get_graphics_reset_status = _cogl_gl_get_graphics_reset_status;
|
||||||
|
driver_klass->create_framebuffer_driver = _cogl_driver_gl_create_framebuffer_driver;
|
||||||
|
driver_klass->flush_framebuffer_state = _cogl_driver_gl_flush_framebuffer_state;
|
||||||
|
driver_klass->flush_attributes_state = _cogl_gl_flush_attributes_state;
|
||||||
|
driver_klass->clip_stack_flush = _cogl_clip_stack_gl_flush;
|
||||||
|
driver_klass->buffer_create = _cogl_buffer_gl_create;
|
||||||
|
driver_klass->buffer_destroy = _cogl_buffer_gl_destroy;
|
||||||
|
driver_klass->buffer_map_range = _cogl_buffer_gl_map_range;
|
||||||
|
driver_klass->buffer_unmap = _cogl_buffer_gl_unmap;
|
||||||
|
driver_klass->buffer_set_data = _cogl_buffer_gl_set_data;
|
||||||
|
driver_klass->sampler_init = _cogl_sampler_gl_init;
|
||||||
|
driver_klass->sampler_free = _cogl_sampler_gl_free;
|
||||||
|
driver_klass->set_uniform = _cogl_gl_set_uniform; /* XXX name is weird... */
|
||||||
|
driver_klass->create_timestamp_query = cogl_gl_create_timestamp_query;
|
||||||
|
driver_klass->free_timestamp_query = cogl_gl_free_timestamp_query;
|
||||||
|
driver_klass->timestamp_query_get_time_ns = cogl_gl_timestamp_query_get_time_ns;
|
||||||
|
driver_klass->get_gpu_time_ns = cogl_gl_get_gpu_time_ns;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_driver_gl_init (CoglDriverGL *driver)
|
||||||
|
{
|
||||||
|
}
|
@ -33,6 +33,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#include <EGL/eglext.h>
|
||||||
|
|
||||||
#include "cogl/cogl-types.h"
|
#include "cogl/cogl-types.h"
|
||||||
#include "cogl/cogl-context-private.h"
|
#include "cogl/cogl-context-private.h"
|
||||||
#include "cogl/cogl-texture.h"
|
#include "cogl/cogl-texture.h"
|
||||||
|
@ -28,17 +28,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cogl/cogl-driver-private.h"
|
#include "cogl/driver/gl/cogl-driver-gl-private.h"
|
||||||
|
|
||||||
struct _CoglDriverGL3
|
struct _CoglDriverGL3
|
||||||
{
|
{
|
||||||
CoglDriver parent_instance;
|
CoglDriverGL parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CoglDriverGL3,
|
G_DECLARE_FINAL_TYPE (CoglDriverGL3,
|
||||||
cogl_driver_gl3,
|
cogl_driver_gl3,
|
||||||
COGL,
|
COGL,
|
||||||
DRIVER_GL3,
|
DRIVER_GL3,
|
||||||
CoglDriver)
|
CoglDriverGL)
|
||||||
|
|
||||||
#define COGL_TYPE_DRIVER_GL3 (cogl_driver_gl3_get_type ())
|
#define COGL_TYPE_DRIVER_GL3 (cogl_driver_gl3_get_type ())
|
||||||
|
@ -34,18 +34,11 @@
|
|||||||
|
|
||||||
#include "cogl/driver/gl/gl/cogl-driver-gl3-private.h"
|
#include "cogl/driver/gl/gl/cogl-driver-gl3-private.h"
|
||||||
#include "cogl/cogl-private.h"
|
#include "cogl/cogl-private.h"
|
||||||
#include "cogl/cogl-context-private.h"
|
|
||||||
#include "cogl/cogl-feature-private.h"
|
#include "cogl/cogl-feature-private.h"
|
||||||
#include "cogl/cogl-renderer-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-util-gl-private.h"
|
#include "cogl/driver/gl/cogl-util-gl-private.h"
|
||||||
#include "cogl/driver/gl/cogl-framebuffer-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-texture-2d-gl-private.h"
|
#include "cogl/driver/gl/cogl-texture-2d-gl-private.h"
|
||||||
#include "cogl/driver/gl/cogl-attribute-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-clip-stack-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-buffer-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-pipeline-opengl-private.h"
|
|
||||||
|
|
||||||
G_DEFINE_FINAL_TYPE (CoglDriverGL3, cogl_driver_gl3, COGL_TYPE_DRIVER);
|
G_DEFINE_FINAL_TYPE (CoglDriverGL3, cogl_driver_gl3, COGL_TYPE_DRIVER_GL);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
cogl_driver_gl3_context_init (CoglDriver *driver,
|
cogl_driver_gl3_context_init (CoglDriver *driver,
|
||||||
@ -609,29 +602,9 @@ cogl_driver_gl3_class_init (CoglDriverGL3Class *klass)
|
|||||||
CoglDriverClass *driver_klass = COGL_DRIVER_CLASS (klass);
|
CoglDriverClass *driver_klass = COGL_DRIVER_CLASS (klass);
|
||||||
|
|
||||||
driver_klass->context_init = cogl_driver_gl3_context_init;
|
driver_klass->context_init = cogl_driver_gl3_context_init;
|
||||||
driver_klass->context_deinit = _cogl_driver_gl_context_deinit;
|
|
||||||
driver_klass->get_vendor = _cogl_context_get_gl_vendor;
|
|
||||||
driver_klass->is_hardware_accelerated = _cogl_driver_gl_is_hardware_accelerated;
|
|
||||||
driver_klass->get_graphics_reset_status = _cogl_gl_get_graphics_reset_status;
|
|
||||||
driver_klass->pixel_format_to_gl = cogl_driver_gl3_pixel_format_to_gl;
|
driver_klass->pixel_format_to_gl = cogl_driver_gl3_pixel_format_to_gl;
|
||||||
driver_klass->get_read_pixels_format = cogl_driver_gl3_get_read_pixels_format;
|
driver_klass->get_read_pixels_format = cogl_driver_gl3_get_read_pixels_format;
|
||||||
driver_klass->update_features = cogl_driver_gl3_update_features;
|
driver_klass->update_features = cogl_driver_gl3_update_features;
|
||||||
driver_klass->create_framebuffer_driver = _cogl_driver_gl_create_framebuffer_driver;
|
|
||||||
driver_klass->flush_framebuffer_state = _cogl_driver_gl_flush_framebuffer_state;
|
|
||||||
driver_klass->flush_attributes_state = _cogl_gl_flush_attributes_state;
|
|
||||||
driver_klass->clip_stack_flush = _cogl_clip_stack_gl_flush;
|
|
||||||
driver_klass->buffer_create = _cogl_buffer_gl_create;
|
|
||||||
driver_klass->buffer_destroy = _cogl_buffer_gl_destroy;
|
|
||||||
driver_klass->buffer_map_range = _cogl_buffer_gl_map_range;
|
|
||||||
driver_klass->buffer_unmap = _cogl_buffer_gl_unmap;
|
|
||||||
driver_klass->buffer_set_data = _cogl_buffer_gl_set_data;
|
|
||||||
driver_klass->sampler_init = _cogl_sampler_gl_init;
|
|
||||||
driver_klass->sampler_free = _cogl_sampler_gl_free;
|
|
||||||
driver_klass->set_uniform = _cogl_gl_set_uniform; /* XXX name is weird... */
|
|
||||||
driver_klass->create_timestamp_query = cogl_gl_create_timestamp_query;
|
|
||||||
driver_klass->free_timestamp_query = cogl_gl_free_timestamp_query;
|
|
||||||
driver_klass->timestamp_query_get_time_ns = cogl_gl_timestamp_query_get_time_ns;
|
|
||||||
driver_klass->get_gpu_time_ns = cogl_gl_get_gpu_time_ns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -28,17 +28,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cogl/cogl-driver-private.h"
|
#include "cogl/driver/gl/cogl-driver-gl-private.h"
|
||||||
|
|
||||||
struct _CoglDriverGLES2
|
struct _CoglDriverGLES2
|
||||||
{
|
{
|
||||||
CoglDriver parent_instance;
|
CoglDriverGL parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CoglDriverGLES2,
|
G_DECLARE_FINAL_TYPE (CoglDriverGLES2,
|
||||||
cogl_driver_gles2,
|
cogl_driver_gles2,
|
||||||
COGL,
|
COGL,
|
||||||
DRIVER_GLES2,
|
DRIVER_GLES2,
|
||||||
CoglDriver)
|
CoglDriverGL)
|
||||||
|
|
||||||
#define COGL_TYPE_DRIVER_GLES2 (cogl_driver_gles2_get_type ())
|
#define COGL_TYPE_DRIVER_GLES2 (cogl_driver_gles2_get_type ())
|
||||||
|
@ -35,15 +35,8 @@
|
|||||||
#include "cogl/driver/gl/gles/cogl-driver-gles2-private.h"
|
#include "cogl/driver/gl/gles/cogl-driver-gles2-private.h"
|
||||||
#include "cogl/cogl-context-private.h"
|
#include "cogl/cogl-context-private.h"
|
||||||
#include "cogl/cogl-feature-private.h"
|
#include "cogl/cogl-feature-private.h"
|
||||||
#include "cogl/cogl-renderer-private.h"
|
|
||||||
#include "cogl/cogl-private.h"
|
#include "cogl/cogl-private.h"
|
||||||
#include "cogl/driver/gl/cogl-util-gl-private.h"
|
#include "cogl/driver/gl/cogl-util-gl-private.h"
|
||||||
#include "cogl/driver/gl/cogl-framebuffer-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-texture-2d-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-attribute-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-clip-stack-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-buffer-gl-private.h"
|
|
||||||
#include "cogl/driver/gl/cogl-pipeline-opengl-private.h"
|
|
||||||
|
|
||||||
#ifndef GL_UNSIGNED_INT_24_8
|
#ifndef GL_UNSIGNED_INT_24_8
|
||||||
#define GL_UNSIGNED_INT_24_8 0x84FA
|
#define GL_UNSIGNED_INT_24_8 0x84FA
|
||||||
@ -100,7 +93,7 @@
|
|||||||
#define GL_RG8 0x822B
|
#define GL_RG8 0x822B
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_DEFINE_FINAL_TYPE (CoglDriverGLES2, cogl_driver_gles2, COGL_TYPE_DRIVER)
|
G_DEFINE_FINAL_TYPE (CoglDriverGLES2, cogl_driver_gles2, COGL_TYPE_DRIVER_GL)
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
cogl_driver_gles2_pixel_format_to_gl (CoglDriver *driver,
|
cogl_driver_gles2_pixel_format_to_gl (CoglDriver *driver,
|
||||||
@ -874,29 +867,9 @@ cogl_driver_gles2_class_init (CoglDriverGLES2Class *klass)
|
|||||||
CoglDriverClass *driver_klass = COGL_DRIVER_CLASS (klass);
|
CoglDriverClass *driver_klass = COGL_DRIVER_CLASS (klass);
|
||||||
|
|
||||||
driver_klass->context_init = _cogl_driver_gl_context_init;
|
driver_klass->context_init = _cogl_driver_gl_context_init;
|
||||||
driver_klass->context_deinit = _cogl_driver_gl_context_deinit;
|
|
||||||
driver_klass->get_vendor = _cogl_context_get_gl_vendor;
|
|
||||||
driver_klass->is_hardware_accelerated = _cogl_driver_gl_is_hardware_accelerated;
|
|
||||||
driver_klass->get_graphics_reset_status = _cogl_gl_get_graphics_reset_status;
|
|
||||||
driver_klass->pixel_format_to_gl = cogl_driver_gles2_pixel_format_to_gl;
|
driver_klass->pixel_format_to_gl = cogl_driver_gles2_pixel_format_to_gl;
|
||||||
driver_klass->get_read_pixels_format = cogl_driver_gles2_get_read_pixels_format;
|
driver_klass->get_read_pixels_format = cogl_driver_gles2_get_read_pixels_format;
|
||||||
driver_klass->update_features = cogl_driver_gles2_update_features;
|
driver_klass->update_features = cogl_driver_gles2_update_features;
|
||||||
driver_klass->create_framebuffer_driver = _cogl_driver_gl_create_framebuffer_driver;
|
|
||||||
driver_klass->flush_framebuffer_state = _cogl_driver_gl_flush_framebuffer_state;
|
|
||||||
driver_klass->flush_attributes_state = _cogl_gl_flush_attributes_state;
|
|
||||||
driver_klass->clip_stack_flush = _cogl_clip_stack_gl_flush;
|
|
||||||
driver_klass->buffer_create = _cogl_buffer_gl_create;
|
|
||||||
driver_klass->buffer_destroy = _cogl_buffer_gl_destroy;
|
|
||||||
driver_klass->buffer_map_range = _cogl_buffer_gl_map_range;
|
|
||||||
driver_klass->buffer_unmap = _cogl_buffer_gl_unmap;
|
|
||||||
driver_klass->buffer_set_data = _cogl_buffer_gl_set_data;
|
|
||||||
driver_klass->sampler_init = _cogl_sampler_gl_init;
|
|
||||||
driver_klass->sampler_free = _cogl_sampler_gl_free;
|
|
||||||
driver_klass->set_uniform = _cogl_gl_set_uniform;
|
|
||||||
driver_klass->create_timestamp_query = cogl_gl_create_timestamp_query;
|
|
||||||
driver_klass->free_timestamp_query = cogl_gl_free_timestamp_query;
|
|
||||||
driver_klass->timestamp_query_get_time_ns = cogl_gl_timestamp_query_get_time_ns;
|
|
||||||
driver_klass->get_gpu_time_ns = cogl_gl_get_gpu_time_ns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -84,6 +84,8 @@ cogl_common_driver_sources = [
|
|||||||
'driver/gl/cogl-buffer-gl.c',
|
'driver/gl/cogl-buffer-gl.c',
|
||||||
'driver/gl/cogl-clip-stack-gl-private.h',
|
'driver/gl/cogl-clip-stack-gl-private.h',
|
||||||
'driver/gl/cogl-clip-stack-gl.c',
|
'driver/gl/cogl-clip-stack-gl.c',
|
||||||
|
'driver/gl/cogl-driver-gl.c',
|
||||||
|
'driver/gl/cogl-driver-gl-private.h',
|
||||||
'driver/gl/cogl-framebuffer-gl-private.h',
|
'driver/gl/cogl-framebuffer-gl-private.h',
|
||||||
'driver/gl/cogl-framebuffer-gl.c',
|
'driver/gl/cogl-framebuffer-gl.c',
|
||||||
'driver/gl/cogl-gl-framebuffer-back.c',
|
'driver/gl/cogl-gl-framebuffer-back.c',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user