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

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1496843003: Revert of Add transfer buffer support. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLIndexBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 58f69be87c5820460498ffcbc2f5673417036ec3..5eac42028eaa86441b54a85571c825846f7cf851 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1399,16 +1399,12 @@
////////////////////////////////////////////////////////////////////////////////
-// GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a client's vertex buffer
-// objects are implemented as client-side-arrays on tile-deferred architectures.
-#define DYNAMIC_USAGE_PARAM GR_GL_STREAM_DRAW
-
GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
GrGLVertexBuffer::Desc desc;
- desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl::kStaticDraw_Usage;
+ desc.fDynamic = dynamic;
desc.fSizeInBytes = size;
- if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) {
+ if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) {
desc.fID = 0;
GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
return vertexBuffer;
@@ -1422,7 +1418,7 @@
BufferData(GR_GL_ARRAY_BUFFER,
(GrGLsizeiptr) desc.fSizeInBytes,
nullptr, // data ptr
- dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
+ desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
GL_CALL(DeleteBuffers(1, &desc.fID));
this->notifyVertexBufferDelete(desc.fID);
@@ -1437,10 +1433,10 @@
GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) {
GrGLIndexBuffer::Desc desc;
- desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl::kStaticDraw_Usage;
+ desc.fDynamic = dynamic;
desc.fSizeInBytes = size;
- if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) {
+ if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) {
desc.fID = 0;
GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
return indexBuffer;
@@ -1454,7 +1450,7 @@
BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
(GrGLsizeiptr) desc.fSizeInBytes,
nullptr, // data ptr
- dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
+ desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
GL_CALL(DeleteBuffers(1, &desc.fID));
this->notifyIndexBufferDelete(desc.fID);
@@ -1465,35 +1461,6 @@
}
return nullptr;
}
-}
-
-GrTransferBuffer* GrGLGpu::onCreateTransferBuffer(size_t size, TransferType type) {
- GrGLTransferBuffer::Desc desc;
- bool toGpu = (kCpuToGpu_TransferType == type);
- desc.fUsage = toGpu ? GrGLBufferImpl::kStreamDraw_Usage : GrGLBufferImpl::kStreamRead_Usage;
-
- desc.fSizeInBytes = size;
-
- // TODO: check caps to see if we can create a PBO, and which kind
- GL_CALL(GenBuffers(1, &desc.fID));
- if (desc.fID) {
- CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
- // make sure driver can allocate memory for this buffer
- GrGLenum type = toGpu ? GR_GL_PIXEL_UNPACK_BUFFER : GR_GL_PIXEL_PACK_BUFFER;
- GL_ALLOC_CALL(this->glInterface(),
- BufferData(type,
- (GrGLsizeiptr) desc.fSizeInBytes,
- nullptr, // data ptr
- (toGpu ? GR_GL_STREAM_DRAW : GR_GL_STREAM_READ)));
- if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
- GL_CALL(DeleteBuffers(1, &desc.fID));
- return nullptr;
- }
- GrTransferBuffer* transferBuffer = new GrGLTransferBuffer(this, desc, type);
- return transferBuffer;
- }
-
- return nullptr;
}
void GrGLGpu::flushScissor(const GrScissorState& scissorState,
@@ -1636,7 +1603,8 @@
this->handleDirtyContext();
if (GR_GL_ARRAY_BUFFER == type) {
this->bindVertexBuffer(id);
- } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) {
+ } else {
+ SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == type);
this->bindIndexBufferAndDefaultVertexArray(id);
}
}
@@ -1646,27 +1614,19 @@
GL_CALL(DeleteBuffers(1, &id));
if (GR_GL_ARRAY_BUFFER == type) {
this->notifyVertexBufferDelete(id);
- } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) {
+ } else {
+ SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == type);
this->notifyIndexBufferDelete(id);
}
}
-static GrGLenum get_gl_usage(GrGLBufferImpl::Usage usage) {
- static const GrGLenum grToGL[] = {
- GR_GL_STATIC_DRAW, // GrGLBufferImpl::kStaticDraw_Usage
- DYNAMIC_USAGE_PARAM, // GrGLBufferImpl::kDynamicDraw_Usage
- GR_GL_STREAM_DRAW, // GrGLBufferImpl::kStreamDraw_Usage
- GR_GL_STREAM_READ, // GrGLBufferImpl::kStreamRead_Usage
- };
- static_assert(SK_ARRAY_COUNT(grToGL) == GrGLBufferImpl::kUsageCount, "array_size_mismatch");
-
- return grToGL[usage];
-}
-
-void* GrGLGpu::mapBuffer(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage,
- size_t currentSize, size_t requestedSize) {
+// GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a client's vertex buffer
+// objects are implemented as client-side-arrays on tile-deferred architectures.
+#define DYNAMIC_USAGE_PARAM GR_GL_STREAM_DRAW
+
+void* GrGLGpu::mapBuffer(GrGLuint id, GrGLenum type, bool dynamic, size_t currentSize,
+ size_t requestedSize) {
void* mapPtr = nullptr;
- GrGLenum glUsage = get_gl_usage(usage);
// Handling dirty context is done in the bindBuffer call
switch (this->glCaps().mapBufferType()) {
case GrGLCaps::kNone_MapBufferType:
@@ -1675,7 +1635,8 @@
this->bindBuffer(id, type);
// Let driver know it can discard the old data
if (GR_GL_USE_BUFFER_DATA_NULL_HINT || currentSize != requestedSize) {
- GL_CALL(BufferData(type, requestedSize, nullptr, glUsage));
+ GL_CALL(BufferData(type, requestedSize, nullptr,
+ dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
}
GL_CALL_RET(mapPtr, MapBuffer(type, GR_GL_WRITE_ONLY));
break;
@@ -1683,7 +1644,8 @@
this->bindBuffer(id, type);
// Make sure the GL buffer size agrees with fDesc before mapping.
if (currentSize != requestedSize) {
- GL_CALL(BufferData(type, requestedSize, nullptr, glUsage));
+ GL_CALL(BufferData(type, requestedSize, nullptr,
+ dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
}
static const GrGLbitfield kAccess = GR_GL_MAP_INVALIDATE_BUFFER_BIT |
GR_GL_MAP_WRITE_BIT;
@@ -1694,7 +1656,8 @@
this->bindBuffer(id, type);
// Make sure the GL buffer size agrees with fDesc before mapping.
if (currentSize != requestedSize) {
- GL_CALL(BufferData(type, requestedSize, nullptr, glUsage));
+ GL_CALL(BufferData(type, requestedSize, nullptr,
+ dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
}
GL_CALL_RET(mapPtr, MapBufferSubData(type, 0, requestedSize, GR_GL_WRITE_ONLY));
break;
@@ -1702,16 +1665,16 @@
return mapPtr;
}
-void GrGLGpu::bufferData(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage,
- size_t currentSize, const void* src, size_t srcSizeInBytes) {
+void GrGLGpu::bufferData(GrGLuint id, GrGLenum type, bool dynamic, size_t currentSize,
+ const void* src, size_t srcSizeInBytes) {
SkASSERT(srcSizeInBytes <= currentSize);
// bindbuffer handles dirty context
this->bindBuffer(id, type);
- GrGLenum glUsage = get_gl_usage(usage);
+ 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, glUsage));
+ 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
@@ -1720,7 +1683,7 @@
// 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, glUsage));
+ GL_CALL(BufferData(type, currentSize, nullptr, usage));
GL_CALL(BufferSubData(type, 0, (GrGLsizeiptr) srcSizeInBytes, src));
}
#else
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLIndexBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698