Don't add the resolve attachment to vulkan render passes.
Also includes some other msaa bug fixes BUG=skia:5127 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2256843002 Review-Url: https://codereview.chromium.org/2256843002
This commit is contained in:
parent
fab4a9b988
commit
ce3bfb1ed1
@ -15,7 +15,6 @@ GrVkFramebuffer* GrVkFramebuffer::Create(GrVkGpu* gpu,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
const GrVkRenderPass* renderPass,
|
const GrVkRenderPass* renderPass,
|
||||||
const GrVkImageView* colorAttachment,
|
const GrVkImageView* colorAttachment,
|
||||||
const GrVkImageView* resolveAttachment,
|
|
||||||
const GrVkImageView* stencilAttachment) {
|
const GrVkImageView* stencilAttachment) {
|
||||||
// At the very least we need a renderPass and a colorAttachment
|
// At the very least we need a renderPass and a colorAttachment
|
||||||
SkASSERT(renderPass);
|
SkASSERT(renderPass);
|
||||||
@ -24,9 +23,6 @@ GrVkFramebuffer* GrVkFramebuffer::Create(GrVkGpu* gpu,
|
|||||||
VkImageView attachments[3];
|
VkImageView attachments[3];
|
||||||
attachments[0] = colorAttachment->imageView();
|
attachments[0] = colorAttachment->imageView();
|
||||||
int numAttachments = 1;
|
int numAttachments = 1;
|
||||||
if (resolveAttachment) {
|
|
||||||
attachments[numAttachments++] = resolveAttachment->imageView();
|
|
||||||
}
|
|
||||||
if (stencilAttachment) {
|
if (stencilAttachment) {
|
||||||
attachments[numAttachments++] = stencilAttachment->imageView();
|
attachments[numAttachments++] = stencilAttachment->imageView();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ public:
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
const GrVkRenderPass* renderPass,
|
const GrVkRenderPass* renderPass,
|
||||||
const GrVkImageView* colorAttachment,
|
const GrVkImageView* colorAttachment,
|
||||||
const GrVkImageView* resolveAttachment,
|
|
||||||
const GrVkImageView* stencilAttachment);
|
const GrVkImageView* stencilAttachment);
|
||||||
|
|
||||||
VkFramebuffer framebuffer() const { return fFramebuffer; }
|
VkFramebuffer framebuffer() const { return fFramebuffer; }
|
||||||
|
@ -401,7 +401,7 @@ void GrVkGpu::onResolveRenderTarget(GrRenderTarget* target) {
|
|||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
fCurrentCmdBuffer->resolveImage(this, *rt, *rt->msaaImage(), 1, &resolveInfo);
|
fCurrentCmdBuffer->resolveImage(this, *rt->msaaImage(), *rt, 1, &resolveInfo);
|
||||||
|
|
||||||
rt->flagAsResolved();
|
rt->flagAsResolved();
|
||||||
}
|
}
|
||||||
@ -1800,6 +1800,6 @@ void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer,
|
|||||||
fCurrentCmdBuffer->executeCommands(this, buffer);
|
fCurrentCmdBuffer->executeCommands(this, buffer);
|
||||||
fCurrentCmdBuffer->endRenderPass(this);
|
fCurrentCmdBuffer->endRenderPass(this);
|
||||||
|
|
||||||
this->didWriteToSurface(target, pBounds);
|
this->didWriteToSurface(target, &bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,12 +100,15 @@ void GrVkGpuCommandBuffer::end() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
|
void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
|
||||||
// Change layout of our render target so it can be used as the color attachment
|
// Change layout of our render target so it can be used as the color attachment. Currently
|
||||||
fRenderTarget->setImageLayout(fGpu,
|
// we don't attach the resolve to the framebuffer so no need to change its layout.
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaImage()
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
: fRenderTarget;
|
||||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
targetImage->setImageLayout(fGpu,
|
||||||
false);
|
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 we are using a stencil attachment we also need to update its layout
|
||||||
if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment()) {
|
if (GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment()) {
|
||||||
@ -118,14 +121,6 @@ void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
|
|||||||
false);
|
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) {
|
for (int i = 0; i < fSampledImages.count(); ++i) {
|
||||||
fSampledImages[i]->setImageLayout(fGpu,
|
fSampledImages[i]->setImageLayout(fGpu,
|
||||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
|
@ -46,12 +46,11 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ
|
|||||||
static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD,
|
static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
VK_ATTACHMENT_STORE_OP_STORE);
|
VK_ATTACHMENT_STORE_OP_STORE);
|
||||||
|
|
||||||
this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps, kBasicLoadStoreOps);
|
this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
||||||
const LoadStoreOps& colorOp,
|
const LoadStoreOps& colorOp,
|
||||||
const LoadStoreOps& resolveOp,
|
|
||||||
const LoadStoreOps& stencilOp) {
|
const LoadStoreOps& stencilOp) {
|
||||||
uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount;
|
uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount;
|
||||||
// Attachment descriptions to be set on the render pass
|
// Attachment descriptions to be set on the render pass
|
||||||
@ -62,11 +61,10 @@ void GrVkRenderPass::init(const GrVkGpu* gpu,
|
|||||||
// Refs to attachments on the render pass (as described by teh VkAttachmentDescription above),
|
// Refs to attachments on the render pass (as described by teh VkAttachmentDescription above),
|
||||||
// that are used by the subpass.
|
// that are used by the subpass.
|
||||||
VkAttachmentReference colorRef;
|
VkAttachmentReference colorRef;
|
||||||
VkAttachmentReference resolveRef;
|
|
||||||
VkAttachmentReference stencilRef;
|
VkAttachmentReference stencilRef;
|
||||||
uint32_t currentAttachment = 0;
|
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.
|
// on the various Vk structs.
|
||||||
VkSubpassDescription subpassDesc;
|
VkSubpassDescription subpassDesc;
|
||||||
memset(&subpassDesc, 0, sizeof(VkSubpassDescription));
|
memset(&subpassDesc, 0, sizeof(VkSubpassDescription));
|
||||||
@ -74,6 +72,8 @@ void GrVkRenderPass::init(const GrVkGpu* gpu,
|
|||||||
subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||||
subpassDesc.inputAttachmentCount = 0;
|
subpassDesc.inputAttachmentCount = 0;
|
||||||
subpassDesc.pInputAttachments = nullptr;
|
subpassDesc.pInputAttachments = nullptr;
|
||||||
|
subpassDesc.pResolveAttachments = nullptr;
|
||||||
|
|
||||||
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
||||||
// set up color attachment
|
// set up color attachment
|
||||||
fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp;
|
fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp;
|
||||||
@ -93,21 +93,6 @@ void GrVkRenderPass::init(const GrVkGpu* gpu,
|
|||||||
}
|
}
|
||||||
subpassDesc.pColorAttachments = &colorRef;
|
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) {
|
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
||||||
// set up stencil attachment
|
// set up stencil attachment
|
||||||
fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp;
|
fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp;
|
||||||
@ -155,22 +140,20 @@ void GrVkRenderPass::init(const GrVkGpu* gpu,
|
|||||||
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
||||||
const GrVkRenderPass& compatibleRenderPass,
|
const GrVkRenderPass& compatibleRenderPass,
|
||||||
const LoadStoreOps& colorOp,
|
const LoadStoreOps& colorOp,
|
||||||
const LoadStoreOps& resolveOp,
|
|
||||||
const LoadStoreOps& stencilOp) {
|
const LoadStoreOps& stencilOp) {
|
||||||
fAttachmentFlags = compatibleRenderPass.fAttachmentFlags;
|
fAttachmentFlags = compatibleRenderPass.fAttachmentFlags;
|
||||||
fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor;
|
fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor;
|
||||||
this->init(gpu, colorOp, resolveOp, stencilOp);
|
this->init(gpu, colorOp, stencilOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
void GrVkRenderPass::init(const GrVkGpu* gpu,
|
||||||
const GrVkRenderTarget& target,
|
const GrVkRenderTarget& target,
|
||||||
const LoadStoreOps& colorOp,
|
const LoadStoreOps& colorOp,
|
||||||
const LoadStoreOps& resolveOp,
|
|
||||||
const LoadStoreOps& stencilOp) {
|
const LoadStoreOps& stencilOp) {
|
||||||
// Get attachment information from render target. This includes which attachments the render
|
// 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);
|
target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags);
|
||||||
this->init(gpu, colorOp, resolveOp, stencilOp);
|
this->init(gpu, colorOp, stencilOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const {
|
void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const {
|
||||||
@ -187,18 +170,6 @@ bool GrVkRenderPass::colorAttachmentIndex(uint32_t* index) const {
|
|||||||
return false;
|
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
|
// Works under the assumption that stencil attachment will always be after the color and resolve
|
||||||
// attachment.
|
// attachment.
|
||||||
bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const {
|
bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const {
|
||||||
@ -206,9 +177,6 @@ bool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const {
|
|||||||
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
||||||
++(*index);
|
++(*index);
|
||||||
}
|
}
|
||||||
if (fAttachmentFlags & kResolve_AttachmentFlag) {
|
|
||||||
++(*index);
|
|
||||||
}
|
|
||||||
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -249,11 +217,6 @@ bool GrVkRenderPass::isCompatible(const AttachmentsDescriptor& desc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fAttachmentFlags & kResolve_AttachmentFlag) {
|
|
||||||
if (!fAttachmentsDescriptor.fResolve.isCompatible(desc.fResolve)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
||||||
if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) {
|
if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) {
|
||||||
return false;
|
return false;
|
||||||
@ -276,18 +239,12 @@ bool GrVkRenderPass::isCompatible(const GrVkRenderPass& renderPass) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps,
|
bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps,
|
||||||
const LoadStoreOps& resolveOps,
|
|
||||||
const LoadStoreOps& stencilOps) const {
|
const LoadStoreOps& stencilOps) const {
|
||||||
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
if (fAttachmentFlags & kColor_AttachmentFlag) {
|
||||||
if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) {
|
if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fAttachmentFlags & kResolve_AttachmentFlag) {
|
|
||||||
if (fAttachmentsDescriptor.fResolve.fLoadStoreOps != resolveOps) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
||||||
if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) {
|
if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) {
|
||||||
return false;
|
return false;
|
||||||
@ -302,10 +259,6 @@ void GrVkRenderPass::genKey(GrProcessorKeyBuilder* b) const {
|
|||||||
b->add32(fAttachmentsDescriptor.fColor.fFormat);
|
b->add32(fAttachmentsDescriptor.fColor.fFormat);
|
||||||
b->add32(fAttachmentsDescriptor.fColor.fSamples);
|
b->add32(fAttachmentsDescriptor.fColor.fSamples);
|
||||||
}
|
}
|
||||||
if (fAttachmentFlags & kResolve_AttachmentFlag) {
|
|
||||||
b->add32(fAttachmentsDescriptor.fResolve.fFormat);
|
|
||||||
b->add32(fAttachmentsDescriptor.fResolve.fSamples);
|
|
||||||
}
|
|
||||||
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
if (fAttachmentFlags & kStencil_AttachmentFlag) {
|
||||||
b->add32(fAttachmentsDescriptor.fStencil.fFormat);
|
b->add32(fAttachmentsDescriptor.fStencil.fFormat);
|
||||||
b->add32(fAttachmentsDescriptor.fStencil.fSamples);
|
b->add32(fAttachmentsDescriptor.fStencil.fSamples);
|
||||||
|
@ -43,13 +43,11 @@ public:
|
|||||||
void init(const GrVkGpu* gpu,
|
void init(const GrVkGpu* gpu,
|
||||||
const GrVkRenderTarget& target,
|
const GrVkRenderTarget& target,
|
||||||
const LoadStoreOps& colorOp,
|
const LoadStoreOps& colorOp,
|
||||||
const LoadStoreOps& resolveOp,
|
|
||||||
const LoadStoreOps& stencilOp);
|
const LoadStoreOps& stencilOp);
|
||||||
|
|
||||||
void init(const GrVkGpu* gpu,
|
void init(const GrVkGpu* gpu,
|
||||||
const GrVkRenderPass& compatibleRenderPass,
|
const GrVkRenderPass& compatibleRenderPass,
|
||||||
const LoadStoreOps& colorOp,
|
const LoadStoreOps& colorOp,
|
||||||
const LoadStoreOps& resolveOp,
|
|
||||||
const LoadStoreOps& stencilOp);
|
const LoadStoreOps& stencilOp);
|
||||||
|
|
||||||
struct AttachmentsDescriptor {
|
struct AttachmentsDescriptor {
|
||||||
@ -75,15 +73,13 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
AttachmentDesc fColor;
|
AttachmentDesc fColor;
|
||||||
AttachmentDesc fResolve;
|
|
||||||
AttachmentDesc fStencil;
|
AttachmentDesc fStencil;
|
||||||
uint32_t fAttachmentCount;
|
uint32_t fAttachmentCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AttachmentFlags {
|
enum AttachmentFlags {
|
||||||
kColor_AttachmentFlag = 0x1,
|
kColor_AttachmentFlag = 0x1,
|
||||||
kResolve_AttachmentFlag = 0x2,
|
kStencil_AttachmentFlag = 0x2,
|
||||||
kStencil_AttachmentFlag = 0x4,
|
|
||||||
};
|
};
|
||||||
GR_DECL_BITFIELD_OPS_FRIENDS(AttachmentFlags);
|
GR_DECL_BITFIELD_OPS_FRIENDS(AttachmentFlags);
|
||||||
|
|
||||||
@ -91,7 +87,6 @@ public:
|
|||||||
// If the render pass does not have the given attachment it will return false and not set the
|
// If the render pass does not have the given attachment it will return false and not set the
|
||||||
// index value.
|
// index value.
|
||||||
bool colorAttachmentIndex(uint32_t* index) const;
|
bool colorAttachmentIndex(uint32_t* index) const;
|
||||||
bool resolveAttachmentIndex(uint32_t* index) const;
|
|
||||||
bool stencilAttachmentIndex(uint32_t* index) const;
|
bool stencilAttachmentIndex(uint32_t* index) const;
|
||||||
|
|
||||||
// Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a render pass.
|
// Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a render pass.
|
||||||
@ -113,7 +108,6 @@ public:
|
|||||||
bool isCompatible(const GrVkRenderPass& renderPass) const;
|
bool isCompatible(const GrVkRenderPass& renderPass) const;
|
||||||
|
|
||||||
bool equalLoadStoreOps(const LoadStoreOps& colorOps,
|
bool equalLoadStoreOps(const LoadStoreOps& colorOps,
|
||||||
const LoadStoreOps& resolveOps,
|
|
||||||
const LoadStoreOps& stencilOps) const;
|
const LoadStoreOps& stencilOps) const;
|
||||||
|
|
||||||
VkRenderPass vkRenderPass() const { return fRenderPass; }
|
VkRenderPass vkRenderPass() const { return fRenderPass; }
|
||||||
@ -133,7 +127,6 @@ private:
|
|||||||
|
|
||||||
void init(const GrVkGpu* gpu,
|
void init(const GrVkGpu* gpu,
|
||||||
const LoadStoreOps& colorOps,
|
const LoadStoreOps& colorOps,
|
||||||
const LoadStoreOps& resolveOps,
|
|
||||||
const LoadStoreOps& stencilOps);
|
const LoadStoreOps& stencilOps);
|
||||||
|
|
||||||
bool isCompatible(const AttachmentsDescriptor&, const AttachmentFlags&) const;
|
bool isCompatible(const AttachmentsDescriptor&, const AttachmentFlags&) const;
|
||||||
|
@ -239,7 +239,7 @@ void GrVkRenderTarget::createFramebuffer(GrVkGpu* gpu) {
|
|||||||
const GrVkImageView* stencilView = this->stencilAttachmentView();
|
const GrVkImageView* stencilView = this->stencilAttachmentView();
|
||||||
fFramebuffer = GrVkFramebuffer::Create(gpu, this->width(), this->height(),
|
fFramebuffer = GrVkFramebuffer::Create(gpu, this->width(), this->height(),
|
||||||
fCachedSimpleRenderPass, fColorAttachmentView,
|
fCachedSimpleRenderPass, fColorAttachmentView,
|
||||||
fResolveAttachmentView, stencilView);
|
stencilView);
|
||||||
SkASSERT(fFramebuffer);
|
SkASSERT(fFramebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,12 +253,6 @@ void GrVkRenderTarget::getAttachmentsDescriptor(
|
|||||||
desc->fColor.fSamples = colorSamples ? colorSamples : 1;
|
desc->fColor.fSamples = colorSamples ? colorSamples : 1;
|
||||||
*attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag;
|
*attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag;
|
||||||
uint32_t attachmentCount = 1;
|
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();
|
const GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment();
|
||||||
if (stencil) {
|
if (stencil) {
|
||||||
@ -284,12 +278,9 @@ GrVkRenderTarget::~GrVkRenderTarget() {
|
|||||||
|
|
||||||
void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer) const {
|
void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer) const {
|
||||||
commandBuffer.addResource(this->framebuffer());
|
commandBuffer.addResource(this->framebuffer());
|
||||||
commandBuffer.addResource(this->resource());
|
|
||||||
commandBuffer.addResource(this->colorAttachmentView());
|
commandBuffer.addResource(this->colorAttachmentView());
|
||||||
if (this->msaaImageResource()) {
|
commandBuffer.addResource(this->msaaImageResource() ? this->msaaImageResource()
|
||||||
commandBuffer.addResource(this->msaaImageResource());
|
: this->resource());
|
||||||
commandBuffer.addResource(this->resolveAttachmentView());
|
|
||||||
}
|
|
||||||
if (this->stencilImageResource()) {
|
if (this->stencilImageResource()) {
|
||||||
commandBuffer.addResource(this->stencilImageResource());
|
commandBuffer.addResource(this->stencilImageResource());
|
||||||
commandBuffer.addResource(this->stencilAttachmentView());
|
commandBuffer.addResource(this->stencilAttachmentView());
|
||||||
|
@ -130,7 +130,6 @@ GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle,
|
|||||||
CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()];
|
CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()];
|
||||||
const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu,
|
const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu,
|
||||||
colorOps,
|
colorOps,
|
||||||
resolveOps,
|
|
||||||
stencilOps);
|
stencilOps);
|
||||||
renderPass->ref();
|
renderPass->ref();
|
||||||
return renderPass;
|
return renderPass;
|
||||||
@ -417,17 +416,16 @@ bool GrVkResourceProvider::CompatibleRenderPassSet::isCompatible(
|
|||||||
GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass(
|
GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass(
|
||||||
const GrVkGpu* gpu,
|
const GrVkGpu* gpu,
|
||||||
const GrVkRenderPass::LoadStoreOps& colorOps,
|
const GrVkRenderPass::LoadStoreOps& colorOps,
|
||||||
const GrVkRenderPass::LoadStoreOps& resolveOps,
|
|
||||||
const GrVkRenderPass::LoadStoreOps& stencilOps) {
|
const GrVkRenderPass::LoadStoreOps& stencilOps) {
|
||||||
for (int i = 0; i < fRenderPasses.count(); ++i) {
|
for (int i = 0; i < fRenderPasses.count(); ++i) {
|
||||||
int idx = (i + fLastReturnedIndex) % fRenderPasses.count();
|
int idx = (i + fLastReturnedIndex) % fRenderPasses.count();
|
||||||
if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, resolveOps, stencilOps)) {
|
if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, stencilOps)) {
|
||||||
fLastReturnedIndex = idx;
|
fLastReturnedIndex = idx;
|
||||||
return fRenderPasses[idx];
|
return fRenderPasses[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GrVkRenderPass* renderPass = fRenderPasses.emplace_back(new GrVkRenderPass());
|
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;
|
fLastReturnedIndex = fRenderPasses.count() - 1;
|
||||||
return renderPass;
|
return renderPass;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,6 @@ private:
|
|||||||
|
|
||||||
GrVkRenderPass* getRenderPass(const GrVkGpu* gpu,
|
GrVkRenderPass* getRenderPass(const GrVkGpu* gpu,
|
||||||
const GrVkRenderPass::LoadStoreOps& colorOps,
|
const GrVkRenderPass::LoadStoreOps& colorOps,
|
||||||
const GrVkRenderPass::LoadStoreOps& resolveOps,
|
|
||||||
const GrVkRenderPass::LoadStoreOps& stencilOps);
|
const GrVkRenderPass::LoadStoreOps& stencilOps);
|
||||||
|
|
||||||
void releaseResources(const GrVkGpu* gpu);
|
void releaseResources(const GrVkGpu* gpu);
|
||||||
|
@ -53,6 +53,7 @@ GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
|
|||||||
msImageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
msImageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||||
|
|
||||||
if (!GrVkImage::InitImageInfo(gpu, msImageDesc, &msInfo)) {
|
if (!GrVkImage::InitImageInfo(gpu, msImageDesc, &msInfo)) {
|
||||||
|
imageView->unref(gpu);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user