diff options
author | cdalton <cdalton@nvidia.com> | 2016-03-16 07:48:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-16 07:48:20 -0700 |
commit | c161310ffdbbcb3b023da2e375faefd211fa52e8 (patch) | |
tree | 523f662f30c0a3307716900e37343ddff069b247 /src | |
parent | d7ea92f2ff8ba41783296ff8e6203a59a5549c1a (diff) |
Begin tracking GL_TEXTURE_ and GL_DRAW_INDIRECT_ buffer bindings
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1796713005
Review URL: https://codereview.chromium.org/1796713005
Diffstat (limited to 'src')
-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; |