OLD | NEW |
---|---|
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 "GrVkRenderTarget.h" | 8 #include "GrVkRenderTarget.h" |
9 | 9 |
10 #include "GrRenderTargetPriv.h" | 10 #include "GrRenderTargetPriv.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 | 232 |
233 // Vulkan requires us to create a compatible renderpass before we can create our framebuffer, | 233 // Vulkan requires us to create a compatible renderpass before we can create our framebuffer, |
234 // so we use this to get a (cached) basic renderpass, only for creation. | 234 // so we use this to get a (cached) basic renderpass, only for creation. |
235 fCachedSimpleRenderPass = | 235 fCachedSimpleRenderPass = |
236 gpu->resourceProvider().findCompatibleRenderPass(*this, &fCompatibleRPHa ndle); | 236 gpu->resourceProvider().findCompatibleRenderPass(*this, &fCompatibleRPHa ndle); |
237 | 237 |
238 // Stencil attachment view is stored in the base RT stencil attachment | 238 // Stencil attachment view is stored in the base RT stencil attachment |
239 const GrVkImageView* stencilView = this->stencilAttachmentView(); | 239 const GrVkImageView* stencilView = this->stencilAttachmentView(); |
240 fFramebuffer = GrVkFramebuffer::Create(gpu, this->width(), this->height(), | 240 fFramebuffer = GrVkFramebuffer::Create(gpu, this->width(), this->height(), |
241 fCachedSimpleRenderPass, fColorAttach mentView, | 241 fCachedSimpleRenderPass, fColorAttach mentView, |
242 fResolveAttachmentView, stencilView); | 242 nullptr, stencilView); |
jvanverth1
2016/08/26 15:03:19
This is the only place we use Framebuffer::Create(
egdaniel
2016/08/26 15:48:45
So in my head I was thinking we should save this c
| |
243 SkASSERT(fFramebuffer); | 243 SkASSERT(fFramebuffer); |
244 } | 244 } |
245 | 245 |
246 void GrVkRenderTarget::getAttachmentsDescriptor( | 246 void GrVkRenderTarget::getAttachmentsDescriptor( |
247 GrVkRenderPass::AttachmentsDescriptor * desc, | 247 GrVkRenderPass::AttachmentsDescriptor * desc, |
248 GrVkRenderPass::AttachmentFlags* atta chmentFlags) const { | 248 GrVkRenderPass::AttachmentFlags* atta chmentFlags) const { |
249 int colorSamples = this->numColorSamples(); | 249 int colorSamples = this->numColorSamples(); |
250 VkFormat colorFormat; | 250 VkFormat colorFormat; |
251 GrPixelConfigToVkFormat(this->config(), &colorFormat); | 251 GrPixelConfigToVkFormat(this->config(), &colorFormat); |
252 desc->fColor.fFormat = colorFormat; | 252 desc->fColor.fFormat = colorFormat; |
253 desc->fColor.fSamples = colorSamples ? colorSamples : 1; | 253 desc->fColor.fSamples = colorSamples ? colorSamples : 1; |
254 *attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag; | 254 *attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag; |
255 uint32_t attachmentCount = 1; | 255 uint32_t attachmentCount = 1; |
256 #if 0 // We don't currently attach the resolve to the framebuffer since we manua lly do all resolving | |
256 if (colorSamples > 0) { | 257 if (colorSamples > 0) { |
jvanverth1
2016/08/26 15:03:19
Do we need this code?
egdaniel
2016/08/26 15:48:45
Done.
| |
257 desc->fResolve.fFormat = colorFormat; | 258 desc->fResolve.fFormat = colorFormat; |
258 desc->fResolve.fSamples = 1; | 259 desc->fResolve.fSamples = 1; |
259 *attachmentFlags |= GrVkRenderPass::kResolve_AttachmentFlag; | 260 *attachmentFlags |= GrVkRenderPass::kResolve_AttachmentFlag; |
260 ++attachmentCount; | 261 ++attachmentCount; |
261 } | 262 } |
262 | 263 #endif |
263 const GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAtta chment(); | 264 const GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAtta chment(); |
264 if (stencil) { | 265 if (stencil) { |
265 const GrVkStencilAttachment* vkStencil = static_cast<const GrVkStencilAt tachment*>(stencil); | 266 const GrVkStencilAttachment* vkStencil = static_cast<const GrVkStencilAt tachment*>(stencil); |
266 desc->fStencil.fFormat = vkStencil->vkFormat(); | 267 desc->fStencil.fFormat = vkStencil->vkFormat(); |
267 desc->fStencil.fSamples = vkStencil->numSamples() ? vkStencil->numSample s() : 1; | 268 desc->fStencil.fSamples = vkStencil->numSamples() ? vkStencil->numSample s() : 1; |
268 // Currently in vulkan stencil and color attachments must all have same number of samples | 269 // Currently in vulkan stencil and color attachments must all have same number of samples |
269 SkASSERT(desc->fColor.fSamples == desc->fStencil.fSamples); | 270 SkASSERT(desc->fColor.fSamples == desc->fStencil.fSamples); |
270 *attachmentFlags |= GrVkRenderPass::kStencil_AttachmentFlag; | 271 *attachmentFlags |= GrVkRenderPass::kStencil_AttachmentFlag; |
271 ++attachmentCount; | 272 ++attachmentCount; |
272 } | 273 } |
273 desc->fAttachmentCount = attachmentCount; | 274 desc->fAttachmentCount = attachmentCount; |
274 } | 275 } |
275 | 276 |
276 GrVkRenderTarget::~GrVkRenderTarget() { | 277 GrVkRenderTarget::~GrVkRenderTarget() { |
277 // either release or abandon should have been called by the owner of this ob ject. | 278 // either release or abandon should have been called by the owner of this ob ject. |
278 SkASSERT(!fMSAAImage); | 279 SkASSERT(!fMSAAImage); |
279 SkASSERT(!fResolveAttachmentView); | 280 SkASSERT(!fResolveAttachmentView); |
280 SkASSERT(!fColorAttachmentView); | 281 SkASSERT(!fColorAttachmentView); |
281 SkASSERT(!fFramebuffer); | 282 SkASSERT(!fFramebuffer); |
282 SkASSERT(!fCachedSimpleRenderPass); | 283 SkASSERT(!fCachedSimpleRenderPass); |
283 } | 284 } |
284 | 285 |
285 void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer) const { | 286 void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer) const { |
286 commandBuffer.addResource(this->framebuffer()); | 287 commandBuffer.addResource(this->framebuffer()); |
287 commandBuffer.addResource(this->resource()); | |
288 commandBuffer.addResource(this->colorAttachmentView()); | 288 commandBuffer.addResource(this->colorAttachmentView()); |
289 if (this->msaaImageResource()) { | 289 if (this->msaaImageResource()) { |
290 commandBuffer.addResource(this->msaaImageResource()); | 290 commandBuffer.addResource(this->msaaImageResource()); |
291 commandBuffer.addResource(this->resolveAttachmentView()); | 291 // Current we do not add the resolve the framebuffer so we don't need to track the resource |
292 // here | |
293 // commandBuffer.addResource(this->resolveAttachmentView()); | |
jvanverth1
2016/08/26 15:03:19
Again, do we need this code?
egdaniel
2016/08/26 15:48:46
Done.
| |
294 // commandBuffer.addResource(this->resource()); | |
295 } else { | |
296 commandBuffer.addResource(this->resource()); | |
292 } | 297 } |
293 if (this->stencilImageResource()) { | 298 if (this->stencilImageResource()) { |
294 commandBuffer.addResource(this->stencilImageResource()); | 299 commandBuffer.addResource(this->stencilImageResource()); |
295 commandBuffer.addResource(this->stencilAttachmentView()); | 300 commandBuffer.addResource(this->stencilAttachmentView()); |
296 } | 301 } |
297 } | 302 } |
298 | 303 |
299 void GrVkRenderTarget::releaseInternalObjects() { | 304 void GrVkRenderTarget::releaseInternalObjects() { |
300 GrVkGpu* gpu = this->getVkGpu(); | 305 GrVkGpu* gpu = this->getVkGpu(); |
301 | 306 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 } | 387 } |
383 | 388 |
384 return nullptr; | 389 return nullptr; |
385 } | 390 } |
386 | 391 |
387 | 392 |
388 GrVkGpu* GrVkRenderTarget::getVkGpu() const { | 393 GrVkGpu* GrVkRenderTarget::getVkGpu() const { |
389 SkASSERT(!this->wasDestroyed()); | 394 SkASSERT(!this->wasDestroyed()); |
390 return static_cast<GrVkGpu*>(this->getGpu()); | 395 return static_cast<GrVkGpu*>(this->getGpu()); |
391 } | 396 } |
OLD | NEW |