Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9823d86

Browse files
mspangCommit Bot
authored andcommitted
Fix EGLSurfaceTest.ResizeWindow on Fuchsia
A VkSurfaceKHR may not have an intrinsic size as is the case on Fuchsia. This is broken since 718ae50 ("Vulkan: Always query EGL_WIDTH and EGL_HEIGHT"); queries for EGL_WIDTH or EGL_HEIGHT now always return -1. Switch back to the old behavior in this case. Bug: angleproject:4624 Change-Id: I7e7bf569db9aec9890b2cb184056be5a6031bd98 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2191173 Reviewed-by: Ian Elliott <[email protected]> Reviewed-by: Jamie Madill <[email protected]> Commit-Queue: Michael Spang <[email protected]>
1 parent 39ce0f6 commit 9823d86

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/libANGLE/renderer/vulkan/SurfaceVk.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ namespace
2929
{
3030
angle::SubjectIndex kAnySurfaceImageSubjectIndex = 0;
3131

32+
// Special value for currentExtent if surface size is determined by the
33+
// swapchain's extent. See VkSurfaceCapabilitiesKHR spec for more details.
34+
constexpr uint32_t kSurfaceSizedBySwapchain = 0xFFFFFFFFu;
35+
3236
GLint GetSampleCount(const egl::Config *config)
3337
{
3438
GLint samples = 1;
@@ -563,9 +567,9 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
563567
EGLAttrib attribWidth = mState.attributes.get(EGL_WIDTH, 0);
564568
EGLAttrib attribHeight = mState.attributes.get(EGL_HEIGHT, 0);
565569

566-
if (mSurfaceCaps.currentExtent.width == 0xFFFFFFFFu)
570+
if (mSurfaceCaps.currentExtent.width == kSurfaceSizedBySwapchain)
567571
{
568-
ASSERT(mSurfaceCaps.currentExtent.height == 0xFFFFFFFFu);
572+
ASSERT(mSurfaceCaps.currentExtent.height == kSurfaceSizedBySwapchain);
569573

570574
width = (attribWidth != 0) ? static_cast<uint32_t>(attribWidth) : windowSize.width;
571575
height = (attribHeight != 0) ? static_cast<uint32_t>(attribHeight) : windowSize.height;
@@ -990,9 +994,9 @@ angle::Result WindowSurfaceVk::checkForOutOfDateSwapchain(ContextVk *contextVk,
990994
uint32_t width = mSurfaceCaps.currentExtent.width;
991995
uint32_t height = mSurfaceCaps.currentExtent.height;
992996

993-
if (width != 0xFFFFFFFFu)
997+
if (width != kSurfaceSizedBySwapchain)
994998
{
995-
ASSERT(height != 0xFFFFFFFFu);
999+
ASSERT(height != kSurfaceSizedBySwapchain);
9961000
currentExtents.width = width;
9971001
currentExtents.height = height;
9981002
}
@@ -1446,12 +1450,20 @@ EGLint WindowSurfaceVk::getHeight() const
14461450
egl::Error WindowSurfaceVk::getUserWidth(const egl::Display *display, EGLint *value) const
14471451
{
14481452
DisplayVk *displayVk = vk::GetImpl(display);
1449-
VkSurfaceCapabilitiesKHR surfaceCaps;
14501453

1454+
if (mSurfaceCaps.currentExtent.width == kSurfaceSizedBySwapchain)
1455+
{
1456+
// Surface has no intrinsic size; use current size.
1457+
*value = getWidth();
1458+
return egl::NoError();
1459+
}
1460+
1461+
VkSurfaceCapabilitiesKHR surfaceCaps;
14511462
angle::Result result = getUserExtentsImpl(displayVk, &surfaceCaps);
14521463
if (result == angle::Result::Continue)
14531464
{
14541465
// The EGL spec states that value is not written if there is an error
1466+
ASSERT(surfaceCaps.currentExtent.width != kSurfaceSizedBySwapchain);
14551467
*value = static_cast<EGLint>(surfaceCaps.currentExtent.width);
14561468
}
14571469
return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE);
@@ -1460,12 +1472,20 @@ egl::Error WindowSurfaceVk::getUserWidth(const egl::Display *display, EGLint *va
14601472
egl::Error WindowSurfaceVk::getUserHeight(const egl::Display *display, EGLint *value) const
14611473
{
14621474
DisplayVk *displayVk = vk::GetImpl(display);
1463-
VkSurfaceCapabilitiesKHR surfaceCaps;
14641475

1476+
if (mSurfaceCaps.currentExtent.height == kSurfaceSizedBySwapchain)
1477+
{
1478+
// Surface has no intrinsic size; use current size.
1479+
*value = getHeight();
1480+
return egl::NoError();
1481+
}
1482+
1483+
VkSurfaceCapabilitiesKHR surfaceCaps;
14651484
angle::Result result = getUserExtentsImpl(displayVk, &surfaceCaps);
14661485
if (result == angle::Result::Continue)
14671486
{
14681487
// The EGL spec states that value is not written if there is an error
1488+
ASSERT(surfaceCaps.currentExtent.height != kSurfaceSizedBySwapchain);
14691489
*value = static_cast<EGLint>(surfaceCaps.currentExtent.height);
14701490
}
14711491
return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE);

0 commit comments

Comments
 (0)