Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1409123004: Revert of Experimental CL to stop using subdata (Closed) Base URL: https://skia.googlesource.com/skia.git@bufferimpl2
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLBufferImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 void* GrGLGpu::mapBuffer(GrGLuint id, GrGLenum type, bool dynamic, size_t curren tSize, 1589 void* GrGLGpu::mapBuffer(GrGLuint id, GrGLenum type, bool dynamic, size_t curren tSize,
1590 size_t requestedSize) { 1590 size_t requestedSize) {
1591 void* mapPtr = nullptr; 1591 void* mapPtr = nullptr;
1592 // Handling dirty context is done in the bindBuffer call 1592 // Handling dirty context is done in the bindBuffer call
1593 switch (this->glCaps().mapBufferType()) { 1593 switch (this->glCaps().mapBufferType()) {
1594 case GrGLCaps::kNone_MapBufferType: 1594 case GrGLCaps::kNone_MapBufferType:
1595 break; 1595 break;
1596 case GrGLCaps::kMapBuffer_MapBufferType: 1596 case GrGLCaps::kMapBuffer_MapBufferType:
1597 this->bindBuffer(id, type); 1597 this->bindBuffer(id, type);
1598 // Let driver know it can discard the old data 1598 // Let driver know it can discard the old data
1599 if (currentSize != requestedSize) { 1599 if (GR_GL_USE_BUFFER_DATA_NULL_HINT || currentSize != requestedSize) {
1600 GL_CALL(BufferData(type, requestedSize, nullptr, 1600 GL_CALL(BufferData(type, requestedSize, nullptr,
1601 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_ DRAW)); 1601 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_ DRAW));
1602 } 1602 }
1603 GL_CALL_RET(mapPtr, MapBuffer(type, GR_GL_WRITE_ONLY)); 1603 GL_CALL_RET(mapPtr, MapBuffer(type, GR_GL_WRITE_ONLY));
1604 break; 1604 break;
1605 case GrGLCaps::kMapBufferRange_MapBufferType: { 1605 case GrGLCaps::kMapBufferRange_MapBufferType: {
1606 this->bindBuffer(id, type); 1606 this->bindBuffer(id, type);
1607 // Make sure the GL buffer size agrees with fDesc before mapping. 1607 // Make sure the GL buffer size agrees with fDesc before mapping.
1608 if (currentSize != requestedSize) { 1608 if (currentSize != requestedSize) {
1609 GL_CALL(BufferData(type, requestedSize, nullptr, 1609 GL_CALL(BufferData(type, requestedSize, nullptr,
(...skipping 17 matching lines...) Expand all
1627 return mapPtr; 1627 return mapPtr;
1628 } 1628 }
1629 1629
1630 void GrGLGpu::bufferData(GrGLuint id, GrGLenum type, bool dynamic, size_t curren tSize, 1630 void GrGLGpu::bufferData(GrGLuint id, GrGLenum type, bool dynamic, size_t curren tSize,
1631 const void* src, size_t srcSizeInBytes) { 1631 const void* src, size_t srcSizeInBytes) {
1632 SkASSERT(srcSizeInBytes <= currentSize); 1632 SkASSERT(srcSizeInBytes <= currentSize);
1633 // bindbuffer handles dirty context 1633 // bindbuffer handles dirty context
1634 this->bindBuffer(id, type); 1634 this->bindBuffer(id, type);
1635 GrGLenum usage = dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW; 1635 GrGLenum usage = dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW;
1636 1636
1637 #if GR_GL_USE_BUFFER_DATA_NULL_HINT
1638 if (currentSize == srcSizeInBytes) {
1639 GL_CALL(BufferData(type, (GrGLsizeiptr) srcSizeInBytes, src, usage));
1640 } else {
1641 // Before we call glBufferSubData we give the driver a hint using
1642 // glBufferData with nullptr. This makes the old buffer contents
1643 // inaccessible to future draws. The GPU may still be processing
1644 // draws that reference the old contents. With this hint it can
1645 // assign a different allocation for the new contents to avoid
1646 // flushing the gpu past draws consuming the old contents.
1647 // TODO I think we actually want to try calling bufferData here
1648 GL_CALL(BufferData(type, currentSize, nullptr, usage));
1649 GL_CALL(BufferSubData(type, 0, (GrGLsizeiptr) srcSizeInBytes, src));
1650 }
1651 #else
1637 // Note that we're cheating on the size here. Currently no methods 1652 // Note that we're cheating on the size here. Currently no methods
1638 // allow a partial update that preserves contents of non-updated 1653 // allow a partial update that preserves contents of non-updated
1639 // portions of the buffer (map() does a glBufferData(..size, nullptr..)) 1654 // portions of the buffer (map() does a glBufferData(..size, nullptr..))
1640 GL_CALL(BufferData(type, srcSizeInBytes, src, usage)); 1655 GL_CALL(BufferData(type, srcSizeInBytes, src, usage));
1656 #endif
1641 } 1657 }
1642 1658
1643 void GrGLGpu::unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr) { 1659 void GrGLGpu::unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr) {
1644 // bind buffer handles the dirty context 1660 // bind buffer handles the dirty context
1645 switch (this->glCaps().mapBufferType()) { 1661 switch (this->glCaps().mapBufferType()) {
1646 case GrGLCaps::kNone_MapBufferType: 1662 case GrGLCaps::kNone_MapBufferType:
1647 SkDEBUGFAIL("Shouldn't get here."); 1663 SkDEBUGFAIL("Shouldn't get here.");
1648 return; 1664 return;
1649 case GrGLCaps::kMapBuffer_MapBufferType: // fall through 1665 case GrGLCaps::kMapBuffer_MapBufferType: // fall through
1650 case GrGLCaps::kMapBufferRange_MapBufferType: 1666 case GrGLCaps::kMapBufferRange_MapBufferType:
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 this->setVertexArrayID(gpu, 0); 3295 this->setVertexArrayID(gpu, 0);
3280 } 3296 }
3281 int attrCount = gpu->glCaps().maxVertexAttributes(); 3297 int attrCount = gpu->glCaps().maxVertexAttributes();
3282 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3298 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3283 fDefaultVertexArrayAttribState.resize(attrCount); 3299 fDefaultVertexArrayAttribState.resize(attrCount);
3284 } 3300 }
3285 attribState = &fDefaultVertexArrayAttribState; 3301 attribState = &fDefaultVertexArrayAttribState;
3286 } 3302 }
3287 return attribState; 3303 return attribState;
3288 } 3304 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLBufferImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698