diff options
author | 2015-10-23 13:54:12 -0700 | |
---|---|---|
committer | 2015-10-23 13:54:12 -0700 | |
commit | 6df232d251cefe8f3498a1ae4dad449bafa9ebb3 (patch) | |
tree | e39e0892367fe2a0e37df4a7969046957d294e56 /src/gpu/gl/GrGLGpu.cpp | |
parent | 043a75e234864161013863c0bf92002a165bb31b (diff) |
Revert of Experimental CL to stop using subdata (patchset #1 id:1 of https://codereview.chromium.org/1413263006/ )
Reason for revert:
might be breaking tsan
Original issue's description:
> Experimental CL to stop using subdata
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/383ce32e3e5ca0c8997ece827205f61d348ee56f
TBR=bsalomon@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1409123004
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 645a508e6c..ce02fe8ea9 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1596,7 +1596,7 @@ void* GrGLGpu::mapBuffer(GrGLuint id, GrGLenum type, bool dynamic, size_t curren case GrGLCaps::kMapBuffer_MapBufferType: this->bindBuffer(id, type); // Let driver know it can discard the old data - if (currentSize != requestedSize) { + if (GR_GL_USE_BUFFER_DATA_NULL_HINT || currentSize != requestedSize) { GL_CALL(BufferData(type, requestedSize, nullptr, dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW)); } @@ -1634,10 +1634,26 @@ void GrGLGpu::bufferData(GrGLuint id, GrGLenum type, bool dynamic, size_t curren this->bindBuffer(id, type); GrGLenum usage = dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW; +#if GR_GL_USE_BUFFER_DATA_NULL_HINT + if (currentSize == srcSizeInBytes) { + GL_CALL(BufferData(type, (GrGLsizeiptr) srcSizeInBytes, src, usage)); + } else { + // Before we call glBufferSubData we give the driver a hint using + // glBufferData with nullptr. 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. + // TODO I think we actually want to try calling bufferData here + GL_CALL(BufferData(type, currentSize, nullptr, usage)); + GL_CALL(BufferSubData(type, 0, (GrGLsizeiptr) srcSizeInBytes, src)); + } +#else // 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 (map() does a glBufferData(..size, nullptr..)) GL_CALL(BufferData(type, srcSizeInBytes, src, usage)); +#endif } void GrGLGpu::unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr) { |