int width, int height,
const GrVkRenderPass* renderPass,
const GrVkImageView* colorAttachment,
- const GrVkImageView* resolveAttachment,
const GrVkImageView* stencilAttachment) {
// At the very least we need a renderPass and a colorAttachment
SkASSERT(renderPass);
VkImageView attachments[3];
attachments[0] = colorAttachment->imageView();
int numAttachments = 1;
- if (resolveAttachment) {
- attachments[numAttachments++] = resolveAttachment->imageView();
- }
if (stencilAttachment) {
attachments[numAttachments++] = stencilAttachment->imageView();
}
int width, int height,
const GrVkRenderPass* renderPass,
const GrVkImageView* colorAttachment,
- const GrVkImageView* resolveAttachment,
const GrVkImageView* stencilAttachment);
VkFramebuffer framebuffer() const { return fFramebuffer; }
VK_PIPELINE_STAGE_TRANSFER_BIT,
false);
- fCurrentCmdBuffer->resolveImage(this, *rt, *rt->msaaImage(), 1, &resolveInfo);
+ fCurrentCmdBuffer->resolveImage(this, *rt->msaaImage(), *rt, 1, &resolveInfo);
rt->flagAsResolved();
}
fCurrentCmdBuffer->executeCommands(this, buffer);
fCurrentCmdBuffer->endRenderPass(this);
- this->didWriteToSurface(target, pBounds);
+ this->didWriteToSurface(target, &bounds);
}
}
void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
- // Change layout of our render target so it can be used as the color attachment
- fRenderTarget->setImageLayout(fGpu,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
- VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- false);
+ // Change layout of our render target so it can be used as the color attachment. Currently
+ // we don't attach the resolve to the framebuffer so no need to change its layout.
+ GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaImage()
+ : fRenderTarget;
+ targetImage->setImageLayout(fGpu,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+ false);
// If we are using a stencil attachment we also need to update its layout
if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment()) {
false);
}
- if (GrVkImage* msaaImage = fRenderTarget->msaaImage()) {
- msaaImage->setImageLayout(fGpu,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
- VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- false);
- }
-
for (int i = 0; i < fSampledImages.count(); ++i) {
fSampledImages[i]->setImageLayout(fGpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_STORE_OP_STORE);
- this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps, kBasicLoadStoreOps);
+ this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps);
}
void GrVkRenderPass::init(const GrVkGpu* gpu,
const LoadStoreOps& colorOp,
- const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp) {
uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount;
// Attachment descriptions to be set on the render pass
// Refs to attachments on the render pass (as described by teh VkAttachmentDescription above),
// that are used by the subpass.
VkAttachmentReference colorRef;
- VkAttachmentReference resolveRef;
VkAttachmentReference stencilRef;
uint32_t currentAttachment = 0;
- // Go through each of the attachment types (color, resolve, stencil) and set the necessary
+ // Go through each of the attachment types (color, stencil) and set the necessary
// on the various Vk structs.
VkSubpassDescription subpassDesc;
memset(&subpassDesc, 0, sizeof(VkSubpassDescription));
subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDesc.inputAttachmentCount = 0;
subpassDesc.pInputAttachments = nullptr;
+ subpassDesc.pResolveAttachments = nullptr;
+
if (fAttachmentFlags & kColor_AttachmentFlag) {
// set up color attachment
fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp;
}
subpassDesc.pColorAttachments = &colorRef;
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- // set up resolve attachment
- fAttachmentsDescriptor.fResolve.fLoadStoreOps = resolveOp;
- setup_vk_attachment_description(&attachments[currentAttachment],
- fAttachmentsDescriptor.fResolve,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
- // setup subpass use of attachment
- resolveRef.attachment = currentAttachment++;
- // I'm really not sure what the layout should be for the resolve textures.
- resolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- subpassDesc.pResolveAttachments = &resolveRef;
- } else {
- subpassDesc.pResolveAttachments = nullptr;
- }
-
if (fAttachmentFlags & kStencil_AttachmentFlag) {
// set up stencil attachment
fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp;
void GrVkRenderPass::init(const GrVkGpu* gpu,
const GrVkRenderPass& compatibleRenderPass,
const LoadStoreOps& colorOp,
- const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp) {
fAttachmentFlags = compatibleRenderPass.fAttachmentFlags;
fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor;
- this->init(gpu, colorOp, resolveOp, stencilOp);
+ this->init(gpu, colorOp, stencilOp);
}
void GrVkRenderPass::init(const GrVkGpu* gpu,
const GrVkRenderTarget& target,
const LoadStoreOps& colorOp,
- const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp) {
// Get attachment information from render target. This includes which attachments the render
- // target has (color, resolve, stencil) and the attachments format and sample count.
+ // target has (color, stencil) and the attachments format and sample count.
target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags);
- this->init(gpu, colorOp, resolveOp, stencilOp);
+ this->init(gpu, colorOp, stencilOp);
}
void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const {
return false;
}
-// Works under the assumption that resolve attachment will always be after the color attachment.
-bool GrVkRenderPass::resolveAttachmentIndex(uint32_t* index) const {
- *index = 0;
- if (fAttachmentFlags & kColor_AttachmentFlag) {
- ++(*index);
- }
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- return true;
- }
- return false;
-}
-
// Works under the assumption that stencil attachment will always be after the color and resolve
// attachment.
bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const {
if (fAttachmentFlags & kColor_AttachmentFlag) {
++(*index);
}
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- ++(*index);
- }
if (fAttachmentFlags & kStencil_AttachmentFlag) {
return true;
}
return false;
}
}
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- if (!fAttachmentsDescriptor.fResolve.isCompatible(desc.fResolve)) {
- return false;
- }
- }
if (fAttachmentFlags & kStencil_AttachmentFlag) {
if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) {
return false;
}
bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps,
- const LoadStoreOps& resolveOps,
const LoadStoreOps& stencilOps) const {
if (fAttachmentFlags & kColor_AttachmentFlag) {
if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) {
return false;
}
}
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- if (fAttachmentsDescriptor.fResolve.fLoadStoreOps != resolveOps) {
- return false;
- }
- }
if (fAttachmentFlags & kStencil_AttachmentFlag) {
if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) {
return false;
b->add32(fAttachmentsDescriptor.fColor.fFormat);
b->add32(fAttachmentsDescriptor.fColor.fSamples);
}
- if (fAttachmentFlags & kResolve_AttachmentFlag) {
- b->add32(fAttachmentsDescriptor.fResolve.fFormat);
- b->add32(fAttachmentsDescriptor.fResolve.fSamples);
- }
if (fAttachmentFlags & kStencil_AttachmentFlag) {
b->add32(fAttachmentsDescriptor.fStencil.fFormat);
b->add32(fAttachmentsDescriptor.fStencil.fSamples);
void init(const GrVkGpu* gpu,
const GrVkRenderTarget& target,
const LoadStoreOps& colorOp,
- const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp);
void init(const GrVkGpu* gpu,
const GrVkRenderPass& compatibleRenderPass,
const LoadStoreOps& colorOp,
- const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp);
struct AttachmentsDescriptor {
}
};
AttachmentDesc fColor;
- AttachmentDesc fResolve;
AttachmentDesc fStencil;
uint32_t fAttachmentCount;
};
enum AttachmentFlags {
kColor_AttachmentFlag = 0x1,
- kResolve_AttachmentFlag = 0x2,
- kStencil_AttachmentFlag = 0x4,
+ kStencil_AttachmentFlag = 0x2,
};
GR_DECL_BITFIELD_OPS_FRIENDS(AttachmentFlags);
// If the render pass does not have the given attachment it will return false and not set the
// index value.
bool colorAttachmentIndex(uint32_t* index) const;
- bool resolveAttachmentIndex(uint32_t* index) const;
bool stencilAttachmentIndex(uint32_t* index) const;
// Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a render pass.
bool isCompatible(const GrVkRenderPass& renderPass) const;
bool equalLoadStoreOps(const LoadStoreOps& colorOps,
- const LoadStoreOps& resolveOps,
const LoadStoreOps& stencilOps) const;
VkRenderPass vkRenderPass() const { return fRenderPass; }
void init(const GrVkGpu* gpu,
const LoadStoreOps& colorOps,
- const LoadStoreOps& resolveOps,
const LoadStoreOps& stencilOps);
bool isCompatible(const AttachmentsDescriptor&, const AttachmentFlags&) const;
const GrVkImageView* stencilView = this->stencilAttachmentView();
fFramebuffer = GrVkFramebuffer::Create(gpu, this->width(), this->height(),
fCachedSimpleRenderPass, fColorAttachmentView,
- fResolveAttachmentView, stencilView);
+ stencilView);
SkASSERT(fFramebuffer);
}
desc->fColor.fSamples = colorSamples ? colorSamples : 1;
*attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag;
uint32_t attachmentCount = 1;
- if (colorSamples > 0) {
- desc->fResolve.fFormat = colorFormat;
- desc->fResolve.fSamples = 1;
- *attachmentFlags |= GrVkRenderPass::kResolve_AttachmentFlag;
- ++attachmentCount;
- }
const GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment();
if (stencil) {
void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer) const {
commandBuffer.addResource(this->framebuffer());
- commandBuffer.addResource(this->resource());
commandBuffer.addResource(this->colorAttachmentView());
- if (this->msaaImageResource()) {
- commandBuffer.addResource(this->msaaImageResource());
- commandBuffer.addResource(this->resolveAttachmentView());
- }
+ commandBuffer.addResource(this->msaaImageResource() ? this->msaaImageResource()
+ : this->resource());
if (this->stencilImageResource()) {
commandBuffer.addResource(this->stencilImageResource());
commandBuffer.addResource(this->stencilAttachmentView());
CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()];
const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu,
colorOps,
- resolveOps,
stencilOps);
renderPass->ref();
return renderPass;
GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass(
const GrVkGpu* gpu,
const GrVkRenderPass::LoadStoreOps& colorOps,
- const GrVkRenderPass::LoadStoreOps& resolveOps,
const GrVkRenderPass::LoadStoreOps& stencilOps) {
for (int i = 0; i < fRenderPasses.count(); ++i) {
int idx = (i + fLastReturnedIndex) % fRenderPasses.count();
- if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, resolveOps, stencilOps)) {
+ if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, stencilOps)) {
fLastReturnedIndex = idx;
return fRenderPasses[idx];
}
}
GrVkRenderPass* renderPass = fRenderPasses.emplace_back(new GrVkRenderPass());
- renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, resolveOps, stencilOps);
+ renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, stencilOps);
fLastReturnedIndex = fRenderPasses.count() - 1;
return renderPass;
}
GrVkRenderPass* getRenderPass(const GrVkGpu* gpu,
const GrVkRenderPass::LoadStoreOps& colorOps,
- const GrVkRenderPass::LoadStoreOps& resolveOps,
const GrVkRenderPass::LoadStoreOps& stencilOps);
void releaseResources(const GrVkGpu* gpu);
msImageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (!GrVkImage::InitImageInfo(gpu, msImageDesc, &msInfo)) {
+ imageView->unref(gpu);
return nullptr;
}