Add support to GrGLInterface for vertex array objects

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

git-svn-id: http://skia.googlecode.com/svn/trunk@7919 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2013-03-01 14:37:18 +00:00
parent 6dd683a435
commit 87c6d7a99e
15 changed files with 249 additions and 127 deletions

View File

@ -214,6 +214,7 @@
'<(skia_src_path)/gpu/gl/debug/GrProgramObj.cpp', '<(skia_src_path)/gpu/gl/debug/GrProgramObj.cpp',
'<(skia_src_path)/gpu/gl/debug/GrDebugGL.h', '<(skia_src_path)/gpu/gl/debug/GrDebugGL.h',
'<(skia_src_path)/gpu/gl/debug/GrDebugGL.cpp', '<(skia_src_path)/gpu/gl/debug/GrDebugGL.cpp',
'<(skia_src_path)/gpu/gl/debug/GrVetexArrayObj.h',
], ],
'gr_null_gl_sources': [ 'gr_null_gl_sources': [
'<(skia_src_path)/gpu/gl/GrGLCreateNullInterface.cpp', '<(skia_src_path)/gpu/gl/GrGLCreateNullInterface.cpp',

View File

@ -52,6 +52,7 @@ extern "C" {
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindVertexArrayProc)(GrGLuint array);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
@ -73,6 +74,7 @@ extern "C" {
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteShaderProc)(GrGLuint shader); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteShaderProc)(GrGLuint shader);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteVertexArraysProc)(GrGLsizei n, const GrGLuint *arrays);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDepthMaskProc)(GrGLboolean flag); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDepthMaskProc)(GrGLboolean flag);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableProc)(GrGLenum cap); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableProc)(GrGLenum cap);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableVertexAttribArrayProc)(GrGLuint index); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableVertexAttribArrayProc)(GrGLuint index);
@ -93,6 +95,7 @@ extern "C" {
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenVertexArraysProc)(GrGLsizei n, GrGLuint *arrays);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
typedef GrGLenum (GR_GL_FUNCTION_TYPE* GrGLGetErrorProc)(); typedef GrGLenum (GR_GL_FUNCTION_TYPE* GrGLGetErrorProc)();
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);

View File

@ -146,6 +146,7 @@ public:
GLPtr<GrGLBindFramebufferProc> fBindFramebuffer; GLPtr<GrGLBindFramebufferProc> fBindFramebuffer;
GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer; GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer;
GLPtr<GrGLBindTextureProc> fBindTexture; GLPtr<GrGLBindTextureProc> fBindTexture;
GLPtr<GrGLBindVertexArrayProc> fBindVertexArray;
GLPtr<GrGLBlendColorProc> fBlendColor; GLPtr<GrGLBlendColorProc> fBlendColor;
GLPtr<GrGLBlendFuncProc> fBlendFunc; GLPtr<GrGLBlendFuncProc> fBlendFunc;
GLPtr<GrGLBlitFramebufferProc> fBlitFramebuffer; GLPtr<GrGLBlitFramebufferProc> fBlitFramebuffer;
@ -168,6 +169,7 @@ public:
GLPtr<GrGLDeleteRenderbuffersProc> fDeleteRenderbuffers; GLPtr<GrGLDeleteRenderbuffersProc> fDeleteRenderbuffers;
GLPtr<GrGLDeleteShaderProc> fDeleteShader; GLPtr<GrGLDeleteShaderProc> fDeleteShader;
GLPtr<GrGLDeleteTexturesProc> fDeleteTextures; GLPtr<GrGLDeleteTexturesProc> fDeleteTextures;
GLPtr<GrGLDeleteVertexArraysProc> fDeleteVertexArrays;
GLPtr<GrGLDepthMaskProc> fDepthMask; GLPtr<GrGLDepthMaskProc> fDepthMask;
GLPtr<GrGLDisableProc> fDisable; GLPtr<GrGLDisableProc> fDisable;
GLPtr<GrGLDisableVertexAttribArrayProc> fDisableVertexAttribArray; GLPtr<GrGLDisableVertexAttribArrayProc> fDisableVertexAttribArray;
@ -188,6 +190,7 @@ public:
GLPtr<GrGLGenQueriesProc> fGenQueries; GLPtr<GrGLGenQueriesProc> fGenQueries;
GLPtr<GrGLGenRenderbuffersProc> fGenRenderbuffers; GLPtr<GrGLGenRenderbuffersProc> fGenRenderbuffers;
GLPtr<GrGLGenTexturesProc> fGenTextures; GLPtr<GrGLGenTexturesProc> fGenTextures;
GLPtr<GrGLGenVertexArraysProc> fGenVertexArrays;
GLPtr<GrGLGetBufferParameterivProc> fGetBufferParameteriv; GLPtr<GrGLGetBufferParameterivProc> fGetBufferParameteriv;
GLPtr<GrGLGetErrorProc> fGetError; GLPtr<GrGLGetErrorProc> fGetError;
GLPtr<GrGLGetFramebufferAttachmentParameterivProc> fGetFramebufferAttachmentParameteriv; GLPtr<GrGLGetFramebufferAttachmentParameterivProc> fGetFramebufferAttachmentParameteriv;

View File

@ -20,6 +20,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLAttachShader(GrGLuint program, GrGLuint shade
GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindVertexArray(GrGLuint id) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLPixelStorei(GrGLenum pname, GrGLint param) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLPixelStorei(GrGLenum pname, GrGLint param) {}
GrGLvoid GR_GL_FUNCTION_TYPE nullGLReadPixels(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLReadPixels(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels) {}
@ -46,7 +47,6 @@ GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateShader(GrGLenum type) {
GrGLvoid GR_GL_FUNCTION_TYPE nullGLDelete(GrGLuint program) { GrGLvoid GR_GL_FUNCTION_TYPE nullGLDelete(GrGLuint program) {
} }
// In debug builds we do asserts that ensure we agree with GL about when a buffer // In debug builds we do asserts that ensure we agree with GL about when a buffer
// is mapped. // is mapped.
static SkTDArray<GrGLuint> gMappedBuffers; static SkTDArray<GrGLuint> gMappedBuffers;
@ -168,6 +168,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
interface->fBindBuffer = nullGLBindBuffer; interface->fBindBuffer = nullGLBindBuffer;
interface->fBindFragDataLocation = noOpGLBindFragDataLocation; interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
interface->fBindTexture = nullGLBindTexture; interface->fBindTexture = nullGLBindTexture;
interface->fBindVertexArray = nullGLBindVertexArray;
interface->fBlendColor = noOpGLBlendColor; interface->fBlendColor = noOpGLBlendColor;
interface->fBlendFunc = noOpGLBlendFunc; interface->fBlendFunc = noOpGLBlendFunc;
interface->fBufferData = nullGLBufferData; interface->fBufferData = nullGLBufferData;
@ -186,6 +187,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
interface->fDeleteQueries = noOpGLDeleteIds; interface->fDeleteQueries = noOpGLDeleteIds;
interface->fDeleteShader = nullGLDelete; interface->fDeleteShader = nullGLDelete;
interface->fDeleteTextures = noOpGLDeleteIds; interface->fDeleteTextures = noOpGLDeleteIds;
interface->fDeleteVertexArrays = noOpGLDeleteIds;
interface->fDepthMask = noOpGLDepthMask; interface->fDepthMask = noOpGLDepthMask;
interface->fDisable = noOpGLDisable; interface->fDisable = noOpGLDisable;
interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
@ -202,6 +204,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
interface->fGenBuffers = noOpGLGenIds; interface->fGenBuffers = noOpGLGenIds;
interface->fGenQueries = noOpGLGenIds; interface->fGenQueries = noOpGLGenIds;
interface->fGenTextures = noOpGLGenIds; interface->fGenTextures = noOpGLGenIds;
interface->fGenVertexArrays = noOpGLGenIds;
interface->fGetBufferParameteriv = nullGLGetBufferParameteriv; interface->fGetBufferParameteriv = nullGLGetBufferParameteriv;
interface->fGetError = noOpGLGetError; interface->fGetError = noOpGLGetError;
interface->fGetIntegerv = noOpGLGetIntegerv; interface->fGetIntegerv = noOpGLGetIntegerv;

View File

@ -349,5 +349,25 @@ bool GrGLInterface::validate(GrGLBinding binding) const {
} }
} }
if (kDesktop_GrGLBinding == binding) {
if (glVer >= GR_GL_VER(3, 0) || extensions.has("GL_ARB_vertex_array_object")) {
if (NULL == fBindVertexArray ||
NULL == fDeleteVertexArrays ||
NULL == fGenVertexArrays) {
return false;
}
}
} else {
#if 0 // Remove this #if once Chromium interfaces set these pointers
if (extensions.has("GL_OES_vertex_array_object")) {
if (NULL == fBindVertexArray ||
NULL == fDeleteVertexArrays ||
NULL == fGenVertexArrays) {
return false;
}
}
#endif
}
return true; return true;
} }

View File

@ -26,6 +26,7 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fBindAttribLocation = glBindAttribLocation; interface->fBindAttribLocation = glBindAttribLocation;
interface->fBindBuffer = glBindBuffer; interface->fBindBuffer = glBindBuffer;
interface->fBindTexture = glBindTexture; interface->fBindTexture = glBindTexture;
interface->fBindVertexArray = glBindVertexArrayOES;
interface->fBlendColor = glBlendColor; interface->fBlendColor = glBlendColor;
interface->fBlendFunc = glBlendFunc; interface->fBlendFunc = glBlendFunc;
interface->fBufferData = glBufferData; interface->fBufferData = glBufferData;
@ -43,6 +44,7 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fDeleteProgram = glDeleteProgram; interface->fDeleteProgram = glDeleteProgram;
interface->fDeleteShader = glDeleteShader; interface->fDeleteShader = glDeleteShader;
interface->fDeleteTextures = glDeleteTextures; interface->fDeleteTextures = glDeleteTextures;
interface->fDeleteVertexArrays = glDeleteVertexArraysOES;
interface->fDepthMask = glDepthMask; interface->fDepthMask = glDepthMask;
interface->fDisable = glDisable; interface->fDisable = glDisable;
interface->fDisableVertexAttribArray = glDisableVertexAttribArray; interface->fDisableVertexAttribArray = glDisableVertexAttribArray;
@ -55,6 +57,7 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fFrontFace = glFrontFace; interface->fFrontFace = glFrontFace;
interface->fGenBuffers = glGenBuffers; interface->fGenBuffers = glGenBuffers;
interface->fGenTextures = glGenTextures; interface->fGenTextures = glGenTextures;
interface->fGenVertexArrays= glGenVertexArraysOES;
interface->fGetBufferParameteriv = glGetBufferParameteriv; interface->fGetBufferParameteriv = glGetBufferParameteriv;
interface->fGetError = glGetError; interface->fGetError = glGetError;
interface->fGetIntegerv = glGetIntegerv; interface->fGetIntegerv = glGetIntegerv;

View File

@ -44,6 +44,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
GR_GET_PROC(GrGLBindAttribLocationProc, BindAttribLocation); GR_GET_PROC(GrGLBindAttribLocationProc, BindAttribLocation);
GR_GET_PROC(GrGLBindBufferProc, BindBuffer); GR_GET_PROC(GrGLBindBufferProc, BindBuffer);
GR_GET_PROC(GrGLBindTextureProc, BindTexture); GR_GET_PROC(GrGLBindTextureProc, BindTexture);
interface->fBindVertexArray = (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES");
GR_GET_PROC(GrGLBlendColorProc, BlendColor); GR_GET_PROC(GrGLBlendColorProc, BlendColor);
GR_GET_PROC(GrGLBlendFuncProc, BlendFunc); GR_GET_PROC(GrGLBlendFuncProc, BlendFunc);
GR_GET_PROC(GrGLBufferDataProc, BufferData); GR_GET_PROC(GrGLBufferDataProc, BufferData);
@ -61,6 +62,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
GR_GET_PROC(GrGLDeleteProgramProc, DeleteProgram); GR_GET_PROC(GrGLDeleteProgramProc, DeleteProgram);
GR_GET_PROC(GrGLDeleteShaderProc, DeleteShader); GR_GET_PROC(GrGLDeleteShaderProc, DeleteShader);
GR_GET_PROC(GrGLDeleteTexturesProc, DeleteTextures); GR_GET_PROC(GrGLDeleteTexturesProc, DeleteTextures);
interface->fDeleteVertexArrays = (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES");
GR_GET_PROC(GrGLDepthMaskProc, DepthMask); GR_GET_PROC(GrGLDepthMaskProc, DepthMask);
GR_GET_PROC(GrGLDisableProc, Disable); GR_GET_PROC(GrGLDisableProc, Disable);
GR_GET_PROC(GrGLDisableVertexAttribArrayProc, DisableVertexAttribArray); GR_GET_PROC(GrGLDisableVertexAttribArrayProc, DisableVertexAttribArray);
@ -73,6 +75,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
GR_GET_PROC(GrGLFrontFaceProc, FrontFace); GR_GET_PROC(GrGLFrontFaceProc, FrontFace);
GR_GET_PROC(GrGLGenBuffersProc, GenBuffers); GR_GET_PROC(GrGLGenBuffersProc, GenBuffers);
GR_GET_PROC(GrGLGenTexturesProc, GenTextures); GR_GET_PROC(GrGLGenTexturesProc, GenTextures);
interface->fGenVertexArrays = (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES");
GR_GET_PROC(GrGLGetBufferParameterivProc, GetBufferParameteriv); GR_GET_PROC(GrGLGetBufferParameterivProc, GetBufferParameteriv);
GR_GET_PROC(GrGLGetErrorProc, GetError); GR_GET_PROC(GrGLGetErrorProc, GetError);
GR_GET_PROC(GrGLGetIntegervProc, GetIntegerv); GR_GET_PROC(GrGLGetIntegervProc, GetIntegerv);
@ -101,9 +104,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
#if GL_ARB_texture_storage #if GL_ARB_texture_storage
GR_GET_PROC(GrGLTexStorage2DProc, TexStorage2D); GR_GET_PROC(GrGLTexStorage2DProc, TexStorage2D);
#elif GL_EXT_texture_storage #elif GL_EXT_texture_storage
interface->fTexStorage2D = (GrGLTexStorage2DProc) interface->fTexStorage2D = (PFNGLTEXSTORAGE2DEXTPROC) eglGetProcAddress("glTexStorage2DEXT");
GetProcAddress(ghANGLELib,
"glTexStorage2DEXT");
#endif #endif
GR_GET_PROC(GrGLUniform1fProc, Uniform1f); GR_GET_PROC(GrGLUniform1fProc, Uniform1f);
GR_GET_PROC(GrGLUniform1iProc, Uniform1i); GR_GET_PROC(GrGLUniform1iProc, Uniform1i);

View File

@ -14,7 +14,7 @@
#include "GrShaderObj.h" #include "GrShaderObj.h"
#include "GrProgramObj.h" #include "GrProgramObj.h"
#include "GrTextureUnitObj.h" #include "GrTextureUnitObj.h"
#include "GrVertexArrayObj.h"
GrDebugGL* GrDebugGL::gObj = NULL; GrDebugGL* GrDebugGL::gObj = NULL;
int GrDebugGL::gStaticRefCount = 0; int GrDebugGL::gStaticRefCount = 0;
@ -26,6 +26,7 @@ GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = {
GrShaderObj::createGrShaderObj, GrShaderObj::createGrShaderObj,
GrProgramObj::createGrProgramObj, GrProgramObj::createGrProgramObj,
GrTextureUnitObj::createGrTextureUnitObj, GrTextureUnitObj::createGrTextureUnitObj,
GrVertexArrayObj::createGrVertexArrayObj,
}; };
@ -38,7 +39,8 @@ GrDebugGL::GrDebugGL()
, fFrameBuffer(NULL) , fFrameBuffer(NULL)
, fRenderBuffer(NULL) , fRenderBuffer(NULL)
, fProgram(NULL) , fProgram(NULL)
, fTexture(NULL) { , fTexture(NULL)
, fVertexArray(NULL) {
for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { for (int i = 0; i < kDefaultMaxTextureUnits; ++i) {
@ -70,6 +72,7 @@ GrDebugGL::~GrDebugGL() {
fRenderBuffer = NULL; fRenderBuffer = NULL;
fProgram = NULL; fProgram = NULL;
fTexture = NULL; fTexture = NULL;
fVertexArray = NULL;
} }
GrFakeRefObj *GrDebugGL::findObject(GrGLuint ID, GrObjTypes type) { GrFakeRefObj *GrDebugGL::findObject(GrGLuint ID, GrObjTypes type) {
@ -107,6 +110,10 @@ void GrDebugGL::setArrayBuffer(GrBufferObj *arrayBuffer) {
} }
} }
void GrDebugGL::setVertexArray(GrVertexArrayObj* vertexArray) {
SkRefCnt_SafeAssign(fVertexArray, vertexArray);
}
void GrDebugGL::setElementArrayBuffer(GrBufferObj *elementArrayBuffer) { void GrDebugGL::setElementArrayBuffer(GrBufferObj *elementArrayBuffer) {
if (fElementArrayBuffer) { if (fElementArrayBuffer) {
// automatically break the binding of the old buffer // automatically break the binding of the old buffer

View File

@ -12,13 +12,14 @@
#include "SkTArray.h" #include "SkTArray.h"
#include "gl/GrGLInterface.h" #include "gl/GrGLInterface.h"
class GrFakeRefObj;
class GrTextureUnitObj;
class GrBufferObj; class GrBufferObj;
class GrTextureObj; class GrFakeRefObj;
class GrFrameBufferObj; class GrFrameBufferObj;
class GrRenderBufferObj;
class GrProgramObj; class GrProgramObj;
class GrRenderBufferObj;
class GrTextureObj;
class GrTextureUnitObj;
class GrVertexArrayObj;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// This is the main debugging object. It is a singleton and keeps track of // This is the main debugging object. It is a singleton and keeps track of
@ -33,6 +34,7 @@ public:
kShader_ObjTypes, kShader_ObjTypes,
kProgram_ObjTypes, kProgram_ObjTypes,
kTextureUnit_ObjTypes, kTextureUnit_ObjTypes,
kVertexArray_ObjTypes,
kObjTypeCount kObjTypeCount
}; };
@ -63,6 +65,9 @@ public:
void setElementArrayBuffer(GrBufferObj *elementArrayBuffer); void setElementArrayBuffer(GrBufferObj *elementArrayBuffer);
GrBufferObj *getElementArrayBuffer() { return fElementArrayBuffer; } GrBufferObj *getElementArrayBuffer() { return fElementArrayBuffer; }
void setVertexArray(GrVertexArrayObj* vertexArray);
GrVertexArrayObj* getVertexArray() { return fVertexArray; }
void setTexture(GrTextureObj *texture); void setTexture(GrTextureObj *texture);
void setFrameBuffer(GrFrameBufferObj *frameBuffer); void setFrameBuffer(GrFrameBufferObj *frameBuffer);
@ -119,13 +124,14 @@ private:
GrGLint fUnPackRowLength; GrGLint fUnPackRowLength;
GrGLuint fMaxTextureUnits; GrGLuint fMaxTextureUnits;
GrGLuint fCurTextureUnit; GrGLuint fCurTextureUnit;
GrBufferObj * fArrayBuffer; GrBufferObj* fArrayBuffer;
GrBufferObj * fElementArrayBuffer; GrBufferObj* fElementArrayBuffer;
GrFrameBufferObj *fFrameBuffer; GrFrameBufferObj* fFrameBuffer;
GrRenderBufferObj *fRenderBuffer; GrRenderBufferObj* fRenderBuffer;
GrProgramObj * fProgram; GrProgramObj* fProgram;
GrTextureObj * fTexture; GrTextureObj* fTexture;
GrTextureUnitObj *fTextureUnits[kDefaultMaxTextureUnits]; GrTextureUnitObj *fTextureUnits[kDefaultMaxTextureUnits];
GrVertexArrayObj *fVertexArray;
typedef GrFakeRefObj *(*Create)(); typedef GrFakeRefObj *(*Create)();

View File

@ -16,6 +16,7 @@
#include "GrTextureObj.h" #include "GrTextureObj.h"
#include "GrFrameBufferObj.h" #include "GrFrameBufferObj.h"
#include "GrRenderBufferObj.h" #include "GrRenderBufferObj.h"
#include "GrVertexArrayObj.h"
#include "SkFloatingPoint.h" #include "SkFloatingPoint.h"
#include "../GrGLNoOpInterface.h" #include "../GrGLNoOpInterface.h"
@ -212,8 +213,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
GrDebugGL::getInstance()->setFrameBuffer(frameBuffer); GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) {
GrGLuint renderBufferID) {
GrAlwaysAssert(GR_GL_RENDERBUFFER == target); GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
@ -225,8 +225,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
GrDebugGL::getInstance()->setRenderBuffer(renderBuffer); GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) {
const GrGLuint* textures) {
// first potentially unbind the texture // first potentially unbind the texture
// TODO: move this into GrDebugGL as unBindTexture? // TODO: move this into GrDebugGL as unBindTexture?
@ -287,7 +286,6 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n, GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n,
const GrGLuint *frameBuffers) { const GrGLuint *frameBuffers) {
@ -518,32 +516,55 @@ GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) { GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids); debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n, GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
GrGLuint* ids) { GrGLuint* ids) {
debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids); debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n, GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
GrGLuint* ids) { GrGLuint* ids) {
debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids); debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) { GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids); debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
} }
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) {
GrGLuint bufferID) { debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids);
}
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) {
GR_GL_ELEMENT_ARRAY_BUFFER == target); for (GrGLsizei i = 0; i < n; ++i) {
GrVertexArrayObj* array =
GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
GrAlwaysAssert(array);
// Deleting the current vertex array binds object 0
if (GrDebugGL::getInstance()->getVertexArray() == array) {
GrDebugGL::getInstance()->setVertexArray(NULL);
}
if (array->getRefCount()) {
// someone is still using this shader so we can't delete it here
array->setMarkedForDeletion();
} else {
array->deleteAction();
}
}
}
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
GrAlwaysAssert(array);
GrDebugGL::getInstance()->setVertexArray(array);
}
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) {
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
GrBufferObj *buffer = GR_FIND(bufferID, GrBufferObj *buffer = GR_FIND(bufferID,
GrBufferObj, GrBufferObj,
@ -564,8 +585,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target,
} }
// deleting a bound buffer has the side effect of binding 0 // deleting a bound buffer has the side effect of binding 0
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
const GrGLuint* ids) {
// first potentially unbind the buffers // first potentially unbind the buffers
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
@ -595,8 +615,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n,
} }
// map a buffer to the caller's address space // map a buffer to the caller's address space
GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
GrGLenum access) {
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
GR_GL_ELEMENT_ARRAY_BUFFER == target); GR_GL_ELEMENT_ARRAY_BUFFER == target);
@ -767,6 +786,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
interface->fBindBuffer = debugGLBindBuffer; interface->fBindBuffer = debugGLBindBuffer;
interface->fBindFragDataLocation = noOpGLBindFragDataLocation; interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
interface->fBindTexture = debugGLBindTexture; interface->fBindTexture = debugGLBindTexture;
interface->fBindVertexArray = debugGLBindVertexArray;
interface->fBlendColor = noOpGLBlendColor; interface->fBlendColor = noOpGLBlendColor;
interface->fBlendFunc = noOpGLBlendFunc; interface->fBlendFunc = noOpGLBlendFunc;
interface->fBufferData = debugGLBufferData; interface->fBufferData = debugGLBufferData;
@ -785,6 +805,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
interface->fDeleteQueries = noOpGLDeleteIds; interface->fDeleteQueries = noOpGLDeleteIds;
interface->fDeleteShader = debugGLDeleteShader; interface->fDeleteShader = debugGLDeleteShader;
interface->fDeleteTextures = debugGLDeleteTextures; interface->fDeleteTextures = debugGLDeleteTextures;
interface->fDeleteVertexArrays = debugGLDeleteVertexArrays;
interface->fDepthMask = noOpGLDepthMask; interface->fDepthMask = noOpGLDepthMask;
interface->fDisable = noOpGLDisable; interface->fDisable = noOpGLDisable;
interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
@ -817,6 +838,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
interface->fGetStringi = noOpGLGetStringi; interface->fGetStringi = noOpGLGetStringi;
interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
interface->fGetUniformLocation = noOpGLGetUniformLocation; interface->fGetUniformLocation = noOpGLGetUniformLocation;
interface->fGenVertexArrays = debugGLGenVertexArrays;
interface->fLineWidth = noOpGLLineWidth; interface->fLineWidth = noOpGLLineWidth;
interface->fLinkProgram = noOpGLLinkProgram; interface->fLinkProgram = noOpGLLinkProgram;
interface->fPixelStorei = debugGLPixelStorei; interface->fPixelStorei = debugGLPixelStorei;

View File

@ -0,0 +1,21 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrVertexArrayObj_DEFINED
#define GrVertexArrayObj_DEFINED
#include "GrFakeRefObj.h"
class GrVertexArrayObj : public GrFakeRefObj {
GR_DEFINE_CREATOR(GrVertexArrayObj);
public:
GrVertexArrayObj() : GrFakeRefObj() {}
typedef GrFakeRefObj INHERITED;
};
#endif

View File

@ -79,11 +79,11 @@ const GrGLInterface* GrGLCreateNativeInterface() {
// mac uses GLenum for internalFormat param (non-standard) // mac uses GLenum for internalFormat param (non-standard)
// amounts to int vs. uint. // amounts to int vs. uint.
interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
#if GL_ARB_texture_storage #if GL_ARB_texture_storage
interface->fTexStorage2D = glTexStorage2D; interface->fTexStorage2D = glTexStorage2D;
#elif GL_EXT_texture_storage #elif GL_EXT_texture_storage
interface->fTexStorage2D = glTexStorage2DEXT; interface->fTexStorage2D = glTexStorage2DEXT;
#endif #endif
interface->fTexParameteri = glTexParameteri; interface->fTexParameteri = glTexParameteri;
interface->fTexParameteriv = glTexParameteriv; interface->fTexParameteriv = glTexParameteriv;
interface->fTexSubImage2D = glTexSubImage2D; interface->fTexSubImage2D = glTexSubImage2D;
@ -124,16 +124,21 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer; interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
interface->fBindRenderbuffer = glBindRenderbuffer; interface->fBindRenderbuffer = glBindRenderbuffer;
#if GL_OES_mapbuffer #if GL_OES_mapbuffer
interface->fMapBuffer = glMapBufferOES; interface->fMapBuffer = glMapBufferOES;
interface->fUnmapBuffer = glUnmapBufferOES; interface->fUnmapBuffer = glUnmapBufferOES;
#endif #endif
#if GL_APPLE_framebuffer_multisample #if GL_APPLE_framebuffer_multisample
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE; interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
interface->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE; interface->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;
#endif #endif
interface->fBindFragDataLocationIndexed = NULL;
#if GL_OES_vertex_array_object
interface->fBindVertexArray = glBindVertexArrayOES;
interface->fDeleteVertexArrays = glDeleteVertexArraysOES;
interface->fGenVertexArrays = glGenVertexArraysOES;
#endif
interface->fBindingsExported = kES2_GrGLBinding; interface->fBindingsExported = kES2_GrGLBinding;
} }

View File

@ -45,11 +45,11 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fBindAttribLocation = glBindAttribLocation; interface->fBindAttribLocation = glBindAttribLocation;
interface->fBindBuffer = glBindBuffer; interface->fBindBuffer = glBindBuffer;
if (ver >= GR_GL_VER(3,0)) { if (ver >= GR_GL_VER(3,0)) {
#if GL_VERSION_3_0 #if GL_VERSION_3_0
interface->fBindFragDataLocation = glBindFragDataLocation; interface->fBindFragDataLocation = glBindFragDataLocation;
#else #else
interface->fBindFragDataLocation = GET_PROC(BindFragDataLocation); GET_PROC(BindFragDataLocation);
#endif #endif
} }
interface->fBindTexture = glBindTexture; interface->fBindTexture = glBindTexture;
interface->fBlendFunc = glBlendFunc; interface->fBlendFunc = glBlendFunc;
@ -131,17 +131,17 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
interface->fTexParameteri = glTexParameteri; interface->fTexParameteri = glTexParameteri;
interface->fTexParameteriv = glTexParameteriv; interface->fTexParameteriv = glTexParameteriv;
#if GL_ARB_texture_storage || GL_VERSION_4_2 #if GL_ARB_texture_storage || GL_VERSION_4_2
interface->fTexStorage2D = glTexStorage2D interface->fTexStorage2D = glTexStorage2D
#elif GL_EXT_texture_storage #elif GL_EXT_texture_storage
interface->fTexStorage2D = glTexStorage2DEXT; interface->fTexStorage2D = glTexStorage2DEXT;
#else #else
if (ver >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { if (ver >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) {
GET_PROC(TexStorage2D); GET_PROC(TexStorage2D);
} else if (extensions.has("GL_EXT_texture_storage")) { } else if (extensions.has("GL_EXT_texture_storage")) {
GET_PROC_SUFFIX(TexStorage2D, EXT); GET_PROC_SUFFIX(TexStorage2D, EXT);
} }
#endif #endif
interface->fTexSubImage2D = glTexSubImage2D; interface->fTexSubImage2D = glTexSubImage2D;
interface->fUniform1f = glUniform1f; interface->fUniform1f = glUniform1f;
interface->fUniform1i = glUniform1i; interface->fUniform1i = glUniform1i;
@ -169,30 +169,43 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fVertexAttribPointer = glVertexAttribPointer; interface->fVertexAttribPointer = glVertexAttribPointer;
interface->fViewport = glViewport; interface->fViewport = glViewport;
if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
// no ARB suffix for GL_ARB_vertex_array_object
#if GL_ARB_vertex_array_object || GL_VERSION_3_0
interface->fBindVertexArray = glBindVertexArray;
interface->fDeleteVertexArrays = glDeleteVertexArrays;
interface->fGenVertexArrays = glGenVertexArrays;
#else
GET_PROC(BindVertexArray);
GET_PROC(DeleteVertexArrays);
GET_PROC(GenVertexArrays);
#endif
}
if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
// ARB extension doesn't use the ARB suffix on the function name // ARB extension doesn't use the ARB suffix on the function name
#if GL_ARB_timer_query || GL_VERSION_3_3 #if GL_ARB_timer_query || GL_VERSION_3_3
interface->fQueryCounter = glQueryCounter; interface->fQueryCounter = glQueryCounter;
interface->fGetQueryObjecti64v = glGetQueryObjecti64v; interface->fGetQueryObjecti64v = glGetQueryObjecti64v;
interface->fGetQueryObjectui64v = glGetQueryObjectui64v; interface->fGetQueryObjectui64v = glGetQueryObjectui64v;
#else #else
interface->fQueryCounter = GET_PROC(QueryCounter); GET_PROC(QueryCounter);
interface->fGetQueryObjecti64v = GET_PROC(GetQueryObjecti64v); GET_PROC(GetQueryObjecti64v);
interface->fGetQueryObjectui64v = GET_PROC(GetQueryObjectui64v); GET_PROC(GetQueryObjectui64v);
#endif #endif
} else if (extensions.has("GL_EXT_timer_query")) { } else if (extensions.has("GL_EXT_timer_query")) {
#if GL_EXT_timer_query #if GL_EXT_timer_query
interface->fGetQueryObjecti64v = glGetQueryObjecti64vEXT; interface->fGetQueryObjecti64v = glGetQueryObjecti64vEXT;
interface->fGetQueryObjectui64v = glGetQueryObjectui64vEXT; interface->fGetQueryObjectui64v = glGetQueryObjectui64vEXT;
#else #else
interface->fGetQueryObjecti64v = GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
interface->fGetQueryObjectui64v = GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
#endif #endif
} }
if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
// ARB extension doesn't use the ARB suffix on the function names // ARB extension doesn't use the ARB suffix on the function names
#if GL_VERSION_3_0 || GL_ARB_framebuffer_object #if GL_VERSION_3_0 || GL_ARB_framebuffer_object
interface->fGenFramebuffers = glGenFramebuffers; interface->fGenFramebuffers = glGenFramebuffers;
interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
@ -207,74 +220,74 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fBindRenderbuffer = glBindRenderbuffer; interface->fBindRenderbuffer = glBindRenderbuffer;
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisample; interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisample;
interface->fBlitFramebuffer = glBlitFramebuffer; interface->fBlitFramebuffer = glBlitFramebuffer;
#else #else
interface->fGenFramebuffers = GET_PROC(GenFramebuffers); GET_PROC(GenFramebuffers);
interface->fGetFramebufferAttachmentParameteriv = GET_PROC(GetFramebufferAttachmentParameteriv); GET_PROC(GetFramebufferAttachmentParameteriv);
interface->fGetRenderbufferParameteriv = GET_PROC(GetRenderbufferParameteriv); GET_PROC(GetRenderbufferParameteriv);
interface->fBindFramebuffer = GET_PROC(BindFramebuffer); GET_PROC(BindFramebuffer);
interface->fFramebufferTexture2D = GET_PROC(FramebufferTexture2D); GET_PROC(FramebufferTexture2D);
interface->fCheckFramebufferStatus = GET_PROC(CheckFramebufferStatus); GET_PROC(CheckFramebufferStatus);
interface->fDeleteFramebuffers = GET_PROC(DeleteFramebuffers); GET_PROC(DeleteFramebuffers);
interface->fRenderbufferStorage = GET_PROC(RenderbufferStorage); GET_PROC(RenderbufferStorage);
interface->fGenRenderbuffers = GET_PROC(GenRenderbuffers); GET_PROC(GenRenderbuffers);
interface->fDeleteRenderbuffers = GET_PROC(DeleteRenderbuffers); GET_PROC(DeleteRenderbuffers);
interface->fFramebufferRenderbuffer = GET_PROC(FramebufferRenderbuffer); GET_PROC(FramebufferRenderbuffer);
interface->fBindRenderbuffer = GET_PROC(BindRenderbuffer); GET_PROC(BindRenderbuffer);
interface->fRenderbufferStorageMultisample = GET_PROC(RenderbufferStorageMultisample); GET_PROC(RenderbufferStorageMultisample);
interface->fBlitFramebuffer = GET_PROC(BlitFramebuffer); GET_PROC(BlitFramebuffer);
#endif #endif
} else { } else {
if (extensions.has("GL_EXT_framebuffer_object")) { if (extensions.has("GL_EXT_framebuffer_object")) {
#if GL_EXT_framebuffer_object #if GL_EXT_framebuffer_object
interface->fGenFramebuffers = glGenFramebuffersEXT; interface->fGenFramebuffers = glGenFramebuffersEXT;
interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameterivEXT; interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameterivEXT;
interface->fGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT; interface->fGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT;
interface->fBindFramebuffer = glBindFramebufferEXT; interface->fBindFramebuffer = glBindFramebufferEXT;
interface->fFramebufferTexture2D = glFramebufferTexture2DEXT; interface->fFramebufferTexture2D = glFramebufferTexture2DEXT;
interface->fCheckFramebufferStatus = glCheckFramebufferStatusEXT; interface->fCheckFramebufferStatus = glCheckFramebufferStatusEXT;
interface->fDeleteFramebuffers = glDeleteFramebuffersEXT; interface->fDeleteFramebuffers = glDeleteFramebuffersEXT;
interface->fRenderbufferStorage = glRenderbufferStorageEXT; interface->fRenderbufferStorage = glRenderbufferStorageEXT;
interface->fGenRenderbuffers = glGenRenderbuffersEXT; interface->fGenRenderbuffers = glGenRenderbuffersEXT;
interface->fDeleteRenderbuffers = glDeleteRenderbuffersEXT; interface->fDeleteRenderbuffers = glDeleteRenderbuffersEXT;
interface->fFramebufferRenderbuffer = glFramebufferRenderbufferEXT; interface->fFramebufferRenderbuffer = glFramebufferRenderbufferEXT;
interface->fBindRenderbuffer = glBindRenderbufferEXT; interface->fBindRenderbuffer = glBindRenderbufferEXT;
#else #else
interface->fGenFramebuffers = GET_PROC_SUFFIX(GenFramebuffers, EXT); GET_PROC_SUFFIX(GenFramebuffers, EXT);
interface->fGetFramebufferAttachmentParameteriv = GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
interface->fGetRenderbufferParameteriv = GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
interface->fBindFramebuffer = GET_PROC_SUFFIX(BindFramebuffer, EXT); GET_PROC_SUFFIX(BindFramebuffer, EXT);
interface->fFramebufferTexture2D = GET_PROC_SUFFIX(FramebufferTexture2D, EXT); GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
interface->fCheckFramebufferStatus = GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
interface->fDeleteFramebuffers = GET_PROC_SUFFIX(DeleteFramebuffers, EXT); GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
interface->fRenderbufferStorage = GET_PROC_SUFFIX(RenderbufferStorage, EXT); GET_PROC_SUFFIX(RenderbufferStorage, EXT);
interface->fGenRenderbuffers = GET_PROC_SUFFIX(GenRenderbuffers, EXT); GET_PROC_SUFFIX(GenRenderbuffers, EXT);
interface->fDeleteRenderbuffers = GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
interface->fFramebufferRenderbuffer = GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
interface->fBindRenderbuffer = GET_PROC_SUFFIX(BindRenderbuffer, EXT); GET_PROC_SUFFIX(BindRenderbuffer, EXT);
#endif #endif
} }
if (extensions.has("GL_EXT_framebuffer_multisample")) { if (extensions.has("GL_EXT_framebuffer_multisample")) {
#if GL_EXT_framebuffer_multisample #if GL_EXT_framebuffer_multisample
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT; interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT;
#else #else
interface->fRenderbufferStorageMultisample = GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
#endif #endif
} }
if (extensions.has("GL_EXT_framebuffer_blit")) { if (extensions.has("GL_EXT_framebuffer_blit")) {
#if GL_EXT_framebuffer_blit #if GL_EXT_framebuffer_blit
interface->fBlitFramebuffer = glBlitFramebufferEXT; interface->fBlitFramebuffer = glBlitFramebufferEXT;
#else #else
interface->fBlitFramebuffer = GET_PROC_SUFFIX(BlitFramebuffer, EXT); GET_PROC_SUFFIX(BlitFramebuffer, EXT);
#endif #endif
} }
} }
if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended")) { if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended")) {
// ARB extension doesn't use the ARB suffix on the function name // ARB extension doesn't use the ARB suffix on the function name
#if GL_VERSION_3_3 || GL_ARB_blend_func_extended #if GL_VERSION_3_3 || GL_ARB_blend_func_extended
interface->fBindFragDataLocationIndexed = glBindFragDataLocationIndexed; interface->fBindFragDataLocationIndexed = glBindFragDataLocationIndexed;
#else #else
interface->fBindFragDataLocationIndexed = GET_PROC(BindFragDataLocationIndexed); GET_PROC(BindFragDataLocationIndexed);
#endif #endif
} }
} }
glInterface.get()->ref(); glInterface.get()->ref();

View File

@ -161,6 +161,13 @@ const GrGLInterface* GrGLCreateMesaInterface() {
GR_GL_GET_PROC(VertexAttribPointer); GR_GL_GET_PROC(VertexAttribPointer);
GR_GL_GET_PROC(Viewport); GR_GL_GET_PROC(Viewport);
if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
// no ARB suffix for GL_ARB_vertex_array_object
GR_GL_GET_PROC(GenBindVertexArray);
GR_GL_GET_PROC(DeleteVertexArrays);
GR_GL_GET_PROC(GenVertexArrays);
}
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
// GL_ARB_framebuffer_object doesn't use ARB suffix.) // GL_ARB_framebuffer_object doesn't use ARB suffix.)
if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {

View File

@ -202,9 +202,16 @@ const GrGLInterface* GrGLCreateNativeInterface() {
WGL_SET_PROC(VertexAttribPointer); WGL_SET_PROC(VertexAttribPointer);
WGL_SET_PROC(BindFragDataLocationIndexed); WGL_SET_PROC(BindFragDataLocationIndexed);
if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
// no ARB suffix for GL_ARB_vertex_array_object
WGL_SET_PROC(BindVertexArray);
WGL_SET_PROC(DeleteVertexArrays);
WGL_SET_PROC(GenVertexArrays);
}
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
// GL_ARB_framebuffer_object doesn't use ARB suffix.) // GL_ARB_framebuffer_object doesn't use ARB suffix.)
if (glVer > GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
WGL_SET_PROC(GenFramebuffers); WGL_SET_PROC(GenFramebuffers);
WGL_SET_PROC(GetFramebufferAttachmentParameteriv); WGL_SET_PROC(GetFramebufferAttachmentParameteriv);
WGL_SET_PROC(GetRenderbufferParameteriv); WGL_SET_PROC(GetRenderbufferParameteriv);