Bug 1048747 - WebGL2 - GL symbols for Uniform Buffers.; r=jgilbert
authorDan Glastonbury <dglastonbury@mozilla.com>
Mon, 14 Jul 2014 14:34:17 +1000
changeset 206622 b3c0b2156cff6f0b3ad2e588d4c8a994821c9f15
parent 206621 037d0c1640ae17bf171a390711e4601d47841bf0
child 206623 6465e8acae5e16b7a26679c7ecc6d80fa8aa4b47
push id49466
push userdglastonbury@mozilla.com
push dateTue, 23 Sep 2014 07:23:11 +0000
treeherdermozilla-inbound@b3c0b2156cff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1048747
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1048747 - WebGL2 - GL symbols for Uniform Buffers.; r=jgilbert
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
gfx/gl/GLContextSymbols.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -88,16 +88,17 @@ static const char *sExtensionNames[] = {
     "GL_ARB_map_buffer_range",
     "GL_ARB_occlusion_query2",
     "GL_ARB_pixel_buffer_object",
     "GL_ARB_robustness",
     "GL_ARB_sync",
     "GL_ARB_texture_float",
     "GL_ARB_texture_non_power_of_two",
     "GL_ARB_texture_rectangle",
+    "GL_ARB_uniform_buffer_object",
     "GL_ARB_vertex_array_object",
     "GL_EXT_bgra",
     "GL_EXT_blend_minmax",
     "GL_EXT_color_buffer_float",
     "GL_EXT_color_buffer_half_float",
     "GL_EXT_draw_buffers",
     "GL_EXT_draw_instanced",
     "GL_EXT_draw_range_elements",
@@ -1097,16 +1098,37 @@ GLContext::InitWithPrefix(const char *pr
             if (!LoadSymbols(mapBufferRangeSymbols, trygl, prefix)) {
                 NS_ERROR("GL supports map_buffer_range without supplying its functions.");
 
                 MarkUnsupported(GLFeature::map_buffer_range);
                 ClearSymbols(mapBufferRangeSymbols);
             }
         }
 
+        if (IsSupported(GLFeature::uniform_buffer_object)) {
+            SymLoadStruct uboSymbols[] = {
+                { (PRFuncPtr*) &mSymbols.fGetUniformIndices, { "GetUniformIndices", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fGetActiveUniformsiv, { "GetActiveUniformsiv", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fGetActiveUniformName, { "GetActiveUniformName", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fGetUniformBlockIndex, { "GetUniformBlockIndex", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockiv, { "GetActiveUniformBlockiv", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockName, { "GetActiveUniformBlockName", nullptr } },
+                { (PRFuncPtr*) &mSymbols.fUniformBlockBinding, { "UniformBlockBinding", nullptr } },
+                END_SYMBOLS
+            };
+
+            if (!LoadSymbols(&uboSymbols[0], trygl, prefix)) {
+                NS_ERROR("GL supports ARB_uniform_buffer_object without supplying its functions.");
+
+                MarkExtensionUnsupported(ARB_uniform_buffer_object);
+                MarkUnsupported(GLFeature::uniform_buffer_object);
+                ClearSymbols(uboSymbols);
+            }
+        }
+
         if (IsExtensionSupported(KHR_debug)) {
             SymLoadStruct extSymbols[] = {
                 { (PRFuncPtr*) &mSymbols.fDebugMessageControl,  { "DebugMessageControl",  "DebugMessageControlKHR",  nullptr } },
                 { (PRFuncPtr*) &mSymbols.fDebugMessageInsert,   { "DebugMessageInsert",   "DebugMessageInsertKHR",   nullptr } },
                 { (PRFuncPtr*) &mSymbols.fDebugMessageCallback, { "DebugMessageCallback", "DebugMessageCallbackKHR", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fGetDebugMessageLog,   { "GetDebugMessageLog",   "GetDebugMessageLogKHR",   nullptr } },
                 { (PRFuncPtr*) &mSymbols.fGetPointerv,          { "GetPointerv",          "GetPointervKHR",          nullptr } },
                 { (PRFuncPtr*) &mSymbols.fPushDebugGroup,       { "PushDebugGroup",       "PushDebugGroupKHR",       nullptr } },
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -109,16 +109,17 @@ MOZ_BEGIN_ENUM_CLASS(GLFeature)
     sRGB,
     standard_derivatives,
     texture_float,
     texture_float_linear,
     texture_half_float,
     texture_half_float_linear,
     texture_non_power_of_two,
     transform_feedback,
+    uniform_buffer_object,
     vertex_array_object,
     EnumMax
 MOZ_END_ENUM_CLASS(GLFeature)
 
 MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
     Unknown = 0,
     OpenGL, // only for IsAtLeast's <profile> parameter
     OpenGLCore,
@@ -360,16 +361,17 @@ public:
         ARB_map_buffer_range,
         ARB_occlusion_query2,
         ARB_pixel_buffer_object,
         ARB_robustness,
         ARB_sync,
         ARB_texture_float,
         ARB_texture_non_power_of_two,
         ARB_texture_rectangle,
+        ARB_uniform_buffer_object,
         ARB_vertex_array_object,
         EXT_bgra,
         EXT_blend_minmax,
         EXT_color_buffer_float,
         EXT_color_buffer_half_float,
         EXT_draw_buffers,
         EXT_draw_instanced,
         EXT_draw_range_elements,
@@ -2698,16 +2700,80 @@ public:
         ASSERT_SYMBOL_PRESENT(fFlushMappedBufferRange);
         BEFORE_GL_CALL;
         mSymbols.fFlushMappedBufferRange(target, offset, length);
         AFTER_GL_CALL;
     }
 
 
 // -----------------------------------------------------------------------------
+// Core GL & Extension ARB_uniform_buffer_object
+public:
+    void fGetUniformIndices(GLuint program, GLsizei uniformCount,
+                            const GLchar* const* uniformNames, GLuint* uniformIndices)
+    {
+        ASSERT_SYMBOL_PRESENT(fGetUniformIndices);
+        BEFORE_GL_CALL;
+        mSymbols.fGetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
+        AFTER_GL_CALL;
+    }
+
+    void fGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices,
+                              GLenum pname, GLint* params)
+    {
+        ASSERT_SYMBOL_PRESENT(fGetActiveUniformsiv);
+        BEFORE_GL_CALL;
+        mSymbols.fGetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
+        AFTER_GL_CALL;
+    }
+
+    void fGetActiveUniformName(GLuint program, GLuint uniformIndex, GLsizei bufSize,
+                               GLsizei* length, GLchar* uniformName)
+    {
+        ASSERT_SYMBOL_PRESENT(fGetActiveUniformName);
+        BEFORE_GL_CALL;
+        mSymbols.fGetActiveUniformName(program, uniformIndex, bufSize, length, uniformName);
+        AFTER_GL_CALL;
+    }
+
+    GLuint fGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) {
+        ASSERT_SYMBOL_PRESENT(fGetUniformBlockIndex);
+        BEFORE_GL_CALL;
+        GLuint result = mSymbols.fGetUniformBlockIndex(program, uniformBlockName);
+        AFTER_GL_CALL;
+        return result;
+    }
+
+    void fGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex,
+                                  GLenum pname, GLint* params)
+    {
+        ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockiv);
+        BEFORE_GL_CALL;
+        mSymbols.fGetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
+        AFTER_GL_CALL;
+    }
+
+    void fGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize,
+                                    GLsizei* length, GLchar* uniformBlockName)
+    {
+        ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockName);
+        BEFORE_GL_CALL;
+        mSymbols.fGetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
+        AFTER_GL_CALL;
+    }
+
+    void fUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) {
+        ASSERT_SYMBOL_PRESENT(fUniformBlockBinding);
+        BEFORE_GL_CALL;
+        mSymbols.fUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
+        AFTER_GL_CALL;
+    }
+
+
+// -----------------------------------------------------------------------------
 // Constructor
 protected:
     explicit GLContext(const SurfaceCaps& caps,
                        GLContext* sharedContext = nullptr,
                        bool isOffscreen = false);
 
 
 // -----------------------------------------------------------------------------
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -463,16 +463,25 @@ static const FeatureInfo sFeatureInfoArr
         GLContext::Extension_None,
         {
             GLContext::EXT_transform_feedback,
             GLContext::NV_transform_feedback,
             GLContext::Extensions_End
         }
     },
     {
+        "uniform_buffer_object",
+        310, // OpenGL version
+        300, // OpenGL ES version
+        GLContext::ARB_uniform_buffer_object,
+        {
+            GLContext::Extensions_End
+        }
+    },
+    {
         "vertex_array_object",
         300, // OpenGL version
         300, // OpenGL ES version
         GLContext::ARB_vertex_array_object, // ARB extension
         {
             GLContext::OES_vertex_array_object,
             GLContext::APPLE_vertex_array_object,
             GLContext::Extensions_End
--- a/gfx/gl/GLContextSymbols.h
+++ b/gfx/gl/GLContextSymbols.h
@@ -528,14 +528,32 @@ struct GLContextSymbols
     typedef void (GLAPIENTRY * pfnGetFenceivT) (GLuint fence, GLenum pname, GLint* params);
     pfnGetFenceivT fGetFenceiv;
 
     // map_buffer_range
     typedef void* (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
     PFNGLMAPBUFFERRANGEPROC fMapBufferRange;
     typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
     PFNGLFLUSHMAPPEDBUFFERRANGEPROC fFlushMappedBufferRange;
+
+    // uniform_buffer_object
+    typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount,
+                                                            const GLchar* const* uniformNames, GLuint* uniformIndices);
+    PFNGLGETUNIFORMINDICESPROC fGetUniformIndices;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices,
+                                                             GLenum pname, GLint* params);
+    PFNGLGETACTIVEUNIFORMSIVPROC fGetActiveUniformsiv;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIdex, GLsizei bufSize, GLsizei* length, GLchar* uniformName);
+    PFNGLGETACTIVEUNIFORMNAMEPROC fGetActiveUniformName;
+    typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName);
+    PFNGLGETUNIFORMBLOCKINDEXPROC fGetUniformBlockIndex;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
+    PFNGLGETACTIVEUNIFORMBLOCKIVPROC fGetActiveUniformBlockiv;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
+    PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC fGetActiveUniformBlockName;
+    typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+    PFNGLUNIFORMBLOCKBINDINGPROC fUniformBlockBinding;
 };
 
 }
 }
 
 #endif /* GLCONTEXTSYMBOLS_H_ */