Commit ce540d8c by Ian Elliott Committed by Commit Bot

Create MSAA-swapchain windows' VkImages differently

The actual VkImage needs to have rotated extents, but the ImageHelper needs to have non-rotated extents in order for the rest of ANGLE's pre-rotation to work. Bug: b/175793022 Change-Id: I6fa25ab8c636886787ac50b194e566111308f30b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2666514Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent d3c00f95
...@@ -1023,9 +1023,14 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context, ...@@ -1023,9 +1023,14 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
{ {
const VkImageUsageFlags usage = kSurfaceVkColorImageUsageFlags; const VkImageUsageFlags usage = kSurfaceVkColorImageUsageFlags;
ANGLE_TRY(mColorImageMS.init(context, gl::TextureType::_2D, vkExtents, format, samples, // Create a multisampled image that will be rendered to, and then resolved to a swapchain
usage, gl::LevelIndex(0), gl::LevelIndex(0), 1, 1, // image. The actual VkImage is created with rotated coordinates to make it easier to do
robustInit)); // the resolve. The ImageHelper::mExtents will have non-rotated extents in order to fit
// with the rest of ANGLE, (e.g. which calculates the Vulkan scissor with non-rotated
// values and then rotates the final rectangle).
ANGLE_TRY(mColorImageMS.initMSAASwapchain(
context, gl::TextureType::_2D, vkExtents, Is90DegreeRotation(getPreTransform()), format,
samples, usage, gl::LevelIndex(0), gl::LevelIndex(0), 1, 1, robustInit));
ANGLE_TRY(mColorImageMS.initMemory(context, renderer->getMemoryProperties(), ANGLE_TRY(mColorImageMS.initMemory(context, renderer->getMemoryProperties(),
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)); VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
...@@ -1325,6 +1330,12 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk, ...@@ -1325,6 +1330,12 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
resolveRegion.dstSubresource = resolveRegion.srcSubresource; resolveRegion.dstSubresource = resolveRegion.srcSubresource;
resolveRegion.dstOffset = {}; resolveRegion.dstOffset = {};
resolveRegion.extent = image.image.getExtents(); resolveRegion.extent = image.image.getExtents();
// ImageHelper extents are non-rotated. If the window is 90 or 270 degrees, swap the width
// and height.
if (Is90DegreeRotation(getPreTransform()))
{
std::swap(resolveRegion.extent.width, resolveRegion.extent.height);
}
mColorImageMS.resolve(&image.image, resolveRegion, commandBuffer); mColorImageMS.resolve(&image.image, resolveRegion, commandBuffer);
} }
......
...@@ -3598,6 +3598,29 @@ angle::Result ImageHelper::init(Context *context, ...@@ -3598,6 +3598,29 @@ angle::Result ImageHelper::init(Context *context,
maxLevel, mipLevels, layerCount, isRobustResourceInitEnabled); maxLevel, mipLevels, layerCount, isRobustResourceInitEnabled);
} }
angle::Result ImageHelper::initMSAASwapchain(Context *context,
gl::TextureType textureType,
const VkExtent3D &extents,
bool rotatedAspectRation,
const Format &format,
GLint samples,
VkImageUsageFlags usage,
gl::LevelIndex baseLevel,
gl::LevelIndex maxLevel,
uint32_t mipLevels,
uint32_t layerCount,
bool isRobustResourceInitEnabled)
{
ANGLE_TRY(initExternal(context, textureType, extents, format, samples, usage,
kVkImageCreateFlagsNone, ImageLayout::Undefined, nullptr, baseLevel,
maxLevel, mipLevels, layerCount, isRobustResourceInitEnabled));
if (rotatedAspectRation)
{
std::swap(mExtents.width, mExtents.height);
}
return angle::Result::Continue;
}
angle::Result ImageHelper::initExternal(Context *context, angle::Result ImageHelper::initExternal(Context *context,
gl::TextureType textureType, gl::TextureType textureType,
const VkExtent3D &extents, const VkExtent3D &extents,
......
...@@ -1336,6 +1336,18 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1336,6 +1336,18 @@ class ImageHelper final : public Resource, public angle::Subject
uint32_t mipLevels, uint32_t mipLevels,
uint32_t layerCount, uint32_t layerCount,
bool isRobustResourceInitEnabled); bool isRobustResourceInitEnabled);
angle::Result initMSAASwapchain(Context *context,
gl::TextureType textureType,
const VkExtent3D &extents,
bool rotatedAspectRation,
const Format &format,
GLint samples,
VkImageUsageFlags usage,
gl::LevelIndex baseLevel,
gl::LevelIndex maxLevel,
uint32_t mipLevels,
uint32_t layerCount,
bool isRobustResourceInitEnabled);
angle::Result initExternal(Context *context, angle::Result initExternal(Context *context,
gl::TextureType textureType, gl::TextureType textureType,
const VkExtent3D &extents, const VkExtent3D &extents,
......
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