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
This commit is contained in:
parent
a4b8704e76
commit
069c464a6b
@ -124,33 +124,37 @@ 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
|
||||
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;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ protected:
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -270,6 +270,7 @@ void GrVkResourceProvider::destroyResources() {
|
||||
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();
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user