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, ...@@ -1357,9 +1357,9 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
ANGLE_TRY(colorRenderTarget->onColorDraw(contextVk)); ANGLE_TRY(colorRenderTarget->onColorDraw(contextVk));
renderPassAttachmentOps.initWithStore( renderPassAttachmentOps.initWithLoadStore(attachmentClearValues.size(),
attachmentClearValues.size(), VK_ATTACHMENT_LOAD_OP_LOAD, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment, vk::ImageLayout::ColorAttachment); vk::ImageLayout::ColorAttachment);
attachmentClearValues.emplace_back(kUninitializedClearValue); attachmentClearValues.emplace_back(kUninitializedClearValue);
} }
...@@ -1375,9 +1375,13 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -1375,9 +1375,13 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
{ {
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
} }
renderPassAttachmentOps.initWithStore(attachmentClearValues.size(), loadOp,
vk::ImageLayout::DepthStencilAttachment, size_t index = attachmentClearValues.size();
vk::ImageLayout::DepthStencilAttachment);
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 // 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 // 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, ...@@ -1189,9 +1189,8 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
std::vector<VkClearValue> clearValues = {{}}; std::vector<VkClearValue> clearValues = {{}};
ASSERT(clearValues.size() == 1); ASSERT(clearValues.size() == 1);
renderPassAttachmentOps.initWithStore(0, VK_ATTACHMENT_LOAD_OP_LOAD, renderPassAttachmentOps.initWithLoadStore(0, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment, vk::ImageLayout::ColorAttachment);
vk::ImageLayout::ColorAttachment);
ANGLE_TRY(contextVk->flushAndBeginRenderPass(framebuffer, renderArea, renderPassDesc, ANGLE_TRY(contextVk->flushAndBeginRenderPass(framebuffer, renderArea, renderPassDesc,
renderPassAttachmentOps, clearValues, renderPassAttachmentOps, clearValues,
......
...@@ -1442,33 +1442,40 @@ PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](size_t index) ...@@ -1442,33 +1442,40 @@ PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](size_t index)
return mOps[index]; return mOps[index];
} }
void AttachmentOpsArray::initDummyOp(size_t index, void AttachmentOpsArray::initWithLoadStore(size_t index,
ImageLayout initialLayout, ImageLayout initialLayout,
ImageLayout finalLayout) 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.initialLayout, initialLayout);
SetBitField(ops.finalLayout, finalLayout); 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, void AttachmentOpsArray::setOps(size_t index,
VkAttachmentLoadOp loadOp, VkAttachmentLoadOp loadOp,
ImageLayout initialLayout, VkAttachmentStoreOp storeOp)
ImageLayout finalLayout)
{ {
PackedAttachmentOpsDesc &ops = mOps[index]; PackedAttachmentOpsDesc &ops = mOps[index];
SetBitField(ops.initialLayout, initialLayout);
SetBitField(ops.finalLayout, finalLayout);
SetBitField(ops.loadOp, loadOp); 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.stencilLoadOp, loadOp);
SetBitField(ops.storeOp, VK_ATTACHMENT_STORE_OP_STORE); SetBitField(ops.stencilStoreOp, storeOp);
SetBitField(ops.stencilStoreOp, VK_ATTACHMENT_STORE_OP_STORE);
} }
size_t AttachmentOpsArray::hash() const size_t AttachmentOpsArray::hash() const
...@@ -1830,7 +1837,7 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk, ...@@ -1830,7 +1837,7 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
vk::RenderPass **renderPassOut) vk::RenderPass **renderPassOut)
{ {
// Insert some dummy attachment ops. Note that render passes with different ops are still // 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. // It would be nice to pre-populate the cache in the Renderer so we rarely miss here.
vk::AttachmentOpsArray ops; vk::AttachmentOpsArray ops;
...@@ -1844,15 +1851,15 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk, ...@@ -1844,15 +1851,15 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
} }
uint32_t colorIndexVk = colorAttachmentCount++; uint32_t colorIndexVk = colorAttachmentCount++;
ops.initDummyOp(colorIndexVk, vk::ImageLayout::ColorAttachment, ops.initWithLoadStore(colorIndexVk, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment); vk::ImageLayout::ColorAttachment);
} }
if (desc.hasDepthStencilAttachment()) if (desc.hasDepthStencilAttachment())
{ {
uint32_t depthStencilIndexVk = colorAttachmentCount; uint32_t depthStencilIndexVk = colorAttachmentCount;
ops.initDummyOp(depthStencilIndexVk, vk::ImageLayout::DepthStencilAttachment, ops.initWithLoadStore(depthStencilIndexVk, vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment); vk::ImageLayout::DepthStencilAttachment);
} }
return getRenderPassWithOps(contextVk, serial, desc, ops, renderPassOut); return getRenderPassWithOps(contextVk, serial, desc, ops, renderPassOut);
......
...@@ -153,13 +153,12 @@ class AttachmentOpsArray final ...@@ -153,13 +153,12 @@ class AttachmentOpsArray final
const PackedAttachmentOpsDesc &operator[](size_t index) const; const PackedAttachmentOpsDesc &operator[](size_t index) const;
PackedAttachmentOpsDesc &operator[](size_t index); PackedAttachmentOpsDesc &operator[](size_t index);
// Initializes an attachment op with whatever values. Used for compatible RenderPass checks. // Initialize an attachment op with all load and store operations.
void initDummyOp(size_t index, ImageLayout initialLayout, ImageLayout finalLayout); void initWithLoadStore(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
// Initialize an attachment op with store operations.
void initWithStore(size_t index, void setLayouts(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
VkAttachmentLoadOp loadOp, void setOps(size_t index, VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp);
ImageLayout initialLayout, void setStencilOps(size_t index, VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp);
ImageLayout finalLayout);
size_t hash() const; 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