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

Side by Side Diff: src/gpu/GrBufferAllocPool.cpp

Issue 1159713006: add context override of GeometryBufferMapThreshold (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 6 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/GrBufferAllocPool.h ('k') | src/gpu/GrCaps.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 fBytesInUse = 0; 50 fBytesInUse = 0;
51 51
52 fPreallocBuffersInUse = 0; 52 fPreallocBuffersInUse = 0;
53 fPreallocBufferStartIdx = 0; 53 fPreallocBufferStartIdx = 0;
54 for (int i = 0; i < preallocBufferCnt; ++i) { 54 for (int i = 0; i < preallocBufferCnt; ++i) {
55 GrGeometryBuffer* buffer = this->createBuffer(fMinBlockSize); 55 GrGeometryBuffer* buffer = this->createBuffer(fMinBlockSize);
56 if (buffer) { 56 if (buffer) {
57 *fPreallocBuffers.append() = buffer; 57 *fPreallocBuffers.append() = buffer;
58 } 58 }
59 } 59 }
60 fGeometryBufferMapThreshold = gpu->caps()->geometryBufferMapThreshold();
60 } 61 }
61 62
62 GrBufferAllocPool::~GrBufferAllocPool() { 63 GrBufferAllocPool::~GrBufferAllocPool() {
63 VALIDATE(); 64 VALIDATE();
64 if (fBlocks.count()) { 65 if (fBlocks.count()) {
65 GrGeometryBuffer* buffer = fBlocks.back().fBuffer; 66 GrGeometryBuffer* buffer = fBlocks.back().fBuffer;
66 if (buffer->isMapped()) { 67 if (buffer->isMapped()) {
67 UNMAP_BUFFER(fBlocks.back()); 68 UNMAP_BUFFER(fBlocks.back());
68 } 69 }
69 } 70 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 fBufferPtr = NULL; 282 fBufferPtr = NULL;
282 } 283 }
283 284
284 SkASSERT(NULL == fBufferPtr); 285 SkASSERT(NULL == fBufferPtr);
285 286
286 // If the buffer is CPU-backed we map it because it is free to do so and sav es a copy. 287 // If the buffer is CPU-backed we map it because it is free to do so and sav es a copy.
287 // Otherwise when buffer mapping is supported we map if the buffer size is g reater than the 288 // Otherwise when buffer mapping is supported we map if the buffer size is g reater than the
288 // threshold. 289 // threshold.
289 bool attemptMap = block.fBuffer->isCPUBacked(); 290 bool attemptMap = block.fBuffer->isCPUBacked();
290 if (!attemptMap && GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags()) { 291 if (!attemptMap && GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags()) {
291 attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD; 292 attemptMap = size > fGeometryBufferMapThreshold;
292 } 293 }
293 294
294 if (attemptMap) { 295 if (attemptMap) {
295 fBufferPtr = block.fBuffer->map(); 296 fBufferPtr = block.fBuffer->map();
296 } 297 }
297 298
298 if (NULL == fBufferPtr) { 299 if (NULL == fBufferPtr) {
299 fBufferPtr = fCpuData.reset(size); 300 fBufferPtr = fCpuData.reset(size);
300 } 301 }
301 302
(...skipping 23 matching lines...) Expand all
325 326
326 void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize) { 327 void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize) {
327 GrGeometryBuffer* buffer = block.fBuffer; 328 GrGeometryBuffer* buffer = block.fBuffer;
328 SkASSERT(buffer); 329 SkASSERT(buffer);
329 SkASSERT(!buffer->isMapped()); 330 SkASSERT(!buffer->isMapped());
330 SkASSERT(fCpuData.get() == fBufferPtr); 331 SkASSERT(fCpuData.get() == fBufferPtr);
331 SkASSERT(flushSize <= buffer->gpuMemorySize()); 332 SkASSERT(flushSize <= buffer->gpuMemorySize());
332 VALIDATE(true); 333 VALIDATE(true);
333 334
334 if (GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags() && 335 if (GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags() &&
335 flushSize > GR_GEOM_BUFFER_MAP_THRESHOLD) { 336 flushSize > fGeometryBufferMapThreshold) {
336 void* data = buffer->map(); 337 void* data = buffer->map();
337 if (data) { 338 if (data) {
338 memcpy(data, fBufferPtr, flushSize); 339 memcpy(data, fBufferPtr, flushSize);
339 UNMAP_BUFFER(block); 340 UNMAP_BUFFER(block);
340 return; 341 return;
341 } 342 }
342 } 343 }
343 buffer->updateData(fBufferPtr, flushSize); 344 buffer->updateData(fBufferPtr, flushSize);
344 VALIDATE(true); 345 VALIDATE(true);
345 } 346 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 &geomBuffer, 413 &geomBuffer,
413 &offset); 414 &offset);
414 415
415 *buffer = (const GrIndexBuffer*) geomBuffer; 416 *buffer = (const GrIndexBuffer*) geomBuffer;
416 SkASSERT(0 == offset % sizeof(uint16_t)); 417 SkASSERT(0 == offset % sizeof(uint16_t));
417 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); 418 *startIndex = static_cast<int>(offset / sizeof(uint16_t));
418 return ptr; 419 return ptr;
419 } 420 }
420 421
421 422
OLDNEW
« no previous file with comments | « src/gpu/GrBufferAllocPool.h ('k') | src/gpu/GrCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698