aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-16 07:48:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-16 07:48:20 -0700
commitc161310ffdbbcb3b023da2e375faefd211fa52e8 (patch)
tree523f662f30c0a3307716900e37343ddff069b247 /src
parentd7ea92f2ff8ba41783296ff8e6203a59a5549c1a (diff)
Begin tracking GL_TEXTURE_ and GL_DRAW_INDIRECT_ buffer bindings
Diffstat (limited to 'src')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp55
-rw-r--r--src/gpu/gl/GrGLGpu.h7
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;