void GrVkPrimaryCommandBuffer::beginRenderPass(const GrVkGpu* gpu,
const GrVkRenderPass* renderPass,
- uint32_t clearCount,
const VkClearValue* clearValues,
const GrVkRenderTarget& target,
const SkIRect& bounds,
beginInfo.renderPass = renderPass->vkRenderPass();
beginInfo.framebuffer = target.framebuffer()->framebuffer();
beginInfo.renderArea = renderArea;
- beginInfo.clearValueCount = clearCount;
+ beginInfo.clearValueCount = renderPass->clearValueCount();
beginInfo.pClearValues = clearValues;
VkSubpassContents contents = forSecondaryCB ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
// in the render pass.
void beginRenderPass(const GrVkGpu* gpu,
const GrVkRenderPass* renderPass,
- uint32_t clearCount,
const VkClearValue* clearValues,
const GrVkRenderTarget& target,
const SkIRect& bounds,
SkASSERT(renderPass->isCompatible(*rt->simpleRenderPass()));
- cmdBuffer->beginRenderPass(gpu, renderPass, 0, nullptr, *rt, bounds, false);
+ cmdBuffer->beginRenderPass(gpu, renderPass, nullptr, *rt, bounds, false);
cmdBuffer->bindPipeline(gpu, pipeline);
// Uniform DescriptorSet, Sampler DescriptorSet, and vertex shader uniformBuffer
pBounds = &adjustedBounds;
}
- // Currently it is fine for us to always pass in 1 for the clear count even if no attachment
- // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment
- // which is always at the first attachment.
- fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true);
+ fCurrentCmdBuffer->beginRenderPass(this, renderPass, colorClear, *target, *pBounds, true);
fCurrentCmdBuffer->executeCommands(this, buffer);
fCurrentCmdBuffer->endRenderPass(this);
colorRef.attachment = currentAttachment++;
colorRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
subpassDesc.colorAttachmentCount = 1;
+
+ if (VK_ATTACHMENT_LOAD_OP_CLEAR == colorOp.fLoadOp) {
+ fClearValueCount++;
+ }
} else {
// I don't think there should ever be a time where we don't have a color attachment
SkASSERT(false);
// setup subpass use of attachment
stencilRef.attachment = currentAttachment++;
stencilRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ if (VK_ATTACHMENT_LOAD_OP_CLEAR == stencilOp.fLoadOp) {
+ fClearValueCount++;
+ }
} else {
stencilRef.attachment = VK_ATTACHMENT_UNUSED;
stencilRef.layout = VK_IMAGE_LAYOUT_UNDEFINED;
}
void GrVkRenderPass::init(const GrVkGpu* gpu,
- const GrVkRenderTarget& target,
+ const GrVkRenderTarget& target,
const LoadStoreOps& colorOp,
const LoadStoreOps& stencilOp) {
// Get attachment information from render target. This includes which attachments the render
return false;
}
-void GrVkRenderPass::getBeginInfo(const GrVkRenderTarget& target,
- VkRenderPassBeginInfo* beginInfo,
- VkSubpassContents* contents) const {
- SkASSERT(this->isCompatible(target));
-
- VkRect2D renderArea;
- renderArea.offset = { 0, 0 };
- renderArea.extent = { (uint32_t)target.width(), (uint32_t)target.height() };
-
- memset(beginInfo, 0, sizeof(VkRenderPassBeginInfo));
- beginInfo->sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- beginInfo->pNext = nullptr;
- beginInfo->renderPass = fRenderPass;
- beginInfo->framebuffer = target.framebuffer()->framebuffer();
- beginInfo->renderArea = renderArea;
- beginInfo->clearValueCount = 0;
- beginInfo->pClearValues = nullptr;
-
- // Currently just assuming no secondary cmd buffers. This value will need to be update if we
- // have them.
- *contents = VK_SUBPASS_CONTENTS_INLINE;
-}
-
bool GrVkRenderPass::isCompatible(const AttachmentsDescriptor& desc,
const AttachmentFlags& flags) const {
if (flags != fAttachmentFlags) {
class GrVkRenderPass : public GrVkResource {
public:
- GrVkRenderPass() : INHERITED(), fRenderPass(VK_NULL_HANDLE) {}
+ GrVkRenderPass() : INHERITED(), fRenderPass(VK_NULL_HANDLE), fClearValueCount(0) {}
struct LoadStoreOps {
VkAttachmentLoadOp fLoadOp;
bool colorAttachmentIndex(uint32_t* index) const;
bool stencilAttachmentIndex(uint32_t* index) const;
- // Sets the VkRenderPassBeginInfo and VkRenderPassContents need to begin a render pass.
- // TODO: In the future I expect this function will also take an optional render area instead of
- // defaulting to the entire render target.
- // TODO: Figure out if load clear values should be passed into this function or should be stored
- // on the GrVkRenderPass at create time since we'll know at that point if we want to do a load
- // clear.
- void getBeginInfo(const GrVkRenderTarget& target,
- VkRenderPassBeginInfo* beginInfo,
- VkSubpassContents* contents) const;
-
// Returns whether or not the structure of a RenderTarget matches that of the VkRenderPass in
// this object. Specifically this compares that the number of attachments, format of
// attachments, and sample counts are all the same. This function is used in the creation of
const VkExtent2D& granularity() const { return fGranularity; }
+ // Returns the number of clear colors needed to begin this render pass. Currently this will
+ // either only be 0 or 1 since we only ever clear the color attachment.
+ uint32_t clearValueCount() const { return fClearValueCount; }
+
+
void genKey(GrProcessorKeyBuilder* b) const;
#ifdef SK_TRACE_VK_RESOURCES
AttachmentFlags fAttachmentFlags;
AttachmentsDescriptor fAttachmentsDescriptor;
VkExtent2D fGranularity;
+ uint32_t fClearValueCount;
typedef GrVkResource INHERITED;
};