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

Side by Side Diff: src/gpu/vk/GrVkImage.cpp

Issue 1943933002: Apply setImageLayout() to all of a VkImage's subresources. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments 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 unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkImage.h ('k') | src/gpu/vk/GrVkRenderTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkGpu.h" 8 #include "GrVkGpu.h"
9 #include "GrVkImage.h" 9 #include "GrVkImage.h"
10 #include "GrVkMemory.h" 10 #include "GrVkMemory.h"
(...skipping 13 matching lines...) Expand all
24 return VK_IMAGE_ASPECT_COLOR_BIT; 24 return VK_IMAGE_ASPECT_COLOR_BIT;
25 } 25 }
26 } 26 }
27 27
28 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, 28 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout,
29 VkAccessFlags srcAccessMask, 29 VkAccessFlags srcAccessMask,
30 VkAccessFlags dstAccessMask, 30 VkAccessFlags dstAccessMask,
31 VkPipelineStageFlags srcStageMask, 31 VkPipelineStageFlags srcStageMask,
32 VkPipelineStageFlags dstStageMask, 32 VkPipelineStageFlags dstStageMask,
33 bool byRegion) { 33 bool byRegion) {
34 SkASSERT(VK_IMAGE_LAYOUT_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI ZED != newLayout); 34 SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED != newLayout &&
35 VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout);
35 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force 36 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force
jvanverth1 2016/05/03 16:34:23 As a side note, I think this is reasonable. If the
36 // a barrier on certain things? 37 // a barrier on certain things?
37 if (newLayout == fCurrentLayout) { 38 if (newLayout == fCurrentLayout) {
38 return; 39 return;
39 } 40 }
40 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fResource->fForma t); 41 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fResource->fForma t);
41 VkImageMemoryBarrier imageMemoryBarrier = { 42 VkImageMemoryBarrier imageMemoryBarrier = {
42 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType 43 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
43 NULL, // pNext 44 NULL, // pNext
44 srcAccessMask, // outputMask 45 srcAccessMask, // outputMask
45 dstAccessMask, // inputMask 46 dstAccessMask, // inputMask
46 fCurrentLayout, // oldLayout 47 fCurrentLayout, // oldLayout
47 newLayout, // newLayout 48 newLayout, // newLayout
48 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex 49 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
49 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex 50 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex
50 fResource->fImage, // image 51 fResource->fImage, // image
51 { aspectFlags, 0, 1, 0, 1 } // subresourceRange 52 { aspectFlags, 0, fResource->fLevelCount, 0, 1 } // subresourceRange
52 }; 53 };
53 54
54 // TODO: restrict to area of image we're interested in 55 // TODO: restrict to area of image we're interested in
55 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier); 56 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier);
56 57
57 fCurrentLayout = newLayout; 58 fCurrentLayout = newLayout;
58 } 59 }
59 60
60 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, 61 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
61 const ImageDesc& imageDesc) { 62 const ImageDesc& imageDesc) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) { 99 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) {
99 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr)); 100 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
100 return nullptr; 101 return nullptr;
101 } 102 }
102 103
103 GrVkImage::Resource::Flags flags = 104 GrVkImage::Resource::Flags flags =
104 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag 105 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag
105 : Resource::kNo_Flags ; 106 : Resource::kNo_Flags ;
106 107
107 return (new GrVkImage::Resource(image, alloc, flags, imageDesc.fFormat)); 108 return (new GrVkImage::Resource(image, alloc, imageDesc.fFormat, imageDesc.f Levels, flags));
108 } 109 }
109 110
110 GrVkImage::~GrVkImage() { 111 GrVkImage::~GrVkImage() {
111 // should have been released or abandoned first 112 // should have been released or abandoned first
112 SkASSERT(!fResource); 113 SkASSERT(!fResource);
113 } 114 }
114 115
115 void GrVkImage::releaseImage(const GrVkGpu* gpu) { 116 void GrVkImage::releaseImage(const GrVkGpu* gpu) {
116 if (fResource) { 117 if (fResource) {
117 fResource->unref(gpu); 118 fResource->unref(gpu);
118 fResource = nullptr; 119 fResource = nullptr;
119 } 120 }
120 } 121 }
121 122
122 void GrVkImage::abandonImage() { 123 void GrVkImage::abandonImage() {
123 if (fResource) { 124 if (fResource) {
124 fResource->unrefAndAbandon(); 125 fResource->unrefAndAbandon();
125 fResource = nullptr; 126 fResource = nullptr;
126 } 127 }
127 } 128 }
128 129
129 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { 130 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const {
130 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); 131 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
131 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); 132 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
132 } 133 }
133 134
134 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { 135 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const {
135 } 136 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkImage.h ('k') | src/gpu/vk/GrVkRenderTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698