summaryrefslogtreecommitdiff
path: root/chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp')
-rw-r--r--chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp71
1 files changed, 46 insertions, 25 deletions
diff --git a/chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp b/chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp
index 4692b2426b9..f87dc9170e4 100644
--- a/chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp
+++ b/chromium/third_party/angle/src/libANGLE/renderer/vulkan/SurfaceVk.cpp
@@ -126,6 +126,8 @@ angle::Result SurfaceVk::getAttachmentRenderTarget(const gl::Context *context,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{
+ ASSERT(samples == 0);
+
if (binding == GL_BACK)
{
*rtOut = &mColorRenderTarget;
@@ -174,6 +176,8 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *display
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
ANGLE_TRY(image.initMemory(displayVk, renderer->getMemoryProperties(), flags));
+ imageViews.init(renderer);
+
return angle::Result::Continue;
}
@@ -210,9 +214,11 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initializeWithExternalMemory(
image.getImage().getMemoryRequirements(renderer->getDevice(), &externalMemoryRequirements);
VkMemoryPropertyFlags flags = 0;
- ANGLE_TRY(image.initExternalMemory(displayVk, renderer->getMemoryProperties(),
- externalMemoryRequirements, &importMemoryHostPointerInfo,
- VK_QUEUE_FAMILY_EXTERNAL, flags));
+ ANGLE_TRY(image.initExternalMemory(
+ displayVk, renderer->getMemoryProperties(), externalMemoryRequirements, nullptr,
+ &importMemoryHostPointerInfo, VK_QUEUE_FAMILY_EXTERNAL, flags));
+
+ imageViews.init(renderer);
return angle::Result::Continue;
}
@@ -226,16 +232,18 @@ void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display)
imageViews.release(renderer);
}
-OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState)
+OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, RendererVk *renderer)
: SurfaceVk(surfaceState),
mWidth(mState.attributes.getAsInt(EGL_WIDTH, 0)),
mHeight(mState.attributes.getAsInt(EGL_HEIGHT, 0)),
mColorAttachment(this),
mDepthStencilAttachment(this)
{
- mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, 0, 0);
+ mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, nullptr, nullptr,
+ 0, 0, false);
mDepthStencilRenderTarget.init(&mDepthStencilAttachment.image,
- &mDepthStencilAttachment.imageViews, 0, 0);
+ &mDepthStencilAttachment.imageViews, nullptr, nullptr, 0, 0,
+ false);
}
OffscreenSurfaceVk::~OffscreenSurfaceVk() {}
@@ -261,7 +269,8 @@ angle::Result OffscreenSurfaceVk::initializeImpl(DisplayVk *displayVk)
{
ANGLE_TRY(mColorAttachment.initialize(
displayVk, mWidth, mHeight, renderer->getFormat(config->renderTargetFormat), samples));
- mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, 0, 0);
+ mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, nullptr,
+ nullptr, 0, 0, false);
}
if (config->depthStencilFormat != GL_NONE)
@@ -269,7 +278,8 @@ angle::Result OffscreenSurfaceVk::initializeImpl(DisplayVk *displayVk)
ANGLE_TRY(mDepthStencilAttachment.initialize(
displayVk, mWidth, mHeight, renderer->getFormat(config->depthStencilFormat), samples));
mDepthStencilRenderTarget.init(&mDepthStencilAttachment.image,
- &mDepthStencilAttachment.imageViews, 0, 0);
+ &mDepthStencilAttachment.imageViews, nullptr, nullptr, 0, 0,
+ false);
}
return angle::Result::Continue;
@@ -471,8 +481,9 @@ WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, EGLNativ
{
// Initialize the color render target with the multisampled targets. If not multisampled, the
// render target will be updated to refer to a swapchain image on every acquire.
- mColorRenderTarget.init(&mColorImageMS, &mColorImageMSViews, 0, 0);
- mDepthStencilRenderTarget.init(&mDepthStencilImage, &mDepthStencilImageViews, 0, 0);
+ mColorRenderTarget.init(&mColorImageMS, &mColorImageMSViews, nullptr, nullptr, 0, 0, false);
+ mDepthStencilRenderTarget.init(&mDepthStencilImage, &mDepthStencilImageViews, nullptr, nullptr,
+ 0, 0, false);
mDepthStencilImageBinding.bind(&mDepthStencilImage);
mColorImageMSBinding.bind(&mColorImageMS);
}
@@ -540,6 +551,9 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
{
RendererVk *renderer = displayVk->getRenderer();
+ mColorImageMSViews.init(renderer);
+ mDepthStencilImageViews.init(renderer);
+
renderer->reloadVolkIfNeeded();
gl::Extents windowSize;
@@ -751,6 +765,9 @@ angle::Result WindowSurfaceVk::recreateSwapchain(ContextVk *contextVk,
angle::Result result = createSwapChain(contextVk, extents, lastSwapchain);
+ // Notify the parent classes of the surface's new state.
+ onStateChange(angle::SubjectMessage::SurfaceChanged);
+
// If the most recent swapchain was never used, destroy it right now.
if (swapchainToDestroy)
{
@@ -930,7 +947,7 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
// Initialize the color render target with the multisampled targets. If not multisampled,
// the render target will be updated to refer to a swapchain image on every acquire.
- mColorRenderTarget.init(&mColorImageMS, &mColorImageMSViews, 0, 0);
+ mColorRenderTarget.init(&mColorImageMS, &mColorImageMSViews, nullptr, nullptr, 0, 0, false);
}
ANGLE_TRY(resizeSwapchainImages(context, imageCount));
@@ -939,6 +956,7 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
{
SwapchainImage &member = mSwapchainImages[imageIndex];
member.image.init2DWeakReference(context, swapchainImages[imageIndex], extents, format, 1);
+ member.imageViews.init(renderer);
}
// Initialize depth/stencil if requested.
@@ -953,7 +971,8 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
ANGLE_TRY(mDepthStencilImage.initMemory(context, renderer->getMemoryProperties(),
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
- mDepthStencilRenderTarget.init(&mDepthStencilImage, &mDepthStencilImageViews, 0, 0);
+ mDepthStencilRenderTarget.init(&mDepthStencilImage, &mDepthStencilImageViews, nullptr,
+ nullptr, 0, 0, false);
// We will need to pass depth/stencil image views to the RenderTargetVk in the future.
}
@@ -1148,17 +1167,14 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
contextVk->optimizeRenderPassForPresent(currentFramebuffer.getHandle());
}
- vk::CommandBuffer *commandBuffer = nullptr;
- ANGLE_TRY(contextVk->endRenderPassAndGetCommandBuffer(&commandBuffer));
+ vk::CommandBuffer *commandBuffer = &contextVk->getOutsideRenderPassCommandBuffer();
if (mColorImageMS.valid())
{
// Transition the multisampled image to TRANSFER_SRC for resolve.
- ANGLE_TRY(contextVk->onImageRead(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc,
- &mColorImageMS));
- ANGLE_TRY(contextVk->onImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
- &image.image));
- ANGLE_TRY(contextVk->endRenderPassAndGetCommandBuffer(&commandBuffer));
+ ANGLE_TRY(contextVk->onImageTransferRead(VK_IMAGE_ASPECT_COLOR_BIT, &mColorImageMS));
+ ANGLE_TRY(contextVk->onImageTransferWrite(VK_IMAGE_ASPECT_COLOR_BIT, &image.image));
+ commandBuffer = &contextVk->getOutsideRenderPassCommandBuffer();
VkImageResolve resolveRegion = {};
resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
@@ -1179,7 +1195,8 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
}
// This does nothing if it already in the requested layout
- image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, commandBuffer);
+ image.image.recordReadBarrier(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present,
+ commandBuffer);
// Knowing that the kSwapHistorySize'th submission ago has finished, we can know that the
// (kSwapHistorySize+1)'th present ago of this image is definitely finished and so its wait
@@ -1236,6 +1253,11 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
rect.extent.width = gl::clamp(*eglRects++, 0, width - rect.offset.x);
rect.extent.height = gl::clamp(*eglRects++, 0, height - rect.offset.y);
rect.layer = 0;
+ if (Is90DegreeRotation(mPreTransform))
+ {
+ std::swap(rect.offset.x, rect.offset.y);
+ std::swap(rect.extent.width, rect.extent.height);
+ }
}
presentRegion.pRectangles = vkRects.data();
@@ -1354,7 +1376,7 @@ VkResult WindowSurfaceVk::nextSwapchainImage(vk::Context *context)
// multisampling, as the swapchain image is essentially unused until then.
if (!mColorImageMS.valid())
{
- mColorRenderTarget.updateSwapchainImage(&image.image, &image.imageViews);
+ mColorRenderTarget.updateSwapchainImage(&image.image, &image.imageViews, nullptr, nullptr);
}
// Notify the owning framebuffer there may be staged updates.
@@ -1615,19 +1637,18 @@ angle::Result WindowSurfaceVk::initializeContents(const gl::Context *context,
void WindowSurfaceVk::updateOverlay(ContextVk *contextVk) const
{
const gl::OverlayType *overlay = contextVk->getOverlay();
- OverlayVk *overlayVk = vk::GetImpl(overlay);
// If overlay is disabled, nothing to do.
- if (overlayVk == nullptr)
+ if (!overlay->isEnabled())
{
return;
}
- RendererVk *rendererVk = contextVk->getRenderer();
+ RendererVk *renderer = contextVk->getRenderer();
uint32_t validationMessageCount = 0;
std::string lastValidationMessage =
- rendererVk->getAndClearLastValidationMessage(&validationMessageCount);
+ renderer->getAndClearLastValidationMessage(&validationMessageCount);
if (validationMessageCount)
{
overlay->getTextWidget(gl::WidgetId::VulkanLastValidationMessage)