Hash :
914fe61b
Author :
Date :
2024-03-15T13:20:49
Vulkan: Rename RendererVk.* to vk_renderer.* Done in a separate CL from the move to namespace vk to avoid possible rebase-time confusion with the file name change. Bug: angleproject:8564 Change-Id: Ibab79029834b88514d4466a7a4c076b1352bc450 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5370107 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
//
// Copyright 2021-2022 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// WindowSurfaceVkWayland.cpp:
// Implements the class methods for WindowSurfaceVkWayland.
//
#include "libANGLE/renderer/vulkan/linux/wayland/WindowSurfaceVkWayland.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
#include <wayland-egl-backend.h>
namespace rx
{
void WindowSurfaceVkWayland::ResizeCallback(wl_egl_window *eglWindow, void *payload)
{
WindowSurfaceVkWayland *windowSurface = reinterpret_cast<WindowSurfaceVkWayland *>(payload);
if (windowSurface->mExtents.width != eglWindow->width ||
windowSurface->mExtents.height != eglWindow->height)
{
windowSurface->mExtents.width = eglWindow->width;
windowSurface->mExtents.height = eglWindow->height;
// Trigger swapchain resize
windowSurface->mResized = true;
}
}
WindowSurfaceVkWayland::WindowSurfaceVkWayland(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window,
wl_display *display)
: WindowSurfaceVk(surfaceState, window), mWaylandDisplay(display)
{
wl_egl_window *eglWindow = reinterpret_cast<wl_egl_window *>(window);
eglWindow->resize_callback = WindowSurfaceVkWayland::ResizeCallback;
eglWindow->driver_private = this;
mExtents = gl::Extents(eglWindow->width, eglWindow->height, 1);
}
angle::Result WindowSurfaceVkWayland::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
{
ANGLE_VK_CHECK(context,
vkGetPhysicalDeviceWaylandPresentationSupportKHR(
context->getRenderer()->getPhysicalDevice(),
context->getRenderer()->getQueueFamilyIndex(), mWaylandDisplay),
VK_ERROR_INITIALIZATION_FAILED);
wl_egl_window *eglWindow = reinterpret_cast<wl_egl_window *>(mNativeWindowType);
VkWaylandSurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
createInfo.flags = 0;
createInfo.display = mWaylandDisplay;
createInfo.surface = eglWindow->surface;
ANGLE_VK_TRY(context, vkCreateWaylandSurfaceKHR(context->getRenderer()->getInstance(),
&createInfo, nullptr, &mSurface));
return getCurrentWindowSize(context, extentsOut);
}
angle::Result WindowSurfaceVkWayland::getCurrentWindowSize(vk::Context *context,
gl::Extents *extentsOut)
{
*extentsOut = mExtents;
return angle::Result::Continue;
}
egl::Error WindowSurfaceVkWayland::getUserWidth(const egl::Display *display, EGLint *value) const
{
*value = getWidth();
return egl::NoError();
}
egl::Error WindowSurfaceVkWayland::getUserHeight(const egl::Display *display, EGLint *value) const
{
*value = getHeight();
return egl::NoError();
}
angle::Result WindowSurfaceVkWayland::getAttachmentRenderTarget(
const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{
if (mResized)
{
// A wl_egl_window_resize() should take effect on the next operation which provokes a
// backbuffer to be pulled
ANGLE_TRY(doDeferredAcquireNextImage(context, true));
mResized = false;
}
return WindowSurfaceVk::getAttachmentRenderTarget(context, binding, imageIndex, samples, rtOut);
}
} // namespace rx