From 9ae4429f9d3ab837ff9352261271974715cabb8a Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Fri, 1 Jul 2011 15:21:59 +0000 Subject: Don't send NULL buffer data hint in chrome Review URL: http://codereview.appspot.com/4657067/ git-svn-id: http://skia.googlecode.com/svn/trunk@1778 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gpu/include/GrGLConfig.h | 14 ++++++++++++++ gpu/include/GrGLConfig_chrome.h | 4 ++++ gpu/src/GrGLIndexBuffer.cpp | 2 ++ gpu/src/GrGLVertexBuffer.cpp | 2 ++ 4 files changed, 22 insertions(+) (limited to 'gpu') 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; -- cgit v1.2.3