[Cogl] [PATCH] buffer: Use GL_STREAM_DRAW on GLES2
Robert Bragg
robert at sixbynine.org
Wed May 2 08:00:54 PDT 2012
Yeah, this all looks sensible and good to land to me.
Reviewed-by: Robert Bragg <robert at linux.intel.com>
regards,
- Robert
On Wed, May 2, 2012 at 10:31 AM, Neil Roberts <neil at linux.intel.com> wrote:
> The function to convert the CoglBufferUpdateHint to a GL enum was
> previously ifdef'd to only use GL_STREAM_DRAW when Cogl is compiled
> with big GL support. One problem with this is that it would end up
> trying to use it on GLES1 if support for both is compiled. The other
> problem is that GLES2 seems to actually support GL_STREAM_DRAW so we
> might as well use it in that case.
>
> This patch also changes it so that if the hint is stream with GLES1
> then it will default to GL_DYNAMIC_DRAW instead of GL_STATIC_DRAW
> because I think that is closer to the meaning of the stream hint.
> ---
> cogl/cogl-buffer.c | 33 +++++++++++++++++++--------------
> 1 files changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
> index 3cfe0dc..92169ee 100644
> --- a/cogl/cogl-buffer.c
> +++ b/cogl/cogl-buffer.c
> @@ -147,21 +147,27 @@ _cogl_buffer_bind_no_create (CoglBuffer *buffer,
> }
>
> static GLenum
> -_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint,
> - CoglBufferUpdateHint update_hint)
> +_cogl_buffer_hints_to_gl_enum (CoglBuffer *buffer)
> {
> - /* usage hint is always TEXTURE for now */
> - if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC)
> - return GL_STATIC_DRAW;
> - if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC)
> - return GL_DYNAMIC_DRAW;
> - /* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */
> -#ifdef HAVE_COGL_GL
> - if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM)
> - return GL_STREAM_DRAW;
> + /* usage hint is always DRAW for now */
> + switch (buffer->update_hint)
> + {
> + case COGL_BUFFER_UPDATE_HINT_STATIC:
> + return GL_STATIC_DRAW;
> + case COGL_BUFFER_UPDATE_HINT_DYNAMIC:
> + return GL_DYNAMIC_DRAW;
> +
> + case COGL_BUFFER_UPDATE_HINT_STREAM:
> + /* OpenGL ES 1.1 only knows about STATIC_DRAW and DYNAMIC_DRAW */
> +#if defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2)
> + if (buffer->context->driver != COGL_DRIVER_GLES1)
> + return GL_STREAM_DRAW;
> +#else
> + return GL_DYNAMIC_DRAW;
> #endif
> + }
>
> - return GL_STATIC_DRAW;
> + g_assert_not_reached ();
> }
>
> static void
> @@ -173,8 +179,7 @@ bo_recreate_store (CoglBuffer *buffer)
> /* This assumes the buffer is already bound */
>
> gl_target = convert_bind_target_to_gl_target (buffer->last_target);
> - gl_enum = _cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
> - buffer->update_hint);
> + gl_enum = _cogl_buffer_hints_to_gl_enum (buffer);
>
> GE( buffer->context, glBufferData (gl_target,
> buffer->size,
> --
> 1.7.3.16.g9464b
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
More information about the Cogl
mailing list