Commit 964c4089 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: fix RenderPassDesc::mColorAttachmentRange

This variable tracks the index range of color attachments. A previous change (d8ce865b) made the range inclusive so it can fit in 3 bits, but that's incorrect as it's no longer possible to specify a range where no color attachments are present. This change partially reverts d8ce865b to restore the previous semantics of RenderPassDesc::mColorAttachmentRange. Bug: chromium:1107884 Change-Id: I08da2568b5e63a48a672edd499a8b6653060eadb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2310578Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 6ca2c116
......@@ -222,7 +222,7 @@ angle::Result InitializeRenderPassFromDesc(vk::Context *context,
uint32_t colorAttachmentCount = 0;
uint32_t attachmentCount = 0;
for (uint32_t colorIndexGL = 0; colorIndexGL <= desc.colorAttachmentRange(); ++colorIndexGL)
for (uint32_t colorIndexGL = 0; colorIndexGL < desc.colorAttachmentRange(); ++colorIndexGL)
{
// Vulkan says:
//
......@@ -422,8 +422,8 @@ void RenderPassDesc::packColorAttachment(size_t colorIndexGL, angle::FormatID fo
SetBitField(packedFormat, formatID);
// Set color attachment range such that it covers the range from index 0 through last
// active index inclusive. This is the reason why we need depth/stencil to be packed last.
SetBitField(mColorAttachmentRange, std::max<size_t>(mColorAttachmentRange, colorIndexGL));
// active index. This is the reason why we need depth/stencil to be packed last.
SetBitField(mColorAttachmentRange, std::max<size_t>(mColorAttachmentRange, colorIndexGL + 1));
}
void RenderPassDesc::packColorAttachmentGap(size_t colorIndexGL)
......@@ -473,7 +473,7 @@ bool RenderPassDesc::isColorAttachmentEnabled(size_t colorIndexGL) const
size_t RenderPassDesc::attachmentCount() const
{
size_t colorAttachmentCount = 0;
for (size_t i = 0; i <= mColorAttachmentRange; ++i)
for (size_t i = 0; i < mColorAttachmentRange; ++i)
{
colorAttachmentCount += isColorAttachmentEnabled(i);
}
......@@ -896,7 +896,7 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
blendState.flags = 0;
blendState.logicOpEnable = static_cast<VkBool32>(inputAndBlend.logic.opEnable);
blendState.logicOp = static_cast<VkLogicOp>(inputAndBlend.logic.op);
blendState.attachmentCount = static_cast<uint32_t>(mRenderPassDesc.colorAttachmentRange() + 1);
blendState.attachmentCount = static_cast<uint32_t>(mRenderPassDesc.colorAttachmentRange());
blendState.pAttachments = blendAttachmentState.data();
for (int i = 0; i < 4; i++)
......@@ -1979,7 +1979,7 @@ angle::Result RenderPassCache::addRenderPass(ContextVk *contextVk,
vk::AttachmentOpsArray ops;
uint32_t colorAttachmentCount = 0;
for (uint32_t colorIndexGL = 0; colorIndexGL <= desc.colorAttachmentRange(); ++colorIndexGL)
for (uint32_t colorIndexGL = 0; colorIndexGL < desc.colorAttachmentRange(); ++colorIndexGL)
{
if (!desc.isColorAttachmentEnabled(colorIndexGL))
{
......
......@@ -73,14 +73,14 @@ class alignas(4) RenderPassDesc final
// Mark a GL color attachment index as disabled.
void packColorAttachmentGap(size_t colorIndexGL);
// The caller must pack the depth/stencil attachment last, which is packed right after the color
// attachments (including gaps), i.e. with an index starting from |colorAttachmentRange() + 1|.
// attachments (including gaps), i.e. with an index starting from |colorAttachmentRange()|.
void packDepthStencilAttachment(angle::FormatID angleFormatID);
size_t hash() const;
// Color attachments are in [0, colorAttachmentRange()], with possible gaps.
// Color attachments are in [0, colorAttachmentRange()), with possible gaps.
size_t colorAttachmentRange() const { return mColorAttachmentRange; }
size_t depthStencilAttachmentIndex() const { return colorAttachmentRange() + 1; }
size_t depthStencilAttachmentIndex() const { return colorAttachmentRange(); }
bool isColorAttachmentEnabled(size_t colorIndexGL) const;
bool hasDepthStencilAttachment() const { return mHasDepthStencilAttachment; }
......@@ -102,11 +102,10 @@ class alignas(4) RenderPassDesc final
private:
// Store log(samples), to be able to store it in 3 bits.
uint8_t mLogSamples : 3;
uint8_t mColorAttachmentRange : 3;
uint8_t mColorAttachmentRange : 4;
uint8_t mHasDepthStencilAttachment : 1;
// Temporary padding for upcoming support for resolve attachments.
ANGLE_MAYBE_UNUSED uint8_t pad : 1;
ANGLE_MAYBE_UNUSED uint8_t pad2;
ANGLE_MAYBE_UNUSED uint8_t pad;
// Color attachment formats are stored with their GL attachment indices. The depth/stencil
// attachment formats follow the last enabled color attachment. When creating a render pass,
// the disabled attachments are removed and the resulting attachments are packed.
......
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