Commit fbc2f063 by Jamie Madill Committed by Commit Bot

Vulkan: Refactor AttachmentOpsArray.

Will allow for more flexibly setting ops when we defer clears. Bug: angleproject:4517 Change-Id: I7d9116bc92e90eb41a1030fea242eadf1cc74562 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2165629 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 6193fd69
......@@ -1357,9 +1357,9 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
ANGLE_TRY(colorRenderTarget->onColorDraw(contextVk));
renderPassAttachmentOps.initWithStore(
attachmentClearValues.size(), VK_ATTACHMENT_LOAD_OP_LOAD,
vk::ImageLayout::ColorAttachment, vk::ImageLayout::ColorAttachment);
renderPassAttachmentOps.initWithLoadStore(attachmentClearValues.size(),
vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
attachmentClearValues.emplace_back(kUninitializedClearValue);
}
......@@ -1375,9 +1375,13 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
{
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
}
renderPassAttachmentOps.initWithStore(attachmentClearValues.size(), loadOp,
vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
size_t index = attachmentClearValues.size();
renderPassAttachmentOps.setLayouts(index, vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
renderPassAttachmentOps.setOps(index, loadOp, VK_ATTACHMENT_STORE_OP_STORE);
renderPassAttachmentOps.setStencilOps(index, loadOp, VK_ATTACHMENT_STORE_OP_STORE);
// This must be called after hasDefinedContent() since it will set content to valid. We are
// tracking content valid very loosely here that as long as it is attached, it assumes will
......
......@@ -1189,9 +1189,8 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
std::vector<VkClearValue> clearValues = {{}};
ASSERT(clearValues.size() == 1);
renderPassAttachmentOps.initWithStore(0, VK_ATTACHMENT_LOAD_OP_LOAD,
vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
renderPassAttachmentOps.initWithLoadStore(0, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
ANGLE_TRY(contextVk->flushAndBeginRenderPass(framebuffer, renderArea, renderPassDesc,
renderPassAttachmentOps, clearValues,
......
......@@ -1442,33 +1442,40 @@ PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](size_t index)
return mOps[index];
}
void AttachmentOpsArray::initDummyOp(size_t index,
ImageLayout initialLayout,
ImageLayout finalLayout)
void AttachmentOpsArray::initWithLoadStore(size_t index,
ImageLayout initialLayout,
ImageLayout finalLayout)
{
PackedAttachmentOpsDesc &ops = mOps[index];
setLayouts(index, initialLayout, finalLayout);
setOps(index, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE);
setStencilOps(index, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE);
}
void AttachmentOpsArray::setLayouts(size_t index,
ImageLayout initialLayout,
ImageLayout finalLayout)
{
PackedAttachmentOpsDesc &ops = mOps[index];
SetBitField(ops.initialLayout, initialLayout);
SetBitField(ops.finalLayout, finalLayout);
SetBitField(ops.loadOp, VK_ATTACHMENT_LOAD_OP_LOAD);
SetBitField(ops.stencilLoadOp, VK_ATTACHMENT_LOAD_OP_DONT_CARE);
SetBitField(ops.storeOp, VK_ATTACHMENT_STORE_OP_STORE);
SetBitField(ops.stencilStoreOp, VK_ATTACHMENT_STORE_OP_DONT_CARE);
}
void AttachmentOpsArray::initWithStore(size_t index,
VkAttachmentLoadOp loadOp,
ImageLayout initialLayout,
ImageLayout finalLayout)
void AttachmentOpsArray::setOps(size_t index,
VkAttachmentLoadOp loadOp,
VkAttachmentStoreOp storeOp)
{
PackedAttachmentOpsDesc &ops = mOps[index];
SetBitField(ops.initialLayout, initialLayout);
SetBitField(ops.finalLayout, finalLayout);
SetBitField(ops.loadOp, loadOp);
SetBitField(ops.storeOp, storeOp);
}
void AttachmentOpsArray::setStencilOps(size_t index,
VkAttachmentLoadOp loadOp,
VkAttachmentStoreOp storeOp)
{
PackedAttachmentOpsDesc &ops = mOps[index];
SetBitField(ops.stencilLoadOp, loadOp);
SetBitField(ops.storeOp, VK_ATTACHMENT_STORE_OP_STORE);
SetBitField(ops.stencilStoreOp, VK_ATTACHMENT_STORE_OP_STORE);
SetBitField(ops.stencilStoreOp, storeOp);
}
size_t AttachmentOpsArray::hash() const
......@@ -1830,7 +1837,7 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
vk::RenderPass **renderPassOut)
{
// Insert some dummy attachment ops. Note that render passes with different ops are still
// compatible.
// compatible. The load/store values are not important as they are aren't used for real RPs.
//
// It would be nice to pre-populate the cache in the Renderer so we rarely miss here.
vk::AttachmentOpsArray ops;
......@@ -1844,15 +1851,15 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
}
uint32_t colorIndexVk = colorAttachmentCount++;
ops.initDummyOp(colorIndexVk, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
ops.initWithLoadStore(colorIndexVk, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
}
if (desc.hasDepthStencilAttachment())
{
uint32_t depthStencilIndexVk = colorAttachmentCount;
ops.initDummyOp(depthStencilIndexVk, vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
ops.initWithLoadStore(depthStencilIndexVk, vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
}
return getRenderPassWithOps(contextVk, serial, desc, ops, renderPassOut);
......
......@@ -153,13 +153,12 @@ class AttachmentOpsArray final
const PackedAttachmentOpsDesc &operator[](size_t index) const;
PackedAttachmentOpsDesc &operator[](size_t index);
// Initializes an attachment op with whatever values. Used for compatible RenderPass checks.
void initDummyOp(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
// Initialize an attachment op with store operations.
void initWithStore(size_t index,
VkAttachmentLoadOp loadOp,
ImageLayout initialLayout,
ImageLayout finalLayout);
// Initialize an attachment op with all load and store operations.
void initWithLoadStore(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
void setLayouts(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
void setOps(size_t index, VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp);
void setStencilOps(size_t index, VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp);
size_t hash() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment