Use EXT_direct_state_access for path matrix manipulation
Use EXT_direct_state_access for path matrix manipulation when using
NV_path_rendering extension. This makes Chromium command buffer
integration easier, since the current matrix mode does not need to be
exposed as state and fewer function calls and enums are needed.
BUG=chromium:344330
R=bsalomon@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/245963009
git-svn-id: http://skia.googlecode.com/svn/trunk@14374 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index bbf9b2a..6fe804f 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -323,7 +323,8 @@
// attachment, hence this min:
fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize);
- fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering");
+ fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering") &&
+ ctxInfo.hasExtension("GL_EXT_direct_state_access");
fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index 92a0ba2..18a9d72 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -327,11 +327,8 @@
functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
functions->fGetUniformLocation = noOpGLGetUniformLocation;
functions->fInsertEventMarker = noOpGLInsertEventMarker;
- functions->fLoadIdentity = noOpGLLoadIdentity;
- functions->fLoadMatrixf = noOpGLLoadMatrixf;
functions->fLineWidth = noOpGLLineWidth;
functions->fLinkProgram = noOpGLLinkProgram;
- functions->fMatrixMode = noOpGLMatrixMode;
functions->fPixelStorei = nullGLPixelStorei;
functions->fPopGroupMarker = noOpGLPopGroupMarker;
functions->fPushGroupMarker = noOpGLPushGroupMarker;
@@ -391,6 +388,8 @@
functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuffer;
functions->fMapBuffer = nullGLMapBuffer;
+ functions->fMatrixLoadf = noOpGLMatrixLoadf;
+ functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
functions->fUnmapBuffer = nullGLUnmapBuffer;
functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed;
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index 8aaa02e..b5da4d3 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -228,13 +228,6 @@
GrGLVersion glVer = GrGLGetVersion(this);
- bool isCoreProfile = false;
- if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) {
- GrGLint profileMask;
- GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
- isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
- }
-
// Now check that baseline ES/Desktop fns not covered above are present
// and that we have fn pointers for any advertised fExtensions that we will
// try to use.
@@ -290,10 +283,9 @@
RETURN_FALSE_INTERFACE
}
}
- if (!isCoreProfile) {
- if (NULL == fFunctions.fLoadIdentity ||
- NULL == fFunctions.fLoadMatrixf ||
- NULL == fFunctions.fMatrixMode) {
+ if (fExtensions.has("GL_EXT_direct_state_access")) {
+ if (NULL == fFunctions.fMatrixLoadf ||
+ NULL == fFunctions.fMatrixLoadIdentity) {
RETURN_FALSE_INTERFACE
}
}
diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp
index be8ac58..2b84b28 100644
--- a/src/gpu/gl/GrGLNoOpInterface.cpp
+++ b/src/gpu/gl/GrGLNoOpInterface.cpp
@@ -164,13 +164,10 @@
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program) {
}
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadIdentity() {
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadf(GrGLenum, const GrGLfloat*) {
}
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadMatrixf(const GrGLfloat*) {
-}
-
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixMode(GrGLenum) {
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadIdentity(GrGLenum) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target) {
diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h
index 597225c..2efc113 100644
--- a/src/gpu/gl/GrGLNoOpInterface.h
+++ b/src/gpu/gl/GrGLNoOpInterface.h
@@ -96,16 +96,14 @@
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFrontFace(GrGLenum mode);
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadIdentity();
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadf(GrGLenum, const GrGLfloat*);
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadMatrixf(const GrGLfloat*);
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadIdentity(GrGLenum);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program);
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixMode(GrGLenum);
-
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id,
GrGLenum target);
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index f24a38f..4b39a163 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -304,8 +304,7 @@
if (this->caps()->pathRenderingSupport()) {
fHWProjectionMatrixState.invalidate();
// we don't use the model view matrix.
- GL_CALL(MatrixMode(GR_GL_MODELVIEW));
- GL_CALL(LoadIdentity());
+ GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW));
for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) {
GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
@@ -2235,8 +2234,7 @@
GrGLfloat glMatrix[4 * 4];
fHWProjectionMatrixState.getGLMatrix<4>(glMatrix);
- GL_CALL(MatrixMode(GR_GL_PROJECTION));
- GL_CALL(LoadMatrixf(glMatrix));
+ GL_CALL(MatrixLoadf(GR_GL_PROJECTION, glMatrix));
}
void GrGpuGL::enablePathTexGen(int unitIdx,
diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
index 2f055cb..2679b80 100644
--- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
+++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
@@ -307,10 +307,11 @@
functions->fGetUniformLocation = (GrGLGetUniformLocationProc) eglGetProcAddress("glGetUniformLocation");
functions->fLineWidth = (GrGLLineWidthProc) eglGetProcAddress("glLineWidth");
functions->fLinkProgram = (GrGLLinkProgramProc) eglGetProcAddress("glLinkProgram");
- functions->fLoadIdentity = (GrGLLoadIdentityProc) eglGetProcAddress("glLoadIdentity");
- functions->fLoadMatrixf = (GrGLLoadMatrixfProc) eglGetProcAddress("glLoadMatrixf");
functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBuffer");
- functions->fMatrixMode = (GrGLMatrixModeProc) eglGetProcAddress("glMatrixMode");
+ if (extensions.has("GL_EXT_direct_state_access")) {
+ functions->fMatrixLoadf = (GrGLMatrixLoadfProc) eglGetProcAddress("glMatrixLoadfEXT");
+ functions->fMatrixLoadIdentity = (GrGLMatrixLoadIdentityProc) eglGetProcAddress("glMatrixLoadIdentityEXT");
+ }
functions->fPixelStorei = (GrGLPixelStoreiProc) eglGetProcAddress("glPixelStorei");
functions->fQueryCounter = (GrGLQueryCounterProc) eglGetProcAddress("glQueryCounter");
functions->fReadBuffer = (GrGLReadBufferProc) eglGetProcAddress("glReadBuffer");
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index d985d87..0a8333b 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -848,11 +848,8 @@
functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
functions->fGetUniformLocation = noOpGLGetUniformLocation;
functions->fGenVertexArrays = debugGLGenVertexArrays;
- functions->fLoadIdentity = noOpGLLoadIdentity;
- functions->fLoadMatrixf = noOpGLLoadMatrixf;
functions->fLineWidth = noOpGLLineWidth;
functions->fLinkProgram = noOpGLLinkProgram;
- functions->fMatrixMode = noOpGLMatrixMode;
functions->fPixelStorei = debugGLPixelStorei;
functions->fQueryCounter = noOpGLQueryCounter;
functions->fReadBuffer = noOpGLReadBuffer;
@@ -913,6 +910,8 @@
functions->fResolveMultisampleFramebuffer =
noOpGLResolveMultisampleFramebuffer;
functions->fMapBuffer = debugGLMapBuffer;
+ functions->fMatrixLoadf = noOpGLMatrixLoadf;
+ functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
functions->fUnmapBuffer = debugGLUnmapBuffer;
functions->fBindFragDataLocationIndexed =
noOpGLBindFragDataLocationIndexed;
diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
index 17d08b1..4c3d03f 100644
--- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
+++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
@@ -124,10 +124,11 @@
GET_PROC(GetUniformLocation);
GET_PROC(LineWidth);
GET_PROC(LinkProgram);
- GET_PROC(LoadIdentity);
- GET_PROC(LoadMatrixf);
GET_PROC(MapBuffer);
- GET_PROC(MatrixMode);
+ if (extensions.has("GL_EXT_direct_state_access")) {
+ GET_PROC_SUFFIX(MatrixLoadf, EXT);
+ GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
+ }
GET_PROC(PixelStorei);
GET_PROC(ReadBuffer);
GET_PROC(ReadPixels);
diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
index 24218b0..ea8026e 100644
--- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
+++ b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
@@ -118,10 +118,11 @@
GR_GL_GET_PROC(GetUniformLocation);
GR_GL_GET_PROC(LineWidth);
GR_GL_GET_PROC(LinkProgram);
- GR_GL_GET_PROC(LoadIdentity);
- GR_GL_GET_PROC(LoadMatrixf);
- GR_GL_GET_PROC(MatrixMode);
GR_GL_GET_PROC(MapBuffer);
+ if (extensions.has("GL_EXT_direct_state_access")) {
+ GR_GL_GET_PROC_SUFFIX(MatrixLoadf, EXT);
+ GR_GL_GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
+ }
GR_GL_GET_PROC(PixelStorei);
GR_GL_GET_PROC(ReadBuffer);
GR_GL_GET_PROC(ReadPixels);
diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
index d47cc61..4d5b8f4 100644
--- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
+++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
@@ -119,6 +119,10 @@
functions->fLineWidth = glLineWidth;
GR_GL_GET_PROC(LinkProgram);
GR_GL_GET_PROC(MapBuffer);
+ if (extensions.has("GL_EXT_direct_state_access")) {
+ GR_GL_GET_PROC_SUFFIX(MatrixLoadf, EXT);
+ GR_GL_GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
+ }
functions->fPixelStorei = glPixelStorei;
functions->fReadBuffer = glReadBuffer;
functions->fReadPixels = glReadPixels;
@@ -214,10 +218,6 @@
return NULL;
}
- GR_GL_GET_PROC(LoadIdentity);
- GR_GL_GET_PROC(LoadMatrixf);
- GR_GL_GET_PROC(MatrixMode);
-
if (extensions.has("GL_NV_path_rendering")) {
GR_GL_GET_PROC_SUFFIX(PathCommands, NV);
GR_GL_GET_PROC_SUFFIX(PathCoords, NV);
diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
index c5c80bc..6fd3d91 100644
--- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
+++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
@@ -103,9 +103,6 @@
SET_PROC(GetString)
SET_PROC(GetTexLevelParameteriv)
SET_PROC(LineWidth)
- SET_PROC(LoadIdentity)
- SET_PROC(LoadMatrixf)
- SET_PROC(MatrixMode)
SET_PROC(PixelStorei)
SET_PROC(ReadBuffer)
SET_PROC(ReadPixels)
@@ -242,7 +239,12 @@
delete interface;
return NULL;
}
+
WGL_SET_PROC(MapBuffer);
+ if (extensions.has("GL_EXT_direct_state_access")) {
+ WGL_SET_PROC_SUFFIX(MatrixLoadf, EXT);
+ WGL_SET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
+ }
WGL_SET_PROC(UnmapBuffer);
if (extensions.has("GL_NV_path_rendering")) {