Bug 1457546 - Add support for GL_OES_mapbuffer. r?jgilbert draft
authorMarkus Stange <mstange@themasta.com>
Fri, 27 Apr 2018 16:39:19 -0400
changeset 789318 e56f446fd30a4bae1366ee1c35fa3ca60def9f50
parent 789317 319c1af2769d743028b613a67f1933c1407f859e
push id108253
push userbmo:mstange@themasta.com
push dateSat, 28 Apr 2018 02:13:32 +0000
reviewersjgilbert
bugs1457546
milestone61.0a1
Bug 1457546 - Add support for GL_OES_mapbuffer. r?jgilbert MozReview-Commit-ID: 9Kk6ylDtFti
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -177,16 +177,17 @@ static const char* const sExtensionNames
     "GL_OES_EGL_image_external",
     "GL_OES_EGL_sync",
     "GL_OES_compressed_ETC1_RGB8_texture",
     "GL_OES_depth24",
     "GL_OES_depth32",
     "GL_OES_depth_texture",
     "GL_OES_element_index_uint",
     "GL_OES_framebuffer_object",
+    "GL_OES_mapbuffer",
     "GL_OES_packed_depth_stencil",
     "GL_OES_rgb8_rgba8",
     "GL_OES_standard_derivatives",
     "GL_OES_stencil8",
     "GL_OES_texture_3D",
     "GL_OES_texture_float",
     "GL_OES_texture_float_linear",
     "GL_OES_texture_half_float",
@@ -589,18 +590,16 @@ GLContext::InitWithPrefixImpl(const char
 
         if (!LoadGLSymbols(this, prefix, trygl, symbols, "OpenGL ES"))
             return false;
     } else {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fClearDepth, { "ClearDepth", nullptr } },
             { (PRFuncPtr*) &mSymbols.fDepthRange, { "DepthRange", nullptr } },
             { (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
             { (PRFuncPtr*) &mSymbols.fPointParameterf, { "PointParameterf", nullptr } },
             { (PRFuncPtr*) &mSymbols.fDrawBuffer, { "DrawBuffer", nullptr } },
             // The following functions are only used by Skia/GL in desktop mode.
             // Other parts of Gecko should avoid using these
             { (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
             { (PRFuncPtr*) &mSymbols.fClientActiveTexture, { "ClientActiveTexture", nullptr } },
             { (PRFuncPtr*) &mSymbols.fDisableClientState, { "DisableClientState", nullptr } },
             { (PRFuncPtr*) &mSymbols.fEnableClientState, { "EnableClientState", nullptr } },
@@ -757,22 +756,16 @@ GLContext::InitWithPrefixImpl(const char
 
         const auto versionStr = (const char*)fGetString(LOCAL_GL_VERSION);
         if (strstr(versionStr, "Mesa")) {
             // DrawElementsInstanced hangs the driver.
             MarkUnsupported(GLFeature::robust_buffer_access_behavior);
         }
     }
 
-    if (IsExtensionSupported(GLContext::ARB_pixel_buffer_object)) {
-        MOZ_ASSERT((mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
-                   "ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer"
-                   " being available!");
-    }
-
     ////////////////////////////////////////////////////////////////////////////
 
     const auto fnLoadForFeature = [this, prefix, trygl](const SymLoadStruct* list,
                                                         GLFeature feature)
     {
         return this->LoadFeatureSymbols(prefix, trygl, list, feature);
     };
 
@@ -871,16 +864,22 @@ GLContext::InitWithPrefixImpl(const char
 
     const auto err = mSymbols.fGetError();
     MOZ_RELEASE_ASSERT(!err);
     if (err)
         return false;
 
     LoadMoreSymbols(prefix, trygl);
 
+    if (IsExtensionSupported(GLContext::ARB_pixel_buffer_object)) {
+        MOZ_ASSERT((mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
+                   "ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer"
+                   " being available!");
+    }
+
     ////////////////////////////////////////////////////////////////////////////
 
     raw_fGetIntegerv(LOCAL_GL_VIEWPORT, mViewportRect);
     raw_fGetIntegerv(LOCAL_GL_SCISSOR_BOX, mScissorRect);
     raw_fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
     raw_fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mMaxCubeMapTextureSize);
     raw_fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize);
     raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
@@ -1363,16 +1362,25 @@ GLContext::LoadMoreSymbols(const char* p
             { (PRFuncPtr*) &mSymbols.fUniform4uiv, { "Uniform4uiv", "Uniform4uivEXT", nullptr } },
             { (PRFuncPtr*) &mSymbols.fGetFragDataLocation, { "GetFragDataLocation", "GetFragDataLocationEXT", nullptr } },
             { (PRFuncPtr*) &mSymbols.fGetUniformuiv, { "GetUniformuiv", "GetUniformuivEXT", nullptr } },
             END_SYMBOLS
         };
         fnLoadForFeature(symbols, GLFeature::gpu_shader4);
     }
 
+    if (IsSupported(GLFeature::mapbuffer)) {
+        const SymLoadStruct symbols[] = {
+            { (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", "MapBufferOES", nullptr } },
+            { (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", "UnmapBufferOES", nullptr } },
+            END_SYMBOLS
+        };
+        fnLoadForFeature(symbols, GLFeature::mapbuffer);
+    }
+
     if (IsSupported(GLFeature::map_buffer_range)) {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fMapBufferRange, { "MapBufferRange", nullptr } },
             { (PRFuncPtr*) &mSymbols.fFlushMappedBufferRange, { "FlushMappedBufferRange", nullptr } },
             { (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
             END_SYMBOLS
         };
         fnLoadForFeature(symbols, GLFeature::map_buffer_range);
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -102,16 +102,17 @@ enum class GLFeature {
     get_integer64_indexed,
     get_query_object_i64v,
     get_query_object_iv,
     gpu_shader4,
     instanced_arrays,
     instanced_non_arrays,
     internalformat_query,
     invalidate_framebuffer,
+    mapbuffer,
     map_buffer_range,
     occlusion_query,
     occlusion_query_boolean,
     occlusion_query2,
     packed_depth_stencil,
     prim_restart,
     prim_restart_fixed,
     query_counter,
@@ -476,16 +477,17 @@ public:
         OES_EGL_image_external,
         OES_EGL_sync,
         OES_compressed_ETC1_RGB8_texture,
         OES_depth24,
         OES_depth32,
         OES_depth_texture,
         OES_element_index_uint,
         OES_framebuffer_object,
+        OES_mapbuffer,
         OES_packed_depth_stencil,
         OES_rgb8_rgba8,
         OES_standard_derivatives,
         OES_stencil8,
         OES_texture_3D,
         OES_texture_float,
         OES_texture_float_linear,
         OES_texture_half_float,
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -362,16 +362,26 @@ static const FeatureInfo sFeatureInfoArr
         GLVersion::GL4_3,
         GLESVersion::ES3,
         GLContext::ARB_invalidate_subdata,
         {
             GLContext::Extensions_End
         }
     },
     {
+        "mapbuffer",
+        GLVersion::GL2,
+        GLESVersion::ES2,
+        GLContext::Extension_None,
+        {
+            GLContext::OES_mapbuffer,
+            GLContext::Extensions_End
+        }
+    },
+    {
         "map_buffer_range",
         GLVersion::GL3,
         GLESVersion::ES3,
         GLContext::ARB_map_buffer_range,
         {
             GLContext::Extensions_End
         }
     },