Commit 317f81dbd9633eff5021ab931c94a4a415780db7

Tim Van Patten 2025-05-01T14:17:47

Fix EGL_RENDER_BUFFER query if EGL_SINGLE_BUFFER unsupported eglCreateWindowSurface() can have the EGL attribute EGL_RENDER_BUFFER specified: EGL_RENDER_BUFFER specifies which buffer should be used by default for client API rendering to the window, as described in section 2.2.2. If its value is EGL_SINGLE_BUFFER, then client APIs should render directly into the visible window. If its value is EGL_BACK_BUFFER, then all client APIs should render into the back buffer. The default value of EGL_RENDER_BUFFER is EGL_BACK_BUFFER. Client APIs may not be able to respect the requested rendering buffer. To determine the actual buffer that a context will render to by default, call eglQueryContext with attribute EGL_RENDER_BUFFER (see section 3.7.4). To support EGL_SINGLE_BUFFER, Vulkan surfaces must support the VkPresentModeKHR value VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR: VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR specifies that the presentation engine and application have concurrent access to a single image, which is referred to as a shared presentable image. The presentation engine is only required to update the current image after a new presentation request is received. Therefore the application must make a presentation request whenever an update is required. However, the presentation engine may update the current image at any point, meaning this mode may result in visible tearing. However, this is only available on Vulkan devices that support the extension VK_KHR_shared_presentable_image. Add checking in Surface::initialize() to update Surface::mRenderBuffer to EGL_BACK_BUFFER if the backend implementation does not support EGL_SINGLE_BUFFER. This includes adding supportsSingleRenderBuffer() to query the backend if it supports single render buffer mode, which defaults to False. The Vulkan backend overrides this and the result is based on support for VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR. Bug: b/412446258 Test: EGLLockSurface3Test.WindowMsaaSurfaceReadTest/ES2_Vulkan_NoFixture Test: EGLSingleBufferTest.VerifyMutableRenderBufferKHR/* Change-Id: I4e6d56f01a895a5bd887580e6ffa34d574c87fad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6506764 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>