aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBuffer.h
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-04-07 18:13:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-07 18:13:29 -0700
commite2e71c2df4e72e897bbe745752be0444aee5c29f (patch)
tree60591705d9f4f99246c156b8a4f98d28ce376af6 /src/gpu/GrBuffer.h
parent8dea4e41a11fd526fa533396173f72af0f9042d7 (diff)
Track GL buffer state based on unique resource ID
Reworks GrGLGpu to track GL buffer state based on the unique GrGpuResource ID. This eliminates the need to notify the gpu object whenever a buffer is deleted. This change also allows us to remove the type specifier from GrBuffer. At this point a buffer is just a chunk of memory, and the type given at creation time is just a suggestion to the GL backend about which target to bind to for updates. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1854283004 Committed: https://skia.googlesource.com/skia/+/deacc97bc63513b5eacaf21f858727f6e8b98ce5 Review URL: https://codereview.chromium.org/1854283004
Diffstat (limited to 'src/gpu/GrBuffer.h')
-rw-r--r--src/gpu/GrBuffer.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/gpu/GrBuffer.h b/src/gpu/GrBuffer.h
index 4fadba6aa7..7e04577543 100644
--- a/src/gpu/GrBuffer.h
+++ b/src/gpu/GrBuffer.h
@@ -18,22 +18,20 @@ public:
* Computes a scratch key for a buffer with a "dynamic" access pattern. (Buffers with "static"
* and "stream" access patterns are disqualified by nature from being cached and reused.)
*/
- static void ComputeScratchKeyForDynamicBuffer(GrBufferType type, size_t size,
+ static void ComputeScratchKeyForDynamicBuffer(size_t size, GrBufferType intendedType,
GrScratchKey* key) {
static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
GrScratchKey::Builder builder(key, kType, 1 + (sizeof(size_t) + 3) / 4);
// TODO: There's not always reason to cache a buffer by type. In some (all?) APIs it's just
// a chunk of memory we can use/reuse for any type of data. We really only need to
// differentiate between the "read" types (e.g. kGpuToCpu_BufferType) and "draw" types.
- builder[0] = type;
+ builder[0] = intendedType;
builder[1] = (uint32_t)size;
if (sizeof(size_t) > 4) {
builder[2] = (uint32_t)((uint64_t)size >> 32);
}
}
- GrBufferType type() const { return fType; }
-
GrAccessPattern accessPattern() const { return fAccessPattern; }
/**
@@ -110,17 +108,16 @@ public:
}
protected:
- GrBuffer(GrGpu* gpu, GrBufferType type, size_t gpuMemorySize, GrAccessPattern accessPattern,
- bool cpuBacked)
+ GrBuffer(GrGpu* gpu, size_t gpuMemorySize, GrBufferType intendedType,
+ GrAccessPattern accessPattern, bool cpuBacked)
: INHERITED(gpu, kCached_LifeCycle),
fMapPtr(nullptr),
- fType(type),
fGpuMemorySize(gpuMemorySize), // TODO: Zero for cpu backed buffers?
fAccessPattern(accessPattern),
fCPUBacked(cpuBacked) {
if (!fCPUBacked && SkIsPow2(fGpuMemorySize) && kDynamic_GrAccessPattern == fAccessPattern) {
GrScratchKey key;
- ComputeScratchKeyForDynamicBuffer(fType, fGpuMemorySize, &key);
+ ComputeScratchKeyForDynamicBuffer(fGpuMemorySize, intendedType, &key);
this->setScratchKey(key);
}
}
@@ -134,7 +131,6 @@ private:
virtual void onUnmap() = 0;
virtual bool onUpdateData(const void* src, size_t srcSizeInBytes) = 0;
- GrBufferType fType;
size_t fGpuMemorySize;
GrAccessPattern fAccessPattern;
bool fCPUBacked;