aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gpu/include/GrGLConfig.h14
-rw-r--r--gpu/include/GrGLConfig_chrome.h4
-rw-r--r--gpu/src/GrGLIndexBuffer.cpp2
-rw-r--r--gpu/src/GrGLVertexBuffer.cpp2
4 files changed, 22 insertions, 0 deletions
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h
index b4ca78cee5..e59fe553cf 100644
--- a/gpu/include/GrGLConfig.h
+++ b/gpu/include/GrGLConfig.h
@@ -65,6 +65,16 @@
* Setting this build flag enables this behavior. GR_GL_NO_CONSTANT_ATTRIBUTES
* must not be set since this uses constant attributes for the matrices.
* Defaults to 0.
+ *
+ * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index
+ * buffer that replaces old data Ganesh can give a hint to the driver that the
+ * previous data will not be used in future draws like this:
+ * glBufferData(GL_..._BUFFER, size, NULL, usage); //<--hint, NULL means
+ * glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) // old data can't be
+ * // used again.
+ * However, this can cause a performance decrease on Chrome cmd buffer because
+ * it will create a new allocation and memset the whole thing to zero (for
+ * security reasons). Defaults to 1 (enabled).
*/
#if !defined(GR_GL_LOG_CALLS)
@@ -91,6 +101,10 @@
#define GR_GL_ATTRIBUTE_MATRICES 0
#endif
+#if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT)
+ #define GR_GL_USE_BUFFER_DATA_NULL_HINT 1
+#endif
+
#if(GR_GL_NO_CONSTANT_ATTRIBUTES) && (GR_GL_ATTRIBUTE_MATRICES)
#error "Cannot combine GR_GL_NO_CONSTANT_ATTRIBUTES and GR_GL_ATTRIBUTE_MATRICES"
#endif
diff --git a/gpu/include/GrGLConfig_chrome.h b/gpu/include/GrGLConfig_chrome.h
index 738e80186b..9c25cb254a 100644
--- a/gpu/include/GrGLConfig_chrome.h
+++ b/gpu/include/GrGLConfig_chrome.h
@@ -10,4 +10,8 @@
// ANGLE creates a temp VB for vertex attributes not specified per-vertex.
#define GR_GL_NO_CONSTANT_ATTRIBUTES GR_WIN32_BUILD
+// cmd buffer allocates memory and memsets it to zero when it sees glBufferData
+// with NULL.
+#define GR_GL_USE_BUFFER_DATA_NULL_HINT 0
+
#endif
diff --git a/gpu/src/GrGLIndexBuffer.cpp b/gpu/src/GrGLIndexBuffer.cpp
index 4fb1e99ce4..1d3f89319d 100644
--- a/gpu/src/GrGLIndexBuffer.cpp
+++ b/gpu/src/GrGLIndexBuffer.cpp
@@ -106,7 +106,9 @@ bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
if (size() == srcSizeInBytes) {
GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, srcSizeInBytes, src, usage));
} else {
+#if GR_GL_USE_BUFFER_DATA_NULL_HINT
GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, size(), NULL, usage));
+#endif
GR_GL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, 0, srcSizeInBytes, src));
}
return true;
diff --git a/gpu/src/GrGLVertexBuffer.cpp b/gpu/src/GrGLVertexBuffer.cpp
index 3fa1425d02..5d274aa260 100644
--- a/gpu/src/GrGLVertexBuffer.cpp
+++ b/gpu/src/GrGLVertexBuffer.cpp
@@ -105,7 +105,9 @@ bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
if (size() == srcSizeInBytes) {
GR_GL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));
} else {
+#if GR_GL_USE_BUFFER_DATA_NULL_HINT
GR_GL(BufferData(GR_GL_ARRAY_BUFFER, size(), NULL, usage));
+#endif
GR_GL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src));
}
return true;