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

Unified Diff: src/gpu/GrResourceProvider.cpp

Issue 1831133004: Revert of Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrResourceProvider.h ('k') | src/gpu/GrSoftwarePathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceProvider.cpp
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index a73bf752b046ad64419a249d53a565924a8063c8..79146d09113c37170a75bd9e025b0fc76b193970 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -7,14 +7,15 @@
#include "GrResourceProvider.h"
-#include "GrBuffer.h"
#include "GrGpu.h"
+#include "GrIndexBuffer.h"
#include "GrPathRendering.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceKey.h"
#include "GrStencilAttachment.h"
+#include "GrVertexBuffer.h"
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
@@ -24,16 +25,16 @@
fQuadIndexBufferKey = gQuadIndexBufferKey;
}
-const GrBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern,
- int patternSize,
- int reps,
- int vertCount,
- const GrUniqueKey& key) {
+const GrIndexBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ const GrUniqueKey& key) {
size_t bufferSize = patternSize * reps * sizeof(uint16_t);
// This is typically used in GrBatchs, so we assume kNoPendingIO.
- GrBuffer* buffer = this->createBuffer(kIndex_GrBufferType, bufferSize, kStatic_GrAccessPattern,
- kNoPendingIO_Flag);
+ GrIndexBuffer* buffer = this->createIndexBuffer(bufferSize, kStatic_BufferUsage,
+ kNoPendingIO_Flag);
if (!buffer) {
return nullptr;
}
@@ -62,7 +63,7 @@
return buffer;
}
-const GrBuffer* GrResourceProvider::createQuadIndexBuffer() {
+const GrIndexBuffer* GrResourceProvider::createQuadIndexBuffer() {
static const int kMaxQuads = 1 << 12; // max possible: (1 << 14) - 1;
GR_STATIC_ASSERT(4 * kMaxQuads <= 65535);
static const uint16_t kPattern[] = { 0, 1, 2, 0, 2, 3 };
@@ -88,31 +89,72 @@
return this->gpu()->pathRendering()->createGlyphs(tf, desc, stroke);
}
-GrBuffer* GrResourceProvider::createBuffer(GrBufferType type, size_t size,
- GrAccessPattern accessPattern, uint32_t flags) {
- if (this->isAbandoned()) {
- return nullptr;
- }
-
- if (kDynamic_GrAccessPattern == accessPattern) {
+GrIndexBuffer* GrResourceProvider::createIndexBuffer(size_t size, BufferUsage usage,
+ uint32_t flags) {
+ if (this->isAbandoned()) {
+ return nullptr;
+ }
+
+ bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag);
+ bool dynamic = kDynamic_BufferUsage == usage;
+ if (dynamic) {
// bin by pow2 with a reasonable min
static const uint32_t MIN_SIZE = 1 << 12;
size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
GrScratchKey key;
- GrBuffer::ComputeScratchKeyForDynamicBuffer(type, size, &key);
+ GrIndexBuffer::ComputeScratchKey(size, true, &key);
uint32_t scratchFlags = 0;
- if (flags & kNoPendingIO_Flag) {
+ if (noPendingIO) {
scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
} else {
scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
}
GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags);
if (resource) {
- return static_cast<GrBuffer*>(resource);
- }
- }
- return this->gpu()->createBuffer(type, size, accessPattern);
+ return static_cast<GrIndexBuffer*>(resource);
+ }
+ }
+ return this->gpu()->createIndexBuffer(size, dynamic);
+}
+
+GrVertexBuffer* GrResourceProvider::createVertexBuffer(size_t size, BufferUsage usage,
+ uint32_t flags) {
+ if (this->isAbandoned()) {
+ return nullptr;
+ }
+
+ bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag);
+ bool dynamic = kDynamic_BufferUsage == usage;
+ if (dynamic) {
+ // bin by pow2 with a reasonable min
+ static const uint32_t MIN_SIZE = 1 << 12;
+ size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
+
+ GrScratchKey key;
+ GrVertexBuffer::ComputeScratchKey(size, true, &key);
+ uint32_t scratchFlags = 0;
+ if (noPendingIO) {
+ scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
+ } else {
+ scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
+ }
+ GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags);
+ if (resource) {
+ return static_cast<GrVertexBuffer*>(resource);
+ }
+ }
+ return this->gpu()->createVertexBuffer(size, dynamic);
+}
+
+GrTransferBuffer* GrResourceProvider::createTransferBuffer(size_t size, TransferType type,
+ uint32_t flags) {
+ if (this->isAbandoned()) {
+ return nullptr;
+ }
+
+ //bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag);
+ return this->gpu()->createTransferBuffer(size, type);
}
GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
« no previous file with comments | « src/gpu/GrResourceProvider.h ('k') | src/gpu/GrSoftwarePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698