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) {
|
void* GrVkBuffer::vkMap(const GrVkGpu* gpu) {
|
||||||
VALIDATE();
|
VALIDATE();
|
||||||
SkASSERT(!this->vkIsMapped());
|
SkASSERT(!this->vkIsMapped());
|
||||||
if (!fDesc.fDynamic) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fResource->unique()) {
|
if (!fResource->unique()) {
|
||||||
// in use by the command buffer, so we need to create a new one
|
// in use by the command buffer, so we need to create a new one
|
||||||
fResource->unref(gpu);
|
fResource->unref(gpu);
|
||||||
fResource = Create(gpu, fDesc);
|
fResource = Create(gpu, fDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GrVkAlloc& alloc = this->alloc();
|
if (fDesc.fDynamic) {
|
||||||
VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
|
const GrVkAlloc& alloc = this->alloc();
|
||||||
VK_WHOLE_SIZE, 0, &fMapPtr));
|
VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
|
||||||
if (err) {
|
VK_WHOLE_SIZE, 0, &fMapPtr));
|
||||||
fMapPtr = nullptr;
|
if (err) {
|
||||||
|
fMapPtr = nullptr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fMapPtr = new unsigned char[this->size()];
|
||||||
}
|
}
|
||||||
|
|
||||||
VALIDATE();
|
VALIDATE();
|
||||||
return fMapPtr;
|
return fMapPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) {
|
void GrVkBuffer::vkUnmap(GrVkGpu* gpu) {
|
||||||
VALIDATE();
|
VALIDATE();
|
||||||
SkASSERT(this->vkIsMapped());
|
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;
|
fMapPtr = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* vkMap(const GrVkGpu* gpu);
|
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 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.
|
// if it creates a new VkBuffer to upload the data to.
|
||||||
bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
|
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) {
|
for (int i = 0; i < fActiveCommandBuffers.count(); ++i) {
|
||||||
SkASSERT(fActiveCommandBuffers[i]->finished(fGpu));
|
SkASSERT(fActiveCommandBuffers[i]->finished(fGpu));
|
||||||
SkASSERT(fActiveCommandBuffers[i]->unique());
|
SkASSERT(fActiveCommandBuffers[i]->unique());
|
||||||
|
fActiveCommandBuffers[i]->reset(fGpu);
|
||||||
fActiveCommandBuffers[i]->unref(fGpu);
|
fActiveCommandBuffers[i]->unref(fGpu);
|
||||||
}
|
}
|
||||||
fActiveCommandBuffers.reset();
|
fActiveCommandBuffers.reset();
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
void* map(const GrVkGpu* gpu) {
|
void* map(const GrVkGpu* gpu) {
|
||||||
return this->vkMap(gpu);
|
return this->vkMap(gpu);
|
||||||
}
|
}
|
||||||
void unmap(const GrVkGpu* gpu) {
|
void unmap(GrVkGpu* gpu) {
|
||||||
this->vkUnmap(gpu);
|
this->vkUnmap(gpu);
|
||||||
}
|
}
|
||||||
// The output variable createdNewBuffer must be set to true if a new VkBuffer is created in
|
// The output variable createdNewBuffer must be set to true if a new VkBuffer is created in
|
||||||
|
Loading…
Reference in New Issue
Block a user