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

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

Issue 2018933004: Add offset to memory allocations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Take care of some additional FreeMemorys Created 4 years, 7 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
Index: src/gpu/vk/GrVkImage.cpp
diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp
index d3195e7e8a0a9f41c6f96fe842e7b69aef471b65..7d8e87812af7f1fabc982992a73a21f7c681d9e2 100644
--- a/src/gpu/vk/GrVkImage.cpp
+++ b/src/gpu/vk/GrVkImage.cpp
@@ -63,6 +63,7 @@ void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout,
bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, GrVkImageInfo* info) {
VkImage image = 0;
VkDeviceMemory alloc;
+ VkDeviceSize offset;
VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling)
? VK_IMAGE_LAYOUT_PREINITIALIZED
@@ -102,13 +103,14 @@ bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr
GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateImage(gpu->device(), &imageCreateInfo, nullptr,
&image));
- if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &alloc)) {
+ if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &alloc, &offset)) {
VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
return false;
}
info->fImage = image;
info->fAlloc = alloc;
+ info->fOffset = offset;
info->fImageTiling = imageDesc.fImageTiling;
info->fImageLayout = initialLayout;
info->fFormat = imageDesc.fFormat;
@@ -118,11 +120,11 @@ bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr
void GrVkImage::DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo* info) {
VK_CALL(gpu, DestroyImage(gpu->device(), info->fImage, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), info->fAlloc, nullptr));
+ GrVkMemory::FreeImageMemory(gpu, info->fAlloc, info->fOffset);
}
-void GrVkImage::setNewResource(VkImage image, VkDeviceMemory alloc) {
- fResource = new Resource(image, alloc);
+void GrVkImage::setNewResource(VkImage image, VkDeviceMemory alloc, VkDeviceSize offset) {
+ fResource = new Resource(image, alloc, offset);
}
GrVkImage::~GrVkImage() {
@@ -146,7 +148,7 @@ void GrVkImage::abandonImage() {
void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const {
VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
+ GrVkMemory::FreeImageMemory(gpu, fAlloc, fOffset);
}
void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const {

Powered by Google App Engine
This is Rietveld 408576698