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 = { |