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

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: 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
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_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI ZED != newLayout);
egdaniel 2016/05/03 16:01:00 What is this assert trying to do here? Currently i
jvanverth1 2016/05/03 16:32:28 I'm not sure why you're asking me, but in any case
35 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force 35 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force
36 // a barrier on certain things? 36 // a barrier on certain things?
37 if (newLayout == fCurrentLayout) { 37 if (newLayout == fCurrentLayout) {
38 return; 38 return;
39 } 39 }
40 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fResource->fForma t); 40 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fResource->fForma t);
41 VkImageMemoryBarrier imageMemoryBarrier = { 41 VkImageMemoryBarrier imageMemoryBarrier = {
42 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType 42 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
43 NULL, // pNext 43 NULL, // pNext
44 srcAccessMask, // outputMask 44 srcAccessMask, // outputMask
45 dstAccessMask, // inputMask 45 dstAccessMask, // inputMask
46 fCurrentLayout, // oldLayout 46 fCurrentLayout, // oldLayout
47 newLayout, // newLayout 47 newLayout, // newLayout
48 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex 48 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
49 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex 49 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex
50 fResource->fImage, // image 50 fResource->fImage, // image
51 { aspectFlags, 0, 1, 0, 1 } // subresourceRange 51 { aspectFlags, 0, fResource->fLevelCount, 0, 1 } // subresourceRange
52 }; 52 };
53 53
54 // TODO: restrict to area of image we're interested in 54 // TODO: restrict to area of image we're interested in
55 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier); 55 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier);
56 56
57 fCurrentLayout = newLayout; 57 fCurrentLayout = newLayout;
58 } 58 }
59 59
60 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, 60 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
61 const ImageDesc& imageDesc) { 61 const ImageDesc& imageDesc) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) { 98 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) {
99 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr)); 99 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
100 return nullptr; 100 return nullptr;
101 } 101 }
102 102
103 GrVkImage::Resource::Flags flags = 103 GrVkImage::Resource::Flags flags =
104 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag 104 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag
105 : Resource::kNo_Flags ; 105 : Resource::kNo_Flags ;
106 106
107 return (new GrVkImage::Resource(image, alloc, flags, imageDesc.fFormat)); 107 return (new GrVkImage::Resource(image, alloc, imageDesc.fFormat, imageDesc.f Levels, flags));
108 } 108 }
109 109
110 GrVkImage::~GrVkImage() { 110 GrVkImage::~GrVkImage() {
111 // should have been released or abandoned first 111 // should have been released or abandoned first
112 SkASSERT(!fResource); 112 SkASSERT(!fResource);
113 } 113 }
114 114
115 void GrVkImage::releaseImage(const GrVkGpu* gpu) { 115 void GrVkImage::releaseImage(const GrVkGpu* gpu) {
116 if (fResource) { 116 if (fResource) {
117 fResource->unref(gpu); 117 fResource->unref(gpu);
118 fResource = nullptr; 118 fResource = nullptr;
119 } 119 }
120 } 120 }
121 121
122 void GrVkImage::abandonImage() { 122 void GrVkImage::abandonImage() {
123 if (fResource) { 123 if (fResource) {
124 fResource->unrefAndAbandon(); 124 fResource->unrefAndAbandon();
125 fResource = nullptr; 125 fResource = nullptr;
126 } 126 }
127 } 127 }
128 128
129 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { 129 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const {
130 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); 130 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
131 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); 131 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
132 } 132 }
133 133
134 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { 134 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const {
135 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698