Commit b0245f68 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Remove superseded updates when flushing to image

Especially with emulated formats and robust resource init, a clear is staged that's often superseded by a data upload to the same subresource. This change ensures that superseded updates are dropped to avoid unnecessary GPU work. Bug: angleproject:4691 Change-Id: I697ccd438b92fd2fff17a5800550694658c95c54 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2262574 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 7538f91e
......@@ -1915,10 +1915,7 @@ bool Texture::doesSubImageNeedInit(const Context *context,
}
ASSERT(mState.mInitState == InitState::MayNeedInit);
bool coversWholeImage = area.x == 0 && area.y == 0 && area.z == 0 &&
area.width == desc.size.width && area.height == desc.size.height &&
area.depth == desc.size.depth;
return !coversWholeImage;
return !area.coversSameExtent(desc.size);
}
angle::Result Texture::ensureSubImageInitialized(const Context *context,
......
......@@ -586,6 +586,12 @@ Rectangle Box::toRect() const
return Rectangle(x, y, width, height);
}
bool Box::coversSameExtent(const Extents &size) const
{
return x == 0 && y == 0 && z == 0 && width == size.width && height == size.height &&
depth == size.depth;
}
bool operator==(const Offset &a, const Offset &b)
{
return a.x == b.x && a.y == b.y && a.z == b.z;
......
......@@ -103,7 +103,8 @@ struct Box
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in)
: x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in)
{}
Box(const Offset &offset, const Extents &size)
template <typename O, typename E>
Box(const O &offset, const E &size)
: x(offset.x),
y(offset.y),
z(offset.z),
......@@ -115,6 +116,9 @@ struct Box
bool operator!=(const Box &other) const;
Rectangle toRect() const;
// Whether the Box has offset 0 and the same extents as argument.
bool coversSameExtent(const Extents &size) const;
int x;
int y;
int z;
......
......@@ -533,9 +533,7 @@ angle::Result TextureStorage11::updateSubresourceLevel(const gl::Context *contex
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
bool fullCopy = copyArea.x == 0 && copyArea.y == 0 && copyArea.z == 0 &&
copyArea.width == texSize.width && copyArea.height == texSize.height &&
copyArea.depth == texSize.depth;
bool fullCopy = copyArea.coversSameExtent(texSize);
const TextureHelper11 *dstTexture = nullptr;
......
......@@ -1423,14 +1423,12 @@ class ImageHelper final : public Resource, public angle::Subject
void release(RendererVk *renderer);
const VkImageSubresourceLayers &dstSubresource() const
{
// Note: destination mip level includes base level.
ASSERT(updateSource == UpdateSource::Buffer || updateSource == UpdateSource::Image);
return updateSource == UpdateSource::Buffer ? buffer.copyRegion.imageSubresource
: image.copyRegion.dstSubresource;
}
bool isUpdateToLayerLevel(uint32_t layerIndex, uint32_t levelIndexGL) const;
void getDestSubresource(uint32_t imageLayerCount,
uint32_t *levelIndexGLOut,
uint32_t *baseLayerOut,
uint32_t *layerCountOut) const;
VkImageAspectFlags getDestAspectFlags() const;
UpdateSource updateSource;
union
......@@ -1441,6 +1439,11 @@ class ImageHelper final : public Resource, public angle::Subject
};
};
// Called from flushStagedUpdates, removes updates that are later superseded by another. This
// cannot be done at the time the updates were staged, as the image is not created (and thus the
// extents are not known).
void removeSupersededUpdates(gl::TexLevelMask skipLevelsMask);
void initImageMemoryBarrierStruct(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
......
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