Vulkan: Minor cleanup of mPrevUploadedMutableTexture

When texture is transit from mutable to immutable, we need to remove it
from SharedGroupVk::mPrevUploadedMutableTexture if it is pointing to.
Right now we did not clear the pointer, but rely on next texImage call
to detect that mPrevUploadedMutableTexture is pointing to a immutable
texture and then set it to new tetxure. This is a bit confusing since we
only add a mutable texture to this mPrevUploadedMutableTexture pointer
but at some point it becomes immutable. This CL changes to immediately
reset the pointer when texture is respecified from mutable to immutable,
and added assertion that mPrevUploadedMutableTexture is mutable.

Bug: b/301289624
Change-Id: I97a11616887367cd4c2069419fe17d3dea052b50
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4879087
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Commit-Queue: Charlie Lao <cclao@google.com>
This commit is contained in:
Charlie Lao
2023-09-21 11:25:16 -07:00
committed by Angle LUCI CQ
parent 9f94ab7f86
commit 26148a0237
2 changed files with 7 additions and 1 deletions

View File

@@ -263,11 +263,13 @@ angle::Result TextureUpload::onMutableTextureUpload(ContextVk *contextVk, Textur
{
// This feature is currently disabled in the case of display-level texture sharing.
ASSERT(!contextVk->hasDisplayTextureShareGroup());
ASSERT(!newTexture->isImmutable());
ASSERT(mPrevUploadedMutableTexture == nullptr || !mPrevUploadedMutableTexture->isImmutable());
// If the previous texture is null, it should be set to the current texture. We also have to
// make sure that the previous texture pointer is still a mutable texture. Otherwise, we skip
// the optimization.
if (mPrevUploadedMutableTexture == nullptr || mPrevUploadedMutableTexture->isImmutable())
if (mPrevUploadedMutableTexture == nullptr)
{
mPrevUploadedMutableTexture = newTexture;
return angle::Result::Continue;

View File

@@ -1580,6 +1580,10 @@ angle::Result TextureVk::setStorageMultisample(const gl::Context *context,
}
else if (mImage)
{
if (!contextVk->hasDisplayTextureShareGroup())
{
contextVk->getShareGroup()->onTextureRelease(this);
}
mImage->releaseStagedUpdates(contextVk->getRenderer());
}