Commit 463e02e6 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Constants for unpacked D/S attachment indices

kClearValueDepth/StencilIndex is renamed and repurposed in other places where depth and stencil are placed at indices MAX_DRAW_BUFFERS and MAX_DRAW_BUFFERS+1. Bug: angleproject:4836 Change-Id: Idaeff5017d944d786a5f388c4f1ce3a4e3fe9b7d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2437505 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent fa082bb5
...@@ -1420,11 +1420,11 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk, ...@@ -1420,11 +1420,11 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
// Remove deferred clears for the invalidated attachments. // Remove deferred clears for the invalidated attachments.
if (invalidateDepthBuffer) if (invalidateDepthBuffer)
{ {
mDeferredClears.reset(vk::kClearValueDepthIndex); mDeferredClears.reset(vk::kUnpackedDepthIndex);
} }
if (invalidateStencilBuffer) if (invalidateStencilBuffer)
{ {
mDeferredClears.reset(vk::kClearValueStencilIndex); mDeferredClears.reset(vk::kUnpackedStencilIndex);
} }
for (size_t colorIndexGL : mState.getEnabledDrawBuffers()) for (size_t colorIndexGL : mState.getEnabledDrawBuffers())
{ {
...@@ -1594,7 +1594,7 @@ angle::Result FramebufferVk::updateDepthStencilAttachment(const gl::Context *con ...@@ -1594,7 +1594,7 @@ angle::Result FramebufferVk::updateDepthStencilAttachment(const gl::Context *con
if (deferClears) if (deferClears)
{ {
ANGLE_TRY(depthStencilRT->flushStagedUpdates(contextVk, &mDeferredClears, ANGLE_TRY(depthStencilRT->flushStagedUpdates(contextVk, &mDeferredClears,
vk::kClearValueDepthIndex)); vk::kUnpackedDepthIndex));
} }
else else
{ {
...@@ -1982,14 +1982,14 @@ angle::Result FramebufferVk::clearImmediatelyWithRenderPassOp( ...@@ -1982,14 +1982,14 @@ angle::Result FramebufferVk::clearImmediatelyWithRenderPassOp(
{ {
VkClearValue clearValue; VkClearValue clearValue;
clearValue.depthStencil = clearDepthStencilValue; clearValue.depthStencil = clearDepthStencilValue;
mDeferredClears.store(vk::kClearValueDepthIndex, VK_IMAGE_ASPECT_DEPTH_BIT, clearValue); mDeferredClears.store(vk::kUnpackedDepthIndex, VK_IMAGE_ASPECT_DEPTH_BIT, clearValue);
} }
if (clearStencil) if (clearStencil)
{ {
VkClearValue clearValue; VkClearValue clearValue;
clearValue.depthStencil = clearDepthStencilValue; clearValue.depthStencil = clearDepthStencilValue;
mDeferredClears.store(vk::kClearValueStencilIndex, VK_IMAGE_ASPECT_STENCIL_BIT, clearValue); mDeferredClears.store(vk::kUnpackedStencilIndex, VK_IMAGE_ASPECT_STENCIL_BIT, clearValue);
} }
// Ensure the clear happens immediately. // Ensure the clear happens immediately.
...@@ -2010,7 +2010,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -2010,7 +2010,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
{ {
VkClearValue clearValue; VkClearValue clearValue;
clearValue.depthStencil = clearDepthStencilValue; clearValue.depthStencil = clearDepthStencilValue;
mDeferredClears.store(vk::kClearValueDepthIndex, VK_IMAGE_ASPECT_DEPTH_BIT, clearValue); mDeferredClears.store(vk::kUnpackedDepthIndex, VK_IMAGE_ASPECT_DEPTH_BIT, clearValue);
// Scissored-only clears are handled in clearImmediatelyWithRenderPassOp. // Scissored-only clears are handled in clearImmediatelyWithRenderPassOp.
ASSERT(clearColorBuffers.any() || clearStencil); ASSERT(clearColorBuffers.any() || clearStencil);
...@@ -2365,14 +2365,14 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -2365,14 +2365,14 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
{ {
depthLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; depthLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
clearValue.depthStencil.depth = mDeferredClears.getDepthValue(); clearValue.depthStencil.depth = mDeferredClears.getDepthValue();
mDeferredClears.reset(vk::kClearValueDepthIndex); mDeferredClears.reset(vk::kUnpackedDepthIndex);
} }
if (mDeferredClears.testStencil()) if (mDeferredClears.testStencil())
{ {
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
clearValue.depthStencil.stencil = mDeferredClears.getStencilValue(); clearValue.depthStencil.stencil = mDeferredClears.getStencilValue();
mDeferredClears.reset(vk::kClearValueStencilIndex); mDeferredClears.reset(vk::kUnpackedStencilIndex);
} }
// Note the aspect is only depth here. That's intentional. // Note the aspect is only depth here. That's intentional.
...@@ -2474,11 +2474,11 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -2474,11 +2474,11 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
vk::FramebufferNonResolveAttachmentMask unresolveMask(unresolveColorMask.bits()); vk::FramebufferNonResolveAttachmentMask unresolveMask(unresolveColorMask.bits());
if (unresolveDepth) if (unresolveDepth)
{ {
unresolveMask.set(gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); unresolveMask.set(vk::kUnpackedDepthIndex);
} }
if (unresolveStencil) if (unresolveStencil)
{ {
unresolveMask.set(gl::IMPLEMENTATION_MAX_DRAW_BUFFERS + 1); unresolveMask.set(vk::kUnpackedStencilIndex);
} }
mCurrentFramebufferDesc.updateUnresolveMask(unresolveMask); mCurrentFramebufferDesc.updateUnresolveMask(unresolveMask);
......
...@@ -1425,8 +1425,7 @@ angle::Result GraphicsPipelineDesc::initializePipeline( ...@@ -1425,8 +1425,7 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
VkPipelineRasterizationStateCreateInfo rasterState = {}; VkPipelineRasterizationStateCreateInfo rasterState = {};
VkPipelineMultisampleStateCreateInfo multisampleState = {}; VkPipelineMultisampleStateCreateInfo multisampleState = {};
VkPipelineDepthStencilStateCreateInfo depthStencilState = {}; VkPipelineDepthStencilStateCreateInfo depthStencilState = {};
std::array<VkPipelineColorBlendAttachmentState, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS> gl::DrawBuffersArray<VkPipelineColorBlendAttachmentState> blendAttachmentState;
blendAttachmentState;
VkPipelineColorBlendStateCreateInfo blendState = {}; VkPipelineColorBlendStateCreateInfo blendState = {};
VkSpecializationInfo specializationInfo = {}; VkSpecializationInfo specializationInfo = {};
VkGraphicsPipelineCreateInfo createInfo = {}; VkGraphicsPipelineCreateInfo createInfo = {};
......
...@@ -739,10 +739,10 @@ void ClearValuesArray::store(uint32_t index, ...@@ -739,10 +739,10 @@ void ClearValuesArray::store(uint32_t index,
if ((aspectFlags & VK_IMAGE_ASPECT_STENCIL_BIT) != 0) if ((aspectFlags & VK_IMAGE_ASPECT_STENCIL_BIT) != 0)
{ {
// Ensure for packed DS we're writing to the depth index. // Ensure for packed DS we're writing to the depth index.
ASSERT(index == kClearValueDepthIndex || ASSERT(index == kUnpackedDepthIndex ||
(index == kClearValueStencilIndex && aspectFlags == VK_IMAGE_ASPECT_STENCIL_BIT)); (index == kUnpackedStencilIndex && aspectFlags == VK_IMAGE_ASPECT_STENCIL_BIT));
storeNoDepthStencil(kClearValueStencilIndex, clearValue); storeNoDepthStencil(kUnpackedStencilIndex, clearValue);
} }
if (aspectFlags != VK_IMAGE_ASPECT_STENCIL_BIT) if (aspectFlags != VK_IMAGE_ASPECT_STENCIL_BIT)
......
...@@ -679,8 +679,8 @@ using SpecializationConstantMap = angle::PackedEnumMap<sh::vk::SpecializationCon ...@@ -679,8 +679,8 @@ using SpecializationConstantMap = angle::PackedEnumMap<sh::vk::SpecializationCon
void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT *label); void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT *label);
constexpr size_t kClearValueDepthIndex = gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; constexpr size_t kUnpackedDepthIndex = gl::IMPLEMENTATION_MAX_DRAW_BUFFERS;
constexpr size_t kClearValueStencilIndex = gl::IMPLEMENTATION_MAX_DRAW_BUFFERS + 1; constexpr size_t kUnpackedStencilIndex = gl::IMPLEMENTATION_MAX_DRAW_BUFFERS + 1;
class ClearValuesArray final class ClearValuesArray final
{ {
...@@ -701,16 +701,13 @@ class ClearValuesArray final ...@@ -701,16 +701,13 @@ class ClearValuesArray final
} }
bool test(size_t index) const { return mEnabled.test(index); } bool test(size_t index) const { return mEnabled.test(index); }
bool testDepth() const { return mEnabled.test(kClearValueDepthIndex); } bool testDepth() const { return mEnabled.test(kUnpackedDepthIndex); }
bool testStencil() const { return mEnabled.test(kClearValueStencilIndex); } bool testStencil() const { return mEnabled.test(kUnpackedStencilIndex); }
const VkClearValue &operator[](size_t index) const { return mValues[index]; } const VkClearValue &operator[](size_t index) const { return mValues[index]; }
float getDepthValue() const { return mValues[kClearValueDepthIndex].depthStencil.depth; } float getDepthValue() const { return mValues[kUnpackedDepthIndex].depthStencil.depth; }
uint32_t getStencilValue() const uint32_t getStencilValue() const { return mValues[kUnpackedStencilIndex].depthStencil.stencil; }
{
return mValues[kClearValueStencilIndex].depthStencil.stencil;
}
const VkClearValue *data() const { return mValues.data(); } const VkClearValue *data() const { return mValues.data(); }
bool empty() const { return mEnabled.none(); } bool empty() const { return mEnabled.none(); }
......
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