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
This commit is contained in:
bsalomon@google.com 2011-07-01 15:21:59 +00:00
parent ee435122d7
commit 9ae4429f9d
4 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;