diff options
author | bsalomon <bsalomon@google.com> | 2014-06-26 12:56:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-26 12:56:22 -0700 |
commit | 3512eda332f3a48ab750a047027e2e254ab53a15 (patch) | |
tree | c3fbc9cd98652fa5630850baa8412386e8a7d523 | |
parent | 8ba8d923da92b9e417ebd8802694fb2630e6c12b (diff) |
Add trace event when GrBufferAllocPool unmaps a buffer indicating what % of the buffer was unwritten.
R=egdaniel@google.com
TBR=egdaniel@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/339433009
-rw-r--r-- | src/gpu/GrBufferAllocPool.cpp | 33 | ||||
-rw-r--r-- | src/gpu/GrBufferAllocPool.h | 2 |
2 files changed, 23 insertions, 12 deletions
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index 03d43c9b93..a197a6719f 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -14,6 +14,8 @@ #include "GrTypes.h" #include "GrVertexBuffer.h" +#include "SkTraceEvent.h" + #ifdef SK_DEBUG #define VALIDATE validate #else @@ -23,6 +25,16 @@ // page size #define GrBufferAllocPool_MIN_BLOCK_SIZE ((size_t)1 << 12) +#define UNMAP_BUFFER(block) \ +do { \ + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), \ + "GrBufferAllocPool Unmapping Buffer", \ + TRACE_EVENT_SCOPE_THREAD, \ + "percent_unwritten", \ + (float)((block).fBytesFree) / (block).fBuffer->gpuMemorySize()); \ + (block).fBuffer->unmap(); \ +} while (false) + GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, BufferType bufferType, bool frequentResetHint, @@ -57,7 +69,7 @@ GrBufferAllocPool::~GrBufferAllocPool() { if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isMapped()) { - buffer->unmap(); + UNMAP_BUFFER(fBlocks.back()); } } while (!fBlocks.empty()) { @@ -80,7 +92,7 @@ void GrBufferAllocPool::reset() { if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isMapped()) { - buffer->unmap(); + UNMAP_BUFFER(fBlocks.back()); } } // fPreallocBuffersInUse will be decremented down to zero in the while loop @@ -107,10 +119,10 @@ void GrBufferAllocPool::unmap() { if (NULL != fBufferPtr) { BufferBlock& block = fBlocks.back(); if (block.fBuffer->isMapped()) { - block.fBuffer->unmap(); + UNMAP_BUFFER(block); } else { size_t flushSize = block.fBuffer->gpuMemorySize() - block.fBytesFree; - this->flushCpuData(fBlocks.back().fBuffer, flushSize); + this->flushCpuData(fBlocks.back(), flushSize); } fBufferPtr = NULL; } @@ -238,7 +250,7 @@ void GrBufferAllocPool::putBack(size_t bytes) { // if we locked a vb to satisfy the make space and we're releasing // beyond it, then unmap it. if (block.fBuffer->isMapped()) { - block.fBuffer->unmap(); + UNMAP_BUFFER(block); } this->destroyBlock(); } else { @@ -287,10 +299,9 @@ bool GrBufferAllocPool::createBlock(size_t requestSize) { SkASSERT(fBlocks.count() > 1); BufferBlock& prev = fBlocks.fromBack(1); if (prev.fBuffer->isMapped()) { - prev.fBuffer->unmap(); + UNMAP_BUFFER(prev); } else { - flushCpuData(prev.fBuffer, - prev.fBuffer->gpuMemorySize() - prev.fBytesFree); + this->flushCpuData(prev, prev.fBuffer->gpuMemorySize() - prev.fBytesFree); } fBufferPtr = NULL; } @@ -343,8 +354,8 @@ void GrBufferAllocPool::destroyBlock() { fBufferPtr = NULL; } -void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, - size_t flushSize) { +void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize) { + GrGeometryBuffer* buffer = block.fBuffer; SkASSERT(NULL != buffer); SkASSERT(!buffer->isMapped()); SkASSERT(fCpuData.get() == fBufferPtr); @@ -356,7 +367,7 @@ void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, void* data = buffer->map(); if (NULL != data) { memcpy(data, fBufferPtr, flushSize); - buffer->unmap(); + UNMAP_BUFFER(block); return; } } diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h index 291d781ac6..e3d398204b 100644 --- a/src/gpu/GrBufferAllocPool.h +++ b/src/gpu/GrBufferAllocPool.h @@ -155,7 +155,7 @@ private: bool createBlock(size_t requestSize); void destroyBlock(); - void flushCpuData(GrGeometryBuffer* buffer, size_t flushSize); + void flushCpuData(const BufferBlock& block, size_t flushSize); #ifdef SK_DEBUG void validate(bool unusedBlockAllowed = false) const; #endif |