[MPlayer-cvslog] r36774 - in trunk/libvo: gl_common.c gl_common.h gl_compat.h vo_gl.c
reimar
subversion at mplayerhq.hu
Sat Feb 1 16:13:00 CET 2014
Author: reimar
Date: Sat Feb 1 16:13:00 2014
New Revision: 36774
Log:
Use glMapBufferRange by default.
It should provide better performance and in addition is
available in GLESv3.
Modified:
trunk/libvo/gl_common.c
trunk/libvo/gl_common.h
trunk/libvo/gl_compat.h
trunk/libvo/vo_gl.c
Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c Sat Feb 1 09:01:55 2014 (r36773)
+++ trunk/libvo/gl_common.c Sat Feb 1 16:13:00 2014 (r36774)
@@ -99,7 +99,8 @@ void (GLAPIENTRY *mpglColorMask)(GLboole
void (GLAPIENTRY *mpglGenBuffers)(GLsizei, GLuint *);
void (GLAPIENTRY *mpglDeleteBuffers)(GLsizei, const GLuint *);
void (GLAPIENTRY *mpglBindBuffer)(GLenum, GLuint);
-GLvoid* (GLAPIENTRY *mpglMapBuffer)(GLenum, GLenum);
+static GLvoid* (GLAPIENTRY *mpglMapBuffer)(GLenum, GLenum);
+GLvoid* (GLAPIENTRY *mpglMapBufferRange)(GLenum, ptrdiff_t, ptrdiff_t, unsigned);
GLboolean (GLAPIENTRY *mpglUnmapBuffer)(GLenum);
void (GLAPIENTRY *mpglBufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
void (GLAPIENTRY *mpglCombinerParameterfv)(GLenum, const GLfloat *);
@@ -488,6 +489,7 @@ static const extfunc_desc_t extfuncs[] =
{&mpglDeleteBuffers, NULL, {"glDeleteBuffers", "glDeleteBuffersARB", NULL}},
{&mpglBindBuffer, NULL, {"glBindBuffer", "glBindBufferARB", NULL}},
{&mpglMapBuffer, NULL, {"glMapBuffer", "glMapBufferARB", NULL}},
+ {&mpglMapBufferRange, NULL, {"glMapBufferRange", "glMapBufferRangeARB", NULL}},
{&mpglUnmapBuffer, NULL, {"glUnmapBuffer", "glUnmapBufferARB", NULL}},
{&mpglBufferData, NULL, {"glBufferData", "glBufferDataARB", NULL}},
{&mpglCombinerParameterfv, "NV_register_combiners", {"glCombinerParameterfv", "glCombinerParameterfvNV", NULL}},
@@ -547,6 +549,17 @@ static const extfunc_desc_t extfuncs[] =
{NULL}
};
+static GLvoid *wrap_glMapBuffer(GLenum target, ptrdiff_t offset, ptrdiff_t range, unsigned flags) {
+ GLenum access = GL_READ_WRITE;
+ if (offset != 0 || range == 0 || !(flags & (GL_MAP_WRITE_BIT | GL_MAP_READ_BIT)))
+ return NULL;
+ if (!(flags & GL_MAP_WRITE_BIT))
+ access = GL_READ_ONLY;
+ else if (!(flags & GL_MAP_READ_BIT))
+ access = GL_WRITE_ONLY;
+ return mpglMapBuffer(target, access);
+}
+
/**
* \brief find the function pointers of some useful OpenGL extensions
* \param getProcAddress function to resolve function names, may be NULL
@@ -598,6 +611,10 @@ static void getFunctions(void *(*getProc
!!strstr(allexts, "GL_ARB_shadow") ||
!!strstr(allexts, "GL_OES_depth_texture");
free(allexts);
+
+ // replacement functions
+ if (!mpglMapBufferRange && mpglMapBuffer)
+ mpglMapBufferRange = wrap_glMapBuffer;
}
/**
Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h Sat Feb 1 09:01:55 2014 (r36773)
+++ trunk/libvo/gl_common.h Sat Feb 1 16:13:00 2014 (r36774)
@@ -281,7 +281,7 @@ extern void (GLAPIENTRY *mpglColorMask)(
extern void (GLAPIENTRY *mpglGenBuffers)(GLsizei, GLuint *);
extern void (GLAPIENTRY *mpglDeleteBuffers)(GLsizei, const GLuint *);
extern void (GLAPIENTRY *mpglBindBuffer)(GLenum, GLuint);
-extern GLvoid* (GLAPIENTRY *mpglMapBuffer)(GLenum, GLenum);
+extern GLvoid* (GLAPIENTRY *mpglMapBufferRange)(GLenum, ptrdiff_t, ptrdiff_t, unsigned);
extern GLboolean (GLAPIENTRY *mpglUnmapBuffer)(GLenum);
extern void (GLAPIENTRY *mpglBufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
extern void (GLAPIENTRY *mpglCombinerParameterfv)(GLenum, const GLfloat *);
Modified: trunk/libvo/gl_compat.h
==============================================================================
--- trunk/libvo/gl_compat.h Sat Feb 1 09:01:55 2014 (r36773)
+++ trunk/libvo/gl_compat.h Sat Feb 1 16:13:00 2014 (r36774)
@@ -308,9 +308,33 @@
#ifndef GL_DYNAMIC_DRAW
#define GL_DYNAMIC_DRAW 0x88E8
#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
+#ifndef GL_MAP_READ_BIT
+#define GL_MAP_READ_BIT 0x0001
+#endif
+#ifndef GL_MAP_WRITE_BIT
+#define GL_MAP_WRITE_BIT 0x0002
+#endif
+#ifndef GL_MAP_INVALIDATE_RANGE_BIT
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#endif
+#ifndef GL_MAP_INVALIDATE_BUFFER_BIT
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#endif
+#ifndef GL_MAP_FLUSH_EXPLICIT_BIT
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#endif
+#ifndef GL_MAP_UNSYNCHRONIZED_BIT
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#endif
#ifndef GL_BGR
#define GL_BGR 0x80E0
#endif
Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c Sat Feb 1 09:01:55 2014 (r36773)
+++ trunk/libvo/vo_gl.c Sat Feb 1 16:13:00 2014 (r36774)
@@ -934,7 +934,7 @@ static int draw_slice(uint8_t *src[], in
static int get_pbo_image(mp_image_t *mpi) {
int needed_size;
- if (!mpglGenBuffers || !mpglBindBuffer || !mpglBufferData || !mpglMapBuffer) {
+ if (!mpglGenBuffers || !mpglBindBuffer || !mpglBufferData || !mpglMapBufferRange) {
if (!err_shown)
mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n"
"Expect a _major_ speed penalty\n");
@@ -964,7 +964,7 @@ static int get_pbo_image(mp_image_t *mpi
NULL, GL_DYNAMIC_DRAW);
}
if (!gl_bufferptr)
- gl_bufferptr = mpglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ gl_bufferptr = mpglMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, needed_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
mpi->priv = gl_bufferptr;
mpi->planes[0] = (uint8_t *)gl_bufferptr + (-(intptr_t)gl_bufferptr & 31);
mpglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
@@ -1002,9 +1002,9 @@ static int get_pbo_image(mp_image_t *mpi
}
if (!gl_bufferptr_uv[0]) {
mpglBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[0]);
- gl_bufferptr_uv[0] = mpglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ gl_bufferptr_uv[0] = mpglMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, mpi->stride[1] * mpi->height, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
mpglBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[1]);
- gl_bufferptr_uv[1] = mpglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ gl_bufferptr_uv[1] = mpglMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, mpi->stride[1] * mpi->height, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
}
mpi->planes[1] = gl_bufferptr_uv[0];
mpi->planes[2] = gl_bufferptr_uv[1];
More information about the MPlayer-cvslog
mailing list