Initialize glGen* call id args to zero

Initialize glGenTexture, glGenBuffer call id buffer items to zero before
calls. Otherwise it's not easy to check if the call succeeded or not.

Assert the rule in debug gl context.

Make TesselatingPathRendererTests use debug gl context. It exercises
some of the GenBuffers call sites.

Review URL: https://codereview.chromium.org/1514033002
This commit is contained in:
kkinnunen 2015-12-11 00:05:33 -08:00 committed by Commit bot
parent 55eeae9722
commit 546eb5c57a
3 changed files with 14 additions and 8 deletions

View File

@ -1077,6 +1077,7 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
GrGLTexture::IDDesc idDesc;
idDesc.fInfo.fID = 0;
GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
idDesc.fLifeCycle = lifeCycle;
// We only support GL_TEXTURE_2D at the moment.
@ -1156,6 +1157,7 @@ GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
}
GrGLTexture::IDDesc idDesc;
idDesc.fInfo.fID = 0;
GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
idDesc.fLifeCycle = lifeCycle;
// We only support GL_TEXTURE_2D at the moment.
@ -1238,7 +1240,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
// Default to unsupported
fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
// Create color texture
GrGLuint colorID;
GrGLuint colorID = 0;
GL_CALL(GenTextures(1, &colorID));
this->setScratchTextureUnit();
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID));
@ -1291,7 +1293,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
// Create Framebuffer
GrGLuint fb;
GrGLuint fb = 0;
GL_CALL(GenFramebuffers(1, &fb));
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
@ -1425,6 +1427,7 @@ GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
return vertexBuffer;
} else {
desc.fID = 0;
GL_CALL(GenBuffers(1, &desc.fID));
if (desc.fID) {
fHWGeometryState.setVertexBufferID(this, desc.fID);
@ -1457,6 +1460,7 @@ GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) {
GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
return indexBuffer;
} else {
desc.fID = 0;
GL_CALL(GenBuffers(1, &desc.fID));
if (desc.fID) {
fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID);
@ -1490,7 +1494,7 @@ GrTransferBuffer* GrGLGpu::onCreateTransferBuffer(size_t size, TransferType xfer
desc.fUsage = toGpu ? GrGLBufferImpl::kStreamDraw_Usage : GrGLBufferImpl::kStreamRead_Usage;
desc.fSizeInBytes = size;
desc.fID = 0;
GL_CALL(GenBuffers(1, &desc.fID));
if (desc.fID) {
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
@ -3147,7 +3151,7 @@ void GrGLGpu::createCopyPrograms() {
GL_CALL(DeleteShader(vshader));
GL_CALL(DeleteShader(fshader));
}
fCopyProgramArrayBuffer = 0;
GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer));
fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer);
static const GrGLfloat vdata[] = {
@ -3510,6 +3514,7 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in
GrPixelConfig config) const {
GrGLTextureInfo* info = new GrGLTextureInfo;
info->fTarget = GR_GL_TEXTURE_2D;
info->fID = 0;
GL_CALL(GenTextures(1, &info->fID));
GL_CALL(ActiveTexture(GR_GL_TEXTURE0));
GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1));

View File

@ -513,9 +513,10 @@ GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
GrGLuint* ids) {
for (int i = 0; i < n; ++i) {
GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
GrAlwaysAssert(obj);
ids[i] = obj->getID();
GrAlwaysAssert(ids[i] == 0);
GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
GrAlwaysAssert(obj);
ids[i] = obj->getID();
}
}

View File

@ -252,7 +252,7 @@ static void test_path(GrDrawTarget* dt, GrRenderTarget* rt, GrResourceProvider*
tess.drawPath(args);
}
DEF_GPUTEST_FOR_NATIVE_CONTEXT(TessellatingPathRendererTests, reporter, context) {
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, context) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = 800;