Skip to content

Commit ac251fa

Browse files
i-nazarov-samsungAngle LUCI CQ
authored and
Angle LUCI CQ
committed
Vulkan: Remove doDeferredAcquireNextImage ContextVk dependency
This is the continuation of the previous CL. After this change `lockSurface()` calls `doDeferredAcquireNextImage()` as the rest of the code do. The `ImageHelper::invalidateSubresourceContentImpl()` required `ContextVk` pointer before this change. The `ContextVk` is only used to print the performance warning when `layerIndex` exceed the maximum count, which is not possible in case of a `WindowSurfaceVk`. Added `layerLimitReachedOut` pointer instead of writing the warning. It is processed in `invalidateSubresource[Stencil]Content()`. Added `invalidateEntireLevel[Stencil]Content()` which do not require `ContextVk` to use in the `WindowSurfaceVk`. Bug: angleproject:397848903 Bug: angleproject:42264593 Change-Id: I58451a4818ad56fa196c3c971df3a5f7793f2bfe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6298735 Reviewed-by: Charlie Lao <[email protected]> Reviewed-by: Shahbaz Youssefi <[email protected]> Commit-Queue: Igor Nazarov <[email protected]>
1 parent 2f5a91b commit ac251fa

File tree

4 files changed

+70
-53
lines changed

4 files changed

+70
-53
lines changed

src/libANGLE/renderer/vulkan/SurfaceVk.cpp

+17-27
Original file line numberDiff line numberDiff line change
@@ -2807,19 +2807,20 @@ angle::Result WindowSurfaceVk::prepareForAcquireNextSwapchainImage(vk::ErrorCont
28072807
return checkForOutOfDateSwapchain(context, false);
28082808
}
28092809

2810-
angle::Result WindowSurfaceVk::doDeferredAcquireNextImage(ContextVk *contextVk)
2810+
angle::Result WindowSurfaceVk::doDeferredAcquireNextImage(vk::ErrorContext *context)
28112811
{
28122812
ASSERT(mAcquireOperation.state != ImageAcquireState::Ready);
28132813
// prepareForAcquireNextSwapchainImage() may recreate Swapchain even if there is an image
28142814
// acquired. Avoid this, by skipping the prepare call.
28152815
if (mAcquireOperation.state == ImageAcquireState::Unacquired)
28162816
{
2817-
ANGLE_TRY(prepareForAcquireNextSwapchainImage(contextVk));
2817+
ANGLE_TRY(prepareForAcquireNextSwapchainImage(context));
28182818
}
2819-
return doDeferredAcquireNextImageWithUsableSwapchain(contextVk);
2819+
return doDeferredAcquireNextImageWithUsableSwapchain(context);
28202820
}
28212821

2822-
angle::Result WindowSurfaceVk::doDeferredAcquireNextImageWithUsableSwapchain(ContextVk *contextVk)
2822+
angle::Result WindowSurfaceVk::doDeferredAcquireNextImageWithUsableSwapchain(
2823+
vk::ErrorContext *context)
28232824
{
28242825
ASSERT(mAcquireOperation.state != ImageAcquireState::Ready);
28252826

@@ -2829,18 +2830,18 @@ angle::Result WindowSurfaceVk::doDeferredAcquireNextImageWithUsableSwapchain(Con
28292830
ANGLE_TRACE_EVENT0("gpu.angle", "acquireNextSwapchainImage");
28302831

28312832
// Get the next available swapchain image.
2832-
VkResult result = acquireNextSwapchainImage(contextVk);
2833+
VkResult result = acquireNextSwapchainImage(context);
28332834

28342835
ASSERT(result != VK_SUBOPTIMAL_KHR);
28352836
// If OUT_OF_DATE is returned, it's ok, we just need to recreate the swapchain before
28362837
// continuing.
28372838
if (ANGLE_UNLIKELY(result == VK_ERROR_OUT_OF_DATE_KHR))
28382839
{
2839-
ANGLE_TRY(checkForOutOfDateSwapchain(contextVk, true));
2840+
ANGLE_TRY(checkForOutOfDateSwapchain(context, true));
28402841
// Try one more time and bail if we fail
2841-
result = acquireNextSwapchainImage(contextVk);
2842+
result = acquireNextSwapchainImage(context);
28422843
}
2843-
ANGLE_VK_TRY(contextVk, result);
2844+
ANGLE_VK_TRY(context, result);
28442845
}
28452846

28462847
// Auto-invalidate the contents of the surface. According to EGL, on swap:
@@ -2856,20 +2857,17 @@ angle::Result WindowSurfaceVk::doDeferredAcquireNextImageWithUsableSwapchain(Con
28562857
{
28572858
if (mState.swapBehavior == EGL_BUFFER_DESTROYED && mBufferAgeQueryFrameNumber == 0)
28582859
{
2859-
mSwapchainImages[mCurrentSwapchainImageIndex].image->invalidateSubresourceContent(
2860-
contextVk, gl::LevelIndex(0), 0, 1, nullptr);
2860+
mSwapchainImages[mCurrentSwapchainImageIndex].image->invalidateEntireLevelContent(
2861+
context, gl::LevelIndex(0));
28612862
if (mColorImageMS.valid())
28622863
{
2863-
mColorImageMS.invalidateSubresourceContent(contextVk, gl::LevelIndex(0), 0, 1,
2864-
nullptr);
2864+
mColorImageMS.invalidateEntireLevelContent(context, gl::LevelIndex(0));
28652865
}
28662866
}
28672867
if (mDepthStencilImage.valid())
28682868
{
2869-
mDepthStencilImage.invalidateSubresourceContent(contextVk, gl::LevelIndex(0), 0, 1,
2870-
nullptr);
2871-
mDepthStencilImage.invalidateSubresourceStencilContent(contextVk, gl::LevelIndex(0), 0,
2872-
1, nullptr);
2869+
mDepthStencilImage.invalidateEntireLevelContent(context, gl::LevelIndex(0));
2870+
mDepthStencilImage.invalidateEntireLevelStencilContent(context, gl::LevelIndex(0));
28732871
}
28742872
}
28752873

@@ -3455,18 +3453,10 @@ egl::Error WindowSurfaceVk::lockSurface(const egl::Display *display,
34553453

34563454
if (mAcquireOperation.state != ImageAcquireState::Ready)
34573455
{
3458-
if (mAcquireOperation.state == ImageAcquireState::Unacquired)
3459-
{
3460-
angle::Result result = prepareForAcquireNextSwapchainImage(displayVk);
3461-
if (result != angle::Result::Continue)
3462-
{
3463-
return angle::ToEGL(result, EGL_BAD_ACCESS);
3464-
}
3465-
}
3466-
VkResult result = acquireNextSwapchainImage(displayVk);
3467-
if (result != VK_SUCCESS)
3456+
angle::Result result = doDeferredAcquireNextImage(displayVk);
3457+
if (result != angle::Result::Continue)
34683458
{
3469-
return angle::ToEGL(angle::Result::Stop, EGL_BAD_ACCESS);
3459+
return angle::ToEGL(result, EGL_BAD_ACCESS);
34703460
}
34713461
}
34723462

src/libANGLE/renderer/vulkan/SurfaceVk.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ class WindowSurfaceVk : public SurfaceVk
408408
// will recreate the swapchain (if needed due to present returning OUT_OF_DATE, swap interval
409409
// changing, surface size changing etc, by calling prepareForAcquireNextSwapchainImage()) and
410410
// call the doDeferredAcquireNextImageWithUsableSwapchain() method.
411-
angle::Result doDeferredAcquireNextImage(ContextVk *contextVk);
411+
angle::Result doDeferredAcquireNextImage(vk::ErrorContext *context);
412412
// Calls acquireNextSwapchainImage() and sets up the acquired image. On some platforms,
413413
// vkAcquireNextImageKHR returns OUT_OF_DATE instead of present, so this function may still
414414
// recreate the swapchain. The main difference with doDeferredAcquireNextImage is that it does
415415
// not check for surface property changes for the purposes of swapchain recreation (because
416416
// that's already done by prepareForAcquireNextSwapchainImage.
417-
angle::Result doDeferredAcquireNextImageWithUsableSwapchain(ContextVk *contextVk);
417+
angle::Result doDeferredAcquireNextImageWithUsableSwapchain(vk::ErrorContext *context);
418418
// This method calls vkAcquireNextImageKHR() to acquire the next swapchain image or to process
419419
// unlocked ANI result. It is scheduled to be called later by deferAcquireNextImage().
420420
VkResult acquireNextSwapchainImage(vk::ErrorContext *context);

src/libANGLE/renderer/vulkan/vk_helpers.cpp

+46-22
Original file line numberDiff line numberDiff line change
@@ -9484,16 +9484,41 @@ bool ImageHelper::hasSubresourceDefinedStencilContent(gl::LevelIndex level,
94849484
.any();
94859485
}
94869486

9487+
void ImageHelper::invalidateEntireLevelContent(vk::ErrorContext *context, gl::LevelIndex level)
9488+
{
9489+
invalidateSubresourceContentImpl(
9490+
context, level, 0, mLayerCount,
9491+
static_cast<VkImageAspectFlagBits>(getAspectFlags() & ~VK_IMAGE_ASPECT_STENCIL_BIT),
9492+
&getLevelContentDefined(toVkLevel(level)), nullptr, nullptr);
9493+
}
9494+
94879495
void ImageHelper::invalidateSubresourceContent(ContextVk *contextVk,
94889496
gl::LevelIndex level,
94899497
uint32_t layerIndex,
94909498
uint32_t layerCount,
94919499
bool *preferToKeepContentsDefinedOut)
94929500
{
9493-
invalidateSubresourceContentImpl(
9494-
contextVk, level, layerIndex, layerCount,
9495-
static_cast<VkImageAspectFlagBits>(getAspectFlags() & ~VK_IMAGE_ASPECT_STENCIL_BIT),
9496-
&getLevelContentDefined(toVkLevel(level)), preferToKeepContentsDefinedOut);
9501+
const VkImageAspectFlagBits aspect =
9502+
static_cast<VkImageAspectFlagBits>(getAspectFlags() & ~VK_IMAGE_ASPECT_STENCIL_BIT);
9503+
bool layerLimitReached = false;
9504+
invalidateSubresourceContentImpl(contextVk, level, layerIndex, layerCount, aspect,
9505+
&getLevelContentDefined(toVkLevel(level)),
9506+
preferToKeepContentsDefinedOut, &layerLimitReached);
9507+
if (layerLimitReached)
9508+
{
9509+
const char *aspectName = (aspect == VK_IMAGE_ASPECT_DEPTH_BIT ? "depth" : "color");
9510+
ANGLE_VK_PERF_WARNING(
9511+
contextVk, GL_DEBUG_SEVERITY_LOW,
9512+
"glInvalidateFramebuffer (%s) ineffective on attachments with layer >= 8", aspectName);
9513+
}
9514+
}
9515+
9516+
void ImageHelper::invalidateEntireLevelStencilContent(vk::ErrorContext *context,
9517+
gl::LevelIndex level)
9518+
{
9519+
invalidateSubresourceContentImpl(context, level, 0, mLayerCount, VK_IMAGE_ASPECT_STENCIL_BIT,
9520+
&getLevelStencilContentDefined(toVkLevel(level)), nullptr,
9521+
nullptr);
94979522
}
94989523

94999524
void ImageHelper::invalidateSubresourceStencilContent(ContextVk *contextVk,
@@ -9502,18 +9527,27 @@ void ImageHelper::invalidateSubresourceStencilContent(ContextVk *contextVk,
95029527
uint32_t layerCount,
95039528
bool *preferToKeepContentsDefinedOut)
95049529
{
9505-
invalidateSubresourceContentImpl(
9506-
contextVk, level, layerIndex, layerCount, VK_IMAGE_ASPECT_STENCIL_BIT,
9507-
&getLevelStencilContentDefined(toVkLevel(level)), preferToKeepContentsDefinedOut);
9530+
bool layerLimitReached = false;
9531+
invalidateSubresourceContentImpl(contextVk, level, layerIndex, layerCount,
9532+
VK_IMAGE_ASPECT_STENCIL_BIT,
9533+
&getLevelStencilContentDefined(toVkLevel(level)),
9534+
preferToKeepContentsDefinedOut, &layerLimitReached);
9535+
if (layerLimitReached)
9536+
{
9537+
ANGLE_VK_PERF_WARNING(
9538+
contextVk, GL_DEBUG_SEVERITY_LOW,
9539+
"glInvalidateFramebuffer (stencil) ineffective on attachments with layer >= 8");
9540+
}
95089541
}
95099542

9510-
void ImageHelper::invalidateSubresourceContentImpl(ContextVk *contextVk,
9543+
void ImageHelper::invalidateSubresourceContentImpl(vk::ErrorContext *context,
95119544
gl::LevelIndex level,
95129545
uint32_t layerIndex,
95139546
uint32_t layerCount,
95149547
VkImageAspectFlagBits aspect,
95159548
LevelContentDefinedMask *contentDefinedMask,
9516-
bool *preferToKeepContentsDefinedOut)
9549+
bool *preferToKeepContentsDefinedOut,
9550+
bool *layerLimitReachedOut)
95179551
{
95189552
// If the aspect being invalidated doesn't exist, skip invalidation altogether.
95199553
if ((getAspectFlags() & aspect) == 0)
@@ -9544,7 +9578,7 @@ void ImageHelper::invalidateSubresourceContentImpl(ContextVk *contextVk,
95449578
break;
95459579
case VK_IMAGE_ASPECT_COLOR_BIT:
95469580
skip = hasEmulatedChannels &&
9547-
contextVk->getFeatures().preferSkippingInvalidateForEmulatedFormats.enabled;
9581+
context->getFeatures().preferSkippingInvalidateForEmulatedFormats.enabled;
95489582
break;
95499583
default:
95509584
UNREACHABLE();
@@ -9562,18 +9596,8 @@ void ImageHelper::invalidateSubresourceContentImpl(ContextVk *contextVk,
95629596

95639597
if (layerIndex >= kMaxContentDefinedLayerCount)
95649598
{
9565-
const char *aspectName = "color";
9566-
if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT)
9567-
{
9568-
aspectName = "depth";
9569-
}
9570-
else if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
9571-
{
9572-
aspectName = "stencil";
9573-
}
9574-
ANGLE_VK_PERF_WARNING(
9575-
contextVk, GL_DEBUG_SEVERITY_LOW,
9576-
"glInvalidateFramebuffer (%s) ineffective on attachments with layer >= 8", aspectName);
9599+
ASSERT(layerLimitReachedOut != nullptr);
9600+
*layerLimitReachedOut = true;
95779601
return;
95789602
}
95799603

src/libANGLE/renderer/vulkan/vk_helpers.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -2970,11 +2970,13 @@ class ImageHelper final : public Resource, public angle::Subject
29702970
bool hasSubresourceDefinedStencilContent(gl::LevelIndex level,
29712971
uint32_t layerIndex,
29722972
uint32_t layerCount) const;
2973+
void invalidateEntireLevelContent(vk::ErrorContext *context, gl::LevelIndex level);
29732974
void invalidateSubresourceContent(ContextVk *contextVk,
29742975
gl::LevelIndex level,
29752976
uint32_t layerIndex,
29762977
uint32_t layerCount,
29772978
bool *preferToKeepContentsDefinedOut);
2979+
void invalidateEntireLevelStencilContent(vk::ErrorContext *context, gl::LevelIndex level);
29782980
void invalidateSubresourceStencilContent(ContextVk *contextVk,
29792981
gl::LevelIndex level,
29802982
uint32_t layerIndex,
@@ -3302,13 +3304,14 @@ class ImageHelper final : public Resource, public angle::Subject
33023304
uint32_t layerStart,
33033305
uint32_t layerCount,
33043306
VkImageAspectFlags aspectFlags);
3305-
void invalidateSubresourceContentImpl(ContextVk *contextVk,
3307+
void invalidateSubresourceContentImpl(vk::ErrorContext *context,
33063308
gl::LevelIndex level,
33073309
uint32_t layerIndex,
33083310
uint32_t layerCount,
33093311
VkImageAspectFlagBits aspect,
33103312
LevelContentDefinedMask *contentDefinedMask,
3311-
bool *preferToKeepContentsDefinedOut);
3313+
bool *preferToKeepContentsDefinedOut,
3314+
bool *layerLimitReachedOut);
33123315
void restoreSubresourceContentImpl(gl::LevelIndex level,
33133316
uint32_t layerIndex,
33143317
uint32_t layerCount,

0 commit comments

Comments
 (0)