Various memory leak fixes in Vulkan
BUG=skia:6101 Change-Id: Iee798dd2d9dcc4521f643b814e65029b9383cc6f Reviewed-on: https://skia-review.googlesource.com/6696 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
d4ed326d6f
commit
f9f2723e72
@ -110,6 +110,9 @@ void GrVkBuffer::vkRelease(const GrVkGpu* gpu) {
|
||||
VALIDATE();
|
||||
fResource->recycle(const_cast<GrVkGpu*>(gpu));
|
||||
fResource = nullptr;
|
||||
if (!fDesc.fDynamic) {
|
||||
delete[] (unsigned char*)fMapPtr;
|
||||
}
|
||||
fMapPtr = nullptr;
|
||||
VALIDATE();
|
||||
}
|
||||
@ -117,6 +120,9 @@ void GrVkBuffer::vkRelease(const GrVkGpu* gpu) {
|
||||
void GrVkBuffer::vkAbandon() {
|
||||
fResource->unrefAndAbandon();
|
||||
fResource = nullptr;
|
||||
if (!fDesc.fDynamic) {
|
||||
delete[] (unsigned char*)fMapPtr;
|
||||
}
|
||||
fMapPtr = nullptr;
|
||||
VALIDATE();
|
||||
}
|
||||
|
@ -25,6 +25,13 @@
|
||||
#include "SkPoint.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
GrVkCopyManager::GrVkCopyManager()
|
||||
: fVertShaderModule(VK_NULL_HANDLE)
|
||||
, fFragShaderModule(VK_NULL_HANDLE)
|
||||
, fPipelineLayout(VK_NULL_HANDLE) {}
|
||||
|
||||
GrVkCopyManager::~GrVkCopyManager() {}
|
||||
|
||||
bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
|
||||
const GrShaderCaps* shaderCaps = gpu->caps()->shaderCaps();
|
||||
const char* version = shaderCaps->versionDeclString();
|
||||
@ -125,8 +132,8 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
|
||||
fVertexBuffer->updateData(vdata, sizeof(vdata));
|
||||
|
||||
// We use 2 vec4's for uniforms
|
||||
fUniformBuffer = GrVkUniformBuffer::Create(gpu, 8 * sizeof(float));
|
||||
SkASSERT(fUniformBuffer);
|
||||
fUniformBuffer.reset(GrVkUniformBuffer::Create(gpu, 8 * sizeof(float)));
|
||||
SkASSERT(fUniformBuffer.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -154,7 +161,7 @@ bool GrVkCopyManager::copySurfaceAsDraw(GrVkGpu* gpu,
|
||||
SkASSERT(VK_NULL_HANDLE == fFragShaderModule &&
|
||||
VK_NULL_HANDLE == fPipelineLayout &&
|
||||
nullptr == fVertexBuffer.get() &&
|
||||
nullptr == fUniformBuffer);
|
||||
nullptr == fUniformBuffer.get());
|
||||
if (!this->createCopyProgram(gpu)) {
|
||||
SkDebugf("Failed to create copy program.\n");
|
||||
return false;
|
||||
@ -392,7 +399,7 @@ void GrVkCopyManager::destroyResources(GrVkGpu* gpu) {
|
||||
|
||||
if (fUniformBuffer) {
|
||||
fUniformBuffer->release(gpu);
|
||||
fUniformBuffer = nullptr;
|
||||
fUniformBuffer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,6 +410,6 @@ void GrVkCopyManager::abandonResources() {
|
||||
|
||||
if (fUniformBuffer) {
|
||||
fUniformBuffer->abandon();
|
||||
fUniformBuffer = nullptr;
|
||||
fUniformBuffer.reset();
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,9 @@ struct SkIRect;
|
||||
|
||||
class GrVkCopyManager {
|
||||
public:
|
||||
GrVkCopyManager()
|
||||
: fVertShaderModule(VK_NULL_HANDLE)
|
||||
, fFragShaderModule(VK_NULL_HANDLE)
|
||||
, fPipelineLayout(VK_NULL_HANDLE)
|
||||
, fUniformBuffer(nullptr) {}
|
||||
GrVkCopyManager();
|
||||
|
||||
~GrVkCopyManager();
|
||||
|
||||
bool copySurfaceAsDraw(GrVkGpu* gpu,
|
||||
GrSurface* dst,
|
||||
@ -49,7 +47,7 @@ private:
|
||||
VkPipelineLayout fPipelineLayout;
|
||||
|
||||
sk_sp<GrVkVertexBuffer> fVertexBuffer;
|
||||
GrVkUniformBuffer* fUniformBuffer;
|
||||
std::unique_ptr<GrVkUniformBuffer> fUniformBuffer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user