Avoid using glUnmapBufferOES with ES3
As reported in https://github.com/flutter/flutter/issues/10617#issuecomment-330935921,
we were mixing ES2 and ES3 API. This makes our interface assembly
code directly parallel our caps code.
Bug: skia:
Change-Id: I91c0696a223f7eaf27641dbe16ab451b0bdc362c
Reviewed-on: https://skia-review.googlesource.com/49440
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
index 6b0234a..d33a8b6 100644
--- a/src/gpu/gl/GrGLAssembleInterface.cpp
+++ b/src/gpu/gl/GrGLAssembleInterface.cpp
@@ -801,8 +801,22 @@
GET_PROC(GetRenderbufferParameteriv);
GET_PROC(RenderbufferStorage);
+ // There are several APIs for buffer mapping:
+ // ES2 + GL_OES_mapbuffer: MapBufferOES and UnmapBufferOES
+ // ES2 + GL_EXT_map_buffer_range: Adds MapBufferRangeEXT and FlushMappedBufferRangeEXT
+ // ES3: MapBufferRange, FlushMappedBufferRange, and UnmapBuffer are core (so no suffix).
+ //
+ // MapBuffer is not part of ES3, but implementations may still report the OES versions of
+ // MapBuffer and UnmapBuffer, per the older GL_OES_mapbuffer extension. Some implementations
+ // let us mix the newer MapBufferRange with the older UnmapBufferOES, but we've hit others that
+ // don't permit it. Note that in GrGLBuffer, we choose which API to use based on version and
+ // extensions. This code is written so that we never mix OES and non-OES functions.
GET_PROC_SUFFIX(MapBuffer, OES);
- GET_PROC_SUFFIX(UnmapBuffer, OES);
+ if (version >= GR_GL_VER(3, 0)) {
+ GET_PROC(UnmapBuffer);
+ } else {
+ GET_PROC_SUFFIX(UnmapBuffer, OES);
+ }
if (version >= GR_GL_VER(3,0)) {
GET_PROC(MapBufferRange);