buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
break;
default:
- GrCrash("Unexpected target to glBufferData");
+ SkFAIL("Unexpected target to glBufferData");
break;
}
GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
break;
default:
- GrCrash("Unexpected target to glBindBuffer");
+ SkFAIL("Unexpected target to glBindBuffer");
break;
}
}
}
// 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) {
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) {
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;
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) {
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)
- *params = buffer->getSize();
+ 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;
}
};
functions->fEndQuery = noOpGLEndQuery;
functions->fFinish = noOpGLFinish;
functions->fFlush = noOpGLFlush;
+ functions->fFlushMappedBufferRange = debugGLFlushMappedBufferRange;
functions->fFrontFace = noOpGLFrontFace;
functions->fGenerateMipmap = debugGLGenerateMipmap;
functions->fGenBuffers = debugGLGenBuffers;
functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
functions->fGetUniformLocation = noOpGLGetUniformLocation;
functions->fGenVertexArrays = debugGLGenVertexArrays;
- functions->fLoadIdentity = noOpGLLoadIdentity;
- functions->fLoadMatrixf = noOpGLLoadMatrixf;
functions->fLineWidth = noOpGLLineWidth;
functions->fLinkProgram = noOpGLLinkProgram;
- functions->fMatrixMode = noOpGLMatrixMode;
+ functions->fMapBuffer = debugGLMapBuffer;
+ functions->fMapBufferRange = debugGLMapBufferRange;
functions->fPixelStorei = debugGLPixelStorei;
functions->fQueryCounter = noOpGLQueryCounter;
functions->fReadBuffer = noOpGLReadBuffer;
functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
functions->fStencilOp = noOpGLStencilOp;
functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
- functions->fTexGenfv = noOpGLTexGenfv;
- functions->fTexGeni = noOpGLTexGeni;
functions->fTexImage2D = noOpGLTexImage2D;
functions->fTexParameteri = noOpGLTexParameteri;
functions->fTexParameteriv = noOpGLTexParameteriv;
functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
+ functions->fUnmapBuffer = debugGLUnmapBuffer;
functions->fUseProgram = debugGLUseProgram;
functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
functions->fResolveMultisampleFramebuffer =
noOpGLResolveMultisampleFramebuffer;
- functions->fMapBuffer = debugGLMapBuffer;
- functions->fUnmapBuffer = debugGLUnmapBuffer;
+ functions->fMatrixLoadf = noOpGLMatrixLoadf;
+ functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
+
functions->fBindFragDataLocationIndexed =
noOpGLBindFragDataLocationIndexed;