cogl: Remove CoglFence
Nothing was really using it...I am removing too much? Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3806>
This commit is contained in:
parent
4eb555a2f0
commit
69835c9ec1
@ -49,7 +49,6 @@
|
||||
#include "cogl/cogl-framebuffer-private.h"
|
||||
#include "cogl/cogl-offscreen-private.h"
|
||||
#include "cogl/cogl-onscreen-private.h"
|
||||
#include "cogl/cogl-fence-private.h"
|
||||
#include "cogl/cogl-poll-private.h"
|
||||
#include "cogl/cogl-private.h"
|
||||
#include "cogl/winsys/cogl-winsys-private.h"
|
||||
@ -254,9 +253,6 @@ struct _CoglContext
|
||||
GHashTable *uniform_name_hash;
|
||||
int n_uniform_names;
|
||||
|
||||
CoglPollSource *fences_poll_source;
|
||||
CoglList fences;
|
||||
|
||||
GHashTable *named_pipelines;
|
||||
|
||||
/* This defines a list of function pointers that Cogl uses from
|
||||
|
@ -398,8 +398,6 @@ cogl_context_new (CoglDisplay *display,
|
||||
context->buffer_map_fallback_array = g_byte_array_new ();
|
||||
context->buffer_map_fallback_in_use = FALSE;
|
||||
|
||||
_cogl_list_init (&context->fences);
|
||||
|
||||
context->named_pipelines =
|
||||
g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
|
||||
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cogl/cogl-fence.h"
|
||||
#include "cogl/cogl-list.h"
|
||||
#include "cogl/winsys/cogl-winsys-private.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FENCE_TYPE_PENDING,
|
||||
#ifdef GL_ARB_sync
|
||||
FENCE_TYPE_GL_ARB,
|
||||
#endif
|
||||
FENCE_TYPE_WINSYS,
|
||||
FENCE_TYPE_ERROR
|
||||
} CoglFenceType;
|
||||
|
||||
struct _CoglFenceClosure
|
||||
{
|
||||
CoglList link;
|
||||
CoglFramebuffer *framebuffer;
|
||||
|
||||
CoglFenceType type;
|
||||
void *fence_obj;
|
||||
|
||||
CoglFenceCallback callback;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
void
|
||||
_cogl_fence_submit (CoglFenceClosure *fence);
|
||||
|
||||
void
|
||||
_cogl_fence_cancel_fences_for_framebuffer (CoglFramebuffer *framebuffer);
|
@ -1,235 +0,0 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-fence.h"
|
||||
#include "cogl/cogl-fence-private.h"
|
||||
#include "cogl/winsys/cogl-winsys-private.h"
|
||||
|
||||
#define FENCE_CHECK_TIMEOUT 5000 /* microseconds */
|
||||
|
||||
void *
|
||||
cogl_fence_closure_get_user_data (CoglFenceClosure *closure)
|
||||
{
|
||||
return closure->user_data;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_fence_check (CoglFenceClosure *fence)
|
||||
{
|
||||
CoglContext *context = cogl_framebuffer_get_context (fence->framebuffer);
|
||||
|
||||
if (fence->type == FENCE_TYPE_WINSYS)
|
||||
{
|
||||
const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
|
||||
gboolean ret;
|
||||
|
||||
ret = winsys->fence_is_complete (context, fence->fence_obj);
|
||||
if (!ret)
|
||||
return;
|
||||
}
|
||||
#ifdef GL_ARB_sync
|
||||
else if (fence->type == FENCE_TYPE_GL_ARB)
|
||||
{
|
||||
GLenum arb;
|
||||
|
||||
arb = context->glClientWaitSync (fence->fence_obj,
|
||||
GL_SYNC_FLUSH_COMMANDS_BIT,
|
||||
0);
|
||||
if (arb != GL_ALREADY_SIGNALED && arb != GL_CONDITION_SATISFIED)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
fence->callback (NULL, /* dummy CoglFence object */
|
||||
fence->user_data);
|
||||
cogl_framebuffer_cancel_fence_callback (fence->framebuffer, fence);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_fence_poll_dispatch (void *source, int revents)
|
||||
{
|
||||
CoglContext *context = source;
|
||||
CoglFenceClosure *fence, *tmp;
|
||||
|
||||
_cogl_list_for_each_safe (fence, tmp, &context->fences, link)
|
||||
_cogl_fence_check (fence);
|
||||
}
|
||||
|
||||
static int64_t
|
||||
_cogl_fence_poll_prepare (void *source)
|
||||
{
|
||||
CoglContext *context = source;
|
||||
GList *l;
|
||||
|
||||
/* If there are any pending fences in any of the journals then we
|
||||
* need to flush the journal otherwise the fence will never be
|
||||
* hit and the main loop might block forever */
|
||||
for (l = context->framebuffers; l; l = l->next)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = l->data;
|
||||
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
|
||||
|
||||
if (!_cogl_list_empty (&journal->pending_fences))
|
||||
_cogl_framebuffer_flush_journal (framebuffer);
|
||||
}
|
||||
|
||||
if (!_cogl_list_empty (&context->fences))
|
||||
return FENCE_CHECK_TIMEOUT;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_fence_submit (CoglFenceClosure *fence)
|
||||
{
|
||||
CoglContext *context = cogl_framebuffer_get_context (fence->framebuffer);
|
||||
const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
|
||||
|
||||
fence->type = FENCE_TYPE_ERROR;
|
||||
|
||||
if (winsys->fence_add)
|
||||
{
|
||||
fence->fence_obj = winsys->fence_add (context);
|
||||
if (fence->fence_obj)
|
||||
{
|
||||
fence->type = FENCE_TYPE_WINSYS;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GL_ARB_sync
|
||||
if (context->glFenceSync)
|
||||
{
|
||||
fence->fence_obj = context->glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE,
|
||||
0);
|
||||
if (fence->fence_obj)
|
||||
{
|
||||
fence->type = FENCE_TYPE_GL_ARB;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
done:
|
||||
_cogl_list_insert (context->fences.prev, &fence->link);
|
||||
|
||||
if (!context->fences_poll_source)
|
||||
{
|
||||
context->fences_poll_source =
|
||||
_cogl_poll_renderer_add_source (context->display->renderer,
|
||||
_cogl_fence_poll_prepare,
|
||||
_cogl_fence_poll_dispatch,
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
||||
CoglFenceClosure *
|
||||
cogl_framebuffer_add_fence_callback (CoglFramebuffer *framebuffer,
|
||||
CoglFenceCallback callback,
|
||||
void *user_data)
|
||||
{
|
||||
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
|
||||
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
|
||||
CoglFenceClosure *fence;
|
||||
|
||||
if (!COGL_FLAGS_GET (context->features, COGL_FEATURE_ID_FENCE))
|
||||
return NULL;
|
||||
|
||||
fence = g_new0 (CoglFenceClosure, 1);
|
||||
fence->framebuffer = framebuffer;
|
||||
fence->callback = callback;
|
||||
fence->user_data = user_data;
|
||||
fence->fence_obj = NULL;
|
||||
|
||||
if (journal->entries->len)
|
||||
{
|
||||
_cogl_list_insert (journal->pending_fences.prev, &fence->link);
|
||||
fence->type = FENCE_TYPE_PENDING;
|
||||
}
|
||||
else
|
||||
_cogl_fence_submit (fence);
|
||||
|
||||
return fence;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_framebuffer_cancel_fence_callback (CoglFramebuffer *framebuffer,
|
||||
CoglFenceClosure *fence)
|
||||
{
|
||||
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
|
||||
|
||||
if (fence->type == FENCE_TYPE_PENDING)
|
||||
{
|
||||
_cogl_list_remove (&fence->link);
|
||||
}
|
||||
else
|
||||
{
|
||||
_cogl_list_remove (&fence->link);
|
||||
|
||||
if (fence->type == FENCE_TYPE_WINSYS)
|
||||
{
|
||||
const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
|
||||
|
||||
winsys->fence_destroy (context, fence->fence_obj);
|
||||
}
|
||||
#ifdef GL_ARB_sync
|
||||
else if (fence->type == FENCE_TYPE_GL_ARB)
|
||||
{
|
||||
context->glDeleteSync (fence->fence_obj);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
g_free (fence);
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_fence_cancel_fences_for_framebuffer (CoglFramebuffer *framebuffer)
|
||||
{
|
||||
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
|
||||
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
|
||||
CoglFenceClosure *fence, *tmp;
|
||||
|
||||
while (!_cogl_list_empty (&journal->pending_fences))
|
||||
{
|
||||
fence = _cogl_container_of (journal->pending_fences.next,
|
||||
CoglFenceClosure,
|
||||
link);
|
||||
cogl_framebuffer_cancel_fence_callback (framebuffer, fence);
|
||||
}
|
||||
|
||||
_cogl_list_for_each_safe (fence, tmp, &context->fences, link)
|
||||
{
|
||||
if (fence->framebuffer == framebuffer)
|
||||
cogl_framebuffer_cancel_fence_callback (framebuffer, fence);
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "cogl/cogl-types.h"
|
||||
#include "cogl/cogl-framebuffer.h"
|
||||
|
||||
/**
|
||||
* CoglFence:
|
||||
*
|
||||
* Functions for notification of command completion
|
||||
*
|
||||
* Cogl allows notification of GPU command completion; users may mark
|
||||
* points in the GPU command stream and receive notification when the GPU
|
||||
* has executed to that point.
|
||||
*/
|
||||
typedef struct _CoglFence CoglFence;
|
||||
|
||||
/**
|
||||
* CoglFenceCallback:
|
||||
* @fence: Unused. In the future this parameter may be used to pass
|
||||
* extra information about the fence completion but for now it
|
||||
* should be ignored.
|
||||
* @user_data: The private data passed to cogl_framebuffer_add_fence_callback()
|
||||
*
|
||||
* The callback prototype used with
|
||||
* cogl_framebuffer_add_fence_callback() for notification of GPU
|
||||
* command completion.
|
||||
*/
|
||||
typedef void (* CoglFenceCallback) (CoglFence *fence,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* CoglFenceClosure:
|
||||
*
|
||||
* An opaque type representing one future callback to be made when the
|
||||
* GPU command stream has passed a certain point.
|
||||
*/
|
||||
typedef struct _CoglFenceClosure CoglFenceClosure;
|
||||
|
||||
/**
|
||||
* cogl_frame_closure_get_user_data:
|
||||
* @closure: A #CoglFenceClosure returned from cogl_framebuffer_add_fence()
|
||||
*
|
||||
* Returns the user_data submitted to cogl_framebuffer_add_fence() which
|
||||
* returned a given #CoglFenceClosure.
|
||||
*/
|
||||
COGL_EXPORT void *
|
||||
cogl_fence_closure_get_user_data (CoglFenceClosure *closure);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_add_fence_callback:
|
||||
* @framebuffer: The #CoglFramebuffer the commands have been submitted to
|
||||
* @callback: (scope async): A #CoglFenceCallback to be called when
|
||||
* all commands submitted to Cogl have been executed
|
||||
* @user_data: (closure): Private data that will be passed to the callback
|
||||
*
|
||||
* Calls the provided callback when all previously-submitted commands have
|
||||
* been executed by the GPU.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): non-NULL if the fence succeeded,
|
||||
* or %NULL if it was unable to be inserted and the callback will never be
|
||||
* called. The user does not need to free the closure; it will be freed
|
||||
* automatically when the callback is called, or cancelled.
|
||||
*/
|
||||
COGL_EXPORT CoglFenceClosure *
|
||||
cogl_framebuffer_add_fence_callback (CoglFramebuffer *framebuffer,
|
||||
CoglFenceCallback callback,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_cancel_fence_callback:
|
||||
* @framebuffer: The #CoglFramebuffer the commands were submitted to
|
||||
* @closure: The #CoglFenceClosure returned from
|
||||
* cogl_framebuffer_add_fence_callback()
|
||||
*
|
||||
* Removes a fence previously submitted with
|
||||
* cogl_framebuffer_add_fence_callback(); the callback will not be
|
||||
* called.
|
||||
*/
|
||||
COGL_EXPORT void
|
||||
cogl_framebuffer_cancel_fence_callback (CoglFramebuffer *framebuffer,
|
||||
CoglFenceClosure *closure);
|
@ -330,8 +330,6 @@ cogl_framebuffer_dispose (GObject *object)
|
||||
_cogl_journal_flush (priv->journal);
|
||||
|
||||
g_signal_emit (framebuffer, signals[DESTROY], 0);
|
||||
|
||||
_cogl_fence_cancel_fences_for_framebuffer (framebuffer);
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->clip_stack, _cogl_clip_stack_unref);
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include "cogl/cogl-texture.h"
|
||||
#include "cogl/cogl-clip-stack.h"
|
||||
#include "cogl/cogl-fence-private.h"
|
||||
|
||||
#define COGL_JOURNAL_VBO_POOL_SIZE 8
|
||||
|
||||
@ -64,8 +63,6 @@ typedef struct _CoglJournal
|
||||
|
||||
int fast_read_pixel_count;
|
||||
|
||||
CoglList pending_fences;
|
||||
|
||||
} CoglJournal;
|
||||
|
||||
#define COGL_TYPE_JOURNAL (cogl_journal_get_type ())
|
||||
|
@ -165,8 +165,6 @@ _cogl_journal_new (CoglFramebuffer *framebuffer)
|
||||
journal->entries = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry));
|
||||
journal->vertices = g_array_new (FALSE, FALSE, sizeof (float));
|
||||
|
||||
_cogl_list_init (&journal->pending_fences);
|
||||
|
||||
return journal;
|
||||
}
|
||||
|
||||
@ -1349,18 +1347,6 @@ _cogl_journal_all_entries_within_bounds (CoglJournal *journal,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
post_fences (CoglJournal *journal)
|
||||
{
|
||||
CoglFenceClosure *fence, *tmp;
|
||||
|
||||
_cogl_list_for_each_safe (fence, tmp, &journal->pending_fences, link)
|
||||
{
|
||||
_cogl_list_remove (&fence->link);
|
||||
_cogl_fence_submit (fence);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX NB: When _cogl_journal_flush() returns all state relating
|
||||
* to pipelines, all glEnable flags and current matrix state
|
||||
* is undefined.
|
||||
@ -1387,7 +1373,6 @@ _cogl_journal_flush (CoglJournal *journal)
|
||||
|
||||
if (journal->entries->len == 0)
|
||||
{
|
||||
post_fences (journal);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1488,8 +1473,6 @@ _cogl_journal_flush (CoglJournal *journal)
|
||||
_cogl_journal_discard (journal);
|
||||
COGL_TIMER_STOP (_cogl_uprof_context, discard_timer);
|
||||
|
||||
post_fences (journal);
|
||||
|
||||
COGL_TIMER_STOP (_cogl_uprof_context, flush_timer);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@
|
||||
#include "cogl/cogl-onscreen.h"
|
||||
#include "cogl/cogl-frame-info.h"
|
||||
#include "cogl/cogl-poll.h"
|
||||
#include "cogl/cogl-fence.h"
|
||||
#include "cogl/cogl-glib-source.h"
|
||||
#include "cogl/cogl-trace.h"
|
||||
#include "cogl/cogl-scanout.h"
|
||||
|
@ -31,7 +31,6 @@ cogl_headers = [
|
||||
'cogl-depth-state.h',
|
||||
'cogl-display.h',
|
||||
'cogl-dma-buf-handle.h',
|
||||
'cogl-fence.h',
|
||||
'cogl-framebuffer.h',
|
||||
'cogl-frame-info.h',
|
||||
'cogl-glib-source.h',
|
||||
@ -187,8 +186,6 @@ cogl_sources = [
|
||||
'cogl-driver.h',
|
||||
'cogl-feature-private.c',
|
||||
'cogl-feature-private.h',
|
||||
'cogl-fence-private.h',
|
||||
'cogl-fence.c',
|
||||
'cogl-flags.h',
|
||||
'cogl-frame-info-private.h',
|
||||
'cogl-frame-info.c',
|
||||
|
@ -542,42 +542,6 @@ _cogl_winsys_context_deinit (CoglContext *context)
|
||||
}
|
||||
|
||||
#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)
|
||||
static void *
|
||||
_cogl_winsys_fence_add (CoglContext *context)
|
||||
{
|
||||
CoglRendererEGL *renderer = context->display->renderer->winsys;
|
||||
void *ret;
|
||||
|
||||
if (renderer->pf_eglCreateSync)
|
||||
ret = renderer->pf_eglCreateSync (renderer->edpy,
|
||||
EGL_SYNC_FENCE_KHR,
|
||||
NULL);
|
||||
else
|
||||
ret = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_winsys_fence_is_complete (CoglContext *context, void *fence)
|
||||
{
|
||||
CoglRendererEGL *renderer = context->display->renderer->winsys;
|
||||
EGLint ret;
|
||||
|
||||
ret = renderer->pf_eglClientWaitSync (renderer->edpy,
|
||||
fence,
|
||||
EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
|
||||
0);
|
||||
return (ret == EGL_CONDITION_SATISFIED_KHR);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_fence_destroy (CoglContext *context, void *fence)
|
||||
{
|
||||
CoglRendererEGL *renderer = context->display->renderer->winsys;
|
||||
|
||||
renderer->pf_eglDestroySync (renderer->edpy, fence);
|
||||
}
|
||||
|
||||
static int
|
||||
_cogl_winsys_get_sync_fd (CoglContext *context)
|
||||
@ -628,9 +592,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
|
||||
.context_deinit = _cogl_winsys_context_deinit,
|
||||
|
||||
#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)
|
||||
.fence_add = _cogl_winsys_fence_add,
|
||||
.fence_is_complete = _cogl_winsys_fence_is_complete,
|
||||
.fence_destroy = _cogl_winsys_fence_destroy,
|
||||
.get_sync_fd = _cogl_winsys_get_sync_fd,
|
||||
.update_sync = _cogl_winsys_update_sync,
|
||||
#endif
|
||||
|
@ -130,17 +130,6 @@ typedef struct _CoglWinsysVtable
|
||||
CoglTexturePixmapStereoMode stereo_mode);
|
||||
#endif
|
||||
|
||||
void *
|
||||
(*fence_add) (CoglContext *ctx);
|
||||
|
||||
gboolean
|
||||
(*fence_is_complete) (CoglContext *ctx,
|
||||
void *fence);
|
||||
|
||||
void
|
||||
(*fence_destroy) (CoglContext *ctx,
|
||||
void *fence);
|
||||
|
||||
void
|
||||
(*update_sync) (CoglContext *ctx);
|
||||
|
||||
|
@ -38,7 +38,6 @@ cogl_tests = [
|
||||
[ 'test-pipeline-cache-unrefs-texture', [] ],
|
||||
[ 'test-pipeline-shader-state', [] ],
|
||||
[ 'test-texture-rg', [] ],
|
||||
[ 'test-fence', [] ],
|
||||
]
|
||||
|
||||
#unported = [
|
||||
|
@ -1,68 +0,0 @@
|
||||
#include <cogl/cogl.h>
|
||||
|
||||
#include "tests/cogl-test-utils.h"
|
||||
|
||||
/* I'm writing this on the train after having dinner at a churrascuria. */
|
||||
#define MAGIC_CHUNK_O_DATA ((void *) 0xdeadbeef)
|
||||
|
||||
static GMainLoop *loop;
|
||||
|
||||
static gboolean
|
||||
timeout (void *user_data)
|
||||
{
|
||||
g_assert (!"timeout not reached");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
callback (CoglFence *fence,
|
||||
void *user_data)
|
||||
{
|
||||
int fb_width = cogl_framebuffer_get_width (test_fb);
|
||||
int fb_height = cogl_framebuffer_get_height (test_fb);
|
||||
|
||||
test_utils_check_pixel (test_fb, fb_width - 1, fb_height - 1, 0x00ff0000);
|
||||
g_assert (user_data == MAGIC_CHUNK_O_DATA && "callback data not mangled");
|
||||
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static void
|
||||
test_fence (void)
|
||||
{
|
||||
GSource *cogl_source;
|
||||
int fb_width = cogl_framebuffer_get_width (test_fb);
|
||||
int fb_height = cogl_framebuffer_get_height (test_fb);
|
||||
CoglFenceClosure *closure;
|
||||
|
||||
if (!cogl_has_feature (test_ctx, COGL_FEATURE_ID_FENCE))
|
||||
{
|
||||
g_test_skip ("Missing fence support");
|
||||
return;
|
||||
}
|
||||
|
||||
cogl_source = cogl_glib_source_new (test_ctx, G_PRIORITY_DEFAULT);
|
||||
g_source_attach (cogl_source, NULL);
|
||||
loop = g_main_loop_new (NULL, TRUE);
|
||||
|
||||
cogl_framebuffer_orthographic (test_fb, 0, 0, fb_width, fb_height, -1, 100);
|
||||
cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR,
|
||||
0.0f, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
closure = cogl_framebuffer_add_fence_callback (test_fb,
|
||||
callback,
|
||||
MAGIC_CHUNK_O_DATA);
|
||||
g_assert (closure != NULL);
|
||||
|
||||
g_timeout_add_seconds (5, timeout, NULL);
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
if (cogl_test_verbose ())
|
||||
g_print ("OK\n");
|
||||
}
|
||||
|
||||
COGL_TEST_SUITE (
|
||||
g_test_add_func ("/fence", test_fence);
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user