#include "libANGLE/renderer/vulkan/SurfaceVk.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Overlay.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/OverlayVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
#include "libANGLE/trace.h"
namespace rx
{
namespace
{
angle::SubjectIndex kAnySurfaceImageSubjectIndex = …;
constexpr uint32_t kSurfaceSizedBySwapchain = …;
constexpr uint32_t kInvalidImageIndex = …;
GLint GetSampleCount(const egl::Config *config)
{ … }
vk::PresentMode GetDesiredPresentMode(const std::vector<vk::PresentMode> &presentModes,
EGLint interval)
{ … }
uint32_t GetMinImageCount(const VkSurfaceCapabilitiesKHR &surfaceCaps)
{ … }
constexpr VkImageUsageFlags kSurfaceVkImageUsageFlags = …;
constexpr VkImageUsageFlags kSurfaceVkColorImageUsageFlags = …;
constexpr VkImageUsageFlags kSurfaceVkDepthStencilImageUsageFlags = …;
constexpr VkSurfaceTransformFlagsKHR k90DegreeRotationVariants = …;
bool Is90DegreeRotation(VkSurfaceTransformFlagsKHR transform)
{ … }
bool NeedsInputAttachmentUsage(const angle::FeaturesVk &features)
{ … }
angle::Result InitImageHelper(DisplayVk *displayVk,
EGLint width,
EGLint height,
const vk::Format &vkFormat,
GLint samples,
bool isRobustResourceInitEnabled,
bool hasProtectedContent,
vk::ImageHelper *imageHelper)
{ … }
VkColorSpaceKHR MapEglColorSpaceToVkColorSpace(vk::Renderer *renderer, EGLenum EGLColorspace)
{ … }
angle::Result LockSurfaceImpl(DisplayVk *displayVk,
vk::ImageHelper *image,
vk::BufferHelper &lockBufferHelper,
EGLint width,
EGLint height,
EGLint usageHint,
bool preservePixels,
uint8_t **bufferPtrOut,
EGLint *bufferPitchOut)
{ … }
angle::Result UnlockSurfaceImpl(DisplayVk *displayVk,
vk::ImageHelper *image,
vk::BufferHelper &lockBufferHelper,
EGLint width,
EGLint height,
bool preservePixels)
{ … }
VkRectLayerKHR ToVkRectLayer(const EGLint *eglRect,
EGLint width,
EGLint height,
bool bottomLeftOrigin)
{ … }
angle::Result GetPresentModes(DisplayVk *displayVk,
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
std::vector<vk::PresentMode> *outPresentModes)
{ … }
angle::Result NewSemaphore(vk::Context *context,
vk::Recycler<vk::Semaphore> *semaphoreRecycler,
vk::Semaphore *semaphoreOut)
{ … }
VkResult NewFence(VkDevice device, vk::Recycler<vk::Fence> *fenceRecycler, vk::Fence *fenceOut)
{ … }
void RecycleUsedFence(VkDevice device, vk::Recycler<vk::Fence> *fenceRecycler, vk::Fence &&fence)
{ … }
void AssociateQueueSerialWithPresentHistory(uint32_t imageIndex,
QueueSerial queueSerial,
std::deque<impl::ImagePresentOperation> *presentHistory)
{ … }
bool HasAnyOldSwapchains(const std::deque<impl::ImagePresentOperation> &presentHistory)
{ … }
bool IsCompatiblePresentMode(vk::PresentMode mode,
VkPresentModeKHR *compatibleModes,
size_t compatibleModesCount)
{ … }
void TryAcquireNextImageUnlocked(VkDevice device,
VkSwapchainKHR swapchain,
impl::ImageAcquireOperation *acquire)
{ … }
bool NeedToProcessAcquireNextImageResult(const impl::UnlockedTryAcquireResult &result)
{ … }
bool AreAllFencesSignaled(VkDevice device, const std::vector<vk::Fence> &fences)
{ … }
}
SurfaceVk::SurfaceVk(const egl::SurfaceState &surfaceState) : … { … }
SurfaceVk::~SurfaceVk() { … }
void SurfaceVk::destroy(const egl::Display *display)
{ … }
angle::Result SurfaceVk::getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{ … }
void SurfaceVk::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
{ … }
OffscreenSurfaceVk::AttachmentImage::AttachmentImage(SurfaceVk *surfaceVk)
: … { … }
OffscreenSurfaceVk::AttachmentImage::~AttachmentImage() = default;
angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *displayVk,
EGLint width,
EGLint height,
const vk::Format &vkFormat,
GLint samples,
bool isRobustResourceInitEnabled,
bool hasProtectedContent)
{ … }
void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display)
{ … }
OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState,
vk::Renderer *renderer)
: … { … }
OffscreenSurfaceVk::~OffscreenSurfaceVk() { … }
egl::Error OffscreenSurfaceVk::initialize(const egl::Display *display)
{ … }
angle::Result OffscreenSurfaceVk::initializeImpl(DisplayVk *displayVk)
{ … }
void OffscreenSurfaceVk::destroy(const egl::Display *display)
{ … }
egl::Error OffscreenSurfaceVk::unMakeCurrent(const gl::Context *context)
{ … }
egl::Error OffscreenSurfaceVk::swap(const gl::Context *context)
{ … }
egl::Error OffscreenSurfaceVk::postSubBuffer(const gl::Context * ,
EGLint ,
EGLint ,
EGLint ,
EGLint )
{ … }
egl::Error OffscreenSurfaceVk::querySurfacePointerANGLE(EGLint , void ** )
{ … }
egl::Error OffscreenSurfaceVk::bindTexImage(const gl::Context * ,
gl::Texture * ,
EGLint )
{ … }
egl::Error OffscreenSurfaceVk::releaseTexImage(const gl::Context * , EGLint )
{ … }
egl::Error OffscreenSurfaceVk::getSyncValues(EGLuint64KHR * ,
EGLuint64KHR * ,
EGLuint64KHR * )
{ … }
egl::Error OffscreenSurfaceVk::getMscRate(EGLint * , EGLint * )
{ … }
void OffscreenSurfaceVk::setSwapInterval(EGLint ) { … }
EGLint OffscreenSurfaceVk::getWidth() const
{ … }
EGLint OffscreenSurfaceVk::getHeight() const
{ … }
EGLint OffscreenSurfaceVk::isPostSubBufferSupported() const
{ … }
EGLint OffscreenSurfaceVk::getSwapBehavior() const
{ … }
angle::Result OffscreenSurfaceVk::initializeContents(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex)
{ … }
vk::ImageHelper *OffscreenSurfaceVk::getColorAttachmentImage()
{ … }
egl::Error OffscreenSurfaceVk::lockSurface(const egl::Display *display,
EGLint usageHint,
bool preservePixels,
uint8_t **bufferPtrOut,
EGLint *bufferPitchOut)
{ … }
egl::Error OffscreenSurfaceVk::unlockSurface(const egl::Display *display, bool preservePixels)
{ … }
EGLint OffscreenSurfaceVk::origin() const
{ … }
egl::Error OffscreenSurfaceVk::attachToFramebuffer(const gl::Context *context,
gl::Framebuffer *framebuffer)
{ … }
egl::Error OffscreenSurfaceVk::detachFromFramebuffer(const gl::Context *context,
gl::Framebuffer *framebuffer)
{ … }
namespace impl
{
SwapchainCleanupData::SwapchainCleanupData() = default;
SwapchainCleanupData::~SwapchainCleanupData()
{ … }
SwapchainCleanupData::SwapchainCleanupData(SwapchainCleanupData &&other)
: … { … }
VkResult SwapchainCleanupData::getFencesStatus(VkDevice device) const
{ … }
void SwapchainCleanupData::waitFences(VkDevice device, uint64_t timeout) const
{ … }
void SwapchainCleanupData::destroy(VkDevice device,
vk::Recycler<vk::Fence> *fenceRecycler,
vk::Recycler<vk::Semaphore> *semaphoreRecycler)
{ … }
ImagePresentOperation::ImagePresentOperation() : … { … }
ImagePresentOperation::~ImagePresentOperation()
{ … }
ImagePresentOperation::ImagePresentOperation(ImagePresentOperation &&other)
: … { … }
ImagePresentOperation &ImagePresentOperation::operator=(ImagePresentOperation &&other)
{ … }
void ImagePresentOperation::destroy(VkDevice device,
vk::Recycler<vk::Fence> *fenceRecycler,
vk::Recycler<vk::Semaphore> *semaphoreRecycler)
{ … }
SwapchainImage::SwapchainImage() = default;
SwapchainImage::~SwapchainImage() = default;
SwapchainImage::SwapchainImage(SwapchainImage &&other)
: … { … }
ImageAcquireOperation::ImageAcquireOperation() : … { … }
}
usingnamespaceimpl;
WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, EGLNativeWindowType window)
: … { … }
WindowSurfaceVk::~WindowSurfaceVk()
{ … }
void WindowSurfaceVk::destroy(const egl::Display *display)
{ … }
egl::Error WindowSurfaceVk::initialize(const egl::Display *display)
{ … }
egl::Error WindowSurfaceVk::unMakeCurrent(const gl::Context *context)
{ … }
angle::FormatID WindowSurfaceVk::getIntendedFormatID(vk::Renderer *renderer)
{ … }
angle::FormatID WindowSurfaceVk::getActualFormatID(vk::Renderer *renderer)
{ … }
bool WindowSurfaceVk::updateColorSpace(DisplayVk *displayVk)
{ … }
angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk, bool *anyMatchesOut)
{ … }
angle::Result WindowSurfaceVk::getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{ … }
angle::Result WindowSurfaceVk::recreateSwapchain(ContextVk *contextVk, const gl::Extents &extents)
{ … }
angle::Result WindowSurfaceVk::resizeSwapchainImages(vk::Context *context, uint32_t imageCount)
{ … }
angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
const gl::Extents &extents,
VkSwapchainKHR lastSwapchain)
{ … }
bool WindowSurfaceVk::isMultiSampled() const
{ … }
angle::Result WindowSurfaceVk::queryAndAdjustSurfaceCaps(ContextVk *contextVk,
VkSurfaceCapabilitiesKHR *surfaceCaps)
{ … }
angle::Result WindowSurfaceVk::checkForOutOfDateSwapchain(ContextVk *contextVk,
bool presentOutOfDate,
bool *swapchainRecreatedOut)
{ … }
void WindowSurfaceVk::releaseSwapchainImages(ContextVk *contextVk)
{ … }
angle::Result WindowSurfaceVk::finish(vk::Context *context)
{ … }
void WindowSurfaceVk::destroySwapChainImages(DisplayVk *displayVk)
{ … }
egl::Error WindowSurfaceVk::prepareSwap(const gl::Context *context)
{ … }
egl::Error WindowSurfaceVk::swapWithDamage(const gl::Context *context,
const EGLint *rects,
EGLint n_rects)
{ … }
egl::Error WindowSurfaceVk::swap(const gl::Context *context)
{ … }
angle::Result WindowSurfaceVk::computePresentOutOfDate(vk::Context *context,
VkResult result,
bool *presentOutOfDate)
{ … }
vk::Framebuffer &WindowSurfaceVk::chooseFramebuffer()
{ … }
angle::Result WindowSurfaceVk::prePresentSubmit(ContextVk *contextVk,
const vk::Semaphore &presentSemaphore)
{ … }
angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
const EGLint *rects,
EGLint n_rects,
const void *pNextChain,
bool *presentOutOfDate)
{ … }
angle::Result WindowSurfaceVk::throttleCPU(vk::Context *context,
const QueueSerial ¤tSubmitSerial)
{ … }
angle::Result WindowSurfaceVk::cleanUpPresentHistory(vk::Context *context)
{ … }
angle::Result WindowSurfaceVk::cleanUpOldSwapchains(vk::Context *context)
{ … }
angle::Result WindowSurfaceVk::swapImpl(const gl::Context *context,
const EGLint *rects,
EGLint n_rects,
const void *pNextChain)
{ … }
angle::Result WindowSurfaceVk::onSharedPresentContextFlush(const gl::Context *context)
{ … }
bool WindowSurfaceVk::hasStagedUpdates() const
{ … }
void WindowSurfaceVk::setTimestampsEnabled(bool enabled)
{ … }
void WindowSurfaceVk::deferAcquireNextImage()
{ … }
angle::Result WindowSurfaceVk::prepareForAcquireNextSwapchainImage(const gl::Context *context,
bool presentOutOfDate,
bool *swapchainRecreatedOut)
{ … }
angle::Result WindowSurfaceVk::doDeferredAcquireNextImage(const gl::Context *context,
bool presentOutOfDate)
{ … }
angle::Result WindowSurfaceVk::doDeferredAcquireNextImageWithUsableSwapchain(
const gl::Context *context)
{ … }
bool WindowSurfaceVk::skipAcquireNextSwapchainImageForSharedPresentMode() const
{ … }
VkResult WindowSurfaceVk::acquireNextSwapchainImage(vk::Context *context)
{ … }
VkResult WindowSurfaceVk::postProcessUnlockedTryAcquire(vk::Context *context)
{ … }
bool WindowSurfaceVk::needsAcquireImageOrProcessResult() const
{ … }
egl::Error WindowSurfaceVk::postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height)
{ … }
egl::Error WindowSurfaceVk::querySurfacePointerANGLE(EGLint attribute, void **value)
{ … }
egl::Error WindowSurfaceVk::bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer)
{ … }
egl::Error WindowSurfaceVk::releaseTexImage(const gl::Context *context, EGLint buffer)
{ … }
egl::Error WindowSurfaceVk::getSyncValues(EGLuint64KHR * ,
EGLuint64KHR * ,
EGLuint64KHR * )
{ … }
egl::Error WindowSurfaceVk::getMscRate(EGLint * , EGLint * )
{ … }
void WindowSurfaceVk::setSwapInterval(EGLint interval)
{ … }
EGLint WindowSurfaceVk::getWidth() const
{ … }
EGLint WindowSurfaceVk::getRotatedWidth() const
{ … }
EGLint WindowSurfaceVk::getHeight() const
{ … }
EGLint WindowSurfaceVk::getRotatedHeight() const
{ … }
egl::Error WindowSurfaceVk::getUserWidth(const egl::Display *display, EGLint *value) const
{ … }
egl::Error WindowSurfaceVk::getUserHeight(const egl::Display *display, EGLint *value) const
{ … }
angle::Result WindowSurfaceVk::getUserExtentsImpl(DisplayVk *displayVk,
VkSurfaceCapabilitiesKHR *surfaceCaps) const
{ … }
EGLint WindowSurfaceVk::isPostSubBufferSupported() const
{ … }
EGLint WindowSurfaceVk::getSwapBehavior() const
{ … }
angle::Result WindowSurfaceVk::getCurrentFramebuffer(ContextVk *contextVk,
FramebufferFetchMode fetchMode,
const vk::RenderPass &compatibleRenderPass,
vk::Framebuffer *framebufferOut)
{ … }
angle::Result WindowSurfaceVk::initializeContents(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex)
{ … }
void WindowSurfaceVk::updateOverlay(ContextVk *contextVk) const
{ … }
ANGLE_INLINE bool WindowSurfaceVk::overlayHasEnabledWidget(ContextVk *contextVk) const
{ … }
angle::Result WindowSurfaceVk::drawOverlay(ContextVk *contextVk, SwapchainImage *image) const
{ … }
egl::Error WindowSurfaceVk::setAutoRefreshEnabled(bool enabled)
{ … }
egl::Error WindowSurfaceVk::getBufferAge(const gl::Context *context, EGLint *age)
{ … }
bool WindowSurfaceVk::supportsPresentMode(vk::PresentMode presentMode) const
{ … }
egl::Error WindowSurfaceVk::setRenderBuffer(EGLint renderBuffer)
{ … }
egl::Error WindowSurfaceVk::lockSurface(const egl::Display *display,
EGLint usageHint,
bool preservePixels,
uint8_t **bufferPtrOut,
EGLint *bufferPitchOut)
{ … }
egl::Error WindowSurfaceVk::unlockSurface(const egl::Display *display, bool preservePixels)
{ … }
EGLint WindowSurfaceVk::origin() const
{ … }
egl::Error WindowSurfaceVk::attachToFramebuffer(const gl::Context *context,
gl::Framebuffer *framebuffer)
{ … }
egl::Error WindowSurfaceVk::detachFromFramebuffer(const gl::Context *context,
gl::Framebuffer *framebuffer)
{ … }
}