Commit 0fc47fdc by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix deferred clears vs swap

If a clear is deffered on the swapchain image, then the clear should be applied before swap takes effect. Bug: angleproject:5262 Change-Id: I61aa8ab2983258a02c25a150e6d8c2d2bdbdf97a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2506780Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 9eff9895
......@@ -1283,6 +1283,10 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
updateOverlay(contextVk);
bool overlayHasWidget = overlayHasEnabledWidget(contextVk);
// Make sure deferred clears are applied, if any.
ANGLE_TRY(
image.image.flushStagedUpdates(contextVk, gl::LevelIndex(0), gl::LevelIndex(1), 0, 1, {}));
// We can only do present related optimization if this is the last renderpass that touches the
// swapchain image. MSAA resolve and overlay will insert another renderpass which disqualifies
// the optimization.
......
......@@ -10,6 +10,7 @@
#include "test_utils/gl_raii.h"
#include "util/random_utils.h"
#include "util/shader_utils.h"
#include "util/test_utils.h"
using namespace angle;
......@@ -2425,6 +2426,27 @@ TEST_P(ClearTest, ClearThenScissoredMaskedClear)
EXPECT_PIXEL_RECT_EQ(kSize / 2, 0, kSize / 2, kSize, GLColor::red);
}
// This is a test that must be verified visually.
//
// Tests that clear of the default framebuffer applies to the window.
TEST_P(ClearTest, DISABLED_ClearReachesWindow)
{
ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue());
// Draw blue.
drawQuad(blueProgram, essl1_shaders::PositionAttrib(), 0.5f);
swapBuffers();
// Use glClear to clear to red. Regression test for the Vulkan backend where this clear
// remained "deferred" and didn't make it to the window on swap.
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
swapBuffers();
// Wait for visual verification.
angle::Sleep(2000);
}
#ifdef Bool
// X11 craziness.
# undef Bool
......
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