summaryrefslogtreecommitdiff
path: root/gpu/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/gl')
-rw-r--r--gpu/gl/GrGLAssembleInterface.cpp5
-rw-r--r--gpu/gl/GrGLBufferImpl.cpp97
-rw-r--r--gpu/gl/GrGLBufferImpl.h2
-rw-r--r--gpu/gl/GrGLCaps.cpp46
-rw-r--r--gpu/gl/GrGLCaps.h23
-rw-r--r--gpu/gl/GrGLCreateNullInterface.cpp38
-rw-r--r--gpu/gl/GrGLDefines.h8
-rw-r--r--gpu/gl/GrGLIndexBuffer.cpp8
-rw-r--r--gpu/gl/GrGLIndexBuffer.h4
-rw-r--r--gpu/gl/GrGLInterface.cpp28
-rw-r--r--gpu/gl/GrGLNoOpInterface.cpp14
-rw-r--r--gpu/gl/GrGLPath.h2
-rw-r--r--gpu/gl/GrGLProgram.cpp6
-rw-r--r--gpu/gl/GrGLProgramEffects.cpp8
-rw-r--r--gpu/gl/GrGLSL.cpp4
-rw-r--r--gpu/gl/GrGLSL.h2
-rw-r--r--gpu/gl/GrGLShaderBuilder.cpp12
-rw-r--r--gpu/gl/GrGLShaderVar.h4
-rw-r--r--gpu/gl/GrGLStencilBuffer.cpp2
-rw-r--r--gpu/gl/GrGLStencilBuffer.h2
-rw-r--r--gpu/gl/GrGLUtil.cpp6
-rw-r--r--gpu/gl/GrGLVertexArray.cpp2
-rw-r--r--gpu/gl/GrGLVertexArray.h8
-rw-r--r--gpu/gl/GrGLVertexBuffer.cpp8
-rw-r--r--gpu/gl/GrGLVertexBuffer.h4
-rw-r--r--gpu/gl/GrGLVertexEffect.h2
-rw-r--r--gpu/gl/GrGpuGL.cpp12
-rw-r--r--gpu/gl/GrGpuGL_program.cpp4
-rw-r--r--gpu/gl/android/GrGLCreateNativeInterface_android.cpp14
-rw-r--r--gpu/gl/angle/GrGLCreateANGLEInterface.cpp8
-rw-r--r--gpu/gl/debug/GrBufferObj.h12
-rw-r--r--gpu/gl/debug/GrGLCreateDebugInterface.cpp90
-rw-r--r--gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp5
33 files changed, 366 insertions, 124 deletions
diff --git a/gpu/gl/GrGLAssembleInterface.cpp b/gpu/gl/GrGLAssembleInterface.cpp
index aed11e53..e4337259 100644
--- a/gpu/gl/GrGLAssembleInterface.cpp
+++ b/gpu/gl/GrGLAssembleInterface.cpp
@@ -173,6 +173,11 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
GET_PROC(DeleteVertexArrays);
}
+ if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) {
+ GET_PROC(MapBufferRange);
+ GET_PROC(FlushMappedBufferRange);
+ }
+
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
// GL_ARB_framebuffer_object doesn't use ARB suffix.)
if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
diff --git a/gpu/gl/GrGLBufferImpl.cpp b/gpu/gl/GrGLBufferImpl.cpp
index 3c75b9fe..46e1f797 100644
--- a/gpu/gl/GrGLBufferImpl.cpp
+++ b/gpu/gl/GrGLBufferImpl.cpp
@@ -26,20 +26,22 @@ GrGLBufferImpl::GrGLBufferImpl(GrGpuGL* gpu, const Desc& desc, GrGLenum bufferTy
, fLockPtr(NULL) {
if (0 == desc.fID) {
fCPUData = sk_malloc_flags(desc.fSizeInBytes, SK_MALLOC_THROW);
+ fGLSizeInBytes = 0;
} else {
fCPUData = NULL;
+ // We assume that the GL buffer was created at the desc's size initially.
+ fGLSizeInBytes = fDesc.fSizeInBytes;
}
VALIDATE();
}
void GrGLBufferImpl::release(GrGpuGL* gpu) {
+ VALIDATE();
// make sure we've not been abandoned or already released
if (NULL != fCPUData) {
- VALIDATE();
sk_free(fCPUData);
fCPUData = NULL;
} else if (fDesc.fID && !fDesc.fIsWrapped) {
- VALIDATE();
GL_CALL(gpu, DeleteBuffers(1, &fDesc.fID));
if (GR_GL_ARRAY_BUFFER == fBufferType) {
gpu->notifyVertexBufferDelete(fDesc.fID);
@@ -48,15 +50,19 @@ void GrGLBufferImpl::release(GrGpuGL* gpu) {
gpu->notifyIndexBufferDelete(fDesc.fID);
}
fDesc.fID = 0;
+ fGLSizeInBytes = 0;
}
fLockPtr = NULL;
+ VALIDATE();
}
void GrGLBufferImpl::abandon() {
fDesc.fID = 0;
+ fGLSizeInBytes = 0;
fLockPtr = NULL;
sk_free(fCPUData);
fCPUData = NULL;
+ VALIDATE();
}
void GrGLBufferImpl::bind(GrGpuGL* gpu) const {
@@ -67,6 +73,7 @@ void GrGLBufferImpl::bind(GrGpuGL* gpu) const {
SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
gpu->bindIndexBufferAndDefaultVertexArray(fDesc.fID);
}
+ VALIDATE();
}
void* GrGLBufferImpl::lock(GrGpuGL* gpu) {
@@ -74,17 +81,55 @@ void* GrGLBufferImpl::lock(GrGpuGL* gpu) {
SkASSERT(!this->isLocked());
if (0 == fDesc.fID) {
fLockPtr = fCPUData;
- } else if (gpu->caps()->bufferLockSupport()) {
- this->bind(gpu);
- // Let driver know it can discard the old data
- GL_CALL(gpu, BufferData(fBufferType,
- (GrGLsizeiptr) fDesc.fSizeInBytes,
- NULL,
- fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
- GR_GL_CALL_RET(gpu->glInterface(),
- fLockPtr,
- MapBuffer(fBufferType, GR_GL_WRITE_ONLY));
+ } else {
+ switch (gpu->glCaps().mapBufferType()) {
+ case GrGLCaps::kNone_MapBufferType:
+ VALIDATE();
+ return NULL;
+ case GrGLCaps::kMapBuffer_MapBufferType:
+ this->bind(gpu);
+ // Let driver know it can discard the old data
+ if (GR_GL_USE_BUFFER_DATA_NULL_HINT || fDesc.fSizeInBytes != fGLSizeInBytes) {
+ fGLSizeInBytes = fDesc.fSizeInBytes;
+ GL_CALL(gpu,
+ BufferData(fBufferType, fGLSizeInBytes, NULL,
+ fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
+ }
+ GR_GL_CALL_RET(gpu->glInterface(), fLockPtr,
+ MapBuffer(fBufferType, GR_GL_WRITE_ONLY));
+ break;
+ case GrGLCaps::kMapBufferRange_MapBufferType: {
+ this->bind(gpu);
+ // Make sure the GL buffer size agrees with fDesc before mapping.
+ if (fDesc.fSizeInBytes != fGLSizeInBytes) {
+ fGLSizeInBytes = fDesc.fSizeInBytes;
+ GL_CALL(gpu,
+ BufferData(fBufferType, fGLSizeInBytes, NULL,
+ fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
+ }
+ static const GrGLbitfield kAccess = GR_GL_MAP_INVALIDATE_BUFFER_BIT |
+ GR_GL_MAP_WRITE_BIT;
+ GR_GL_CALL_RET(gpu->glInterface(),
+ fLockPtr,
+ MapBufferRange(fBufferType, 0, fGLSizeInBytes, kAccess));
+ break;
+ }
+ case GrGLCaps::kChromium_MapBufferType:
+ this->bind(gpu);
+ // Make sure the GL buffer size agrees with fDesc before mapping.
+ if (fDesc.fSizeInBytes != fGLSizeInBytes) {
+ fGLSizeInBytes = fDesc.fSizeInBytes;
+ GL_CALL(gpu,
+ BufferData(fBufferType, fGLSizeInBytes, NULL,
+ fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
+ }
+ GR_GL_CALL_RET(gpu->glInterface(),
+ fLockPtr,
+ MapBufferSubData(fBufferType, 0, fGLSizeInBytes, GR_GL_WRITE_ONLY));
+ break;
+ }
}
+ VALIDATE();
return fLockPtr;
}
@@ -92,9 +137,20 @@ void GrGLBufferImpl::unlock(GrGpuGL* gpu) {
VALIDATE();
SkASSERT(this->isLocked());
if (0 != fDesc.fID) {
- SkASSERT(gpu->caps()->bufferLockSupport());
- this->bind(gpu);
- GL_CALL(gpu, UnmapBuffer(fBufferType));
+ switch (gpu->glCaps().mapBufferType()) {
+ case GrGLCaps::kNone_MapBufferType:
+ SkDEBUGFAIL("Shouldn't get here.");
+ return;
+ case GrGLCaps::kMapBuffer_MapBufferType: // fall through
+ case GrGLCaps::kMapBufferRange_MapBufferType:
+ this->bind(gpu);
+ GL_CALL(gpu, UnmapBuffer(fBufferType));
+ break;
+ case GrGLCaps::kChromium_MapBufferType:
+ this->bind(gpu);
+ GR_GL_CALL(gpu->glInterface(), UnmapBufferSubData(fLockPtr));
+ break;
+ }
}
fLockPtr = NULL;
}
@@ -127,7 +183,8 @@ bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB
// draws that reference the old contents. With this hint it can
// assign a different allocation for the new contents to avoid
// flushing the gpu past draws consuming the old contents.
- GL_CALL(gpu, BufferData(fBufferType, (GrGLsizeiptr) fDesc.fSizeInBytes, NULL, usage));
+ fGLSizeInBytes = fDesc.fSizeInBytes;
+ GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, usage));
GL_CALL(gpu, BufferSubData(fBufferType, 0, (GrGLsizeiptr) srcSizeInBytes, src));
}
#else
@@ -147,10 +204,12 @@ bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB
// Chromium's command buffer may turn a glBufferSubData where the size
// exactly matches the buffer size into a glBufferData. So we tack 1
// extra byte onto the glBufferData.
- GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes + 1, NULL, usage));
+ fGLSizeInBytes = srcSizeInBytes + 1;
+ GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, usage));
GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src));
} else {
- GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes, src, usage));
+ fGLSizeInBytes = srcSizeInBytes;
+ GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage));
}
#endif
return true;
@@ -161,5 +220,7 @@ void GrGLBufferImpl::validate() const {
// The following assert isn't valid when the buffer has been abandoned:
// SkASSERT((0 == fDesc.fID) == (NULL != fCPUData));
SkASSERT(0 != fDesc.fID || !fDesc.fIsWrapped);
+ SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes);
+ SkASSERT(NULL == fLockPtr || NULL != fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes);
SkASSERT(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr);
}
diff --git a/gpu/gl/GrGLBufferImpl.h b/gpu/gl/GrGLBufferImpl.h
index 148ca1b2..19d23e0d 100644
--- a/gpu/gl/GrGLBufferImpl.h
+++ b/gpu/gl/GrGLBufferImpl.h
@@ -53,6 +53,8 @@ private:
GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER
void* fCPUData;
void* fLockPtr;
+ size_t fGLSizeInBytes; // In certain cases we make the size of the GL buffer object
+ // smaller or larger than the size in fDesc.
typedef SkNoncopyable INHERITED;
};
diff --git a/gpu/gl/GrGLCaps.cpp b/gpu/gl/GrGLCaps.cpp
index 501411c0..f577e9d7 100644
--- a/gpu/gl/GrGLCaps.cpp
+++ b/gpu/gl/GrGLCaps.cpp
@@ -24,6 +24,7 @@ void GrGLCaps::reset() {
fMSFBOType = kNone_MSFBOType;
fFBFetchType = kNone_FBFetchType;
fInvalidateFBType = kNone_InvalidateFBType;
+ fMapBufferType = kNone_MapBufferType;
fMaxFragmentUniformVectors = 0;
fMaxVertexAttributes = 0;
fMaxFragmentTextureUnits = 0;
@@ -47,7 +48,6 @@ void GrGLCaps::reset() {
fIsCoreProfile = false;
fFullClearIsFree = false;
fDropsTileOnZeroDivide = false;
- fMapSubSupport = false;
}
GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
@@ -66,6 +66,7 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
fMSFBOType = caps.fMSFBOType;
fFBFetchType = caps.fFBFetchType;
fInvalidateFBType = caps.fInvalidateFBType;
+ fMapBufferType = caps.fMapBufferType;
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
fBGRAFormatSupport = caps.fBGRAFormatSupport;
fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
@@ -85,7 +86,6 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
fIsCoreProfile = caps.fIsCoreProfile;
fFullClearIsFree = caps.fFullClearIsFree;
fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
- fMapSubSupport = caps.fMapSubSupport;
return *this;
}
@@ -290,12 +290,27 @@ bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
}
if (kGL_GrGLStandard == standard) {
- fBufferLockSupport = true; // we require VBO support and the desktop VBO extension includes
- // glMapBuffer.
- fMapSubSupport = false;
+ fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO
+ // extension includes glMapBuffer.
+ if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) {
+ fMapBufferFlags |= kSubset_MapFlag;
+ fMapBufferType = kMapBufferRange_MapBufferType;
+ } else {
+ fMapBufferType = kMapBuffer_MapBufferType;
+ }
} else {
- fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer");
- fMapSubSupport = ctxInfo.hasExtension("GL_CHROMIUM_map_sub");
+ // Unextended GLES2 doesn't have any buffer mapping.
+ fMapBufferFlags = kNone_MapBufferType;
+ if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
+ fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
+ fMapBufferType = kChromium_MapBufferType;
+ } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
+ fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
+ fMapBufferType = kMapBufferRange_MapBufferType;
+ } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) {
+ fMapBufferFlags = kCanMap_MapFlag;
+ fMapBufferType = kMapBuffer_MapBufferType;
+ }
}
if (kGL_GrGLStandard == standard) {
@@ -579,7 +594,7 @@ void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
return;
}
}
- GrCrash("Why are we seeing a stencil format that "
+ SkFAIL("Why are we seeing a stencil format that "
"GrGLCaps doesn't know about.");
}
@@ -600,7 +615,7 @@ bool GrGLCaps::isColorConfigAndStencilFormatVerified(
return fStencilVerifiedColorConfigs[i].isVerified(config);
}
}
- GrCrash("Why are we seeing a stencil format that "
+ SkFAIL("Why are we seeing a stencil format that "
"GLCaps doesn't know about.");
return false;
}
@@ -655,10 +670,23 @@ SkString GrGLCaps::dump() const {
GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
+ static const char* kMapBufferTypeStr[] = {
+ "None",
+ "MapBuffer",
+ "MapBufferRange",
+ "Chromium",
+ };
+ GR_STATIC_ASSERT(0 == kNone_MapBufferType);
+ GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
+ GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
+ GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
+ GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
+
r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]);
r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
+ r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
if (!fIsCoreProfile) {
diff --git a/gpu/gl/GrGLCaps.h b/gpu/gl/GrGLCaps.h
index 48925d48..ea0f4124 100644
--- a/gpu/gl/GrGLCaps.h
+++ b/gpu/gl/GrGLCaps.h
@@ -86,6 +86,15 @@ public:
kLast_InvalidateFBType = kInvalidate_InvalidateFBType
};
+ enum MapBufferType {
+ kNone_MapBufferType,
+ kMapBuffer_MapBufferType, // glMapBuffer()
+ kMapBufferRange_MapBufferType, // glMapBufferRange()
+ kChromium_MapBufferType, // GL_CHROMIUM_map_sub
+
+ kLast_MapBufferType = kChromium_MapBufferType,
+ };
+
/**
* Creates a GrGLCaps that advertises no support for any extensions,
* formats, etc. Call init to initialize from a GrGLContextInfo.
@@ -169,10 +178,8 @@ public:
InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
- /**
- * Returs a string containeng the caps info.
- */
- virtual SkString dump() const SK_OVERRIDE;
+ /// What type of buffer mapping is supported?
+ MapBufferType mapBufferType() const { return fMapBufferType; }
/**
* Gets an array of legal stencil formats. These formats are not guaranteed
@@ -258,8 +265,10 @@ public:
bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
- /// Is GL_CHROMIUM_map_sub supported?
- bool mapSubSupport() const { return fMapSubSupport; }
+ /**
+ * Returns a string containing the caps info.
+ */
+ virtual SkString dump() const SK_OVERRIDE;
private:
/**
@@ -322,6 +331,7 @@ private:
MSFBOType fMSFBOType;
FBFetchType fFBFetchType;
InvalidateFBType fInvalidateFBType;
+ MapBufferType fMapBufferType;
bool fRGBA8RenderbufferSupport : 1;
bool fBGRAFormatSupport : 1;
@@ -342,7 +352,6 @@ private:
bool fIsCoreProfile : 1;
bool fFullClearIsFree : 1;
bool fDropsTileOnZeroDivide : 1;
- bool fMapSubSupport : 1;
typedef GrDrawTargetCaps INHERITED;
};
diff --git a/gpu/gl/GrGLCreateNullInterface.cpp b/gpu/gl/GrGLCreateNullInterface.cpp
index 18a9d726..6cfa8c29 100644
--- a/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/gpu/gl/GrGLCreateNullInterface.cpp
@@ -125,7 +125,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target,
id = gCurrElementArrayBuffer;
break;
default:
- GrCrash("Unexpected target to nullGLBufferData");
+ SkFAIL("Unexpected target to nullGLBufferData");
break;
}
@@ -186,8 +186,29 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* id
}
}
-GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) {
+GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr offset,
+ GrGLsizeiptr length, GrGLbitfield access) {
+ GrGLuint id = 0;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = gCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = gCurrElementArrayBuffer;
+ break;
+ }
+ if (id > 0) {
+ // We just ignore the offset and length here.
+ GrBufferObj* buffer = look_up(id);
+ SkASSERT(!buffer->mapped());
+ buffer->setMapped(true);
+ return buffer->dataPtr();
+ }
+ return NULL;
+}
+
+GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) {
GrGLuint id = 0;
switch (target) {
case GR_GL_ARRAY_BUFFER:
@@ -209,6 +230,11 @@ GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access)
return NULL; // no buffer bound to target
}
+GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target,
+ GrGLintptr offset,
+ GrGLsizeiptr length) {}
+
+
GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) {
GrGLuint id = 0;
switch (target) {
@@ -251,7 +277,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenu
}
break; }
default:
- GrCrash("Unexpected pname to GetBufferParamateriv");
+ SkFAIL("Unexpected pname to GetBufferParamateriv");
break;
}
};
@@ -304,6 +330,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
functions->fEndQuery = noOpGLEndQuery;
functions->fFinish = noOpGLFinish;
functions->fFlush = noOpGLFlush;
+ functions->fFlushMappedBufferRange = nullGLFlushMappedBufferRange;
functions->fFrontFace = noOpGLFrontFace;
functions->fGenBuffers = nullGLGenBuffers;
functions->fGenerateMipmap = nullGLGenerateMipmap;
@@ -329,6 +356,8 @@ const GrGLInterface* GrGLCreateNullInterface() {
functions->fInsertEventMarker = noOpGLInsertEventMarker;
functions->fLineWidth = noOpGLLineWidth;
functions->fLinkProgram = noOpGLLinkProgram;
+ functions->fMapBuffer = nullGLMapBuffer;
+ functions->fMapBufferRange = nullGLMapBufferRange;
functions->fPixelStorei = nullGLPixelStorei;
functions->fPopGroupMarker = noOpGLPopGroupMarker;
functions->fPushGroupMarker = noOpGLPushGroupMarker;
@@ -368,6 +397,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
+ functions->fUnmapBuffer = nullGLUnmapBuffer;
functions->fUseProgram = nullGLUseProgram;
functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
@@ -387,10 +417,8 @@ const GrGLInterface* GrGLCreateNullInterface() {
functions->fRenderbufferStorageMultisample = noOpGLRenderbufferStorageMultisample;
functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuffer;
- functions->fMapBuffer = nullGLMapBuffer;
functions->fMatrixLoadf = noOpGLMatrixLoadf;
functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
- functions->fUnmapBuffer = nullGLUnmapBuffer;
functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed;
interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functions->fGetStringi,
diff --git a/gpu/gl/GrGLDefines.h b/gpu/gl/GrGLDefines.h
index a4dc2f78..73f3d2e1 100644
--- a/gpu/gl/GrGLDefines.h
+++ b/gpu/gl/GrGLDefines.h
@@ -601,6 +601,14 @@
/* Vertex Buffer Object */
#define GR_GL_WRITE_ONLY 0x88B9
#define GR_GL_BUFFER_MAPPED 0x88BC
+
+#define GR_GL_MAP_READ_BIT 0x0001
+#define GR_GL_MAP_WRITE_BIT 0x0002
+#define GR_GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GR_GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GR_GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GR_GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+
/* Read Format */
#define GR_GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
diff --git a/gpu/gl/GrGLIndexBuffer.cpp b/gpu/gl/GrGLIndexBuffer.cpp
index b6290b18..4e7f989c 100644
--- a/gpu/gl/GrGLIndexBuffer.cpp
+++ b/gpu/gl/GrGLIndexBuffer.cpp
@@ -14,7 +14,7 @@ GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc)
}
void GrGLIndexBuffer::onRelease() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.release(this->getGpuGL());
}
@@ -27,7 +27,7 @@ void GrGLIndexBuffer::onAbandon() {
}
void* GrGLIndexBuffer::lock() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
return fImpl.lock(this->getGpuGL());
} else {
return NULL;
@@ -39,7 +39,7 @@ void* GrGLIndexBuffer::lockPtr() const {
}
void GrGLIndexBuffer::unlock() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.unlock(this->getGpuGL());
}
}
@@ -49,7 +49,7 @@ bool GrGLIndexBuffer::isLocked() const {
}
bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
} else {
return false;
diff --git a/gpu/gl/GrGLIndexBuffer.h b/gpu/gl/GrGLIndexBuffer.h
index 32a80860..893e3571 100644
--- a/gpu/gl/GrGLIndexBuffer.h
+++ b/gpu/gl/GrGLIndexBuffer.h
@@ -26,7 +26,7 @@ public:
size_t baseOffset() const { return fImpl.baseOffset(); }
void bind() const {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.bind(this->getGpuGL());
}
}
@@ -45,7 +45,7 @@ protected:
private:
GrGpuGL* getGpuGL() const {
- SkASSERT(this->isValid());
+ SkASSERT(!this->wasDestroyed());
return (GrGpuGL*)(this->getGpu());
}
diff --git a/gpu/gl/GrGLInterface.cpp b/gpu/gl/GrGLInterface.cpp
index 7efa067d..ee184d0a 100644
--- a/gpu/gl/GrGLInterface.cpp
+++ b/gpu/gl/GrGLInterface.cpp
@@ -116,9 +116,15 @@ GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
return clone;
}
-#define RETURN_FALSE_INTERFACE \
- GrDebugCrash("GrGLInterface::validate() failed."); \
- return false; \
+#ifdef SK_DEBUG
+ static int kIsDebug = 1;
+#else
+ static int kIsDebug = 0;
+#endif
+
+#define RETURN_FALSE_INTERFACE \
+ if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
+ return false;
bool GrGLInterface::validate() const {
@@ -480,8 +486,8 @@ bool GrGLInterface::validate() const {
}
}
-#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 ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
+ fExtensions.has("GL_ARB_invalidate_subdata")) {
if (NULL == fFunctions.fInvalidateBufferData ||
NULL == fFunctions.fInvalidateBufferSubData ||
NULL == fFunctions.fInvalidateFramebuffer ||
@@ -490,7 +496,7 @@ bool GrGLInterface::validate() const {
NULL == fFunctions.fInvalidateTexSubImage) {
RETURN_FALSE_INTERFACE;
}
- } else if (glVer >= GR_GL_VER(3,0)) {
+ } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
// ES 3.0 adds the framebuffer functions but not the others.
if (NULL == fFunctions.fInvalidateFramebuffer ||
NULL == fFunctions.fInvalidateSubFramebuffer) {
@@ -506,7 +512,15 @@ bool GrGLInterface::validate() const {
RETURN_FALSE_INTERFACE;
}
}
-#endif
+ // These functions are added to the 3.0 version of both GLES and GL.
+ if (glVer >= GR_GL_VER(3,0) ||
+ (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
+ (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
+ if (NULL == fFunctions.fMapBufferRange ||
+ NULL == fFunctions.fFlushMappedBufferRange) {
+ RETURN_FALSE_INTERFACE;
+ }
+ }
return true;
}
diff --git a/gpu/gl/GrGLNoOpInterface.cpp b/gpu/gl/GrGLNoOpInterface.cpp
index 2b84b280..a433c0e1 100644
--- a/gpu/gl/GrGLNoOpInterface.cpp
+++ b/gpu/gl/GrGLNoOpInterface.cpp
@@ -500,7 +500,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params)
*params = SK_ARRAY_COUNT(kExtensions);
break;
default:
- GrCrash("Unexpected pname to GetIntegerv");
+ SkFAIL("Unexpected pname to GetIntegerv");
}
}
@@ -529,7 +529,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetShaderOrProgramiv(GrGLuint program,
break;
// we don't expect any other pnames
default:
- GrCrash("Unexpected pname to GetProgramiv");
+ SkFAIL("Unexpected pname to GetProgramiv");
break;
}
}
@@ -545,7 +545,7 @@ void query_result(GrGLenum GLtarget, GrGLenum pname, T *params) {
*params = 0;
break;
default:
- GrCrash("Unexpected pname passed to GetQueryObject.");
+ SkFAIL("Unexpected pname passed to GetQueryObject.");
break;
}
}
@@ -562,7 +562,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryiv(GrGLenum GLtarget,
*params = 32;
break;
default:
- GrCrash("Unexpected pname passed GetQueryiv.");
+ SkFAIL("Unexpected pname passed GetQueryiv.");
}
}
@@ -603,7 +603,7 @@ const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name) {
case GR_GL_RENDERER:
return (const GrGLubyte*)"The Debug (Non-)Renderer";
default:
- GrCrash("Unexpected name passed to GetString");
+ SkFAIL("Unexpected name passed to GetString");
return NULL;
}
}
@@ -617,7 +617,7 @@ const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i)
return NULL;
}
default:
- GrCrash("Unexpected name passed to GetStringi");
+ SkFAIL("Unexpected name passed to GetStringi");
return NULL;
}
}
@@ -628,7 +628,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetTexLevelParameteriv(GrGLenum target,
GrGLint* params) {
// we used to use this to query stuff about externally created textures,
// now we just require clients to tell us everything about the texture.
- GrCrash("Should never query texture parameters.");
+ SkFAIL("Should never query texture parameters.");
}
GrGLint GR_GL_FUNCTION_TYPE noOpGLGetUniformLocation(GrGLuint program, const char* name) {
diff --git a/gpu/gl/GrGLPath.h b/gpu/gl/GrGLPath.h
index 3647d4d6..3409547b 100644
--- a/gpu/gl/GrGLPath.h
+++ b/gpu/gl/GrGLPath.h
@@ -27,7 +27,7 @@ public:
GrGLuint pathID() const { return fPathID; }
// TODO: Figure out how to get an approximate size of the path in Gpu
// memory.
- virtual size_t sizeInBytes() const SK_OVERRIDE { return 100; }
+ virtual size_t gpuMemorySize() const SK_OVERRIDE { return 100; }
protected:
virtual void onRelease() SK_OVERRIDE;
diff --git a/gpu/gl/GrGLProgram.cpp b/gpu/gl/GrGLProgram.cpp
index 9b997c85..aa46aeda 100644
--- a/gpu/gl/GrGLProgram.cpp
+++ b/gpu/gl/GrGLProgram.cpp
@@ -89,7 +89,7 @@ void GrGLProgram::overrideBlend(GrBlendCoeff* srcCoeff,
SkASSERT(kOne_GrBlendCoeff == *srcCoeff && kZero_GrBlendCoeff == *dstCoeff);
break;
default:
- GrCrash("Unexpected coverage output");
+ SkFAIL("Unexpected coverage output");
break;
}
}
@@ -270,7 +270,7 @@ void GrGLProgram::setColor(const GrDrawState& drawState,
sharedState->fConstAttribColorIndex = -1;
break;
default:
- GrCrash("Unknown color type.");
+ SkFAIL("Unknown color type.");
}
} else {
sharedState->fConstAttribColorIndex = -1;
@@ -309,7 +309,7 @@ void GrGLProgram::setCoverage(const GrDrawState& drawState,
sharedState->fConstAttribCoverageIndex = -1;
break;
default:
- GrCrash("Unknown coverage type.");
+ SkFAIL("Unknown coverage type.");
}
} else {
sharedState->fConstAttribCoverageIndex = -1;
diff --git a/gpu/gl/GrGLProgramEffects.cpp b/gpu/gl/GrGLProgramEffects.cpp
index 1695a8e3..04cebf85 100644
--- a/gpu/gl/GrGLProgramEffects.cpp
+++ b/gpu/gl/GrGLProgramEffects.cpp
@@ -341,7 +341,7 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder,
varyingType = kVec3f_GrSLType;
break;
default:
- GrCrash("Unexpected key.");
+ SkFAIL("Unexpected key.");
}
SkString suffixedUniName;
if (kVoid_GrSLType != transforms[t].fType) {
@@ -393,7 +393,7 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder,
break;
}
default:
- GrCrash("Unexpected uniform type.");
+ SkFAIL("Unexpected uniform type.");
}
SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords,
(SkString(fsVaryingName), varyingType));
@@ -446,7 +446,7 @@ void GrGLVertexProgramEffects::setTransformData(const GrGLUniformManager& unifor
break;
}
default:
- GrCrash("Unexpected uniform type.");
+ SkFAIL("Unexpected uniform type.");
}
}
}
@@ -572,7 +572,7 @@ void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
break;
}
default:
- GrCrash("Unexpected matrixs type.");
+ SkFAIL("Unexpected matrixs type.");
}
}
}
diff --git a/gpu/gl/GrGLSL.cpp b/gpu/gl/GrGLSL.cpp
index 7587fe8d..468b13b1 100644
--- a/gpu/gl/GrGLSL.cpp
+++ b/gpu/gl/GrGLSL.cpp
@@ -34,7 +34,7 @@ bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation)
*generation = k110_GrGLSLGeneration;
return true;
default:
- GrCrash("Unknown GL Standard");
+ SkFAIL("Unknown GL Standard");
return false;
}
}
@@ -64,7 +64,7 @@ const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
return "#version 150 compatibility\n";
}
default:
- GrCrash("Unknown GL version.");
+ SkFAIL("Unknown GL version.");
return ""; // suppress warning
}
}
diff --git a/gpu/gl/GrGLSL.h b/gpu/gl/GrGLSL.h
index 8234be9c..ff39c2b6 100644
--- a/gpu/gl/GrGLSL.h
+++ b/gpu/gl/GrGLSL.h
@@ -70,7 +70,7 @@ static inline const char* GrGLSLTypeString(GrSLType t) {
case kSampler2D_GrSLType:
return "sampler2D";
default:
- GrCrash("Unknown shader var type.");
+ SkFAIL("Unknown shader var type.");
return ""; // suppress warning
}
}
diff --git a/gpu/gl/GrGLShaderBuilder.cpp b/gpu/gl/GrGLShaderBuilder.cpp
index b72e23f9..c5df4c80 100644
--- a/gpu/gl/GrGLShaderBuilder.cpp
+++ b/gpu/gl/GrGLShaderBuilder.cpp
@@ -187,7 +187,7 @@ bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) {
}
return true;
default:
- GrCrash("Unexpected GLSLFeature requested.");
+ SkFAIL("Unexpected GLSLFeature requested.");
return false;
}
}
@@ -218,7 +218,7 @@ bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) {
"GL_NV_shader_framebuffer_fetch");
return true;
default:
- GrCrash("Unexpected GLSLPrivateFeature requested.");
+ SkFAIL("Unexpected GLSLPrivateFeature requested.");
return false;
}
}
@@ -249,7 +249,7 @@ const char* GrGLShaderBuilder::dstColor() {
if (fCodeStage.inStageCode()) {
const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
if (!effect->willReadDstColor()) {
- GrDebugCrash("GrGLEffect asked for dst color but its generating GrEffect "
+ SkDEBUGFAIL("GrGLEffect asked for dst color but its generating GrEffect "
"did not request access.");
return "";
}
@@ -399,7 +399,7 @@ const char* GrGLShaderBuilder::fragmentPosition() {
if (fCodeStage.inStageCode()) {
const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
if (!effect->willReadFragmentPosition()) {
- GrDebugCrash("GrGLEffect asked for frag position but its generating GrEffect "
+ SkDEBUGFAIL("GrGLEffect asked for frag position but its generating GrEffect "
"did not request access.");
return "";
}
@@ -483,9 +483,9 @@ inline void append_default_precision_qualifier(GrGLShaderVar::Precision p,
str->append("precision lowp float;\n");
break;
case GrGLShaderVar::kDefault_Precision:
- GrCrash("Default precision now allowed.");
+ SkFAIL("Default precision now allowed.");
default:
- GrCrash("Unknown precision value.");
+ SkFAIL("Unknown precision value.");
}
}
}
diff --git a/gpu/gl/GrGLShaderVar.h b/gpu/gl/GrGLShaderVar.h
index 7862abdb..68c4bbd2 100644
--- a/gpu/gl/GrGLShaderVar.h
+++ b/gpu/gl/GrGLShaderVar.h
@@ -315,7 +315,7 @@ public:
case kDefault_Precision:
return "";
default:
- GrCrash("Unexpected precision type.");
+ SkFAIL("Unexpected precision type.");
}
}
return "";
@@ -341,7 +341,7 @@ private:
case kVaryingOut_TypeModifier:
return k110_GrGLSLGeneration == gen ? "varying" : "out";
default:
- GrCrash("Unknown shader variable type modifier.");
+ SkFAIL("Unknown shader variable type modifier.");
return ""; // suppress warning
}
}
diff --git a/gpu/gl/GrGLStencilBuffer.cpp b/gpu/gl/GrGLStencilBuffer.cpp
index 33e346c6..abcb3c4b 100644
--- a/gpu/gl/GrGLStencilBuffer.cpp
+++ b/gpu/gl/GrGLStencilBuffer.cpp
@@ -13,7 +13,7 @@ GrGLStencilBuffer::~GrGLStencilBuffer() {
this->release();
}
-size_t GrGLStencilBuffer::sizeInBytes() const {
+size_t GrGLStencilBuffer::gpuMemorySize() const {
uint64_t size = this->width();
size *= this->height();
size *= fFormat.fTotalBits;
diff --git a/gpu/gl/GrGLStencilBuffer.h b/gpu/gl/GrGLStencilBuffer.h
index 2bf33ef7..1cb0a330 100644
--- a/gpu/gl/GrGLStencilBuffer.h
+++ b/gpu/gl/GrGLStencilBuffer.h
@@ -36,7 +36,7 @@ public:
virtual ~GrGLStencilBuffer();
- virtual size_t sizeInBytes() const SK_OVERRIDE;
+ virtual size_t gpuMemorySize() const SK_OVERRIDE;
GrGLuint renderbufferID() const {
return fRenderbufferID;
diff --git a/gpu/gl/GrGLUtil.cpp b/gpu/gl/GrGLUtil.cpp
index ddfcfbf0..0fa2d2ce 100644
--- a/gpu/gl/GrGLUtil.cpp
+++ b/gpu/gl/GrGLUtil.cpp
@@ -99,7 +99,7 @@ bool get_gl_version_for_mesa(int mesaMajorVersion, int* major, int* minor) {
GrGLStandard GrGLGetStandardInUseFromString(const char* versionString) {
if (NULL == versionString) {
- SkDEBUGFAIL("NULL GL version string.");
+ SkDebugf("NULL GL version string.");
return kNone_GrGLStandard;
}
@@ -139,7 +139,7 @@ bool GrGLIsChromiumFromRendererString(const char* rendererString) {
GrGLVersion GrGLGetVersionFromString(const char* versionString) {
if (NULL == versionString) {
- SkDEBUGFAIL("NULL GL version string.");
+ SkDebugf("NULL GL version string.");
return GR_GL_INVALID_VER;
}
@@ -178,7 +178,7 @@ GrGLVersion GrGLGetVersionFromString(const char* versionString) {
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) {
if (NULL == versionString) {
- SkDEBUGFAIL("NULL GLSL version string.");
+ SkDebugf("NULL GLSL version string.");
return GR_GLSL_INVALID_VER;
}
diff --git a/gpu/gl/GrGLVertexArray.cpp b/gpu/gl/GrGLVertexArray.cpp
index abd337a8..66feb820 100644
--- a/gpu/gl/GrGLVertexArray.cpp
+++ b/gpu/gl/GrGLVertexArray.cpp
@@ -69,7 +69,7 @@ void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount)
- : GrResource(gpu, false)
+ : INHERITED(gpu, false)
, fID(id)
, fAttribArrays(attribCount)
, fIndexBufferIDIsValid(false) {
diff --git a/gpu/gl/GrGLVertexArray.h b/gpu/gl/GrGLVertexArray.h
index 8a61f1a2..0e5bffe4 100644
--- a/gpu/gl/GrGLVertexArray.h
+++ b/gpu/gl/GrGLVertexArray.h
@@ -8,7 +8,7 @@
#ifndef GrGLVertexArray_DEFINED
#define GrGLVertexArray_DEFINED
-#include "GrResource.h"
+#include "GrGpuObject.h"
#include "GrTypesPriv.h"
#include "gl/GrGLDefines.h"
#include "gl/GrGLFunctions.h"
@@ -130,7 +130,7 @@ private:
* This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
* and is used to track the state of the vertex array to avoid redundant GL calls.
*/
-class GrGLVertexArray : public GrResource {
+class GrGLVertexArray : public GrGpuObject {
public:
GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount);
@@ -157,7 +157,7 @@ public:
void invalidateCachedState();
- virtual size_t sizeInBytes() const SK_OVERRIDE { return 0; }
+ virtual size_t gpuMemorySize() const SK_OVERRIDE { return 0; }
protected:
virtual void onAbandon() SK_OVERRIDE;
@@ -170,7 +170,7 @@ private:
GrGLuint fIndexBufferID;
bool fIndexBufferIDIsValid;
- typedef GrResource INHERITED;
+ typedef GrGpuObject INHERITED;
};
#endif
diff --git a/gpu/gl/GrGLVertexBuffer.cpp b/gpu/gl/GrGLVertexBuffer.cpp
index 685166c9..8bfe1f0c 100644
--- a/gpu/gl/GrGLVertexBuffer.cpp
+++ b/gpu/gl/GrGLVertexBuffer.cpp
@@ -14,7 +14,7 @@ GrGLVertexBuffer::GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc)
}
void GrGLVertexBuffer::onRelease() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.release(this->getGpuGL());
}
@@ -28,7 +28,7 @@ void GrGLVertexBuffer::onAbandon() {
}
void* GrGLVertexBuffer::lock() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
return fImpl.lock(this->getGpuGL());
} else {
return NULL;
@@ -40,7 +40,7 @@ void* GrGLVertexBuffer::lockPtr() const {
}
void GrGLVertexBuffer::unlock() {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.unlock(this->getGpuGL());
}
}
@@ -50,7 +50,7 @@ bool GrGLVertexBuffer::isLocked() const {
}
bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
} else {
return false;
diff --git a/gpu/gl/GrGLVertexBuffer.h b/gpu/gl/GrGLVertexBuffer.h
index 1741adc2..1b9c4f17 100644
--- a/gpu/gl/GrGLVertexBuffer.h
+++ b/gpu/gl/GrGLVertexBuffer.h
@@ -26,7 +26,7 @@ public:
size_t baseOffset() const { return fImpl.baseOffset(); }
void bind() const {
- if (this->isValid()) {
+ if (!this->wasDestroyed()) {
fImpl.bind(this->getGpuGL());
}
}
@@ -45,7 +45,7 @@ protected:
private:
GrGpuGL* getGpuGL() const {
- SkASSERT(this->isValid());
+ SkASSERT(!this->wasDestroyed());
return (GrGpuGL*)(this->getGpu());
}
diff --git a/gpu/gl/GrGLVertexEffect.h b/gpu/gl/GrGLVertexEffect.h
index 1b4c7444..40b4b340 100644
--- a/gpu/gl/GrGLVertexEffect.h
+++ b/gpu/gl/GrGLVertexEffect.h
@@ -42,7 +42,7 @@ public:
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) SK_OVERRIDE {
- GrCrash("GrGLVertexEffect requires GrGLFullShaderBuilder* overload for emitCode().");
+ SkFAIL("GrGLVertexEffect requires GrGLFullShaderBuilder* overload for emitCode().");
}
private:
diff --git a/gpu/gl/GrGpuGL.cpp b/gpu/gl/GrGpuGL.cpp
index 4b39a163..1a1bad7f 100644
--- a/gpu/gl/GrGpuGL.cpp
+++ b/gpu/gl/GrGpuGL.cpp
@@ -730,7 +730,7 @@ static bool renderbuffer_storage_msaa(GrGLContext& ctx,
width, height));
break;
case GrGLCaps::kNone_MSFBOType:
- GrCrash("Shouldn't be here if we don't support multisampled renderbuffers.");
+ SkFAIL("Shouldn't be here if we don't support multisampled renderbuffers.");
break;
}
return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));;
@@ -1303,7 +1303,7 @@ void GrGpuGL::discard(GrRenderTarget* renderTarget) {
}
switch (this->glCaps().invalidateFBType()) {
case GrGLCaps::kNone_FBFetchType:
- GrCrash("Should never get here.");
+ SkFAIL("Should never get here.");
break;
case GrGLCaps::kInvalidate_InvalidateFBType:
if (0 == glRT->renderFBOID()) {
@@ -1463,7 +1463,7 @@ bool GrGpuGL::onReadPixels(GrRenderTarget* target,
tgt->textureFBOID()));
break;
default:
- GrCrash("Unknown resolve type");
+ SkFAIL("Unknown resolve type");
}
const GrGLIRect& glvp = tgt->getViewport();
@@ -1656,7 +1656,7 @@ void GrGpuGL::onGpuDraw(const DrawInfo& info) {
static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) {
switch (op) {
default:
- GrCrash("Unexpected path fill.");
+ SkFAIL("Unexpected path fill.");
/* fallthrough */;
case kIncClamp_StencilOp:
return GR_GL_COUNT_UP;
@@ -2357,7 +2357,7 @@ void GrGpuGL::flushMiscFixedFunctionState() {
GL_CALL(Disable(GR_GL_CULL_FACE));
break;
default:
- GrCrash("Unknown draw face.");
+ SkFAIL("Unknown draw face.");
}
fHWDrawFace = drawState.getDrawFace();
}
@@ -2788,7 +2788,7 @@ GrGLAttribArrayState* GrGpuGL::HWGeometryState::bindArrayAndBuffersToDraw(
// We use a vertex array if we're on a core profile and the verts are in a VBO.
if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) {
- if (NULL == fVBOVertexArray || !fVBOVertexArray->isValid()) {
+ if (NULL == fVBOVertexArray || fVBOVertexArray->wasDestroyed()) {
SkSafeUnref(fVBOVertexArray);
GrGLuint arrayID;
GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID));
diff --git a/gpu/gl/GrGpuGL_program.cpp b/gpu/gl/GrGpuGL_program.cpp
index 0a7bb0e3..b9b09847 100644
--- a/gpu/gl/GrGpuGL_program.cpp
+++ b/gpu/gl/GrGpuGL_program.cpp
@@ -309,7 +309,7 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
break;
default:
vbuf = NULL; // suppress warning
- GrCrash("Unknown geometry src type!");
+ SkFAIL("Unknown geometry src type!");
}
SkASSERT(NULL != vbuf);
@@ -333,7 +333,7 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
break;
default:
ibuf = NULL; // suppress warning
- GrCrash("Unknown geometry src type!");
+ SkFAIL("Unknown geometry src type!");
}
SkASSERT(NULL != ibuf);
diff --git a/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
index b50063fb..312299ad 100644
--- a/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
+++ b/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
@@ -75,7 +75,7 @@ static GrGLInterface* create_es_interface(GrGLVersion version,
functions->fGetShaderInfoLog = glGetShaderInfoLog;
functions->fGetShaderiv = glGetShaderiv;
functions->fGetString = glGetString;
-#if GL_ES_VERSION_30
+#if GL_ES_VERSION_3_0
functions->fGetStringi = glGetStringi;
#else
functions->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
@@ -183,12 +183,24 @@ static GrGLInterface* create_es_interface(GrGLVersion version,
functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
functions->fRenderbufferStorage = glRenderbufferStorage;
+
#if GL_OES_mapbuffer
functions->fMapBuffer = glMapBufferOES;
functions->fUnmapBuffer = glUnmapBufferOES;
#else
functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
+
+#endif
+
+#if GL_ES_VERSION_3_0 || GL_EXT_map_buffer_range
+ functions->fMapBufferRange = glMapBufferRange;
+ functions->fFlushMappedBufferRange = glFlushMappedBufferRange;
+#else
+ if (version >= GR_GL_VER(3,0) || extensions->has("GL_EXT_map_buffer_range")) {
+ functions->fMapBufferRange = (GrGLMapBufferRangeProc) eglGetProcAddress("glMapBufferRange");
+ functions->fFlushMappedBufferRange = (GrGLFlushMappedBufferRangeProc) eglGetProcAddress("glFlushMappedBufferRange");
+ }
#endif
if (extensions->has("GL_EXT_debug_marker")) {
diff --git a/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
index a316ff1c..cb2fc953 100644
--- a/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
+++ b/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
@@ -154,6 +154,14 @@ const GrGLInterface* GrGLCreateANGLEInterface() {
functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
+#if GL_ES_VERSION_3_0
+ functions->fMapBufferRange = GET_PROC(glMapBufferRange);
+ functions->fFlushMappedBufferRange = GET_PROC(glFlushMappedBufferRange);
+#else
+ functions->fMapBufferRange = (GrGLMapBufferRangeProc) eglGetProcAddress("glMapBufferRange");
+ functions->fFlushMappedBufferRange = (GrGLFlushMappedBufferRangeProc) eglGetProcAddress("glFlushMappedBufferRange");
+#endif
+
functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glInsertEventMarkerEXT");
functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glPushGroupMarkerEXT");
functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGroupMarkerEXT");
diff --git a/gpu/gl/debug/GrBufferObj.h b/gpu/gl/debug/GrBufferObj.h
index fecfeb5e..05d3cfdd 100644
--- a/gpu/gl/debug/GrBufferObj.h
+++ b/gpu/gl/debug/GrBufferObj.h
@@ -34,9 +34,15 @@ public:
GrAlwaysAssert(!fMapped);
}
- void setMapped() { fMapped = true; }
+ void setMapped(GrGLintptr offset, GrGLsizeiptr length) {
+ fMapped = true;
+ fMappedOffset = offset;
+ fMappedLength = length;
+ }
void resetMapped() { fMapped = false; }
bool getMapped() const { return fMapped; }
+ GrGLsizei getMappedOffset() const { return fMappedOffset; }
+ GrGLsizei getMappedLength() const { return fMappedLength; }
void setBound() { fBound = true; }
void resetBound() { fBound = false; }
@@ -55,7 +61,9 @@ protected:
private:
GrGLchar* fDataPtr;
- bool fMapped; // is the buffer object mapped via "glMapBuffer"?
+ bool fMapped; // is the buffer object mapped via "glMapBuffer[Range]"?
+ GrGLintptr fMappedOffset; // the offset of the buffer range that is mapped
+ GrGLsizeiptr fMappedLength; // the size of the buffer range that is mapped
bool fBound; // is the buffer object bound via "glBindBuffer"?
GrGLsizeiptr fSize; // size in bytes
GrGLint fUsage; // one of: GL_STREAM_DRAW,
diff --git a/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 0a8333b8..7c430b4b 100644
--- a/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -93,7 +93,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
break;
default:
- GrCrash("Unexpected target to glBufferData");
+ SkFAIL("Unexpected target to glBufferData");
break;
}
@@ -586,7 +586,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferI
GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
break;
default:
- GrCrash("Unexpected target to glBindBuffer");
+ SkFAIL("Unexpected target to glBindBuffer");
break;
}
}
@@ -622,12 +622,14 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* i
}
// map a buffer to the caller's address space
-GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
-
+GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBufferRange(GrGLenum target, GrGLintptr offset,
+ GrGLsizeiptr length, GrGLbitfield access) {
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
GR_GL_ELEMENT_ARRAY_BUFFER == target);
- // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access);
- GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
+
+ // We only expect read access and we expect that the buffer or range is always invalidated.
+ GrAlwaysAssert(!SkToBool(GR_GL_MAP_READ_BIT & access));
+ GrAlwaysAssert((GR_GL_MAP_INVALIDATE_BUFFER_BIT | GR_GL_MAP_INVALIDATE_RANGE_BIT) & access);
GrBufferObj *buffer = NULL;
switch (target) {
@@ -638,20 +640,41 @@ GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access)
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
break;
default:
- GrCrash("Unexpected target to glMapBuffer");
+ SkFAIL("Unexpected target to glMapBufferRange");
break;
}
- if (buffer) {
+ if (NULL != buffer) {
+ GrAlwaysAssert(offset >= 0 && offset + length <= buffer->getSize());
GrAlwaysAssert(!buffer->getMapped());
- buffer->setMapped();
- return buffer->getDataPtr();
+ buffer->setMapped(offset, length);
+ return buffer->getDataPtr() + offset;
}
GrAlwaysAssert(false);
return NULL; // no buffer bound to the target
}
+GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
+ GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
+
+ GrBufferObj *buffer = NULL;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ buffer = GrDebugGL::getInstance()->getArrayBuffer();
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
+ break;
+ default:
+ SkFAIL("Unexpected target to glMapBuffer");
+ break;
+ }
+
+ return debugGLMapBufferRange(target, 0, buffer->getSize(),
+ GR_GL_MAP_WRITE_BIT | GR_GL_MAP_INVALIDATE_BUFFER_BIT);
+}
+
// remove a buffer from the caller's address space
// TODO: check if the "access" method from "glMapBuffer" was honored
GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
@@ -668,11 +691,11 @@ GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
break;
default:
- GrCrash("Unexpected target to glUnmapBuffer");
+ SkFAIL("Unexpected target to glUnmapBuffer");
break;
}
- if (buffer) {
+ if (NULL != buffer) {
GrAlwaysAssert(buffer->getMapped());
buffer->resetMapped();
return GR_GL_TRUE;
@@ -682,6 +705,34 @@ GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
}
+GrGLvoid GR_GL_FUNCTION_TYPE debugGLFlushMappedBufferRange(GrGLenum target,
+ GrGLintptr offset,
+ GrGLsizeiptr length) {
+ GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
+ GR_GL_ELEMENT_ARRAY_BUFFER == target);
+
+ GrBufferObj *buffer = NULL;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ buffer = GrDebugGL::getInstance()->getArrayBuffer();
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
+ break;
+ default:
+ SkFAIL("Unexpected target to glUnmapBuffer");
+ break;
+ }
+
+ if (NULL != buffer) {
+ GrAlwaysAssert(buffer->getMapped());
+ GrAlwaysAssert(offset >= 0 && (offset + length) <= buffer->getMappedLength());
+ } else {
+ GrAlwaysAssert(false);
+ }
+}
+
+
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
GrGLenum value,
GrGLint* params) {
@@ -706,21 +757,21 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
switch (value) {
case GR_GL_BUFFER_MAPPED:
*params = GR_GL_FALSE;
- if (buffer)
+ if (NULL != buffer)
*params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
break;
case GR_GL_BUFFER_SIZE:
*params = 0;
- if (buffer)
+ if (NULL != buffer)
*params = SkToInt(buffer->getSize());
break;
case GR_GL_BUFFER_USAGE:
*params = GR_GL_STATIC_DRAW;
- if (buffer)
+ if (NULL != buffer)
*params = buffer->getUsage();
break;
default:
- GrCrash("Unexpected value to glGetBufferParamateriv");
+ SkFAIL("Unexpected value to glGetBufferParamateriv");
break;
}
};
@@ -826,6 +877,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
functions->fEndQuery = noOpGLEndQuery;
functions->fFinish = noOpGLFinish;
functions->fFlush = noOpGLFlush;
+ functions->fFlushMappedBufferRange = debugGLFlushMappedBufferRange;
functions->fFrontFace = noOpGLFrontFace;
functions->fGenerateMipmap = debugGLGenerateMipmap;
functions->fGenBuffers = debugGLGenBuffers;
@@ -850,6 +902,8 @@ const GrGLInterface* GrGLCreateDebugInterface() {
functions->fGenVertexArrays = debugGLGenVertexArrays;
functions->fLineWidth = noOpGLLineWidth;
functions->fLinkProgram = noOpGLLinkProgram;
+ functions->fMapBuffer = debugGLMapBuffer;
+ functions->fMapBufferRange = debugGLMapBufferRange;
functions->fPixelStorei = debugGLPixelStorei;
functions->fQueryCounter = noOpGLQueryCounter;
functions->fReadBuffer = noOpGLReadBuffer;
@@ -887,6 +941,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
+ functions->fUnmapBuffer = debugGLUnmapBuffer;
functions->fUseProgram = debugGLUseProgram;
functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
@@ -909,10 +964,9 @@ const GrGLInterface* GrGLCreateDebugInterface() {
functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
functions->fResolveMultisampleFramebuffer =
noOpGLResolveMultisampleFramebuffer;
- functions->fMapBuffer = debugGLMapBuffer;
functions->fMatrixLoadf = noOpGLMatrixLoadf;
functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
- functions->fUnmapBuffer = debugGLUnmapBuffer;
+
functions->fBindFragDataLocationIndexed =
noOpGLBindFragDataLocationIndexed;
diff --git a/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp b/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp
index 6af04715..08e7ac8a 100644
--- a/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp
+++ b/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp
@@ -132,6 +132,11 @@ const GrGLInterface* GrGLCreateNativeInterface() {
functions->fUnmapBuffer = glUnmapBufferOES;
#endif
+#if GL_EXT_map_buffer_range || GL_ES_VERSION_3_0
+ functions->fMapBufferRange = glMapBufferRangeEXT;
+ functions->fFlushMappedBufferRange = glFlushMappedBufferRangeEXT;
+#endif
+
#if GL_APPLE_framebuffer_multisample
functions->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
functions->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;