Add GL_ARB_invalidate_subdata functions to GrGLInterface.
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 13:07:29 +0000 (13:07 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 13:07:29 +0000 (13:07 +0000)
BUG=skia:1541
R=egdaniel@google.com

Review URL: https://codereview.chromium.org/217503003

git-svn-id: http://skia.googlecode.com/svn/trunk@14004 2bbb7eff-a529-9590-31e7-b0007b416f81

include/gpu/gl/GrGLFunctions.h
include/gpu/gl/GrGLInterface.h
src/gpu/gl/GrGLInterface.cpp
src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp
src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp

index a896800d6b734b58b3279296a560ef230aad0bb1..532c19c42ea92e83e35d82d3ff2eae7d7242ace7 100644 (file)
@@ -141,6 +141,12 @@ extern "C" {
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetTexLevelParameterivProc)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params);
     typedef GrGLint (GR_GL_FUNCTION_TYPE* GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInsertEventMarkerProc)(GrGLsizei length, const char* marker);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateBufferDataProc)(GrGLuint buffer);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateBufferSubDataProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateFramebufferProc)(GrGLenum target, GrGLsizei numAttachments,  const GrGLenum *attachments);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateSubFramebufferProc)(GrGLenum target, GrGLsizei numAttachments, const GrGLenum *attachments, GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateTexImageProc)(GrGLuint texture, GrGLint level);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLInvalidateTexSubImageProc)(GrGLuint texture, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint zoffset, GrGLsizei width, GrGLsizei height, GrGLsizei depth);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLLineWidthProc)(GrGLfloat width);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLLinkProgramProc)(GrGLuint program);
     typedef GrGLvoid* (GR_GL_FUNCTION_TYPE* GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
index 3d34ae65bf25917cc9e70d95cb4a15bc53e11125..c403ce4dffe58318ac9730524f003866c8def3d4 100644 (file)
@@ -222,6 +222,12 @@ public:
         GLPtr<GrGLGetTexLevelParameterivProc> fGetTexLevelParameteriv;
         GLPtr<GrGLGetUniformLocationProc> fGetUniformLocation;
         GLPtr<GrGLInsertEventMarkerProc> fInsertEventMarker;
+        GLPtr<GrGLInvalidateBufferDataProc> fInvalidateBufferData;
+        GLPtr<GrGLInvalidateBufferSubDataProc> fInvalidateBufferSubData;
+        GLPtr<GrGLInvalidateFramebufferProc> fInvalidateFramebuffer;
+        GLPtr<GrGLInvalidateSubFramebufferProc> fInvalidateSubFramebuffer;
+        GLPtr<GrGLInvalidateTexImageProc> fInvalidateTexImage;
+        GLPtr<GrGLInvalidateTexSubImageProc> fInvalidateTexSubImage;
         GLPtr<GrGLLineWidthProc> fLineWidth;
         GLPtr<GrGLLinkProgramProc> fLinkProgram;
         GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
index f40821f3dafc31225936df1fed3a797de252a6b3..c5ab39ac7b55d1c6b6951d172f883aeb57287a64 100644 (file)
@@ -486,5 +486,25 @@ bool GrGLInterface::validate() const {
             RETURN_FALSE_INTERFACE
         }
     }
+
+#if 0 // This can be enabled once Chromium is updated to set these functions pointers.
+    if ((kGL_GrGLStandard == fStandard) || fExtensions.has("GL_ARB_invalidate_subdata")) {
+        if (NULL == fFunctions.fInvalidateBufferData ||
+            NULL == fFunctions.fInvalidateBufferSubData ||
+            NULL == fFunctions.fInvalidateFramebuffer ||
+            NULL == fFunctions.fInvalidateSubFramebuffer ||
+            NULL == fFunctions.fInvalidateTexImage ||
+            NULL == fFunctions.fInvalidateTexSubImage) {
+            RETURN_FALSE_INTERFACE;
+        }
+    } else if (glVer >= GR_GL_VER(3,0)) {
+        // ES 3.0 adds the framebuffer functions but not the others.
+        if (NULL == fFunctions.fInvalidateFramebuffer ||
+            NULL == fFunctions.fInvalidateSubFramebuffer) {
+            RETURN_FALSE_INTERFACE;
+        }
+    }
+#endif
+
     return true;
 }
index 984d318a2185c3bee7330c636e76fa0f5609e00b..aa5b2243064d462380f1d665e780f718c4d46e74 100644 (file)
@@ -203,6 +203,18 @@ static GrGLInterface* create_es_interface(GrGLVersion version,
         }
     }
 
+#if GL_ES_VERSION_3_0
+    functions->fInvalidateFramebuffer = glInvalidateFramebuffer;
+    functions->fInvalidateSubFramebuffer = glInvalidateSubFramebuffer;
+#else
+    functions->fInvalidateFramebuffer = (GrGLInvalidateFramebufferProc) eglGetProcAddress("glInvalidateFramebuffer");
+    functions->fInvalidateSubFramebuffer = (GrGLInvalidateSubFramebufferProc) eglGetProcAddress("glInvalidateSubFramebuffer");
+#endif
+    functions->fInvalidateBufferData = (GrGLInvalidateBufferDataProc) eglGetProcAddress("glInvalidateBufferData");
+    functions->fInvalidateBufferSubData = (GrGLInvalidateBufferSubDataProc) eglGetProcAddress("glInvalidateBufferSubData");
+    functions->fInvalidateTexImage = (GrGLInvalidateTexImageProc) eglGetProcAddress("glInvalidateTexImage");
+    functions->fInvalidateTexSubImage = (GrGLInvalidateTexSubImageProc) eglGetProcAddress("glInvalidateTexSubImage");
+
     return interface;
 }
 
@@ -403,6 +415,13 @@ static GrGLInterface* create_desktop_interface(GrGLVersion version,
         functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGroupMarkerEXT");
     }
 
+    functions->fInvalidateBufferData = (GrGLInvalidateBufferDataProc) eglGetProcAddress("glInvalidateBufferData");
+    functions->fInvalidateBufferSubData = (GrGLInvalidateBufferSubDataProc) eglGetProcAddress("glInvalidateBufferSubData");
+    functions->fInvalidateFramebuffer = (GrGLInvalidateFramebufferProc) eglGetProcAddress("glInvalidateFramebuffer");
+    functions->fInvalidateSubFramebuffer = (GrGLInvalidateSubFramebufferProc) eglGetProcAddress("glInvalidateSubFramebuffer");
+    functions->fInvalidateTexImage = (GrGLInvalidateTexImageProc) eglGetProcAddress("glInvalidateTexImage");
+    functions->fInvalidateTexSubImage = (GrGLInvalidateTexSubImageProc) eglGetProcAddress("glInvalidateTexSubImage");
+
     return interface;
 }
 
index 681eab468c9cf528e4a95acc500670fe6b6a1916..a316ff1c11913c6c8eb82822e9535577019f213b 100644 (file)
@@ -88,6 +88,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
     GET_PROC(GetShaderInfoLog);
     GET_PROC(GetShaderiv);
     GET_PROC(GetString);
+    GET_PROC(GetStringi);
     GET_PROC(GetUniformLocation);
     GET_PROC(LineWidth);
     GET_PROC(LinkProgram);
@@ -153,15 +154,25 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
     functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
     functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
 
-#if GL_EXT_debug_marker
     functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glInsertEventMarkerEXT");
     functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glPushGroupMarkerEXT");
     functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGroupMarkerEXT");
+
+#if GL_ES_VERSION_3_0
+    GET_PROC(InvalidateFramebuffer);
+    GET_PROC(InvalidateSubFramebuffer);
+#else
+    functions->fInvalidateFramebuffer = (GrGLInvalidateFramebufferProc) eglGetProcAddress("glInvalidateFramebuffer");
+    functions->fInvalidateSubFramebuffer = (GrGLInvalidateSubFramebufferProc) eglGetProcAddress("glInvalidateSubFramebuffer");
 #endif
+    functions->fInvalidateBufferData = (GrGLInvalidateBufferDataProc) eglGetProcAddress("glInvalidateBufferData");
+    functions->fInvalidateBufferSubData = (GrGLInvalidateBufferSubDataProc) eglGetProcAddress("glInvalidateBufferSubData");
+    functions->fInvalidateTexImage = (GrGLInvalidateTexImageProc) eglGetProcAddress("glInvalidateTexImage");
+    functions->fInvalidateTexSubImage = (GrGLInvalidateTexSubImageProc) eglGetProcAddress("glInvalidateTexSubImage");
 
     interface->fExtensions.init(kGLES_GrGLStandard,
-                                interface->fFunctions.fGetString,
-                                interface->fFunctions.fGetStringi,
-                                interface->fFunctions.fGetIntegerv);
+                                functions->fGetString,
+                                functions->fGetStringi,
+                                functions->fGetIntegerv);
     return interface;
 }
index decc23498c1d8680793392813a5e8907de9b21e5..553831d6eff6b3369a56942c6ed7fffeb9147113 100644 (file)
@@ -150,6 +150,18 @@ const GrGLInterface* GrGLCreateNativeInterface() {
     functions->fPopGroupMarker = glPopGroupMarkerEXT;
 #endif
 
+#if GL_ES_VERSION_3_0 || GL_ARB_invalidate_subdata
+    functions->fInvalidateFramebuffer = glInvalidateFramebuffer;
+    functions->fInvalidateSubFramebuffer = glInvalidateSubFramebuffer;
+#endif
+
+#if GL_ARB_invalidate_subdata
+    functions->fInvalidateBufferData = glInvalidateBufferData;
+    functions->fInvalidateBufferSubData = glInvalidateBufferSubData;
+    functions->fInvalidateTexImage = glInvalidateTexImage;
+    functions->fInvalidateTexSubImage = glInvalidateTexSubImage;
+#endif
+
     interface->fStandard = kGLES_GrGLStandard;
     interface->fExtensions.init(kGLES_GrGLStandard, glGetString, NULL, glGetIntegerv);
 
index 3a6e07a64b76e875afc7e616262ef491b242cb3d..04898d111098a8e46ec2811f2300726a3dc38f9a 100644 (file)
@@ -242,6 +242,15 @@ const GrGLInterface* GrGLCreateNativeInterface() {
         GET_PROC_SUFFIX(PopGroupMarker, EXT);
     }
 
+    if (ver >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
+        GET_PROC(InvalidateBufferData);
+        GET_PROC(InvalidateBufferSubData);
+        GET_PROC(InvalidateFramebuffer);
+        GET_PROC(InvalidateSubFramebuffer);
+        GET_PROC(InvalidateTexImage);
+        GET_PROC(InvalidateTexSubImage);
+    }
+
     interface->fExtensions.swap(&extensions);
     return interface;
 }
index 9cde81ce63fe97dddd464f0e3f45dfefb1d47227..fd8be26fe969161043dd397cf6d3fb69a6a39378 100644 (file)
@@ -224,6 +224,15 @@ const GrGLInterface* GrGLCreateMesaInterface() {
         GR_GL_GET_PROC_SUFFIX(PushGroupMarker, EXT);
     }
 
+    if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
+        GR_GL_GET_PROC(InvalidateBufferData);
+        GR_GL_GET_PROC(InvalidateBufferSubData);
+        GR_GL_GET_PROC(InvalidateFramebuffer);
+        GR_GL_GET_PROC(InvalidateSubFramebuffer);
+        GR_GL_GET_PROC(InvalidateTexImage);
+        GR_GL_GET_PROC(InvalidateTexSubImage);
+    }
+
     interface->fStandard = kGL_GrGLStandard;
     interface->fExtensions.swap(&extensions);
 
index e46309b4487ab003d5cb09ff2c2ebc523750459c..93807637fbbf165ca5fea98e8ce7a9c6f38e5f9f 100644 (file)
@@ -278,6 +278,15 @@ const GrGLInterface* GrGLCreateNativeInterface() {
         GR_GL_GET_PROC_SUFFIX(PopGroupMarker, EXT);
     }
 
+    if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
+        GR_GL_GET_PROC(InvalidateBufferData);
+        GR_GL_GET_PROC(InvalidateBufferSubData);
+        GR_GL_GET_PROC(InvalidateFramebuffer);
+        GR_GL_GET_PROC(InvalidateSubFramebuffer);
+        GR_GL_GET_PROC(InvalidateTexImage);
+        GR_GL_GET_PROC(InvalidateTexSubImage);
+    }
+
     interface->fStandard = kGL_GrGLStandard;
     interface->fExtensions.swap(&extensions);
 
index adc90a4bed550244b2728f895bba889ce2dcdce8..9a237825e986f1576d9fbedb94c8f8bffb6cdbc0 100644 (file)
@@ -305,6 +305,15 @@ const GrGLInterface* GrGLCreateNativeInterface() {
             WGL_SET_PROC_SUFFIX(PopGroupMarker, EXT);
         }
 
+        if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
+            WGL_SET_PROC(InvalidateBufferData);
+            WGL_SET_PROC(InvalidateBufferSubData);
+            WGL_SET_PROC(InvalidateFramebuffer);
+            WGL_SET_PROC(InvalidateSubFramebuffer);
+            WGL_SET_PROC(InvalidateTexImage);
+            WGL_SET_PROC(InvalidateTexSubImage);
+        }
+
         interface->fStandard = kGL_GrGLStandard;
         interface->fExtensions.swap(&extensions);