cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrGLBuffer.h" |
| 9 | #include "GrGLGpu.h" |
Robert Phillips | a5b39fa | 2017-06-08 15:34:16 -0400 | [diff] [blame] | 10 | #include "GrGpuResourcePriv.h" |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 11 | #include "SkTraceMemoryDump.h" |
| 12 | |
| 13 | #define GL_CALL(X) GR_GL_CALL(this->glGpu()->glInterface(), X) |
| 14 | #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glGpu()->glInterface(), RET, X) |
| 15 | |
| 16 | #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
| 17 | #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) |
| 18 | #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) |
| 19 | #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) |
| 20 | #else |
| 21 | #define CLEAR_ERROR_BEFORE_ALLOC(iface) |
| 22 | #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) |
| 23 | #define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR |
| 24 | #endif |
| 25 | |
| 26 | #ifdef SK_DEBUG |
| 27 | #define VALIDATE() this->validate() |
| 28 | #else |
| 29 | #define VALIDATE() do {} while(false) |
| 30 | #endif |
| 31 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 32 | sk_sp<GrGLBuffer> GrGLBuffer::Make(GrGLGpu* gpu, size_t size, GrGpuBufferType intendedType, |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 33 | GrAccessPattern accessPattern, const void* data) { |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 34 | if (gpu->glCaps().transferBufferType() == GrGLCaps::kNone_TransferBufferType && |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 35 | (GrGpuBufferType::kXferCpuToGpu == intendedType || |
| 36 | GrGpuBufferType::kXferGpuToCpu == intendedType)) { |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 37 | return nullptr; |
| 38 | } |
| 39 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 40 | sk_sp<GrGLBuffer> buffer(new GrGLBuffer(gpu, size, intendedType, accessPattern, data)); |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 41 | if (0 == buffer->bufferID()) { |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 42 | return nullptr; |
| 43 | } |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 44 | return buffer; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | // GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a client's vertex buffer |
| 48 | // objects are implemented as client-side-arrays on tile-deferred architectures. |
| 49 | #define DYNAMIC_DRAW_PARAM GR_GL_STREAM_DRAW |
| 50 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 51 | inline static GrGLenum gr_to_gl_access_pattern(GrGpuBufferType bufferType, |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 52 | GrAccessPattern accessPattern) { |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 53 | auto drawUsage = [](GrAccessPattern pattern) { |
| 54 | switch (pattern) { |
| 55 | case kDynamic_GrAccessPattern: |
| 56 | // TODO: Do we really want to use STREAM_DRAW here on non-Chromium? |
| 57 | return DYNAMIC_DRAW_PARAM; |
| 58 | case kStatic_GrAccessPattern: |
| 59 | return GR_GL_STATIC_DRAW; |
| 60 | case kStream_GrAccessPattern: |
| 61 | return GR_GL_STREAM_DRAW; |
| 62 | } |
| 63 | SK_ABORT("Unexpected access pattern"); |
| 64 | return GR_GL_STATIC_DRAW; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 65 | }; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 66 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 67 | auto readUsage = [](GrAccessPattern pattern) { |
| 68 | switch (pattern) { |
| 69 | case kDynamic_GrAccessPattern: |
| 70 | return GR_GL_DYNAMIC_READ; |
| 71 | case kStatic_GrAccessPattern: |
| 72 | return GR_GL_STATIC_READ; |
| 73 | case kStream_GrAccessPattern: |
| 74 | return GR_GL_STREAM_READ; |
| 75 | } |
| 76 | SK_ABORT("Unexpected access pattern"); |
| 77 | return GR_GL_STATIC_READ; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 78 | }; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 79 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 80 | auto usageType = [&drawUsage, &readUsage](GrGpuBufferType type, GrAccessPattern pattern) { |
| 81 | switch (type) { |
| 82 | case GrGpuBufferType::kVertex: |
| 83 | case GrGpuBufferType::kIndex: |
| 84 | case GrGpuBufferType::kXferCpuToGpu: |
| 85 | return drawUsage(pattern); |
| 86 | case GrGpuBufferType::kXferGpuToCpu: |
| 87 | return readUsage(pattern); |
| 88 | } |
| 89 | SK_ABORT("Unexpected gpu buffer type."); |
| 90 | return GR_GL_STATIC_DRAW; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 93 | return usageType(bufferType, accessPattern); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 96 | GrGLBuffer::GrGLBuffer(GrGLGpu* gpu, size_t size, GrGpuBufferType intendedType, |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 97 | GrAccessPattern accessPattern, const void* data) |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 98 | : INHERITED(gpu, size, intendedType, accessPattern) |
| 99 | , fIntendedType(intendedType) |
| 100 | , fBufferID(0) |
| 101 | , fUsage(gr_to_gl_access_pattern(intendedType, accessPattern)) |
| 102 | , fGLSizeInBytes(0) |
| 103 | , fHasAttachedToTexture(false) { |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 104 | GL_CALL(GenBuffers(1, &fBufferID)); |
| 105 | if (fBufferID) { |
| 106 | GrGLenum target = gpu->bindBuffer(fIntendedType, this); |
| 107 | CLEAR_ERROR_BEFORE_ALLOC(gpu->glInterface()); |
| 108 | // make sure driver can allocate memory for this buffer |
| 109 | GL_ALLOC_CALL(gpu->glInterface(), BufferData(target, |
| 110 | (GrGLsizeiptr) size, |
| 111 | data, |
| 112 | fUsage)); |
| 113 | if (CHECK_ALLOC_ERROR(gpu->glInterface()) != GR_GL_NO_ERROR) { |
| 114 | GL_CALL(DeleteBuffers(1, &fBufferID)); |
| 115 | fBufferID = 0; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 116 | } else { |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 117 | fGLSizeInBytes = size; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | VALIDATE(); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 121 | this->registerWithCache(SkBudgeted::kYes); |
Robert Phillips | a5b39fa | 2017-06-08 15:34:16 -0400 | [diff] [blame] | 122 | if (!fBufferID) { |
| 123 | this->resourcePriv().removeScratchKey(); |
| 124 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | inline GrGLGpu* GrGLBuffer::glGpu() const { |
| 128 | SkASSERT(!this->wasDestroyed()); |
| 129 | return static_cast<GrGLGpu*>(this->getGpu()); |
| 130 | } |
| 131 | |
| 132 | inline const GrGLCaps& GrGLBuffer::glCaps() const { |
| 133 | return this->glGpu()->glCaps(); |
| 134 | } |
| 135 | |
| 136 | void GrGLBuffer::onRelease() { |
| 137 | if (!this->wasDestroyed()) { |
| 138 | VALIDATE(); |
| 139 | // make sure we've not been abandoned or already released |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 140 | if (fBufferID) { |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 141 | GL_CALL(DeleteBuffers(1, &fBufferID)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 142 | fBufferID = 0; |
| 143 | fGLSizeInBytes = 0; |
| 144 | } |
| 145 | fMapPtr = nullptr; |
| 146 | VALIDATE(); |
| 147 | } |
| 148 | |
| 149 | INHERITED::onRelease(); |
| 150 | } |
| 151 | |
| 152 | void GrGLBuffer::onAbandon() { |
| 153 | fBufferID = 0; |
| 154 | fGLSizeInBytes = 0; |
| 155 | fMapPtr = nullptr; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 156 | VALIDATE(); |
| 157 | INHERITED::onAbandon(); |
| 158 | } |
| 159 | |
| 160 | void GrGLBuffer::onMap() { |
Robert Phillips | a5b39fa | 2017-06-08 15:34:16 -0400 | [diff] [blame] | 161 | SkASSERT(fBufferID); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 162 | if (this->wasDestroyed()) { |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | VALIDATE(); |
| 167 | SkASSERT(!this->isMapped()); |
| 168 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 169 | // TODO: Make this a function parameter. |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 170 | bool readOnly = (GrGpuBufferType::kXferGpuToCpu == fIntendedType); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 171 | |
| 172 | // Handling dirty context is done in the bindBuffer call |
| 173 | switch (this->glCaps().mapBufferType()) { |
| 174 | case GrGLCaps::kNone_MapBufferType: |
| 175 | break; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 176 | case GrGLCaps::kMapBuffer_MapBufferType: { |
| 177 | GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 178 | // Let driver know it can discard the old data |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 179 | if (this->glCaps().useBufferDataNullHint() || fGLSizeInBytes != this->size()) { |
| 180 | GL_CALL(BufferData(target, this->size(), nullptr, fUsage)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 181 | } |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 182 | GL_CALL_RET(fMapPtr, MapBuffer(target, readOnly ? GR_GL_READ_ONLY : GR_GL_WRITE_ONLY)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 183 | break; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 184 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 185 | case GrGLCaps::kMapBufferRange_MapBufferType: { |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 186 | GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 187 | // Make sure the GL buffer size agrees with fDesc before mapping. |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 188 | if (fGLSizeInBytes != this->size()) { |
| 189 | GL_CALL(BufferData(target, this->size(), nullptr, fUsage)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 190 | } |
| 191 | GrGLbitfield writeAccess = GR_GL_MAP_WRITE_BIT; |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 192 | if (GrGpuBufferType::kXferCpuToGpu != fIntendedType) { |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 193 | // TODO: Make this a function parameter. |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 194 | writeAccess |= GR_GL_MAP_INVALIDATE_BUFFER_BIT; |
| 195 | } |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 196 | GL_CALL_RET(fMapPtr, MapBufferRange(target, 0, this->size(), |
| 197 | readOnly ? GR_GL_MAP_READ_BIT : writeAccess)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 198 | break; |
| 199 | } |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 200 | case GrGLCaps::kChromium_MapBufferType: { |
| 201 | GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 202 | // Make sure the GL buffer size agrees with fDesc before mapping. |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 203 | if (fGLSizeInBytes != this->size()) { |
| 204 | GL_CALL(BufferData(target, this->size(), nullptr, fUsage)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 205 | } |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 206 | GL_CALL_RET(fMapPtr, MapBufferSubData(target, 0, this->size(), |
| 207 | readOnly ? GR_GL_READ_ONLY : GR_GL_WRITE_ONLY)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 208 | break; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 209 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 210 | } |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 211 | fGLSizeInBytes = this->size(); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 212 | VALIDATE(); |
| 213 | } |
| 214 | |
| 215 | void GrGLBuffer::onUnmap() { |
Robert Phillips | a5b39fa | 2017-06-08 15:34:16 -0400 | [diff] [blame] | 216 | SkASSERT(fBufferID); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 217 | if (this->wasDestroyed()) { |
| 218 | return; |
| 219 | } |
| 220 | |
| 221 | VALIDATE(); |
| 222 | SkASSERT(this->isMapped()); |
| 223 | if (0 == fBufferID) { |
| 224 | fMapPtr = nullptr; |
| 225 | return; |
| 226 | } |
| 227 | // bind buffer handles the dirty context |
| 228 | switch (this->glCaps().mapBufferType()) { |
| 229 | case GrGLCaps::kNone_MapBufferType: |
| 230 | SkDEBUGFAIL("Shouldn't get here."); |
| 231 | return; |
| 232 | case GrGLCaps::kMapBuffer_MapBufferType: // fall through |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 233 | case GrGLCaps::kMapBufferRange_MapBufferType: { |
| 234 | GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); |
| 235 | GL_CALL(UnmapBuffer(target)); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 236 | break; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 237 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 238 | case GrGLCaps::kChromium_MapBufferType: |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 239 | this->glGpu()->bindBuffer(fIntendedType, this); // TODO: Is this needed? |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 240 | GL_CALL(UnmapBufferSubData(fMapPtr)); |
| 241 | break; |
| 242 | } |
| 243 | fMapPtr = nullptr; |
| 244 | } |
| 245 | |
| 246 | bool GrGLBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) { |
Robert Phillips | a5b39fa | 2017-06-08 15:34:16 -0400 | [diff] [blame] | 247 | SkASSERT(fBufferID); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 248 | if (this->wasDestroyed()) { |
| 249 | return false; |
| 250 | } |
| 251 | |
| 252 | SkASSERT(!this->isMapped()); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 253 | VALIDATE(); |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 254 | if (srcSizeInBytes > this->size()) { |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 255 | return false; |
| 256 | } |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 257 | SkASSERT(srcSizeInBytes <= this->size()); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 258 | // bindbuffer handles dirty context |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 259 | GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 260 | |
Robert Phillips | f2ec024 | 2018-03-01 16:51:25 -0500 | [diff] [blame] | 261 | if (this->glCaps().useBufferDataNullHint()) { |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 262 | if (this->size() == srcSizeInBytes) { |
Robert Phillips | f2ec024 | 2018-03-01 16:51:25 -0500 | [diff] [blame] | 263 | GL_CALL(BufferData(target, (GrGLsizeiptr) srcSizeInBytes, src, fUsage)); |
| 264 | } else { |
| 265 | // Before we call glBufferSubData we give the driver a hint using |
| 266 | // glBufferData with nullptr. This makes the old buffer contents |
| 267 | // inaccessible to future draws. The GPU may still be processing |
| 268 | // draws that reference the old contents. With this hint it can |
| 269 | // assign a different allocation for the new contents to avoid |
| 270 | // flushing the gpu past draws consuming the old contents. |
| 271 | // TODO I think we actually want to try calling bufferData here |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 272 | GL_CALL(BufferData(target, this->size(), nullptr, fUsage)); |
Robert Phillips | f2ec024 | 2018-03-01 16:51:25 -0500 | [diff] [blame] | 273 | GL_CALL(BufferSubData(target, 0, (GrGLsizeiptr) srcSizeInBytes, src)); |
| 274 | } |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 275 | fGLSizeInBytes = this->size(); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 276 | } else { |
Robert Phillips | f2ec024 | 2018-03-01 16:51:25 -0500 | [diff] [blame] | 277 | // Note that we're cheating on the size here. Currently no methods |
| 278 | // allow a partial update that preserves contents of non-updated |
| 279 | // portions of the buffer (map() does a glBufferData(..size, nullptr..)) |
| 280 | GL_CALL(BufferData(target, srcSizeInBytes, src, fUsage)); |
| 281 | fGLSizeInBytes = srcSizeInBytes; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 282 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 283 | VALIDATE(); |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | void GrGLBuffer::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 288 | const SkString& dumpName) const { |
| 289 | SkString buffer_id; |
| 290 | buffer_id.appendU32(this->bufferID()); |
| 291 | traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_buffer", |
| 292 | buffer_id.c_str()); |
| 293 | } |
| 294 | |
| 295 | #ifdef SK_DEBUG |
| 296 | |
| 297 | void GrGLBuffer::validate() const { |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 298 | SkASSERT(0 != fBufferID || 0 == fGLSizeInBytes); |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 299 | SkASSERT(nullptr == fMapPtr || fGLSizeInBytes <= this->size()); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | #endif |