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

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

Issue 2256843002: Don't add the resolve attachment to vulkan render passes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 4 years, 3 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/GrVkRenderPass.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 "GrVkRenderPass.h" 8 #include "GrVkRenderPass.h"
9 9
10 #include "GrProcessor.h" 10 #include "GrProcessor.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 attachment->initialLayout = layout; 41 attachment->initialLayout = layout;
42 attachment->finalLayout = layout; 42 attachment->finalLayout = layout;
43 } 43 }
44 44
45 void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ et) { 45 void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ et) {
46 static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_L OAD_OP_LOAD, 46 static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_L OAD_OP_LOAD,
47 VK_ATTACHMENT_S TORE_OP_STORE); 47 VK_ATTACHMENT_S TORE_OP_STORE);
48 48
49 this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps, kBasicLoadSt oreOps); 49 this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps);
50 } 50 }
51 51
52 void GrVkRenderPass::init(const GrVkGpu* gpu, 52 void GrVkRenderPass::init(const GrVkGpu* gpu,
53 const LoadStoreOps& colorOp, 53 const LoadStoreOps& colorOp,
54 const LoadStoreOps& resolveOp,
55 const LoadStoreOps& stencilOp) { 54 const LoadStoreOps& stencilOp) {
56 uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount; 55 uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount;
57 // Attachment descriptions to be set on the render pass 56 // Attachment descriptions to be set on the render pass
58 SkTArray<VkAttachmentDescription> attachments(numAttachments); 57 SkTArray<VkAttachmentDescription> attachments(numAttachments);
59 attachments.reset(numAttachments); 58 attachments.reset(numAttachments);
60 memset(attachments.begin(), 0, numAttachments * sizeof(VkAttachmentDescripti on)); 59 memset(attachments.begin(), 0, numAttachments * sizeof(VkAttachmentDescripti on));
61 60
62 // Refs to attachments on the render pass (as described by teh VkAttachmentD escription above), 61 // Refs to attachments on the render pass (as described by teh VkAttachmentD escription above),
63 // that are used by the subpass. 62 // that are used by the subpass.
64 VkAttachmentReference colorRef; 63 VkAttachmentReference colorRef;
65 VkAttachmentReference resolveRef;
66 VkAttachmentReference stencilRef; 64 VkAttachmentReference stencilRef;
67 uint32_t currentAttachment = 0; 65 uint32_t currentAttachment = 0;
68 66
69 // Go through each of the attachment types (color, resolve, stencil) and set the necessary 67 // Go through each of the attachment types (color, stencil) and set the nece ssary
70 // on the various Vk structs. 68 // on the various Vk structs.
71 VkSubpassDescription subpassDesc; 69 VkSubpassDescription subpassDesc;
72 memset(&subpassDesc, 0, sizeof(VkSubpassDescription)); 70 memset(&subpassDesc, 0, sizeof(VkSubpassDescription));
73 subpassDesc.flags = 0; 71 subpassDesc.flags = 0;
74 subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; 72 subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
75 subpassDesc.inputAttachmentCount = 0; 73 subpassDesc.inputAttachmentCount = 0;
76 subpassDesc.pInputAttachments = nullptr; 74 subpassDesc.pInputAttachments = nullptr;
75 subpassDesc.pResolveAttachments = nullptr;
76
77 if (fAttachmentFlags & kColor_AttachmentFlag) { 77 if (fAttachmentFlags & kColor_AttachmentFlag) {
78 // set up color attachment 78 // set up color attachment
79 fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp; 79 fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp;
80 setup_vk_attachment_description(&attachments[currentAttachment], 80 setup_vk_attachment_description(&attachments[currentAttachment],
81 fAttachmentsDescriptor.fColor, 81 fAttachmentsDescriptor.fColor,
82 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL ); 82 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL );
83 // setup subpass use of attachment 83 // setup subpass use of attachment
84 colorRef.attachment = currentAttachment++; 84 colorRef.attachment = currentAttachment++;
85 colorRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; 85 colorRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
86 subpassDesc.colorAttachmentCount = 1; 86 subpassDesc.colorAttachmentCount = 1;
87 } else { 87 } else {
88 // I don't think there should ever be a time where we don't have a color attachment 88 // I don't think there should ever be a time where we don't have a color attachment
89 SkASSERT(false); 89 SkASSERT(false);
90 colorRef.attachment = VK_ATTACHMENT_UNUSED; 90 colorRef.attachment = VK_ATTACHMENT_UNUSED;
91 colorRef.layout = VK_IMAGE_LAYOUT_UNDEFINED; 91 colorRef.layout = VK_IMAGE_LAYOUT_UNDEFINED;
92 subpassDesc.colorAttachmentCount = 0; 92 subpassDesc.colorAttachmentCount = 0;
93 } 93 }
94 subpassDesc.pColorAttachments = &colorRef; 94 subpassDesc.pColorAttachments = &colorRef;
95 95
96 if (fAttachmentFlags & kResolve_AttachmentFlag) {
97 // set up resolve attachment
98 fAttachmentsDescriptor.fResolve.fLoadStoreOps = resolveOp;
99 setup_vk_attachment_description(&attachments[currentAttachment],
100 fAttachmentsDescriptor.fResolve,
101 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL );
102 // setup subpass use of attachment
103 resolveRef.attachment = currentAttachment++;
104 // I'm really not sure what the layout should be for the resolve texture s.
105 resolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
106 subpassDesc.pResolveAttachments = &resolveRef;
107 } else {
108 subpassDesc.pResolveAttachments = nullptr;
109 }
110
111 if (fAttachmentFlags & kStencil_AttachmentFlag) { 96 if (fAttachmentFlags & kStencil_AttachmentFlag) {
112 // set up stencil attachment 97 // set up stencil attachment
113 fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp; 98 fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp;
114 setup_vk_attachment_description(&attachments[currentAttachment], 99 setup_vk_attachment_description(&attachments[currentAttachment],
115 fAttachmentsDescriptor.fStencil, 100 fAttachmentsDescriptor.fStencil,
116 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT _OPTIMAL); 101 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT _OPTIMAL);
117 // setup subpass use of attachment 102 // setup subpass use of attachment
118 stencilRef.attachment = currentAttachment++; 103 stencilRef.attachment = currentAttachment++;
119 stencilRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; 104 stencilRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
120 } else { 105 } else {
(...skipping 27 matching lines...) Expand all
148 133
149 // Get granularity for this render pass 134 // Get granularity for this render pass
150 GR_VK_CALL(gpu->vkInterface(), GetRenderAreaGranularity(gpu->device(), 135 GR_VK_CALL(gpu->vkInterface(), GetRenderAreaGranularity(gpu->device(),
151 fRenderPass, 136 fRenderPass,
152 &fGranularity)); 137 &fGranularity));
153 } 138 }
154 139
155 void GrVkRenderPass::init(const GrVkGpu* gpu, 140 void GrVkRenderPass::init(const GrVkGpu* gpu,
156 const GrVkRenderPass& compatibleRenderPass, 141 const GrVkRenderPass& compatibleRenderPass,
157 const LoadStoreOps& colorOp, 142 const LoadStoreOps& colorOp,
158 const LoadStoreOps& resolveOp,
159 const LoadStoreOps& stencilOp) { 143 const LoadStoreOps& stencilOp) {
160 fAttachmentFlags = compatibleRenderPass.fAttachmentFlags; 144 fAttachmentFlags = compatibleRenderPass.fAttachmentFlags;
161 fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor; 145 fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor;
162 this->init(gpu, colorOp, resolveOp, stencilOp); 146 this->init(gpu, colorOp, stencilOp);
163 } 147 }
164 148
165 void GrVkRenderPass::init(const GrVkGpu* gpu, 149 void GrVkRenderPass::init(const GrVkGpu* gpu,
166 const GrVkRenderTarget& target, 150 const GrVkRenderTarget& target,
167 const LoadStoreOps& colorOp, 151 const LoadStoreOps& colorOp,
168 const LoadStoreOps& resolveOp,
169 const LoadStoreOps& stencilOp) { 152 const LoadStoreOps& stencilOp) {
170 // Get attachment information from render target. This includes which attach ments the render 153 // Get attachment information from render target. This includes which attach ments the render
171 // target has (color, resolve, stencil) and the attachments format and sampl e count. 154 // target has (color, stencil) and the attachments format and sample count.
172 target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags); 155 target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags);
173 this->init(gpu, colorOp, resolveOp, stencilOp); 156 this->init(gpu, colorOp, stencilOp);
174 } 157 }
175 158
176 void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const { 159 void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const {
177 GR_VK_CALL(gpu->vkInterface(), DestroyRenderPass(gpu->device(), fRenderPass, nullptr)); 160 GR_VK_CALL(gpu->vkInterface(), DestroyRenderPass(gpu->device(), fRenderPass, nullptr));
178 } 161 }
179 162
180 // Works under the assumption that color attachment will always be the first att achment in our 163 // Works under the assumption that color attachment will always be the first att achment in our
181 // attachment array if it exists. 164 // attachment array if it exists.
182 bool GrVkRenderPass::colorAttachmentIndex(uint32_t* index) const { 165 bool GrVkRenderPass::colorAttachmentIndex(uint32_t* index) const {
183 *index = 0; 166 *index = 0;
184 if (fAttachmentFlags & kColor_AttachmentFlag) { 167 if (fAttachmentFlags & kColor_AttachmentFlag) {
185 return true; 168 return true;
186 } 169 }
187 return false; 170 return false;
188 } 171 }
189 172
190 // Works under the assumption that resolve attachment will always be after the c olor attachment.
191 bool GrVkRenderPass::resolveAttachmentIndex(uint32_t* index) const {
192 *index = 0;
193 if (fAttachmentFlags & kColor_AttachmentFlag) {
194 ++(*index);
195 }
196 if (fAttachmentFlags & kResolve_AttachmentFlag) {
197 return true;
198 }
199 return false;
200 }
201
202 // Works under the assumption that stencil attachment will always be after the c olor and resolve 173 // Works under the assumption that stencil attachment will always be after the c olor and resolve
203 // attachment. 174 // attachment.
204 bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const { 175 bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const {
205 *index = 0; 176 *index = 0;
206 if (fAttachmentFlags & kColor_AttachmentFlag) { 177 if (fAttachmentFlags & kColor_AttachmentFlag) {
207 ++(*index); 178 ++(*index);
208 } 179 }
209 if (fAttachmentFlags & kResolve_AttachmentFlag) {
210 ++(*index);
211 }
212 if (fAttachmentFlags & kStencil_AttachmentFlag) { 180 if (fAttachmentFlags & kStencil_AttachmentFlag) {
213 return true; 181 return true;
214 } 182 }
215 return false; 183 return false;
216 } 184 }
217 185
218 void GrVkRenderPass::getBeginInfo(const GrVkRenderTarget& target, 186 void GrVkRenderPass::getBeginInfo(const GrVkRenderTarget& target,
219 VkRenderPassBeginInfo* beginInfo, 187 VkRenderPassBeginInfo* beginInfo,
220 VkSubpassContents* contents) const { 188 VkSubpassContents* contents) const {
221 SkASSERT(this->isCompatible(target)); 189 SkASSERT(this->isCompatible(target));
(...skipping 20 matching lines...) Expand all
242 const AttachmentFlags& flags) const { 210 const AttachmentFlags& flags) const {
243 if (flags != fAttachmentFlags) { 211 if (flags != fAttachmentFlags) {
244 return false; 212 return false;
245 } 213 }
246 214
247 if (fAttachmentFlags & kColor_AttachmentFlag) { 215 if (fAttachmentFlags & kColor_AttachmentFlag) {
248 if (!fAttachmentsDescriptor.fColor.isCompatible(desc.fColor)) { 216 if (!fAttachmentsDescriptor.fColor.isCompatible(desc.fColor)) {
249 return false; 217 return false;
250 } 218 }
251 } 219 }
252 if (fAttachmentFlags & kResolve_AttachmentFlag) {
253 if (!fAttachmentsDescriptor.fResolve.isCompatible(desc.fResolve)) {
254 return false;
255 }
256 }
257 if (fAttachmentFlags & kStencil_AttachmentFlag) { 220 if (fAttachmentFlags & kStencil_AttachmentFlag) {
258 if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) { 221 if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) {
259 return false; 222 return false;
260 } 223 }
261 } 224 }
262 225
263 return true; 226 return true;
264 } 227 }
265 228
266 bool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const { 229 bool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const {
267 AttachmentsDescriptor desc; 230 AttachmentsDescriptor desc;
268 AttachmentFlags flags; 231 AttachmentFlags flags;
269 target.getAttachmentsDescriptor(&desc, &flags); 232 target.getAttachmentsDescriptor(&desc, &flags);
270 233
271 return this->isCompatible(desc, flags); 234 return this->isCompatible(desc, flags);
272 } 235 }
273 236
274 bool GrVkRenderPass::isCompatible(const GrVkRenderPass& renderPass) const { 237 bool GrVkRenderPass::isCompatible(const GrVkRenderPass& renderPass) const {
275 return this->isCompatible(renderPass.fAttachmentsDescriptor, renderPass.fAtt achmentFlags); 238 return this->isCompatible(renderPass.fAttachmentsDescriptor, renderPass.fAtt achmentFlags);
276 } 239 }
277 240
278 bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps, 241 bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps,
279 const LoadStoreOps& resolveOps,
280 const LoadStoreOps& stencilOps) const { 242 const LoadStoreOps& stencilOps) const {
281 if (fAttachmentFlags & kColor_AttachmentFlag) { 243 if (fAttachmentFlags & kColor_AttachmentFlag) {
282 if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) { 244 if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) {
283 return false; 245 return false;
284 } 246 }
285 } 247 }
286 if (fAttachmentFlags & kResolve_AttachmentFlag) {
287 if (fAttachmentsDescriptor.fResolve.fLoadStoreOps != resolveOps) {
288 return false;
289 }
290 }
291 if (fAttachmentFlags & kStencil_AttachmentFlag) { 248 if (fAttachmentFlags & kStencil_AttachmentFlag) {
292 if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) { 249 if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) {
293 return false; 250 return false;
294 } 251 }
295 } 252 }
296 return true; 253 return true;
297 } 254 }
298 255
299 void GrVkRenderPass::genKey(GrProcessorKeyBuilder* b) const { 256 void GrVkRenderPass::genKey(GrProcessorKeyBuilder* b) const {
300 b->add32(fAttachmentFlags); 257 b->add32(fAttachmentFlags);
301 if (fAttachmentFlags & kColor_AttachmentFlag) { 258 if (fAttachmentFlags & kColor_AttachmentFlag) {
302 b->add32(fAttachmentsDescriptor.fColor.fFormat); 259 b->add32(fAttachmentsDescriptor.fColor.fFormat);
303 b->add32(fAttachmentsDescriptor.fColor.fSamples); 260 b->add32(fAttachmentsDescriptor.fColor.fSamples);
304 } 261 }
305 if (fAttachmentFlags & kResolve_AttachmentFlag) {
306 b->add32(fAttachmentsDescriptor.fResolve.fFormat);
307 b->add32(fAttachmentsDescriptor.fResolve.fSamples);
308 }
309 if (fAttachmentFlags & kStencil_AttachmentFlag) { 262 if (fAttachmentFlags & kStencil_AttachmentFlag) {
310 b->add32(fAttachmentsDescriptor.fStencil.fFormat); 263 b->add32(fAttachmentsDescriptor.fStencil.fFormat);
311 b->add32(fAttachmentsDescriptor.fStencil.fSamples); 264 b->add32(fAttachmentsDescriptor.fStencil.fSamples);
312 } 265 }
313 } 266 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkRenderPass.h ('k') | src/gpu/vk/GrVkRenderTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698