diff options
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 55 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 7 |
2 files changed, 51 insertions, 11 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 3e8f507b4a..f742efe70d 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -412,6 +412,9 @@ void GrGLGpu::onResetContext(uint32_t resetBits) { GL_CALL(Disable(GR_GL_DEPTH_TEST)); GL_CALL(DepthMask(GR_GL_FALSE)); + fHWBoundTextureBufferIDIsValid = false; + fHWBoundDrawIndirectBufferIDIsValid = false; + fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; if (kGL_GrGLStandard == this->glStandard()) { @@ -2177,22 +2180,54 @@ void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, void GrGLGpu::bindBuffer(GrGLuint id, GrGLenum type) { this->handleDirtyContext(); - if (GR_GL_ARRAY_BUFFER == type) { - this->bindVertexBuffer(id); - } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) { - this->bindIndexBufferAndDefaultVertexArray(id); - } else { - GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); + switch (type) { + case GR_GL_ARRAY_BUFFER: + this->bindVertexBuffer(id); + break; + case GR_GL_ELEMENT_ARRAY_BUFFER: + this->bindIndexBufferAndDefaultVertexArray(id); + break; + case GR_GL_TEXTURE_BUFFER: + if (!fHWBoundTextureBufferIDIsValid || id != fHWBoundTextureBufferID) { + GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); + fHWBoundTextureBufferID = id; + fHWBoundTextureBufferIDIsValid = true; + } + break; + case GR_GL_DRAW_INDIRECT_BUFFER: + if (!fHWBoundDrawIndirectBufferIDIsValid || id != fHWBoundDrawIndirectBufferID) { + GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); + fHWBoundDrawIndirectBufferID = id; + fHWBoundDrawIndirectBufferIDIsValid = true; + } + break; + default: + SkDebugf("WARNING: buffer target 0x%x is not tracked by GrGLGpu.\n", type); + GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); + break; } } void GrGLGpu::releaseBuffer(GrGLuint id, GrGLenum type) { this->handleDirtyContext(); GL_CALL(DeleteBuffers(1, &id)); - if (GR_GL_ARRAY_BUFFER == type) { - this->notifyVertexBufferDelete(id); - } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) { - this->notifyIndexBufferDelete(id); + switch (type) { + case GR_GL_ARRAY_BUFFER: + this->notifyVertexBufferDelete(id); + break; + case GR_GL_ELEMENT_ARRAY_BUFFER: + this->notifyIndexBufferDelete(id); + break; + case GR_GL_TEXTURE_BUFFER: + if (fHWBoundTextureBufferIDIsValid && id == fHWBoundTextureBufferID) { + fHWBoundTextureBufferID = 0; + } + break; + case GR_GL_DRAW_INDIRECT_BUFFER: + if (fHWBoundDrawIndirectBufferIDIsValid && id == fHWBoundDrawIndirectBufferID) { + fHWBoundDrawIndirectBufferID = 0; + } + break; } } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 1ad519a5ce..39d565987d 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -99,7 +99,7 @@ public: const GrPrimitiveProcessor&, const GrPipeline&) const override; - // id and type (GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER) of buffer to bind + // id and type (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.) of buffer to bind void bindBuffer(GrGLuint id, GrGLenum type); void releaseBuffer(GrGLuint id, GrGLenum type); @@ -542,6 +542,11 @@ private: GrGLVertexArray* fVBOVertexArray; } fHWGeometryState; + GrGLuint fHWBoundTextureBufferID; + GrGLuint fHWBoundDrawIndirectBufferID; + bool fHWBoundTextureBufferIDIsValid; + bool fHWBoundDrawIndirectBufferIDIsValid; + struct { GrBlendEquation fEquation; GrBlendCoeff fSrcCoeff; |