Mercurial > mplayer.hg
diff libvo/gl_common.c @ 36678:61a9df2e25d0
Use glMapBufferRange by default.
It should provide better performance and in addition is
available in GLESv3.
author | reimar |
---|---|
date | Sat, 01 Feb 2014 15:13:00 +0000 |
parents | e8640e3f9b7e |
children |
line wrap: on
line diff
--- a/libvo/gl_common.c Sat Feb 01 08:01:55 2014 +0000 +++ b/libvo/gl_common.c Sat Feb 01 15:13:00 2014 +0000 @@ -99,7 +99,8 @@ 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 @@ {&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 @@ {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 @@ !!strstr(allexts, "GL_ARB_shadow") || !!strstr(allexts, "GL_OES_depth_texture"); free(allexts); + + // replacement functions + if (!mpglMapBufferRange && mpglMapBuffer) + mpglMapBufferRange = wrap_glMapBuffer; } /**