mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
cogl-framebuffer: Remove swap_throttled config
Since now we don't set the swap throttled value based on sync-to-vblank, we can effectively remove it from Cogl. Throttling swap buffers in Cogl is as much a historical artifact as sync-to-vblank. Furthermore, it doesn't make sense to disable it on a compositor, which is the case with the embedded Cogl. In addition to that, the winsys vfunc for updating whenever swap throttling changes could also be removed, since swap throttling is always enabled now. Removing it means less code, less branches when running, and one less config option to deal with. This also removes the micro-perf test, since it doesn't make sense for the case where Cogl is embedded into the compositor. https://gitlab.gnome.org/GNOME/mutter/merge_requests/191
This commit is contained in:
parent
ae4d3bc27d
commit
7d20101198
@ -631,7 +631,6 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
|
||||
|
||||
stage_x11->onscreen = cogl_onscreen_new (backend->cogl_context, width, height);
|
||||
|
||||
cogl_onscreen_set_swap_throttled (stage_x11->onscreen, TRUE);
|
||||
stage_x11->frame_closure =
|
||||
cogl_onscreen_add_frame_callback (stage_x11->onscreen,
|
||||
frame_cb,
|
||||
|
1
cogl/.gitignore
vendored
1
cogl/.gitignore
vendored
@ -66,7 +66,6 @@ TAGS
|
||||
/tests/conform/config.env
|
||||
/tests/conform/.log
|
||||
/tests/unit/.log
|
||||
/tests/micro-perf/test-journal
|
||||
/tests/config.env
|
||||
/po/POTFILES
|
||||
/po/*.gmo
|
||||
|
@ -59,7 +59,6 @@ typedef struct
|
||||
CoglSwapChain *swap_chain;
|
||||
CoglBool need_stencil;
|
||||
int samples_per_pixel;
|
||||
CoglBool swap_throttled;
|
||||
CoglBool depth_texture_enabled;
|
||||
CoglBool stereo_enabled;
|
||||
} CoglFramebufferConfig;
|
||||
|
@ -65,8 +65,6 @@ struct _CoglOnscreen
|
||||
void *foreign_update_mask_data;
|
||||
#endif
|
||||
|
||||
CoglBool swap_throttled;
|
||||
|
||||
CoglList frame_closures;
|
||||
|
||||
CoglBool resizable;
|
||||
|
@ -62,7 +62,6 @@ cogl_onscreen_template_new (CoglSwapChain *swap_chain)
|
||||
else
|
||||
onscreen_template->config.swap_chain = cogl_swap_chain_new ();
|
||||
|
||||
onscreen_template->config.swap_throttled = TRUE;
|
||||
onscreen_template->config.need_stencil = TRUE;
|
||||
onscreen_template->config.samples_per_pixel = 0;
|
||||
|
||||
@ -86,14 +85,6 @@ cogl_onscreen_template_set_samples_per_pixel (
|
||||
onscreen_template->config.samples_per_pixel = samples_per_pixel;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_template_set_swap_throttled (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
CoglBool throttled)
|
||||
{
|
||||
onscreen_template->config.swap_throttled = throttled;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_template_set_stereo_enabled (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
|
@ -85,23 +85,6 @@ cogl_onscreen_template_set_samples_per_pixel (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
int n);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_template_set_swap_throttled:
|
||||
* @onscreen_template: A #CoglOnscreenTemplate template framebuffer
|
||||
* @throttled: Whether throttling should be enabled
|
||||
*
|
||||
* Requests that any future #CoglOnscreen framebuffers derived from this
|
||||
* template should enable or disable swap throttling according to the given
|
||||
* @throttled argument.
|
||||
*
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_onscreen_template_set_swap_throttled (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
CoglBool throttled);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_template_set_stereo_enabled:
|
||||
* @onscreen_template: A #CoglOnscreenTemplate template framebuffer
|
||||
|
@ -557,20 +557,6 @@ cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen,
|
||||
cogl_onscreen_remove_frame_callback (onscreen, closure);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen,
|
||||
CoglBool throttled)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
framebuffer->config.swap_throttled = throttled;
|
||||
if (framebuffer->allocated)
|
||||
{
|
||||
const CoglWinsysVtable *winsys =
|
||||
_cogl_framebuffer_get_winsys (framebuffer);
|
||||
winsys->onscreen_update_swap_throttled (onscreen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_show (CoglOnscreen *onscreen)
|
||||
{
|
||||
|
@ -162,23 +162,6 @@ uint32_t
|
||||
cogl_x11_onscreen_get_visual_xid (CoglOnscreen *onscreen);
|
||||
#endif /* COGL_HAS_X11 */
|
||||
|
||||
/**
|
||||
* cogl_onscreen_set_swap_throttled:
|
||||
* @onscreen: A #CoglOnscreen framebuffer
|
||||
* @throttled: Whether swap throttling is wanted or not.
|
||||
*
|
||||
* Requests that the given @onscreen framebuffer should have swap buffer
|
||||
* requests (made using cogl_onscreen_swap_buffers()) throttled either by a
|
||||
* displays vblank period or perhaps some other mechanism in a composited
|
||||
* environment.
|
||||
*
|
||||
* Since: 1.8
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen,
|
||||
CoglBool throttled);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_show:
|
||||
* @onscreen: The onscreen framebuffer to make visible
|
||||
@ -554,9 +537,8 @@ typedef void (*CoglSwapBuffersNotify) (CoglFramebuffer *framebuffer,
|
||||
* registered callbacks will be called if this feature is not supported.</note>
|
||||
*
|
||||
* We recommend using this mechanism when available to manually throttle your
|
||||
* applications (in conjunction with cogl_onscreen_set_swap_throttled()) so
|
||||
* your application will be able to avoid long blocks in the driver caused by
|
||||
* throttling when you request to swap buffers too quickly.
|
||||
* applications so your application will be able to avoid long blocks in the
|
||||
* driver caused by throttling when you request to swap buffers too quickly.
|
||||
*
|
||||
* Return value: a unique identifier that can be used to remove to remove
|
||||
* the callback later.
|
||||
|
@ -578,7 +578,6 @@ cogl_onscreen_get_gtype
|
||||
cogl_onscreen_get_resizable
|
||||
cogl_onscreen_hide
|
||||
cogl_onscreen_new
|
||||
cogl_onscreen_set_swap_throttled
|
||||
cogl_onscreen_remove_dirty_callback
|
||||
cogl_onscreen_remove_frame_callback
|
||||
cogl_onscreen_remove_resize_callback
|
||||
@ -587,7 +586,6 @@ cogl_onscreen_remove_swap_buffers_callback
|
||||
cogl_onscreen_resize_closure_get_gtype
|
||||
#endif
|
||||
cogl_onscreen_set_resizable
|
||||
cogl_onscreen_set_swap_throttled
|
||||
cogl_onscreen_show
|
||||
cogl_onscreen_swap_buffers
|
||||
cogl_onscreen_swap_buffers_with_damage
|
||||
@ -597,7 +595,6 @@ cogl_onscreen_template_get_gtype
|
||||
#endif
|
||||
cogl_onscreen_template_new
|
||||
cogl_onscreen_template_set_samples_per_pixel
|
||||
cogl_onscreen_template_set_swap_throttled
|
||||
|
||||
cogl_ortho
|
||||
|
||||
|
@ -724,10 +724,7 @@ bind_onscreen_with_context (CoglOnscreen *onscreen,
|
||||
CoglRenderer *renderer = context->display->renderer;
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
|
||||
if (fb->config.swap_throttled)
|
||||
eglSwapInterval (egl_renderer->edpy, 1);
|
||||
else
|
||||
eglSwapInterval (egl_renderer->edpy, 0);
|
||||
eglSwapInterval (egl_renderer->edpy, 1);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -854,21 +851,6 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
|
||||
{
|
||||
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
||||
CoglDisplayEGL *egl_display = context->display->winsys;
|
||||
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
||||
|
||||
if (egl_display->current_draw_surface != egl_onscreen->egl_surface)
|
||||
return;
|
||||
|
||||
egl_display->current_draw_surface = EGL_NO_SURFACE;
|
||||
|
||||
_cogl_winsys_onscreen_bind (onscreen);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_save_context (CoglContext *ctx)
|
||||
{
|
||||
@ -985,8 +967,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
|
||||
_cogl_winsys_onscreen_swap_buffers_with_damage,
|
||||
.onscreen_swap_region = _cogl_winsys_onscreen_swap_region,
|
||||
.onscreen_get_buffer_age = _cogl_winsys_onscreen_get_buffer_age,
|
||||
.onscreen_update_swap_throttled =
|
||||
_cogl_winsys_onscreen_update_swap_throttled,
|
||||
|
||||
/* CoglGLES2Context related methods */
|
||||
.save_context = _cogl_winsys_save_context,
|
||||
|
@ -1685,13 +1685,7 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
|
||||
* exclusive.
|
||||
*/
|
||||
if (glx_renderer->glXSwapInterval)
|
||||
{
|
||||
CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
|
||||
if (fb->config.swap_throttled)
|
||||
glx_renderer->glXSwapInterval (1);
|
||||
else
|
||||
glx_renderer->glXSwapInterval (0);
|
||||
}
|
||||
glx_renderer->glXSwapInterval (1);
|
||||
|
||||
XSync (xlib_renderer->xdpy, False);
|
||||
|
||||
@ -2074,16 +2068,8 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
framebuffer,
|
||||
COGL_FRAMEBUFFER_STATE_BIND);
|
||||
|
||||
if (framebuffer->config.swap_throttled)
|
||||
{
|
||||
have_counter = glx_display->have_vblank_counter;
|
||||
can_wait = glx_display->can_vblank_wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
have_counter = FALSE;
|
||||
can_wait = FALSE;
|
||||
}
|
||||
have_counter = glx_display->have_vblank_counter;
|
||||
can_wait = glx_display->can_vblank_wait;
|
||||
|
||||
/* We need to ensure that all the rendering is done, otherwise
|
||||
* redraw operations that are slower than the framerate can
|
||||
@ -2250,71 +2236,66 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
|
||||
drawable = glx_onscreen->glxwin ? glx_onscreen->glxwin : xlib_onscreen->xwin;
|
||||
|
||||
if (framebuffer->config.swap_throttled)
|
||||
have_counter = glx_display->have_vblank_counter;
|
||||
|
||||
if (glx_renderer->glXSwapInterval)
|
||||
{
|
||||
have_counter = glx_display->have_vblank_counter;
|
||||
|
||||
if (glx_renderer->glXSwapInterval)
|
||||
if (_cogl_has_private_feature (context, COGL_PRIVATE_FEATURE_THREADED_SWAP_WAIT))
|
||||
{
|
||||
if (_cogl_has_private_feature (context, COGL_PRIVATE_FEATURE_THREADED_SWAP_WAIT))
|
||||
{
|
||||
/* If we didn't wait for the GPU here, then it's easy to get the case
|
||||
* where there is a VBlank between the point where we get the vsync counter
|
||||
* and the point where the GPU is ready to actually perform the glXSwapBuffers(),
|
||||
* and the swap wait terminates at the first VBlank rather than the one
|
||||
* where the swap buffers happens. Calling glFinish() here makes this a
|
||||
* rare race since the GPU is already ready to swap when we call glXSwapBuffers().
|
||||
* The glFinish() also prevents any serious damage if the rare race happens,
|
||||
* since it will wait for the preceding glXSwapBuffers() and prevent us from
|
||||
* getting premanently ahead. (For NVIDIA drivers, glFinish() after glXSwapBuffers()
|
||||
* waits for the buffer swap to happen.)
|
||||
*/
|
||||
_cogl_winsys_wait_for_gpu (onscreen);
|
||||
start_threaded_swap_wait (onscreen, _cogl_winsys_get_vsync_counter (context));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CoglBool can_wait = have_counter || glx_display->can_vblank_wait;
|
||||
|
||||
uint32_t end_frame_vsync_counter = 0;
|
||||
|
||||
/* If the swap_region API is also being used then we need to track
|
||||
* the vsync counter for each swap request so we can manually
|
||||
* throttle swap_region requests. */
|
||||
if (have_counter)
|
||||
end_frame_vsync_counter = _cogl_winsys_get_vsync_counter (context);
|
||||
|
||||
/* If we are going to wait for VBLANK manually, we not only
|
||||
* need to flush out pending drawing to the GPU before we
|
||||
* sleep, we need to wait for it to finish. Otherwise, we
|
||||
* may end up with the situation:
|
||||
*
|
||||
* - We finish drawing - GPU drawing continues
|
||||
* - We go to sleep - GPU drawing continues
|
||||
* VBLANK - We call glXSwapBuffers - GPU drawing continues
|
||||
* - GPU drawing continues
|
||||
* - Swap buffers happens
|
||||
*
|
||||
* Producing a tear. Calling glFinish() first will cause us
|
||||
* to properly wait for the next VBLANK before we swap. This
|
||||
* obviously does not happen when we use _GLX_SWAP and let
|
||||
* the driver do the right thing
|
||||
/* If we didn't wait for the GPU here, then it's easy to get the case
|
||||
* where there is a VBlank between the point where we get the vsync counter
|
||||
* and the point where the GPU is ready to actually perform the glXSwapBuffers(),
|
||||
* and the swap wait terminates at the first VBlank rather than the one
|
||||
* where the swap buffers happens. Calling glFinish() here makes this a
|
||||
* rare race since the GPU is already ready to swap when we call glXSwapBuffers().
|
||||
* The glFinish() also prevents any serious damage if the rare race happens,
|
||||
* since it will wait for the preceding glXSwapBuffers() and prevent us from
|
||||
* getting premanently ahead. (For NVIDIA drivers, glFinish() after glXSwapBuffers()
|
||||
* waits for the buffer swap to happen.)
|
||||
*/
|
||||
_cogl_winsys_wait_for_gpu (onscreen);
|
||||
|
||||
if (have_counter && can_wait)
|
||||
{
|
||||
if (glx_onscreen->last_swap_vsync_counter ==
|
||||
end_frame_vsync_counter)
|
||||
_cogl_winsys_wait_for_vblank (onscreen);
|
||||
}
|
||||
else if (can_wait)
|
||||
_cogl_winsys_wait_for_vblank (onscreen);
|
||||
start_threaded_swap_wait (onscreen, _cogl_winsys_get_vsync_counter (context));
|
||||
}
|
||||
}
|
||||
else
|
||||
have_counter = FALSE;
|
||||
{
|
||||
CoglBool can_wait = have_counter || glx_display->can_vblank_wait;
|
||||
|
||||
uint32_t end_frame_vsync_counter = 0;
|
||||
|
||||
/* If the swap_region API is also being used then we need to track
|
||||
* the vsync counter for each swap request so we can manually
|
||||
* throttle swap_region requests. */
|
||||
if (have_counter)
|
||||
end_frame_vsync_counter = _cogl_winsys_get_vsync_counter (context);
|
||||
|
||||
/* If we are going to wait for VBLANK manually, we not only
|
||||
* need to flush out pending drawing to the GPU before we
|
||||
* sleep, we need to wait for it to finish. Otherwise, we
|
||||
* may end up with the situation:
|
||||
*
|
||||
* - We finish drawing - GPU drawing continues
|
||||
* - We go to sleep - GPU drawing continues
|
||||
* VBLANK - We call glXSwapBuffers - GPU drawing continues
|
||||
* - GPU drawing continues
|
||||
* - Swap buffers happens
|
||||
*
|
||||
* Producing a tear. Calling glFinish() first will cause us
|
||||
* to properly wait for the next VBLANK before we swap. This
|
||||
* obviously does not happen when we use _GLX_SWAP and let
|
||||
* the driver do the right thing
|
||||
*/
|
||||
_cogl_winsys_wait_for_gpu (onscreen);
|
||||
|
||||
if (have_counter && can_wait)
|
||||
{
|
||||
if (glx_onscreen->last_swap_vsync_counter ==
|
||||
end_frame_vsync_counter)
|
||||
_cogl_winsys_wait_for_vblank (onscreen);
|
||||
}
|
||||
else if (can_wait)
|
||||
_cogl_winsys_wait_for_vblank (onscreen);
|
||||
}
|
||||
|
||||
glx_renderer->glXSwapBuffers (xlib_renderer->xdpy, drawable);
|
||||
|
||||
@ -2332,23 +2313,6 @@ _cogl_winsys_onscreen_x11_get_window_xid (CoglOnscreen *onscreen)
|
||||
return xlib_onscreen->xwin;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
|
||||
{
|
||||
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
||||
CoglContextGLX *glx_context = context->winsys;
|
||||
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
|
||||
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
|
||||
GLXDrawable drawable =
|
||||
glx_onscreen->glxwin ? glx_onscreen->glxwin : xlib_onscreen->xwin;
|
||||
|
||||
if (glx_context->current_drawable != drawable)
|
||||
return;
|
||||
|
||||
glx_context->current_drawable = 0;
|
||||
_cogl_winsys_onscreen_bind (onscreen);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
|
||||
CoglBool visibility)
|
||||
@ -3022,8 +2986,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
|
||||
_cogl_winsys_onscreen_swap_buffers_with_damage,
|
||||
.onscreen_swap_region = _cogl_winsys_onscreen_swap_region,
|
||||
.onscreen_get_buffer_age = _cogl_winsys_onscreen_get_buffer_age,
|
||||
.onscreen_update_swap_throttled =
|
||||
_cogl_winsys_onscreen_update_swap_throttled,
|
||||
.onscreen_x11_get_window_xid =
|
||||
_cogl_winsys_onscreen_x11_get_window_xid,
|
||||
.onscreen_set_visibility = _cogl_winsys_onscreen_set_visibility,
|
||||
|
@ -122,9 +122,6 @@ typedef struct _CoglWinsysVtable
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
|
||||
void
|
||||
(*onscreen_update_swap_throttled) (CoglOnscreen *onscreen);
|
||||
|
||||
void
|
||||
(*onscreen_set_visibility) (CoglOnscreen *onscreen,
|
||||
CoglBool visibility);
|
||||
|
@ -143,11 +143,6 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
|
||||
CoglBool visibility)
|
||||
@ -184,8 +179,6 @@ _cogl_winsys_stub_get_vtable (void)
|
||||
vtable.onscreen_bind = _cogl_winsys_onscreen_bind;
|
||||
vtable.onscreen_swap_buffers_with_damage =
|
||||
_cogl_winsys_onscreen_swap_buffers_with_damage;
|
||||
vtable.onscreen_update_swap_throttled =
|
||||
_cogl_winsys_onscreen_update_swap_throttled;
|
||||
vtable.onscreen_set_visibility = _cogl_winsys_onscreen_set_visibility;
|
||||
|
||||
vtable_inited = TRUE;
|
||||
|
@ -693,7 +693,6 @@ tests/Makefile
|
||||
tests/config.env
|
||||
tests/conform/Makefile
|
||||
tests/unit/Makefile
|
||||
tests/micro-perf/Makefile
|
||||
tests/data/Makefile
|
||||
)
|
||||
|
||||
|
@ -4,9 +4,9 @@ if UNIT_TESTS
|
||||
SUBDIRS += unit
|
||||
endif
|
||||
|
||||
SUBDIRS += micro-perf data
|
||||
SUBDIRS += data
|
||||
|
||||
DIST_SUBDIRS = conform unit micro-perf data
|
||||
DIST_SUBDIRS = conform unit data
|
||||
|
||||
EXTRA_DIST = README test-launcher.sh run-tests.sh
|
||||
|
||||
|
@ -11,4 +11,3 @@ cogl_config_env = configure_file(
|
||||
|
||||
subdir('conform')
|
||||
subdir('unit')
|
||||
subdir('micro-perf')
|
||||
|
@ -1,24 +0,0 @@
|
||||
NULL =
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/cogl \
|
||||
-DCOGL_DISABLE_DEPRECATED
|
||||
|
||||
test_conformance_CPPFLAGS = \
|
||||
-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\"
|
||||
|
||||
|
||||
noinst_PROGRAMS =
|
||||
|
||||
noinst_PROGRAMS += test-journal
|
||||
|
||||
AM_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS)
|
||||
|
||||
common_ldadd = \
|
||||
$(COGL_DEP_LIBS) \
|
||||
$(top_builddir)/cogl/libmutter-cogl-$(LIBMUTTER_API_VERSION).la \
|
||||
$(LIBM)
|
||||
|
||||
test_journal_SOURCES = test-journal.c
|
||||
test_journal_LDADD = $(common_ldadd)
|
@ -1,18 +0,0 @@
|
||||
cogl_test_journal_sources = [
|
||||
'test-journal.c',
|
||||
]
|
||||
|
||||
cogl_test_journal = executable('test-journal',
|
||||
sources: cogl_test_journal_sources,
|
||||
c_args: cogl_debug_c_args + [
|
||||
'-DCOGL_DISABLE_DEPRECATED',
|
||||
'-DTESTS_DATADIR="@0@"'.format(join_paths(cogl_srcdir, 'tests/data')),
|
||||
],
|
||||
include_directories: cogl_includepath,
|
||||
dependencies: [
|
||||
cogl_deps,
|
||||
libmutter_cogl_dep,
|
||||
libmutter_cogl_path_dep,
|
||||
],
|
||||
install: false,
|
||||
)
|
@ -1,190 +0,0 @@
|
||||
#include <glib.h>
|
||||
#include <cogl/cogl.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "cogl/cogl-profile.h"
|
||||
|
||||
#define FRAMEBUFFER_WIDTH 800
|
||||
#define FRAMEBUFFER_HEIGHT 600
|
||||
|
||||
CoglBool run_all = FALSE;
|
||||
|
||||
typedef struct _Data
|
||||
{
|
||||
CoglContext *ctx;
|
||||
CoglFramebuffer *fb;
|
||||
CoglPipeline *pipeline;
|
||||
CoglPipeline *alpha_pipeline;
|
||||
GTimer *timer;
|
||||
int frame;
|
||||
} Data;
|
||||
|
||||
static void
|
||||
test_rectangles (Data *data)
|
||||
{
|
||||
#define RECT_WIDTH 5
|
||||
#define RECT_HEIGHT 5
|
||||
int x;
|
||||
int y;
|
||||
|
||||
cogl_framebuffer_clear4f (data->fb, COGL_BUFFER_BIT_COLOR, 1, 1, 1, 1);
|
||||
|
||||
cogl_framebuffer_push_rectangle_clip (data->fb,
|
||||
10,
|
||||
10,
|
||||
FRAMEBUFFER_WIDTH - 10,
|
||||
FRAMEBUFFER_HEIGHT - 10);
|
||||
|
||||
/* Should the rectangles be randomly positioned/colored/rotated?
|
||||
*
|
||||
* It could be good to develop equivalent GL and Cairo tests so we can
|
||||
* have a sanity check for our Cogl performance.
|
||||
*
|
||||
* The color should vary to check that we correctly batch color changes
|
||||
* The use of alpha should vary so we have a variation of which rectangles
|
||||
* require blending.
|
||||
* Should this be a random variation?
|
||||
* It could be good to experiment with focibly enabling blending for
|
||||
* rectangles that don't technically need it for the sake of extending
|
||||
* batching. E.g. if you a long run of interleved rectangles with every
|
||||
* other rectangle needing blending then it may be worth enabling blending
|
||||
* for all the rectangles to avoid the state changes.
|
||||
* The modelview should change between rectangles to check the software
|
||||
* transform codepath.
|
||||
* Should we group some rectangles under the same modelview? Potentially
|
||||
* we could avoid software transform for long runs of rectangles with the
|
||||
* same modelview.
|
||||
*
|
||||
*/
|
||||
for (y = 0; y < FRAMEBUFFER_HEIGHT; y += RECT_HEIGHT)
|
||||
{
|
||||
for (x = 0; x < FRAMEBUFFER_WIDTH; x += RECT_WIDTH)
|
||||
{
|
||||
cogl_framebuffer_push_matrix (data->fb);
|
||||
cogl_framebuffer_translate (data->fb, x, y, 0);
|
||||
cogl_framebuffer_rotate (data->fb, 45, 0, 0, 1);
|
||||
|
||||
cogl_pipeline_set_color4f (data->pipeline,
|
||||
1,
|
||||
(1.0f/FRAMEBUFFER_WIDTH)*y,
|
||||
(1.0f/FRAMEBUFFER_HEIGHT)*x,
|
||||
1);
|
||||
cogl_framebuffer_draw_rectangle (data->fb,
|
||||
data->pipeline,
|
||||
0, 0, RECT_WIDTH, RECT_HEIGHT);
|
||||
|
||||
cogl_framebuffer_pop_matrix (data->fb);
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < FRAMEBUFFER_HEIGHT; y += RECT_HEIGHT)
|
||||
{
|
||||
for (x = 0; x < FRAMEBUFFER_WIDTH; x += RECT_WIDTH)
|
||||
{
|
||||
cogl_framebuffer_push_matrix (data->fb);
|
||||
cogl_framebuffer_translate (data->fb, x, y, 0);
|
||||
|
||||
cogl_pipeline_set_color4f (data->alpha_pipeline,
|
||||
1,
|
||||
(1.0f/FRAMEBUFFER_WIDTH)*x,
|
||||
(1.0f/FRAMEBUFFER_HEIGHT)*y,
|
||||
(1.0f/FRAMEBUFFER_WIDTH)*x);
|
||||
cogl_framebuffer_draw_rectangle (data->fb,
|
||||
data->alpha_pipeline,
|
||||
0, 0, RECT_WIDTH, RECT_HEIGHT);
|
||||
|
||||
cogl_framebuffer_pop_matrix (data->fb);
|
||||
}
|
||||
}
|
||||
|
||||
cogl_framebuffer_pop_clip (data->fb);
|
||||
}
|
||||
|
||||
static CoglBool
|
||||
paint_cb (void *user_data)
|
||||
{
|
||||
Data *data = user_data;
|
||||
double elapsed;
|
||||
|
||||
data->frame++;
|
||||
|
||||
test_rectangles (data);
|
||||
|
||||
cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
|
||||
|
||||
elapsed = g_timer_elapsed (data->timer, NULL);
|
||||
if (elapsed > 1.0)
|
||||
{
|
||||
g_print ("fps = %f\n", data->frame / elapsed);
|
||||
g_timer_start (data->timer);
|
||||
data->frame = 0;
|
||||
}
|
||||
|
||||
return FALSE; /* remove the callback */
|
||||
}
|
||||
|
||||
static void
|
||||
frame_event_cb (CoglOnscreen *onscreen,
|
||||
CoglFrameEvent event,
|
||||
CoglFrameInfo *info,
|
||||
void *user_data)
|
||||
{
|
||||
if (event == COGL_FRAME_EVENT_SYNC)
|
||||
paint_cb (user_data);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
Data data;
|
||||
CoglOnscreen *onscreen;
|
||||
GSource *cogl_source;
|
||||
GMainLoop *loop;
|
||||
COGL_STATIC_TIMER (mainloop_timer,
|
||||
NULL, //no parent
|
||||
"Mainloop",
|
||||
"The time spent in the glib mainloop",
|
||||
0); // no application private data
|
||||
|
||||
data.ctx = cogl_context_new (NULL, NULL);
|
||||
|
||||
onscreen = cogl_onscreen_new (data.ctx,
|
||||
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT);
|
||||
cogl_onscreen_set_swap_throttled (onscreen, FALSE);
|
||||
cogl_onscreen_show (onscreen);
|
||||
|
||||
data.fb = onscreen;
|
||||
cogl_framebuffer_orthographic (data.fb,
|
||||
0, 0,
|
||||
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
|
||||
-1,
|
||||
100);
|
||||
|
||||
data.pipeline = cogl_pipeline_new (data.ctx);
|
||||
cogl_pipeline_set_color4f (data.pipeline, 1, 1, 1, 1);
|
||||
data.alpha_pipeline = cogl_pipeline_new (data.ctx);
|
||||
cogl_pipeline_set_color4f (data.alpha_pipeline, 1, 1, 1, 0.5);
|
||||
|
||||
cogl_source = cogl_glib_source_new (data.ctx, G_PRIORITY_DEFAULT);
|
||||
|
||||
g_source_attach (cogl_source, NULL);
|
||||
|
||||
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (data.fb),
|
||||
frame_event_cb,
|
||||
&data,
|
||||
NULL); /* destroy notify */
|
||||
|
||||
g_idle_add (paint_cb, &data);
|
||||
|
||||
data.frame = 0;
|
||||
data.timer = g_timer_new ();
|
||||
g_timer_start (data.timer);
|
||||
|
||||
loop = g_main_loop_new (NULL, TRUE);
|
||||
COGL_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);
|
||||
g_main_loop_run (loop);
|
||||
COGL_TIMER_STOP (uprof_get_mainloop_context (), mainloop_timer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2727,9 +2727,6 @@ meta_renderer_native_create_onscreen (MetaRendererNative *renderer_native,
|
||||
|
||||
onscreen = cogl_onscreen_new (context, width, height);
|
||||
|
||||
/* We have wait_for_pending_flips hardcoded, so throttling always. */
|
||||
cogl_onscreen_set_swap_throttled (onscreen, TRUE);
|
||||
|
||||
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), error))
|
||||
{
|
||||
cogl_object_unref (onscreen);
|
||||
|
Loading…
Reference in New Issue
Block a user