2008-04-25 09:37:36 -04:00
|
|
|
/*
|
2009-04-27 10:48:12 -04:00
|
|
|
* Cogl
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2013-05-14 08:39:48 -04:00
|
|
|
* Copyright (C) 2007,2008,2009,2013 Intel Corporation.
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* 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:
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* 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.
|
2010-03-01 07:56:10 -05:00
|
|
|
*
|
|
|
|
*
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
|
|
|
|
2023-11-07 05:56:00 -05:00
|
|
|
#include "config.h"
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2023-08-07 09:38:12 -04:00
|
|
|
#include "cogl/cogl-mutter.h"
|
|
|
|
#include "cogl/cogl-private.h"
|
|
|
|
#include "cogl/cogl-profile.h"
|
|
|
|
#include "cogl/cogl-util.h"
|
|
|
|
#include "cogl/cogl-context-private.h"
|
|
|
|
#include "cogl/cogl-display-private.h"
|
|
|
|
#include "cogl/cogl-renderer-private.h"
|
|
|
|
#include "cogl/cogl-journal-private.h"
|
|
|
|
#include "cogl/cogl-texture-private.h"
|
|
|
|
#include "cogl/cogl-texture-2d-private.h"
|
|
|
|
#include "cogl/cogl-pipeline-private.h"
|
|
|
|
#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"
|
2014-01-01 22:33:03 -05:00
|
|
|
|
2021-09-07 11:23:40 -04:00
|
|
|
#include <gio/gio.h>
|
2009-01-26 06:07:35 -05:00
|
|
|
#include <string.h>
|
2012-10-02 06:44:00 -04:00
|
|
|
#include <stdlib.h>
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2023-08-17 06:08:32 -04:00
|
|
|
G_DEFINE_TYPE (CoglContext, cogl_context, G_TYPE_OBJECT);
|
2010-11-04 20:00:25 -04:00
|
|
|
|
2010-11-24 13:37:47 -05:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *
|
|
|
|
_cogl_context_get_winsys (CoglContext *context)
|
|
|
|
{
|
|
|
|
return context->display->renderer->winsys_vtable;
|
|
|
|
}
|
|
|
|
|
2019-10-18 16:44:43 -04:00
|
|
|
static const CoglDriverVtable *
|
|
|
|
_cogl_context_get_driver (CoglContext *context)
|
|
|
|
{
|
|
|
|
return context->driver_vtable;
|
|
|
|
}
|
|
|
|
|
2023-08-17 06:08:32 -04:00
|
|
|
static void
|
|
|
|
cogl_context_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_CONTEXT (object);
|
|
|
|
const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
|
|
|
|
const CoglDriverVtable *driver = _cogl_context_get_driver (context);
|
|
|
|
|
|
|
|
winsys->context_deinit (context);
|
|
|
|
|
|
|
|
if (context->default_gl_texture_2d_tex)
|
2023-09-18 10:58:36 -04:00
|
|
|
g_object_unref (context->default_gl_texture_2d_tex);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->opaque_color_pipeline)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->opaque_color_pipeline);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->blit_texture_pipeline)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->blit_texture_pipeline);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->swap_callback_closures)
|
|
|
|
g_hash_table_destroy (context->swap_callback_closures);
|
|
|
|
|
|
|
|
if (context->journal_flush_attributes_array)
|
|
|
|
g_array_free (context->journal_flush_attributes_array, TRUE);
|
|
|
|
if (context->journal_clip_bounds)
|
|
|
|
g_array_free (context->journal_clip_bounds, TRUE);
|
|
|
|
|
|
|
|
if (context->rectangle_byte_indices)
|
2023-08-18 03:52:51 -04:00
|
|
|
g_object_unref (context->rectangle_byte_indices);
|
2023-08-17 06:08:32 -04:00
|
|
|
if (context->rectangle_short_indices)
|
2023-08-18 03:52:51 -04:00
|
|
|
g_object_unref (context->rectangle_short_indices);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->default_pipeline)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->default_pipeline);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->dummy_layer_dependant)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->dummy_layer_dependant);
|
2023-08-17 06:08:32 -04:00
|
|
|
if (context->default_layer_n)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->default_layer_n);
|
2023-08-17 06:08:32 -04:00
|
|
|
if (context->default_layer_0)
|
2023-09-19 05:16:43 -04:00
|
|
|
g_object_unref (context->default_layer_0);
|
2023-08-17 06:08:32 -04:00
|
|
|
|
|
|
|
if (context->current_clip_stack_valid)
|
|
|
|
_cogl_clip_stack_unref (context->current_clip_stack);
|
|
|
|
|
|
|
|
g_slist_free (context->atlases);
|
|
|
|
g_hook_list_clear (&context->atlas_reorganize_callbacks);
|
|
|
|
|
|
|
|
_cogl_bitmask_destroy (&context->enabled_custom_attributes);
|
|
|
|
_cogl_bitmask_destroy (&context->enable_custom_attributes_tmp);
|
|
|
|
_cogl_bitmask_destroy (&context->changed_bits_tmp);
|
|
|
|
|
|
|
|
if (context->current_modelview_entry)
|
|
|
|
cogl_matrix_entry_unref (context->current_modelview_entry);
|
|
|
|
if (context->current_projection_entry)
|
|
|
|
cogl_matrix_entry_unref (context->current_projection_entry);
|
|
|
|
|
|
|
|
_cogl_pipeline_cache_free (context->pipeline_cache);
|
|
|
|
|
|
|
|
_cogl_sampler_cache_free (context->sampler_cache);
|
|
|
|
|
|
|
|
g_ptr_array_free (context->uniform_names, TRUE);
|
|
|
|
g_hash_table_destroy (context->uniform_name_hash);
|
|
|
|
|
|
|
|
g_hash_table_destroy (context->attribute_name_states_hash);
|
|
|
|
g_array_free (context->attribute_name_index_map, TRUE);
|
|
|
|
|
|
|
|
g_byte_array_free (context->buffer_map_fallback_array, TRUE);
|
|
|
|
|
|
|
|
driver->context_deinit (context);
|
|
|
|
|
|
|
|
g_object_unref (context->display);
|
|
|
|
|
|
|
|
g_hash_table_remove_all (context->named_pipelines);
|
|
|
|
g_hash_table_destroy (context->named_pipelines);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cogl_context_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cogl_context_init (CoglContext *info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cogl_context_class_init (CoglContextClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->dispose = cogl_context_dispose;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void
|
|
|
|
_cogl_create_context_driver (CoglContext *context);
|
|
|
|
|
|
|
|
static CoglContext *_cogl_context = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_init_feature_overrides (CoglContext *ctx)
|
|
|
|
{
|
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PBOS)))
|
|
|
|
COGL_FLAGS_SET (ctx->private_features, COGL_PRIVATE_FEATURE_PBOS, FALSE);
|
|
|
|
}
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
/* For reference: There was some deliberation over whether to have a
|
|
|
|
* constructor that could throw an exception but looking at standard
|
|
|
|
* practices with several high level OO languages including python, C++,
|
|
|
|
* C# Java and Ruby they all support exceptions in constructors and the
|
|
|
|
* general consensus appears to be that throwing an exception is neater
|
|
|
|
* than successfully constructing with an internal error status that
|
|
|
|
* would then have to be explicitly checked via some form of ::is_ok()
|
|
|
|
* method.
|
2010-11-04 20:00:25 -04:00
|
|
|
*/
|
|
|
|
CoglContext *
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
cogl_context_new (CoglDisplay *display,
|
2019-06-18 02:02:10 -04:00
|
|
|
GError **error)
|
2008-04-25 09:37:36 -04:00
|
|
|
{
|
2010-11-04 20:00:25 -04:00
|
|
|
CoglContext *context;
|
2013-06-23 11:18:18 -04:00
|
|
|
uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys;
|
2010-07-05 18:24:34 -04:00
|
|
|
int i;
|
2021-09-07 11:23:40 -04:00
|
|
|
GError *local_error = NULL;
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2011-06-14 17:33:44 -04:00
|
|
|
_cogl_init ();
|
|
|
|
|
2011-06-13 05:30:49 -04:00
|
|
|
#ifdef COGL_ENABLE_PROFILE
|
2010-08-16 16:11:42 -04:00
|
|
|
/* We need to be absolutely sure that uprof has been initialized
|
|
|
|
* before calling _cogl_uprof_init. uprof_init (NULL, NULL)
|
|
|
|
* will be a NOP if it has been initialized but it will also
|
|
|
|
* mean subsequent parsing of the UProf GOptionGroup will have no
|
|
|
|
* affect.
|
|
|
|
*
|
|
|
|
* Sadly GOptionGroup based library initialization is extremely
|
|
|
|
* fragile by design because GOptionGroups have no notion of
|
|
|
|
* dependencies and so the order things are initialized isn't
|
|
|
|
* currently under tight control.
|
|
|
|
*/
|
|
|
|
uprof_init (NULL, NULL);
|
|
|
|
_cogl_uprof_init ();
|
|
|
|
#endif
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Allocate context memory */
|
2023-08-17 06:08:32 -04:00
|
|
|
context = g_object_new (COGL_TYPE_CONTEXT, NULL);
|
2012-03-13 10:46:18 -04:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
/* XXX: Gross hack!
|
|
|
|
* Currently everything in Cogl just assumes there is a default
|
|
|
|
* context which it can access via _COGL_GET_CONTEXT() including
|
|
|
|
* code used to construct a CoglContext. Until all of that code
|
|
|
|
* has been updated to take an explicit context argument we have
|
2010-11-05 08:28:33 -04:00
|
|
|
* to immediately make our pointer the default context.
|
2010-11-04 20:00:25 -04:00
|
|
|
*/
|
2012-09-10 05:42:03 -04:00
|
|
|
_cogl_context = context;
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Init default values */
|
2011-10-12 17:31:12 -04:00
|
|
|
memset (context->features, 0, sizeof (context->features));
|
2013-11-25 11:11:36 -05:00
|
|
|
memset (context->private_features, 0, sizeof (context->private_features));
|
2011-04-15 10:39:14 -04:00
|
|
|
memset (context->winsys_features, 0, sizeof (context->winsys_features));
|
2010-11-05 08:28:33 -04:00
|
|
|
|
|
|
|
if (!display)
|
2012-04-10 14:21:55 -04:00
|
|
|
{
|
|
|
|
CoglRenderer *renderer = cogl_renderer_new ();
|
|
|
|
if (!cogl_renderer_connect (renderer, error))
|
|
|
|
{
|
2023-08-21 06:31:27 -04:00
|
|
|
g_object_unref (renderer);
|
2023-08-17 06:08:32 -04:00
|
|
|
g_object_unref (context);
|
2012-04-10 14:21:55 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
display = cogl_display_new (renderer, NULL);
|
2023-08-21 06:31:27 -04:00
|
|
|
g_object_unref (renderer);
|
2012-04-10 14:21:55 -04:00
|
|
|
}
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
else
|
2023-08-17 05:40:09 -04:00
|
|
|
g_object_ref (display);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
|
|
|
if (!cogl_display_setup (display, error))
|
|
|
|
{
|
2023-08-17 05:40:09 -04:00
|
|
|
g_object_unref (display);
|
2023-08-17 06:08:32 -04:00
|
|
|
g_object_unref (context);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
context->display = display;
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
/* This is duplicated data, but it's much more convenient to have
|
|
|
|
the driver attached to the context and the value is accessed a
|
|
|
|
lot throughout Cogl */
|
|
|
|
context->driver = display->renderer->driver;
|
|
|
|
|
2012-08-31 19:04:00 -04:00
|
|
|
/* Again this is duplicated data, but it convenient to be able
|
|
|
|
* access these from the context. */
|
|
|
|
context->driver_vtable = display->renderer->driver_vtable;
|
|
|
|
context->texture_driver = display->renderer->texture_driver;
|
2011-07-07 15:44:56 -04:00
|
|
|
|
2013-11-25 11:11:36 -05:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (context->private_features); i++)
|
|
|
|
context->private_features[i] |= display->renderer->private_features[i];
|
2013-05-11 13:15:25 -04:00
|
|
|
|
2012-03-22 12:32:56 -04:00
|
|
|
winsys = _cogl_context_get_winsys (context);
|
|
|
|
if (!winsys->context_init (context, error))
|
|
|
|
{
|
2023-08-17 05:40:09 -04:00
|
|
|
g_object_unref (display);
|
2012-03-22 12:32:56 -04:00
|
|
|
g_free (context);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-03-26 18:04:38 -04:00
|
|
|
if (!context->driver_vtable->context_init (context))
|
2019-10-18 16:44:43 -04:00
|
|
|
{
|
2023-08-17 05:40:09 -04:00
|
|
|
g_object_unref (display);
|
2023-08-17 06:08:32 -04:00
|
|
|
g_object_unref (context);
|
2021-09-07 11:23:40 -04:00
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
|
"Failed to initialize context");
|
2019-10-18 16:44:43 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
context->attribute_name_states_hash =
|
|
|
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
context->attribute_name_index_map = NULL;
|
|
|
|
context->n_attribute_names = 0;
|
|
|
|
|
|
|
|
/* The "cogl_color_in" attribute needs a deterministic name_index
|
|
|
|
* so we make sure it's the first attribute name we register */
|
|
|
|
_cogl_attribute_register_attribute_name (context, "cogl_color_in");
|
|
|
|
|
|
|
|
|
2011-11-04 14:26:17 -04:00
|
|
|
context->uniform_names =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
|
|
|
|
context->uniform_name_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
cogl-pipeline: Add support for setting uniform values
This adds the following new public experimental functions to set
uniform values on a CoglPipeline:
void
cogl_pipeline_set_uniform_1f (CoglPipeline *pipeline,
int uniform_location,
float value);
void
cogl_pipeline_set_uniform_1i (CoglPipeline *pipeline,
int uniform_location,
int value);
void
cogl_pipeline_set_uniform_float (CoglPipeline *pipeline,
int uniform_location,
int n_components,
int count,
const float *value);
void
cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
int uniform_location,
int n_components,
int count,
const int *value);
void
cogl_pipeline_set_uniform_matrix (CoglPipeline *pipeline,
int uniform_location,
int dimensions,
int count,
gboolean transpose,
const float *value);
These are similar to the old functions used to set uniforms on a
CoglProgram. To get a value to pass in as the uniform_location there
is also:
int
cogl_pipeline_get_uniform_location (CoglPipeline *pipeline,
const char *uniform_name);
Conceptually the uniform locations are tied to the pipeline so that
whenever setting a value for a new pipeline the application is
expected to call this function. However in practice the uniform
locations are global to the CoglContext. The names are stored in a
linked list where the position in the list is the uniform location.
The global indices are used so that each pipeline can store a mask of
which uniforms it overrides. That way it is quicker to detect which
uniforms are different from the last pipeline that used the same
CoglProgramState so it can avoid flushing uniforms that haven't
changed. Currently the values are not actually compared which means
that it will only avoid flushing a uniform if there is a common
ancestor that sets the value (or if the same pipeline is being flushed
again - in which case the pipeline and its common ancestor are the
same thing).
The uniform values are stored in the big state of the pipeline as a
sparse linked list. A bitmask stores which values have been overridden
and only overridden values are stored in the linked list.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-03 13:20:43 -04:00
|
|
|
context->n_uniform_names = 0;
|
|
|
|
|
2009-10-22 07:35:33 -04:00
|
|
|
/* Initialise the driver specific state */
|
2010-11-04 20:34:37 -04:00
|
|
|
_cogl_init_feature_overrides (context);
|
2009-10-22 07:35:33 -04:00
|
|
|
|
2012-09-10 05:42:03 -04:00
|
|
|
context->sampler_cache = _cogl_sampler_cache_new (context);
|
2012-04-04 17:20:04 -04:00
|
|
|
|
2023-10-30 06:24:03 -04:00
|
|
|
_cogl_pipeline_init_default_pipeline (context);
|
|
|
|
_cogl_pipeline_init_default_layers (context);
|
2010-11-04 09:57:36 -04:00
|
|
|
_cogl_pipeline_init_state_hash_functions ();
|
|
|
|
_cogl_pipeline_init_layer_state_hash_functions ();
|
2009-11-11 07:50:48 -05:00
|
|
|
|
2011-07-12 00:37:09 -04:00
|
|
|
context->current_clip_stack_valid = FALSE;
|
|
|
|
context->current_clip_stack = NULL;
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2020-09-11 17:45:25 -04:00
|
|
|
graphene_matrix_init_identity (&context->identity_matrix);
|
|
|
|
graphene_matrix_init_identity (&context->y_flip_matrix);
|
|
|
|
graphene_matrix_scale (&context->y_flip_matrix, 1, -1, 1);
|
2009-10-22 11:13:01 -04:00
|
|
|
|
2012-02-18 11:03:10 -05:00
|
|
|
context->opaque_color_pipeline = cogl_pipeline_new (context);
|
2019-11-22 10:49:07 -05:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->codegen_header_buffer = g_string_new ("");
|
|
|
|
context->codegen_source_buffer = g_string_new ("");
|
2013-01-19 11:00:33 -05:00
|
|
|
context->codegen_boilerplate_buffer = g_string_new ("");
|
2008-12-04 08:45:09 -05:00
|
|
|
|
2011-08-24 16:30:34 -04:00
|
|
|
context->default_gl_texture_2d_tex = NULL;
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->framebuffers = NULL;
|
2011-11-21 10:53:40 -05:00
|
|
|
context->current_draw_buffer = NULL;
|
|
|
|
context->current_read_buffer = NULL;
|
|
|
|
context->current_draw_buffer_state_flushed = 0;
|
|
|
|
context->current_draw_buffer_changes = COGL_FRAMEBUFFER_STATE_ALL;
|
2011-01-21 12:28:34 -05:00
|
|
|
|
2012-11-12 11:58:10 -05:00
|
|
|
context->swap_callback_closures =
|
|
|
|
g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
2013-06-08 18:03:25 -04:00
|
|
|
_cogl_list_init (&context->onscreen_events_queue);
|
|
|
|
_cogl_list_init (&context->onscreen_dirty_queue);
|
2012-11-12 11:58:10 -05:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->journal_flush_attributes_array =
|
2011-01-20 14:31:53 -05:00
|
|
|
g_array_new (TRUE, FALSE, sizeof (CoglAttribute *));
|
2010-11-04 20:00:25 -04:00
|
|
|
context->journal_clip_bounds = NULL;
|
2008-12-09 10:10:33 -05:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->current_pipeline = NULL;
|
|
|
|
context->current_pipeline_changes_since_flush = 0;
|
2013-05-16 10:19:30 -04:00
|
|
|
context->current_pipeline_with_color_attrib = FALSE;
|
2010-04-26 05:01:43 -04:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_init (&context->enabled_custom_attributes);
|
|
|
|
_cogl_bitmask_init (&context->enable_custom_attributes_tmp);
|
|
|
|
_cogl_bitmask_init (&context->changed_bits_tmp);
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->max_texture_units = -1;
|
|
|
|
context->max_activateable_texture_units = -1;
|
2010-04-26 05:01:43 -04:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->current_gl_program = 0;
|
2010-04-26 05:01:43 -04:00
|
|
|
|
2011-07-13 11:33:25 -04:00
|
|
|
context->current_gl_dither_enabled = TRUE;
|
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->gl_blend_enable_cache = FALSE;
|
2010-04-08 07:21:04 -04:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->depth_test_enabled_cache = FALSE;
|
|
|
|
context->depth_test_function_cache = COGL_DEPTH_TEST_FUNCTION_LESS;
|
|
|
|
context->depth_writing_enabled_cache = TRUE;
|
|
|
|
context->depth_range_near_cache = 0;
|
|
|
|
context->depth_range_far_cache = 1;
|
2010-05-26 06:33:32 -04:00
|
|
|
|
2023-10-30 06:24:03 -04:00
|
|
|
context->pipeline_cache = _cogl_pipeline_cache_new (context);
|
2010-12-03 07:01:18 -05:00
|
|
|
|
2010-07-05 18:24:34 -04:00
|
|
|
for (i = 0; i < COGL_BUFFER_BIND_TARGET_COUNT; i++)
|
2010-11-04 20:00:25 -04:00
|
|
|
context->current_buffer[i] = NULL;
|
2010-07-05 18:24:34 -04:00
|
|
|
|
2012-02-18 11:03:10 -05:00
|
|
|
context->stencil_pipeline = cogl_pipeline_new (context);
|
2008-05-27 13:42:50 -04:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->rectangle_byte_indices = NULL;
|
|
|
|
context->rectangle_short_indices = NULL;
|
|
|
|
context->rectangle_short_indices_len = 0;
|
2010-10-12 07:48:58 -04:00
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
context->blit_texture_pipeline = NULL;
|
2009-08-30 06:36:11 -04:00
|
|
|
|
2012-09-10 05:42:03 -04:00
|
|
|
context->current_modelview_entry = NULL;
|
|
|
|
context->current_projection_entry = NULL;
|
|
|
|
_cogl_matrix_entry_identity_init (&context->identity_entry);
|
2010-12-06 07:31:51 -05:00
|
|
|
|
2009-01-26 06:07:35 -05:00
|
|
|
/* Create default textures used for fall backs */
|
2010-11-04 20:00:25 -04:00
|
|
|
context->default_gl_texture_2d_tex =
|
2013-06-23 11:18:18 -04:00
|
|
|
cogl_texture_2d_new_from_data (context,
|
|
|
|
1, 1,
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
|
|
0, /* rowstride */
|
|
|
|
white_pixel,
|
2021-09-07 11:23:40 -04:00
|
|
|
&local_error);
|
|
|
|
if (!context->default_gl_texture_2d_tex)
|
|
|
|
{
|
2023-08-17 05:40:09 -04:00
|
|
|
g_object_unref (display);
|
2021-09-07 11:23:40 -04:00
|
|
|
g_free (context);
|
|
|
|
g_propagate_prefixed_error (error, local_error,
|
|
|
|
"Failed to create 1x1 fallback texture: ");
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-31 14:28:27 -04:00
|
|
|
|
2010-11-04 20:00:25 -04:00
|
|
|
context->atlases = NULL;
|
2011-03-30 07:53:50 -04:00
|
|
|
g_hook_list_init (&context->atlas_reorganize_callbacks, sizeof (GHook));
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2012-09-10 05:42:03 -04:00
|
|
|
context->buffer_map_fallback_array = g_byte_array_new ();
|
|
|
|
context->buffer_map_fallback_in_use = FALSE;
|
2011-01-13 10:35:30 -05:00
|
|
|
|
2013-06-08 18:03:25 -04:00
|
|
|
_cogl_list_init (&context->fences);
|
2013-01-10 20:13:34 -05:00
|
|
|
|
2020-08-10 08:24:58 -04:00
|
|
|
context->named_pipelines =
|
2023-09-19 05:16:43 -04:00
|
|
|
g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
|
2020-08-10 08:24:58 -04:00
|
|
|
|
2012-03-13 10:46:18 -04:00
|
|
|
return context;
|
2008-04-25 09:37:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CoglContext *
|
2010-05-27 07:18:29 -04:00
|
|
|
_cogl_context_get_default (void)
|
2008-04-25 09:37:36 -04:00
|
|
|
{
|
2019-06-18 02:02:10 -04:00
|
|
|
GError *error = NULL;
|
2009-01-26 06:07:35 -05:00
|
|
|
/* Create if doesn't exist yet */
|
2012-09-10 05:42:03 -04:00
|
|
|
if (_cogl_context == NULL)
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
{
|
2012-09-10 05:42:03 -04:00
|
|
|
_cogl_context = cogl_context_new (NULL, &error);
|
|
|
|
if (!_cogl_context)
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
{
|
|
|
|
g_warning ("Failed to create default context: %s",
|
|
|
|
error->message);
|
2019-06-18 02:02:10 -04:00
|
|
|
g_error_free (error);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
}
|
|
|
|
}
|
2009-01-26 06:07:35 -05:00
|
|
|
|
2012-09-10 05:42:03 -04:00
|
|
|
return _cogl_context;
|
2008-04-25 09:37:36 -04:00
|
|
|
}
|
2009-02-24 13:51:25 -05:00
|
|
|
|
2011-08-25 12:39:35 -04:00
|
|
|
CoglDisplay *
|
|
|
|
cogl_context_get_display (CoglContext *context)
|
|
|
|
{
|
|
|
|
return context->display;
|
|
|
|
}
|
|
|
|
|
2013-04-16 18:46:03 -04:00
|
|
|
CoglRenderer *
|
|
|
|
cogl_context_get_renderer (CoglContext *context)
|
|
|
|
{
|
|
|
|
return context->display->renderer;
|
|
|
|
}
|
|
|
|
|
2018-11-24 07:04:47 -05:00
|
|
|
gboolean
|
2011-07-13 13:29:56 -04:00
|
|
|
_cogl_context_update_features (CoglContext *context,
|
2019-06-18 02:02:10 -04:00
|
|
|
GError **error)
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
2012-03-22 12:32:56 -04:00
|
|
|
return context->driver_vtable->update_features (context, error);
|
2011-07-07 15:44:56 -04:00
|
|
|
}
|
2011-11-29 09:21:07 -05:00
|
|
|
|
|
|
|
void
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
_cogl_context_set_current_projection_entry (CoglContext *context,
|
|
|
|
CoglMatrixEntry *entry)
|
2011-11-29 09:21:07 -05:00
|
|
|
{
|
2012-11-20 12:08:43 -05:00
|
|
|
cogl_matrix_entry_ref (entry);
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
if (context->current_projection_entry)
|
2012-11-20 12:08:43 -05:00
|
|
|
cogl_matrix_entry_unref (context->current_projection_entry);
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
context->current_projection_entry = entry;
|
2011-11-29 09:21:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
_cogl_context_set_current_modelview_entry (CoglContext *context,
|
|
|
|
CoglMatrixEntry *entry)
|
2011-11-29 09:21:07 -05:00
|
|
|
{
|
2012-11-20 12:08:43 -05:00
|
|
|
cogl_matrix_entry_ref (entry);
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
if (context->current_modelview_entry)
|
2012-11-20 12:08:43 -05:00
|
|
|
cogl_matrix_entry_unref (context->current_modelview_entry);
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
context->current_modelview_entry = entry;
|
2011-11-29 09:21:07 -05:00
|
|
|
}
|
2012-07-31 11:30:33 -04:00
|
|
|
|
2016-05-29 14:30:36 -04:00
|
|
|
CoglGraphicsResetStatus
|
|
|
|
cogl_get_graphics_reset_status (CoglContext *context)
|
|
|
|
{
|
2020-01-28 15:16:25 -05:00
|
|
|
return context->driver_vtable->get_graphics_reset_status (context);
|
2016-05-29 14:30:36 -04:00
|
|
|
}
|
2020-06-17 18:42:53 -04:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
cogl_context_is_hardware_accelerated (CoglContext *context)
|
|
|
|
{
|
|
|
|
return context->driver_vtable->is_hardware_accelerated (context);
|
|
|
|
}
|
2019-09-19 15:41:55 -04:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
cogl_context_format_supports_upload (CoglContext *ctx,
|
|
|
|
CoglPixelFormat format)
|
|
|
|
{
|
|
|
|
return ctx->texture_driver->format_supports_upload (ctx, format);
|
|
|
|
}
|
2020-08-10 08:24:58 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_context_set_named_pipeline (CoglContext *context,
|
|
|
|
CoglPipelineKey *key,
|
|
|
|
CoglPipeline *pipeline)
|
|
|
|
{
|
|
|
|
if (pipeline)
|
|
|
|
{
|
|
|
|
g_debug ("Adding named pipeline %s", *key);
|
|
|
|
g_hash_table_insert (context->named_pipelines, (gpointer) key, pipeline);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_debug ("Removing named pipeline %s", *key);
|
|
|
|
g_hash_table_remove (context->named_pipelines, (gpointer) key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglPipeline *
|
|
|
|
cogl_context_get_named_pipeline (CoglContext *context,
|
|
|
|
CoglPipelineKey *key)
|
|
|
|
{
|
|
|
|
return g_hash_table_lookup (context->named_pipelines, key);
|
|
|
|
}
|
2021-05-15 06:56:49 -04:00
|
|
|
|
2022-04-05 06:40:12 -04:00
|
|
|
/**
|
|
|
|
* cogl_context_free_timestamp_query:
|
|
|
|
* @context: a #CoglContext object
|
|
|
|
* @query: (transfer full): the #CoglTimestampQuery to free
|
|
|
|
*
|
|
|
|
* Free the #CoglTimestampQuery
|
|
|
|
*/
|
2021-05-15 06:56:49 -04:00
|
|
|
void
|
|
|
|
cogl_context_free_timestamp_query (CoglContext *context,
|
|
|
|
CoglTimestampQuery *query)
|
|
|
|
{
|
|
|
|
context->driver_vtable->free_timestamp_query (context, query);
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
|
|
|
cogl_context_timestamp_query_get_time_ns (CoglContext *context,
|
|
|
|
CoglTimestampQuery *query)
|
|
|
|
{
|
|
|
|
return context->driver_vtable->timestamp_query_get_time_ns (context, query);
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
|
|
|
cogl_context_get_gpu_time_ns (CoglContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (cogl_has_feature (context,
|
2022-01-21 02:25:53 -05:00
|
|
|
COGL_FEATURE_ID_TIMESTAMP_QUERY),
|
2021-05-15 06:56:49 -04:00
|
|
|
0);
|
|
|
|
|
|
|
|
return context->driver_vtable->get_gpu_time_ns (context);
|
|
|
|
}
|