mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl-buffer: Support mapping buffers for write on GLES
GLES has an extension called GL_OES_mapbuffer to support mapping buffer objects but only for writing. Cogl now has two new feature flags to advertise whether mapping for reading and writing is supported. Under OpenGL, these features are always set if the VBO extension is advertised and under GLES only the write flag is set if the GL_OES_mapbuffer extension is advertised.
This commit is contained in:
parent
36b996672c
commit
4f08e3cf6e
@ -57,11 +57,13 @@
|
|||||||
#define glBufferSubData ctx->drv.pf_glBufferSubData
|
#define glBufferSubData ctx->drv.pf_glBufferSubData
|
||||||
#define glGetBufferSubData ctx->drv.pf_glGetBufferSubData
|
#define glGetBufferSubData ctx->drv.pf_glGetBufferSubData
|
||||||
#define glDeleteBuffers ctx->drv.pf_glDeleteBuffers
|
#define glDeleteBuffers ctx->drv.pf_glDeleteBuffers
|
||||||
#define glMapBuffer ctx->drv.pf_glMapBuffer
|
|
||||||
#define glUnmapBuffer ctx->drv.pf_glUnmapBuffer
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* These two are always accessed through an extension, even on GLES */
|
||||||
|
#define glMapBuffer ctx->drv.pf_glMapBuffer
|
||||||
|
#define glUnmapBuffer ctx->drv.pf_glUnmapBuffer
|
||||||
|
|
||||||
#ifndef GL_PIXEL_PACK_BUFFER
|
#ifndef GL_PIXEL_PACK_BUFFER
|
||||||
#define GL_PIXEL_PACK_BUFFER 0x88EB
|
#define GL_PIXEL_PACK_BUFFER 0x88EB
|
||||||
#endif
|
#endif
|
||||||
@ -74,6 +76,15 @@
|
|||||||
#ifndef GL_ELEMENT_ARRAY_BUFFER
|
#ifndef GL_ELEMENT_ARRAY_BUFFER
|
||||||
#define GL_ARRAY_BUFFER 0x8893
|
#define GL_ARRAY_BUFFER 0x8893
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GL_READ_ONLY
|
||||||
|
#define GL_READ_ONLY 0x88B8
|
||||||
|
#endif
|
||||||
|
#ifndef GL_WRITE_ONLY
|
||||||
|
#define GL_WRITE_ONLY 0x88B9
|
||||||
|
#endif
|
||||||
|
#ifndef GL_READ_WRITE
|
||||||
|
#define GL_READ_WRITE 0x88BA
|
||||||
|
#endif
|
||||||
|
|
||||||
/* XXX:
|
/* XXX:
|
||||||
* The CoglHandle macros don't support any form of inheritance, so for
|
* The CoglHandle macros don't support any form of inheritance, so for
|
||||||
@ -131,13 +142,19 @@ bo_map (CoglBuffer *buffer,
|
|||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints)
|
CoglBufferMapHint hints)
|
||||||
{
|
{
|
||||||
#ifndef COGL_HAS_GLES
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
CoglBufferBindTarget target;
|
CoglBufferBindTarget target;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
_COGL_GET_CONTEXT (ctx, NULL);
|
||||||
|
|
||||||
|
if ((access & COGL_BUFFER_ACCESS_READ) &&
|
||||||
|
!cogl_features_available (COGL_FEATURE_MAP_BUFFER_FOR_READ))
|
||||||
|
return NULL;
|
||||||
|
if ((access & COGL_BUFFER_ACCESS_WRITE) &&
|
||||||
|
!cogl_features_available (COGL_FEATURE_MAP_BUFFER_FOR_WRITE))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
target = buffer->last_target;
|
target = buffer->last_target;
|
||||||
_cogl_buffer_bind (buffer, target);
|
_cogl_buffer_bind (buffer, target);
|
||||||
|
|
||||||
@ -164,18 +181,11 @@ bo_map (CoglBuffer *buffer,
|
|||||||
_cogl_buffer_unbind (buffer);
|
_cogl_buffer_unbind (buffer);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
#else /* COGL_HAS_GLES */
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
#endif /* COGL_HAS_GLES */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bo_unmap (CoglBuffer *buffer)
|
bo_unmap (CoglBuffer *buffer)
|
||||||
{
|
{
|
||||||
#ifndef COGL_HAS_GLES
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
_cogl_buffer_bind (buffer, buffer->last_target);
|
_cogl_buffer_bind (buffer, buffer->last_target);
|
||||||
@ -184,9 +194,6 @@ bo_unmap (CoglBuffer *buffer)
|
|||||||
buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED;
|
buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED;
|
||||||
|
|
||||||
_cogl_buffer_unbind (buffer);
|
_cogl_buffer_unbind (buffer);
|
||||||
#else
|
|
||||||
g_return_if_reached ();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -306,16 +313,6 @@ _cogl_buffer_fini (CoglBuffer *buffer)
|
|||||||
g_free (buffer->data);
|
g_free (buffer->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenGL ES 1.1 and 2 have a GL_OES_mapbuffer extension that is able to map
|
|
||||||
* VBOs for write only, we don't support that in CoglBuffer */
|
|
||||||
#if defined (COGL_HAS_GLES)
|
|
||||||
GLenum
|
|
||||||
_cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
GLenum
|
GLenum
|
||||||
_cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
|
_cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
|
||||||
{
|
{
|
||||||
@ -326,7 +323,6 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
|
|||||||
else
|
else
|
||||||
return GL_READ_ONLY;
|
return GL_READ_ONLY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */
|
/* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */
|
||||||
#if defined (COGL_HAS_GLES)
|
#if defined (COGL_HAS_GLES)
|
||||||
|
@ -252,6 +252,10 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
|
|||||||
* @COGL_FEATURE_POINT_SPRITE: Whether
|
* @COGL_FEATURE_POINT_SPRITE: Whether
|
||||||
* cogl_material_set_layer_point_sprite_coords_enabled() is supported.
|
* cogl_material_set_layer_point_sprite_coords_enabled() is supported.
|
||||||
* @COGL_FEATURE_TEXTURE_3D: 3D texture support
|
* @COGL_FEATURE_TEXTURE_3D: 3D texture support
|
||||||
|
* @COGL_FEATURE_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is
|
||||||
|
* supported with CoglBufferAccess including read support.
|
||||||
|
* @COGL_FEATURE_MAP_BUFFER_FOR_WRITE: Whether cogl_buffer_map() is
|
||||||
|
* supported with CoglBufferAccess including write support.
|
||||||
*
|
*
|
||||||
* Flags for the supported features.
|
* Flags for the supported features.
|
||||||
*
|
*
|
||||||
@ -278,7 +282,9 @@ typedef enum
|
|||||||
COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17),
|
COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17),
|
||||||
COGL_FEATURE_POINT_SPRITE = (1 << 18),
|
COGL_FEATURE_POINT_SPRITE = (1 << 18),
|
||||||
COGL_FEATURE_TEXTURE_3D = (1 << 19),
|
COGL_FEATURE_TEXTURE_3D = (1 << 19),
|
||||||
COGL_FEATURE_SHADERS_ARBFP = (1 << 20)
|
COGL_FEATURE_SHADERS_ARBFP = (1 << 20),
|
||||||
|
COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21),
|
||||||
|
COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22)
|
||||||
} CoglFeatureFlags;
|
} CoglFeatureFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +295,9 @@ COGL_FEATURE_END ()
|
|||||||
COGL_FEATURE_BEGIN (vbos, 1, 5,
|
COGL_FEATURE_BEGIN (vbos, 1, 5,
|
||||||
"ARB\0",
|
"ARB\0",
|
||||||
"vertex_buffer_object\0",
|
"vertex_buffer_object\0",
|
||||||
COGL_FEATURE_VBOS,
|
COGL_FEATURE_VBOS |
|
||||||
|
COGL_FEATURE_MAP_BUFFER_FOR_READ |
|
||||||
|
COGL_FEATURE_MAP_BUFFER_FOR_WRITE,
|
||||||
0)
|
0)
|
||||||
COGL_FEATURE_FUNCTION (void, glGenBuffers,
|
COGL_FEATURE_FUNCTION (void, glGenBuffers,
|
||||||
(GLuint n,
|
(GLuint n,
|
||||||
|
@ -109,3 +109,15 @@ COGL_FEATURE_FUNCTION (void, glTexSubImage3D,
|
|||||||
GLsizei width, GLsizei height, GLsizei depth,
|
GLsizei width, GLsizei height, GLsizei depth,
|
||||||
GLenum format, GLenum type, const GLvoid* pixels))
|
GLenum format, GLenum type, const GLvoid* pixels))
|
||||||
COGL_FEATURE_END ()
|
COGL_FEATURE_END ()
|
||||||
|
|
||||||
|
COGL_FEATURE_BEGIN (map_buffer, 255, 255,
|
||||||
|
"OES\0",
|
||||||
|
"mapbuffer\0",
|
||||||
|
COGL_FEATURE_MAP_BUFFER_FOR_WRITE,
|
||||||
|
0)
|
||||||
|
COGL_FEATURE_FUNCTION (void *, glMapBuffer,
|
||||||
|
(GLenum target,
|
||||||
|
GLenum access))
|
||||||
|
COGL_FEATURE_FUNCTION (GLboolean, glUnmapBuffer,
|
||||||
|
(GLenum target))
|
||||||
|
COGL_FEATURE_END ()
|
||||||
|
Loading…
Reference in New Issue
Block a user