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

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

Issue 2112653002: Add static buffer support (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 6 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/GrVkBuffer.h ('k') | src/gpu/vk/GrVkCommandBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkBuffer.cpp
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp
index 1c7c4d0e25358f03631a9a6ed290cadff4ee9c6d..d28a8ccbf1e1cfaf542dd0293a47e13a21ed9ee2 100644
--- a/src/gpu/vk/GrVkBuffer.cpp
+++ b/src/gpu/vk/GrVkBuffer.cpp
@@ -29,23 +29,26 @@ const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& d
bufInfo.flags = 0;
bufInfo.size = desc.fSizeInBytes;
switch (desc.fType) {
- case kVertex_Type:
- bufInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
- break;
- case kIndex_Type:
- bufInfo.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
- break;
- case kUniform_Type:
- bufInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
- break;
- case kCopyRead_Type:
- bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
- break;
- case kCopyWrite_Type:
- bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
- break;
-
+ case kVertex_Type:
+ bufInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
+ break;
+ case kIndex_Type:
+ bufInfo.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
+ break;
+ case kUniform_Type:
+ bufInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
+ break;
+ case kCopyRead_Type:
+ bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ break;
+ case kCopyWrite_Type:
+ bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+ break;
+ }
+ if (!desc.fDynamic) {
+ bufInfo.usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
}
+
bufInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bufInfo.queueFamilyIndexCount = 0;
bufInfo.pQueueFamilyIndices = nullptr;
@@ -59,6 +62,7 @@ const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& d
if (!GrVkMemory::AllocAndBindBufferMemory(gpu,
buffer,
desc.fType,
+ desc.fDynamic,
&alloc)) {
return nullptr;
}
@@ -120,6 +124,9 @@ void GrVkBuffer::vkAbandon() {
void* GrVkBuffer::vkMap(const GrVkGpu* gpu) {
VALIDATE();
SkASSERT(!this->vkIsMapped());
+ if (!fDesc.fDynamic) {
+ return nullptr;
+ }
if (!fResource->unique()) {
// in use by the command buffer, so we need to create a new one
@@ -141,6 +148,7 @@ void* GrVkBuffer::vkMap(const GrVkGpu* gpu) {
void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) {
VALIDATE();
SkASSERT(this->vkIsMapped());
+ SkASSERT(fDesc.fDynamic);
VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory));
@@ -152,7 +160,7 @@ bool GrVkBuffer::vkIsMapped() const {
return SkToBool(fMapPtr);
}
-bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
+bool GrVkBuffer::vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
bool* createdNewBuffer) {
SkASSERT(!this->vkIsMapped());
VALIDATE();
@@ -160,6 +168,10 @@ bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz
return false;
}
+ if (!fDesc.fDynamic) {
+ return gpu->updateBuffer(this, src, srcSizeInBytes);
+ }
+
if (!fResource->unique()) {
// in use by the command buffer, so we need to create a new one
fResource->unref(gpu);
« no previous file with comments | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkCommandBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698