aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src/GrGLIndexBuffer.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-10 14:49:29 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-10 14:49:29 +0000
commit96e96dfd1edea2ceaf0311fce71cddae50175086 (patch)
tree7aac870f9e2d1cb935f0082dfa65e81de86e293e /gpu/src/GrGLIndexBuffer.cpp
parente05cc8e94ee2ad853233262d74047119939111f2 (diff)
When we're not using the NULL buffer data hint update with glBufferData rather than glBufferSubData.
Review URL: http://codereview.appspot.com/5253047/ git-svn-id: http://skia.googlecode.com/svn/trunk@2443 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrGLIndexBuffer.cpp')
-rw-r--r--gpu/src/GrGLIndexBuffer.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/gpu/src/GrGLIndexBuffer.cpp b/gpu/src/GrGLIndexBuffer.cpp
index 084a4c61b0..b64668ede2 100644
--- a/gpu/src/GrGLIndexBuffer.cpp
+++ b/gpu/src/GrGLIndexBuffer.cpp
@@ -104,31 +104,28 @@ bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
}
this->bind();
GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;
+#if !GR_GL_USE_BUFFER_DATA_NULL_HINT
+ // Note that we're cheating on the size here. Currently no methods
+ // allow a partial update that preserves contents of non-updated
+ // portions of the buffer (and lock() does a glBufferData(..size, NULL..))
+ GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, srcSizeInBytes, src, usage));
+#else
if (this->sizeInBytes() == srcSizeInBytes) {
GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
srcSizeInBytes, src, usage));
} else {
-#if GR_GL_USE_BUFFER_DATA_NULL_HINT
+ // Before we call glBufferSubData we give the driver a hint using
+ // glBufferData with NULL. This makes the old buffer contents
+ // inaccessible to future draws. The GPU may still be processing draws
+ // that reference the old contents. With this hint it can assign a
+ // different allocation for the new contents to avoid flushing the gpu
+ // past draws consuming the old contents.
GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
this->sizeInBytes(), NULL, usage));
-#endif
GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER,
0, srcSizeInBytes, src));
}
- return true;
-}
-
-bool GrGLIndexBuffer::updateSubData(const void* src,
- size_t srcSizeInBytes,
- size_t offset) {
- GrAssert(fBufferID);
- GrAssert(!isLocked());
- if (srcSizeInBytes + offset > this->sizeInBytes()) {
- return false;
- }
- this->bind();
- GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER,
- offset, srcSizeInBytes, src));
+#endif
return true;
}