Commit aefa3aa9 by Jamie Madill Committed by Commit Bot

Vulkan: Make staged clears store aspect mask.

This will allow us to store depth- or stencil-only clear when we defer clears in FramebufferVk syncing. Currently a refactoring change only. Bug: angleproject:4517 Change-Id: Ifc9bf8f9ebab993509155cf6cf66db5b11f35163 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2151169Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 3fb33ade
...@@ -2413,8 +2413,7 @@ void ImageHelper::clearColor(const VkClearColorValue &color, ...@@ -2413,8 +2413,7 @@ void ImageHelper::clearColor(const VkClearColorValue &color,
commandBuffer->clearColorImage(mImage, getCurrentLayout(), color, 1, &range); commandBuffer->clearColorImage(mImage, getCurrentLayout(), color, 1, &range);
} }
void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags, void ImageHelper::clearDepthStencil(VkImageAspectFlags clearAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
...@@ -2437,7 +2436,8 @@ void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags, ...@@ -2437,7 +2436,8 @@ void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags,
commandBuffer->clearDepthStencilImage(mImage, getCurrentLayout(), depthStencil, 1, &clearRange); commandBuffer->clearDepthStencilImage(mImage, getCurrentLayout(), depthStencil, 1, &clearRange);
} }
void ImageHelper::clear(const VkClearValue &value, void ImageHelper::clear(VkImageAspectFlags aspectFlags,
const VkClearValue &value,
uint32_t mipLevel, uint32_t mipLevel,
uint32_t baseArrayLayer, uint32_t baseArrayLayer,
uint32_t layerCount, uint32_t layerCount,
...@@ -2448,9 +2448,8 @@ void ImageHelper::clear(const VkClearValue &value, ...@@ -2448,9 +2448,8 @@ void ImageHelper::clear(const VkClearValue &value,
if (isDepthStencil) if (isDepthStencil)
{ {
const VkImageAspectFlags aspect = GetDepthStencilAspectFlags(mFormat->actualImageFormat()); clearDepthStencil(aspectFlags, value.depthStencil, mipLevel, 1, baseArrayLayer, layerCount,
clearDepthStencil(aspect, aspect, value.depthStencil, mipLevel, 1, baseArrayLayer, commandBuffer);
layerCount, commandBuffer);
} }
else else
{ {
...@@ -3092,17 +3091,21 @@ void ImageHelper::stageSubresourceUpdateFromImage(ImageHelper *image, ...@@ -3092,17 +3091,21 @@ void ImageHelper::stageSubresourceUpdateFromImage(ImageHelper *image,
void ImageHelper::stageSubresourceClear(const gl::ImageIndex &index) void ImageHelper::stageSubresourceClear(const gl::ImageIndex &index)
{ {
const VkImageAspectFlags aspectFlags = getAspectFlags();
ASSERT(mFormat); ASSERT(mFormat);
VkClearValue clearValue = GetClearValue(*mFormat); VkClearValue clearValue = GetClearValue(*mFormat);
appendSubresourceUpdate(SubresourceUpdate(clearValue, index)); appendSubresourceUpdate(SubresourceUpdate(aspectFlags, clearValue, index));
} }
void ImageHelper::stageRobustResourceClear(const gl::ImageIndex &index, const vk::Format &format) void ImageHelper::stageRobustResourceClear(const gl::ImageIndex &index, const vk::Format &format)
{ {
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(format.actualImageFormat());
// Robust clears must only be staged if we do not have any prior data for this subresource. // Robust clears must only be staged if we do not have any prior data for this subresource.
ASSERT(!isUpdateStaged(index.getLevelIndex(), index.getLayerIndex())); ASSERT(!isUpdateStaged(index.getLevelIndex(), index.getLayerIndex()));
VkClearValue clearValue = GetClearValue(format); VkClearValue clearValue = GetClearValue(format);
appendSubresourceUpdate(SubresourceUpdate(clearValue, index)); appendSubresourceUpdate(SubresourceUpdate(aspectFlags, clearValue, index));
} }
void ImageHelper::stageClearIfEmulatedFormat(Context *context) void ImageHelper::stageClearIfEmulatedFormat(Context *context)
...@@ -3121,13 +3124,15 @@ void ImageHelper::stageClearIfEmulatedFormat(Context *context) ...@@ -3121,13 +3124,15 @@ void ImageHelper::stageClearIfEmulatedFormat(Context *context)
clearValue.color = kEmulatedInitColorValue; clearValue.color = kEmulatedInitColorValue;
} }
const VkImageAspectFlags aspectFlags = getAspectFlags();
// If the image has an emulated channel and robust resource init is not enabled, always clear // If the image has an emulated channel and robust resource init is not enabled, always clear
// it. These channels will be masked out in future writes, and shouldn't contain uninitialized // it. These channels will be masked out in future writes, and shouldn't contain uninitialized
// values. // values.
for (uint32_t level = 0; level < mLevelCount; ++level) for (uint32_t level = 0; level < mLevelCount; ++level)
{ {
gl::ImageIndex index = gl::ImageIndex::Make2DArrayRange(level, 0, mLayerCount); gl::ImageIndex index = gl::ImageIndex::Make2DArrayRange(level, 0, mLayerCount);
prependSubresourceUpdate(SubresourceUpdate(clearValue, index)); prependSubresourceUpdate(SubresourceUpdate(aspectFlags, clearValue, index));
} }
} }
...@@ -3259,8 +3264,8 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk, ...@@ -3259,8 +3264,8 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
if (update.updateSource == UpdateSource::Clear) if (update.updateSource == UpdateSource::Clear)
{ {
clear(update.clear.value, updateMipLevel, updateBaseLayer, updateLayerCount, clear(update.clear.aspectFlags, update.clear.value, updateMipLevel, updateBaseLayer,
commandBuffer); updateLayerCount, commandBuffer);
} }
else if (update.updateSource == UpdateSource::Buffer) else if (update.updateSource == UpdateSource::Buffer)
{ {
...@@ -3705,14 +3710,16 @@ ImageHelper::SubresourceUpdate::SubresourceUpdate(ImageHelper *imageIn, ...@@ -3705,14 +3710,16 @@ ImageHelper::SubresourceUpdate::SubresourceUpdate(ImageHelper *imageIn,
: updateSource(UpdateSource::Image), image{imageIn, copyRegionIn} : updateSource(UpdateSource::Image), image{imageIn, copyRegionIn}
{} {}
ImageHelper::SubresourceUpdate::SubresourceUpdate(const VkClearValue &clearValue, ImageHelper::SubresourceUpdate::SubresourceUpdate(VkImageAspectFlags aspectFlags,
const VkClearValue &clearValue,
const gl::ImageIndex &imageIndex) const gl::ImageIndex &imageIndex)
: updateSource(UpdateSource::Clear) : updateSource(UpdateSource::Clear)
{ {
clear.value = clearValue; clear.aspectFlags = aspectFlags;
clear.levelIndex = imageIndex.getLevelIndex(); clear.value = clearValue;
clear.layerIndex = imageIndex.hasLayer() ? imageIndex.getLayerIndex() : 0; clear.levelIndex = imageIndex.getLevelIndex();
clear.layerCount = imageIndex.getLayerCount(); clear.layerIndex = imageIndex.hasLayer() ? imageIndex.getLayerIndex() : 0;
clear.layerCount = imageIndex.getLayerCount();
} }
ImageHelper::SubresourceUpdate::SubresourceUpdate(const SubresourceUpdate &other) ImageHelper::SubresourceUpdate::SubresourceUpdate(const SubresourceUpdate &other)
......
...@@ -825,7 +825,8 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -825,7 +825,8 @@ class ImageHelper final : public Resource, public angle::Subject
gl::Extents getLevelExtents2D(uint32_t level) const; gl::Extents getLevelExtents2D(uint32_t level) const;
// Clear either color or depth/stencil based on image format. // Clear either color or depth/stencil based on image format.
void clear(const VkClearValue &value, void clear(VkImageAspectFlags aspectFlags,
const VkClearValue &value,
uint32_t mipLevel, uint32_t mipLevel,
uint32_t baseArrayLayer, uint32_t baseArrayLayer,
uint32_t layerCount, uint32_t layerCount,
...@@ -1031,6 +1032,7 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1031,6 +1032,7 @@ class ImageHelper final : public Resource, public angle::Subject
}; };
struct ClearUpdate struct ClearUpdate
{ {
VkImageAspectFlags aspectFlags;
VkClearValue value; VkClearValue value;
uint32_t levelIndex; uint32_t levelIndex;
uint32_t layerIndex; uint32_t layerIndex;
...@@ -1052,7 +1054,9 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1052,7 +1054,9 @@ class ImageHelper final : public Resource, public angle::Subject
SubresourceUpdate(); SubresourceUpdate();
SubresourceUpdate(BufferHelper *bufferHelperIn, const VkBufferImageCopy &copyRegion); SubresourceUpdate(BufferHelper *bufferHelperIn, const VkBufferImageCopy &copyRegion);
SubresourceUpdate(ImageHelper *image, const VkImageCopy &copyRegion); SubresourceUpdate(ImageHelper *image, const VkImageCopy &copyRegion);
SubresourceUpdate(const VkClearValue &clearValue, const gl::ImageIndex &imageIndex); SubresourceUpdate(VkImageAspectFlags aspectFlags,
const VkClearValue &clearValue,
const gl::ImageIndex &imageIndex);
SubresourceUpdate(const SubresourceUpdate &other); SubresourceUpdate(const SubresourceUpdate &other);
void release(RendererVk *renderer); void release(RendererVk *renderer);
...@@ -1092,8 +1096,7 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1092,8 +1096,7 @@ class ImageHelper final : public Resource, public angle::Subject
uint32_t layerCount, uint32_t layerCount,
CommandBuffer *commandBuffer); CommandBuffer *commandBuffer);
void clearDepthStencil(VkImageAspectFlags imageAspectFlags, void clearDepthStencil(VkImageAspectFlags clearAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
......
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