Commit 8c67c079 by Charlie Lao Committed by Commit Bot

Vulkan: store ImageLayout in PackedAttachmentOpsDesc

The layout in the PackedAttachmentOpsDesc only have 5 bits, not enough for raw VKImageLayout enums. This change will store vk::ImageLayout which are ANGLE defined and packed for 5 bits and able to handle the extension bits of VKImageLayout. Bug: b/153885625 Change-Id: Ida268a974094188d8aeee39c61019eef30a60507 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2153845 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6cea4405
......@@ -1358,8 +1358,8 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
ANGLE_TRY(colorRenderTarget->onColorDraw(contextVk));
renderPassAttachmentOps.initWithLoadStore(attachmentClearValues.size(),
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
attachmentClearValues.emplace_back(kUninitializedClearValue);
}
......@@ -1369,8 +1369,8 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
ANGLE_TRY(depthStencilRenderTarget->onDepthStencilDraw(contextVk));
renderPassAttachmentOps.initWithLoadStore(attachmentClearValues.size(),
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
attachmentClearValues.emplace_back(kUninitializedClearValue);
}
......
......@@ -1189,8 +1189,8 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
std::vector<VkClearValue> clearValues = {{}};
ASSERT(clearValues.size() == 1);
renderPassAttachmentOps.initWithLoadStore(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
renderPassAttachmentOps.initWithLoadStore(0, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
ANGLE_TRY(contextVk->flushAndBeginRenderPass(framebuffer, renderArea, renderPassDesc,
renderPassAttachmentOps, clearValues,
......
......@@ -155,8 +155,10 @@ void UnpackAttachmentDesc(VkAttachmentDescription *desc,
desc->storeOp = static_cast<VkAttachmentStoreOp>(ops.storeOp);
desc->stencilLoadOp = static_cast<VkAttachmentLoadOp>(ops.stencilLoadOp);
desc->stencilStoreOp = static_cast<VkAttachmentStoreOp>(ops.stencilStoreOp);
desc->initialLayout = static_cast<VkImageLayout>(ops.initialLayout);
desc->finalLayout = static_cast<VkImageLayout>(ops.finalLayout);
desc->initialLayout =
ConvertImageLayoutToVkImageLayout(static_cast<ImageLayout>(ops.initialLayout));
desc->finalLayout =
ConvertImageLayoutToVkImageLayout(static_cast<ImageLayout>(ops.finalLayout));
}
void UnpackStencilState(const vk::PackedStencilOpState &packedState,
......@@ -1441,8 +1443,8 @@ PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](size_t index)
}
void AttachmentOpsArray::initDummyOp(size_t index,
VkImageLayout initialLayout,
VkImageLayout finalLayout)
ImageLayout initialLayout,
ImageLayout finalLayout)
{
PackedAttachmentOpsDesc &ops = mOps[index];
......@@ -1455,8 +1457,8 @@ void AttachmentOpsArray::initDummyOp(size_t index,
}
void AttachmentOpsArray::initWithLoadStore(size_t index,
VkImageLayout initialLayout,
VkImageLayout finalLayout)
ImageLayout initialLayout,
ImageLayout finalLayout)
{
PackedAttachmentOpsDesc &ops = mOps[index];
......@@ -1732,15 +1734,15 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
}
uint32_t colorIndexVk = colorAttachmentCount++;
ops.initDummyOp(colorIndexVk, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
ops.initDummyOp(colorIndexVk, vk::ImageLayout::ColorAttachment,
vk::ImageLayout::ColorAttachment);
}
if (desc.hasDepthStencilAttachment())
{
uint32_t depthStencilIndexVk = colorAttachmentCount;
ops.initDummyOp(depthStencilIndexVk, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
ops.initDummyOp(depthStencilIndexVk, vk::ImageLayout::DepthStencilAttachment,
vk::ImageLayout::DepthStencilAttachment);
}
return getRenderPassWithOps(contextVk, serial, desc, ops, renderPassOut);
......
......@@ -21,6 +21,7 @@ namespace rx
namespace vk
{
class ImageHelper;
enum class ImageLayout;
using RenderPassAndSerial = ObjectAndSerial<RenderPass>;
using PipelineAndSerial = ObjectAndSerial<Pipeline>;
......@@ -152,9 +153,9 @@ class AttachmentOpsArray final
PackedAttachmentOpsDesc &operator[](size_t index);
// Initializes an attachment op with whatever values. Used for compatible RenderPass checks.
void initDummyOp(size_t index, VkImageLayout initialLayout, VkImageLayout finalLayout);
void initDummyOp(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
// Initialize an attachment op with all load and store operations.
void initWithLoadStore(size_t index, VkImageLayout initialLayout, VkImageLayout finalLayout);
void initWithLoadStore(size_t index, ImageLayout initialLayout, ImageLayout finalLayout);
size_t hash() const;
......
......@@ -448,6 +448,11 @@ VkClearValue GetClearValue(const vk::Format &format)
}
} // anonymous namespace
VkImageLayout ConvertImageLayoutToVkImageLayout(ImageLayout imageLayout)
{
return kImageMemoryBarrierData[imageLayout].layout;
}
// DynamicBuffer implementation.
DynamicBuffer::DynamicBuffer()
: mUsage(0),
......
......@@ -719,6 +719,8 @@ enum class ImageLayout
EnumCount = 19,
};
VkImageLayout ConvertImageLayoutToVkImageLayout(ImageLayout imageLayout);
class ImageHelper final : public Resource, public angle::Subject
{
public:
......
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