Vulkan fixes for TesselatingPathRenderer test
- Be sure to release all secondard command buffers on shutdown
- Allow mapping of static buffers
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2123323002
Review-Url: https://codereview.chromium.org/2123323002
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp
index d28a8cc..ff809eb 100644
--- a/src/gpu/vk/GrVkBuffer.cpp
+++ b/src/gpu/vk/GrVkBuffer.cpp
@@ -124,33 +124,37 @@
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
fResource->unref(gpu);
fResource = Create(gpu, fDesc);
}
- const GrVkAlloc& alloc = this->alloc();
- VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
- VK_WHOLE_SIZE, 0, &fMapPtr));
- if (err) {
- fMapPtr = nullptr;
+ if (fDesc.fDynamic) {
+ const GrVkAlloc& alloc = this->alloc();
+ VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
+ VK_WHOLE_SIZE, 0, &fMapPtr));
+ if (err) {
+ fMapPtr = nullptr;
+ }
+ } else {
+ fMapPtr = new unsigned char[this->size()];
}
VALIDATE();
return fMapPtr;
}
-void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) {
+void GrVkBuffer::vkUnmap(GrVkGpu* gpu) {
VALIDATE();
SkASSERT(this->vkIsMapped());
- SkASSERT(fDesc.fDynamic);
- VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory));
+ if (fDesc.fDynamic) {
+ VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory));
+ } else {
+ gpu->updateBuffer(this, fMapPtr, this->size());
+ delete fMapPtr;
+ }
fMapPtr = nullptr;
}
diff --git a/src/gpu/vk/GrVkBuffer.h b/src/gpu/vk/GrVkBuffer.h
index bb053cc..3ea9b86 100644
--- a/src/gpu/vk/GrVkBuffer.h
+++ b/src/gpu/vk/GrVkBuffer.h
@@ -81,7 +81,7 @@
}
void* vkMap(const GrVkGpu* gpu);
- void vkUnmap(const GrVkGpu* gpu);
+ void vkUnmap(GrVkGpu* gpu);
// If the caller passes in a non null createdNewBuffer, this function will set the bool to true
// if it creates a new VkBuffer to upload the data to.
bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index 7980a2d..c7a66ca 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -270,6 +270,7 @@
for (int i = 0; i < fActiveCommandBuffers.count(); ++i) {
SkASSERT(fActiveCommandBuffers[i]->finished(fGpu));
SkASSERT(fActiveCommandBuffers[i]->unique());
+ fActiveCommandBuffers[i]->reset(fGpu);
fActiveCommandBuffers[i]->unref(fGpu);
}
fActiveCommandBuffers.reset();
diff --git a/src/gpu/vk/GrVkUniformBuffer.h b/src/gpu/vk/GrVkUniformBuffer.h
index bfaf240..ed6c8a0 100644
--- a/src/gpu/vk/GrVkUniformBuffer.h
+++ b/src/gpu/vk/GrVkUniformBuffer.h
@@ -20,7 +20,7 @@
void* map(const GrVkGpu* gpu) {
return this->vkMap(gpu);
}
- void unmap(const GrVkGpu* gpu) {
+ void unmap(GrVkGpu* gpu) {
this->vkUnmap(gpu);
}
// The output variable createdNewBuffer must be set to true if a new VkBuffer is created in