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
This commit is contained in:
commit-bot@chromium.org 2014-04-25 06:21:30 +00:00
parent 0ea05d8491
commit f66967243c
14 changed files with 40 additions and 53 deletions

View File

@ -211,9 +211,8 @@ extern "C" {
// Experimental: Functions for GL_NV_path_rendering. These will be
// alphabetized with the above functions once this is fully supported
// (and functions we are unlikely to use will possibly be omitted).
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLMatrixModeProc)(GrGLenum);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLLoadIdentityProc)();
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLLoadMatrixfProc)(const GrGLfloat* m);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLMatrixLoadfProc)(GrGLenum matrixMode, const GrGLfloat* m);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLMatrixLoadIdentityProc)(GrGLenum);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLPathCommandsProc)(GrGLuint path, GrGLsizei numCommands, const GrGLubyte *commands, GrGLsizei numCoords, GrGLenum coordType, const GrGLvoid *coords);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLPathCoordsProc)(GrGLuint path, GrGLsizei numCoords, GrGLenum coordType, const GrGLvoid *coords);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLPathSubCommandsProc)(GrGLuint path, GrGLsizei commandStart, GrGLsizei commandsToDelete, GrGLsizei numCommands, const GrGLubyte *commands, GrGLsizei numCoords, GrGLenum coordType, const GrGLvoid *coords);

View File

@ -230,12 +230,11 @@ public:
GLPtr<GrGLInvalidateTexSubImageProc> fInvalidateTexSubImage;
GLPtr<GrGLLineWidthProc> fLineWidth;
GLPtr<GrGLLinkProgramProc> fLinkProgram;
GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
GLPtr<GrGLLoadMatrixfProc> fLoadMatrixf;
GLPtr<GrGLMapBufferProc> fMapBuffer;
GLPtr<GrGLMapBufferSubDataProc> fMapBufferSubData;
GLPtr<GrGLMapTexSubImage2DProc> fMapTexSubImage2D;
GLPtr<GrGLMatrixModeProc> fMatrixMode;
GLPtr<GrGLMatrixLoadfProc> fMatrixLoadf;
GLPtr<GrGLMatrixLoadIdentityProc> fMatrixLoadIdentity;
GLPtr<GrGLPixelStoreiProc> fPixelStorei;
GLPtr<GrGLPopGroupMarkerProc> fPopGroupMarker;
GLPtr<GrGLPushGroupMarkerProc> fPushGroupMarker;

View File

@ -323,7 +323,8 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
// 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");

View File

@ -327,11 +327,8 @@ const GrGLInterface* GrGLCreateNullInterface() {
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 @@ const GrGLInterface* GrGLCreateNullInterface() {
functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuffer;
functions->fMapBuffer = nullGLMapBuffer;
functions->fMatrixLoadf = noOpGLMatrixLoadf;
functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
functions->fUnmapBuffer = nullGLUnmapBuffer;
functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed;

View File

@ -228,13 +228,6 @@ bool GrGLInterface::validate() const {
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 @@ bool GrGLInterface::validate() const {
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
}
}

View File

@ -164,13 +164,10 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width) {
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) {

View File

@ -96,16 +96,14 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFlush();
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);

View File

@ -304,8 +304,7 @@ void GrGpuGL::onResetContext(uint32_t resetBits) {
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 @@ void GrGpuGL::setProjectionMatrix(const SkMatrix& matrix,
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,

View File

@ -307,10 +307,11 @@ static GrGLInterface* create_desktop_interface(GrGLVersion version,
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");

View File

@ -848,11 +848,8 @@ const GrGLInterface* GrGLCreateDebugInterface() {
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 @@ const GrGLInterface* GrGLCreateDebugInterface() {
functions->fResolveMultisampleFramebuffer =
noOpGLResolveMultisampleFramebuffer;
functions->fMapBuffer = debugGLMapBuffer;
functions->fMatrixLoadf = noOpGLMatrixLoadf;
functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
functions->fUnmapBuffer = debugGLUnmapBuffer;
functions->fBindFragDataLocationIndexed =
noOpGLBindFragDataLocationIndexed;

View File

@ -124,10 +124,11 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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);

View File

@ -118,10 +118,11 @@ const GrGLInterface* GrGLCreateMesaInterface() {
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);

View File

@ -119,6 +119,10 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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);

View File

@ -103,9 +103,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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")) {