buffer: Use GL_STREAM_DRAW on GLES2

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.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9e997476a7f9271bc000abdc82b1e343b92afb4c)
This commit is contained in:
Neil Roberts 2012-05-02 10:08:36 +01:00 committed by Robert Bragg
parent 2db173c316
commit d57fcd952e

View File

@ -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)
/* usage hint is always DRAW for now */
switch (buffer->update_hint)
{
case COGL_BUFFER_UPDATE_HINT_STATIC:
return GL_STATIC_DRAW;
if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC)
case 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;
#endif
return GL_STATIC_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
}
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,