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

Unified Diff: src/gpu/vk/GrVkGpu.cpp

Issue 1825393002: Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: asserts 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/vk/GrVkGpu.h ('k') | src/gpu/vk/GrVkIndexBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkGpu.cpp
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 21e4ee358d57c3b04411452466f0c29e6a9afe15..5796f11d51562d1d311c9a969321798ff0c52fc5 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -171,18 +171,26 @@ void GrVkGpu::submitCommandBuffer(SyncQueue sync) {
}
///////////////////////////////////////////////////////////////////////////////
-GrVertexBuffer* GrVkGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
- return GrVkVertexBuffer::Create(this, size, dynamic);
-}
-
-GrIndexBuffer* GrVkGpu::onCreateIndexBuffer(size_t size, bool dynamic) {
- return GrVkIndexBuffer::Create(this, size, dynamic);
-}
-
-GrTransferBuffer* GrVkGpu::onCreateTransferBuffer(size_t size, TransferType type) {
- GrVkBuffer::Type bufferType = kCpuToGpu_TransferType ? GrVkBuffer::kCopyRead_Type
- : GrVkBuffer::kCopyWrite_Type;
- return GrVkTransferBuffer::Create(this, size, bufferType);
+GrBuffer* GrVkGpu::onCreateBuffer(GrBufferType type, size_t size, GrAccessPattern accessPattern) {
+ switch (type) {
+ case kVertex_GrBufferType:
+ SkASSERT(kDynamic_GrAccessPattern == accessPattern ||
+ kStatic_GrAccessPattern == accessPattern);
+ return GrVkVertexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern);
+ case kIndex_GrBufferType:
+ SkASSERT(kDynamic_GrAccessPattern == accessPattern ||
+ kStatic_GrAccessPattern == accessPattern);
+ return GrVkIndexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern);
+ case kXferCpuToGpu_GrBufferType:
+ SkASSERT(kStream_GrAccessPattern == accessPattern);
+ return GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyRead_Type);
+ case kXferGpuToCpu_GrBufferType:
+ SkASSERT(kStream_GrAccessPattern == accessPattern);
+ return GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyWrite_Type);
+ default:
+ SkFAIL("Unknown buffer type.");
+ return nullptr;
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -1217,8 +1225,9 @@ bool GrVkGpu::onReadPixels(GrSurface* surface,
false);
GrVkTransferBuffer* transferBuffer =
- reinterpret_cast<GrVkTransferBuffer*>(this->createTransferBuffer(rowBytes * height,
- kGpuToCpu_TransferType));
+ static_cast<GrVkTransferBuffer*>(this->createBuffer(kXferGpuToCpu_GrBufferType,
+ rowBytes * height,
+ kStream_GrAccessPattern));
bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin();
VkOffset3D offset = {
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | src/gpu/vk/GrVkIndexBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698