Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2016 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // SurfaceVk.cpp: |
| 7 | // Implements the class methods for SurfaceVk. |
| 8 | // |
| 9 | |
| 10 | #include "libANGLE/renderer/vulkan/SurfaceVk.h" |
| 11 | |
| 12 | #include "common/debug.h" |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 13 | #include "libANGLE/Context.h" |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 14 | #include "libANGLE/Display.h" |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 15 | #include "libANGLE/Surface.h" |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 16 | #include "libANGLE/renderer/vulkan/ContextVk.h" |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 17 | #include "libANGLE/renderer/vulkan/DisplayVk.h" |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 18 | #include "libANGLE/renderer/vulkan/FramebufferVk.h" |
| 19 | #include "libANGLE/renderer/vulkan/RendererVk.h" |
Jamie Madill | 3c424b4 | 2018-01-19 12:35:09 -0500 | [diff] [blame] | 20 | #include "libANGLE/renderer/vulkan/vk_format_utils.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 21 | |
| 22 | namespace rx |
| 23 | { |
| 24 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 25 | namespace |
| 26 | { |
| 27 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 28 | VkPresentModeKHR GetDesiredPresentMode(const std::vector<VkPresentModeKHR> &presentModes, |
| 29 | EGLint minSwapInterval, |
| 30 | EGLint maxSwapInterval) |
| 31 | { |
| 32 | ASSERT(!presentModes.empty()); |
| 33 | |
| 34 | // Use FIFO mode for v-sync, since it throttles you to the display rate. Mailbox is more |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 35 | // similar to triple-buffering. For now we hard-code Mailbox for perf testing. |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 36 | // TODO(jmadill): Properly select present mode and re-create display if changed. |
| 37 | VkPresentModeKHR bestChoice = VK_PRESENT_MODE_MAILBOX_KHR; |
| 38 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 39 | for (VkPresentModeKHR presentMode : presentModes) |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 40 | { |
| 41 | if (presentMode == bestChoice) |
| 42 | { |
| 43 | return bestChoice; |
| 44 | } |
| 45 | } |
| 46 | |
Jamie Madill | 98de826 | 2017-05-29 13:01:02 -0400 | [diff] [blame] | 47 | WARN() << "Present mode " << bestChoice << " not available. Falling back to " |
| 48 | << presentModes[0]; |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 49 | return presentModes[0]; |
| 50 | } |
| 51 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 52 | constexpr VkImageUsageFlags kSurfaceVKImageUsageFlags = |
| 53 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 54 | constexpr VkImageUsageFlags kSurfaceVKColorImageUsageFlags = |
| 55 | kSurfaceVKImageUsageFlags | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 56 | constexpr VkImageUsageFlags kSurfaceVKDepthStencilImageUsageFlags = |
| 57 | kSurfaceVKImageUsageFlags | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 58 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 59 | } // namespace |
| 60 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 61 | OffscreenSurfaceVk::AttachmentImage::AttachmentImage() : renderTarget(&image, &imageView, 0) |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 62 | { |
| 63 | } |
| 64 | |
| 65 | OffscreenSurfaceVk::AttachmentImage::~AttachmentImage() = default; |
| 66 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 67 | angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *displayVk, |
| 68 | EGLint width, |
| 69 | EGLint height, |
| 70 | const vk::Format &vkFormat) |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 71 | { |
Geoff Lang | 38971fd | 2018-06-28 15:19:18 -0400 | [diff] [blame] | 72 | RendererVk *renderer = displayVk->getRenderer(); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 73 | |
| 74 | const angle::Format &textureFormat = vkFormat.textureFormat(); |
| 75 | bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0; |
| 76 | const VkImageUsageFlags usage = isDepthOrStencilFormat ? kSurfaceVKDepthStencilImageUsageFlags |
| 77 | : kSurfaceVKColorImageUsageFlags; |
| 78 | |
| 79 | gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 80 | ANGLE_TRY(image.init(displayVk, gl::TextureType::_2D, extents, vkFormat, 1, usage, 1)); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 81 | |
| 82 | VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 83 | ANGLE_TRY(image.initMemory(displayVk, renderer->getMemoryProperties(), flags)); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 84 | |
| 85 | VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat); |
| 86 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 87 | ANGLE_TRY(image.initImageView(displayVk, gl::TextureType::_2D, aspect, gl::SwizzleState(), |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 88 | &imageView, 1)); |
| 89 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 90 | return angle::Result::Continue(); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 91 | } |
| 92 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 93 | void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display) |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 94 | { |
| 95 | const DisplayVk *displayVk = vk::GetImpl(display); |
| 96 | RendererVk *renderer = displayVk->getRenderer(); |
| 97 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 98 | image.release(renderer); |
| 99 | renderer->releaseObject(renderer->getCurrentQueueSerial(), &imageView); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 100 | } |
| 101 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 102 | OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, |
| 103 | EGLint width, |
| 104 | EGLint height) |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 105 | : SurfaceImpl(surfaceState), mWidth(width), mHeight(height) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 106 | { |
| 107 | } |
| 108 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 109 | OffscreenSurfaceVk::~OffscreenSurfaceVk() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 110 | { |
| 111 | } |
| 112 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 113 | egl::Error OffscreenSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 114 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 115 | DisplayVk *displayVk = vk::GetImpl(display); |
| 116 | angle::Result result = initializeImpl(displayVk); |
| 117 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 118 | } |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 119 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 120 | angle::Result OffscreenSurfaceVk::initializeImpl(DisplayVk *displayVk) |
| 121 | { |
| 122 | RendererVk *renderer = displayVk->getRenderer(); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 123 | const egl::Config *config = mState.config; |
| 124 | |
| 125 | if (config->renderTargetFormat != GL_NONE) |
| 126 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 127 | ANGLE_TRY(mColorAttachment.initialize(displayVk, mWidth, mHeight, |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 128 | renderer->getFormat(config->renderTargetFormat))); |
| 129 | } |
| 130 | |
| 131 | if (config->depthStencilFormat != GL_NONE) |
| 132 | { |
| 133 | ANGLE_TRY(mDepthStencilAttachment.initialize( |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 134 | displayVk, mWidth, mHeight, renderer->getFormat(config->depthStencilFormat))); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 135 | } |
| 136 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 137 | return angle::Result::Continue(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 138 | } |
| 139 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 140 | void OffscreenSurfaceVk::destroy(const egl::Display *display) |
| 141 | { |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 142 | mColorAttachment.destroy(display); |
| 143 | mDepthStencilAttachment.destroy(display); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 144 | } |
| 145 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 146 | FramebufferImpl *OffscreenSurfaceVk::createDefaultFramebuffer(const gl::Context *context, |
| 147 | const gl::FramebufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 148 | { |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 149 | RendererVk *renderer = vk::GetImpl(context)->getRenderer(); |
| 150 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 151 | // Use a user FBO for an offscreen RT. |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 152 | return FramebufferVk::CreateUserFBO(renderer, state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 153 | } |
| 154 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 155 | egl::Error OffscreenSurfaceVk::swap(const gl::Context *context) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 156 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 157 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 158 | } |
| 159 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 160 | egl::Error OffscreenSurfaceVk::postSubBuffer(const gl::Context * /*context*/, |
| 161 | EGLint /*x*/, |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 162 | EGLint /*y*/, |
| 163 | EGLint /*width*/, |
| 164 | EGLint /*height*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 165 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 166 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 169 | egl::Error OffscreenSurfaceVk::querySurfacePointerANGLE(EGLint /*attribute*/, void ** /*value*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 170 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 171 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 172 | return egl::EglBadCurrentSurface(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 173 | } |
| 174 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 175 | egl::Error OffscreenSurfaceVk::bindTexImage(const gl::Context * /*context*/, |
| 176 | gl::Texture * /*texture*/, |
| 177 | EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 178 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 179 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 180 | } |
| 181 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 182 | egl::Error OffscreenSurfaceVk::releaseTexImage(const gl::Context * /*context*/, EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 183 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 184 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 185 | } |
| 186 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 187 | egl::Error OffscreenSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 188 | EGLuint64KHR * /*msc*/, |
| 189 | EGLuint64KHR * /*sbc*/) |
| 190 | { |
| 191 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 192 | return egl::EglBadAccess(); |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 195 | void OffscreenSurfaceVk::setSwapInterval(EGLint /*interval*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 196 | { |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 197 | } |
| 198 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 199 | EGLint OffscreenSurfaceVk::getWidth() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 200 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 201 | return mWidth; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 202 | } |
| 203 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 204 | EGLint OffscreenSurfaceVk::getHeight() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 205 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 206 | return mHeight; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 207 | } |
| 208 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 209 | EGLint OffscreenSurfaceVk::isPostSubBufferSupported() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 210 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 211 | return EGL_FALSE; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 212 | } |
| 213 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 214 | EGLint OffscreenSurfaceVk::getSwapBehavior() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 215 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 216 | return EGL_BUFFER_PRESERVED; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 217 | } |
| 218 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 219 | angle::Result OffscreenSurfaceVk::getAttachmentRenderTarget( |
| 220 | const gl::Context *context, |
| 221 | GLenum binding, |
| 222 | const gl::ImageIndex &imageIndex, |
| 223 | FramebufferAttachmentRenderTarget **rtOut) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 224 | { |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 225 | if (binding == GL_BACK) |
| 226 | { |
| 227 | *rtOut = &mColorAttachment.renderTarget; |
| 228 | } |
| 229 | else |
| 230 | { |
| 231 | ASSERT(binding == GL_DEPTH || binding == GL_STENCIL || binding == GL_DEPTH_STENCIL); |
| 232 | *rtOut = &mDepthStencilAttachment.renderTarget; |
| 233 | } |
| 234 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 235 | return angle::Result::Continue(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 236 | } |
| 237 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 238 | angle::Result OffscreenSurfaceVk::initializeContents(const gl::Context *context, |
| 239 | const gl::ImageIndex &imageIndex) |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 240 | { |
| 241 | UNIMPLEMENTED(); |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 242 | return angle::Result::Continue(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 243 | } |
| 244 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 245 | WindowSurfaceVk::SwapchainImage::SwapchainImage() = default; |
| 246 | WindowSurfaceVk::SwapchainImage::~SwapchainImage() = default; |
| 247 | |
| 248 | WindowSurfaceVk::SwapchainImage::SwapchainImage(SwapchainImage &&other) |
| 249 | : image(std::move(other.image)), |
| 250 | imageView(std::move(other.imageView)), |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame^] | 251 | framebuffer(std::move(other.framebuffer)) |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 252 | { |
| 253 | } |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 254 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 255 | WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, |
| 256 | EGLNativeWindowType window, |
| 257 | EGLint width, |
| 258 | EGLint height) |
| 259 | : SurfaceImpl(surfaceState), |
| 260 | mNativeWindowType(window), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 261 | mSurface(VK_NULL_HANDLE), |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 262 | mInstance(VK_NULL_HANDLE), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 263 | mSwapchain(VK_NULL_HANDLE), |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 264 | mColorRenderTarget(nullptr, nullptr, 0), |
| 265 | mDepthStencilRenderTarget(&mDepthStencilImage, &mDepthStencilImageView, 0), |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 266 | mCurrentSwapchainImageIndex(0) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 267 | { |
| 268 | } |
| 269 | |
| 270 | WindowSurfaceVk::~WindowSurfaceVk() |
| 271 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 272 | ASSERT(mSurface == VK_NULL_HANDLE); |
| 273 | ASSERT(mSwapchain == VK_NULL_HANDLE); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 274 | } |
| 275 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 276 | void WindowSurfaceVk::destroy(const egl::Display *display) |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 277 | { |
Geoff Lang | 38971fd | 2018-06-28 15:19:18 -0400 | [diff] [blame] | 278 | DisplayVk *displayVk = vk::GetImpl(display); |
| 279 | RendererVk *renderer = displayVk->getRenderer(); |
| 280 | VkDevice device = renderer->getDevice(); |
| 281 | VkInstance instance = renderer->getInstance(); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 282 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 283 | // We might not need to flush the pipe here. |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 284 | (void)renderer->finish(displayVk); |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 285 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 286 | mDepthStencilImage.release(renderer); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 287 | mDepthStencilImageView.destroy(device); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 288 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 289 | for (SwapchainImage &swapchainImage : mSwapchainImages) |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 290 | { |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 291 | // Although we don't own the swapchain image handles, we need to keep our shutdown clean. |
Jamie Madill | 858c1cc | 2018-03-31 14:19:13 -0400 | [diff] [blame] | 292 | swapchainImage.image.resetImageWeakReference(); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 293 | swapchainImage.image.destroy(device); |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 294 | swapchainImage.imageView.destroy(device); |
| 295 | swapchainImage.framebuffer.destroy(device); |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 296 | } |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 297 | |
| 298 | if (mSwapchain) |
| 299 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 300 | vkDestroySwapchainKHR(device, mSwapchain, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 301 | mSwapchain = VK_NULL_HANDLE; |
| 302 | } |
| 303 | |
| 304 | if (mSurface) |
| 305 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 306 | vkDestroySurfaceKHR(instance, mSurface, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 307 | mSurface = VK_NULL_HANDLE; |
| 308 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 309 | } |
| 310 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 311 | egl::Error WindowSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 312 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 313 | DisplayVk *displayVk = vk::GetImpl(display); |
| 314 | angle::Result result = initializeImpl(displayVk); |
| 315 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 316 | } |
| 317 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 318 | angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 319 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 320 | RendererVk *renderer = displayVk->getRenderer(); |
| 321 | |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 322 | gl::Extents windowSize; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 323 | ANGLE_TRY(createSurfaceVk(displayVk, &windowSize)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 324 | |
| 325 | uint32_t presentQueue = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 326 | ANGLE_TRY(renderer->selectPresentQueueForSurface(displayVk, mSurface, &presentQueue)); |
Jamie Madill | c6dbc25 | 2018-04-30 19:07:56 -0400 | [diff] [blame] | 327 | ANGLE_UNUSED_VARIABLE(presentQueue); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 328 | |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 329 | const VkPhysicalDevice &physicalDevice = renderer->getPhysicalDevice(); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 330 | |
| 331 | VkSurfaceCapabilitiesKHR surfaceCaps; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 332 | ANGLE_VK_TRY(displayVk, |
| 333 | vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface, &surfaceCaps)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 334 | |
| 335 | // Adjust width and height to the swapchain if necessary. |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 336 | uint32_t width = surfaceCaps.currentExtent.width; |
| 337 | uint32_t height = surfaceCaps.currentExtent.height; |
| 338 | |
| 339 | // TODO(jmadill): Support devices which don't support copy. We use this for ReadPixels. |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 340 | ANGLE_VK_CHECK(displayVk, |
| 341 | (surfaceCaps.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) != 0, |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 342 | VK_ERROR_INITIALIZATION_FAILED); |
| 343 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 344 | EGLAttrib attribWidth = mState.attributes.get(EGL_WIDTH, 0); |
| 345 | EGLAttrib attribHeight = mState.attributes.get(EGL_HEIGHT, 0); |
| 346 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 347 | if (surfaceCaps.currentExtent.width == 0xFFFFFFFFu) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 348 | { |
| 349 | ASSERT(surfaceCaps.currentExtent.height == 0xFFFFFFFFu); |
| 350 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 351 | if (attribWidth == 0) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 352 | { |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 353 | width = windowSize.width; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 354 | } |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 355 | if (attribHeight == 0) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 356 | { |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 357 | height = windowSize.height; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 361 | gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 362 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 363 | uint32_t presentModeCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 364 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, mSurface, |
| 365 | &presentModeCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 366 | ASSERT(presentModeCount > 0); |
| 367 | |
| 368 | std::vector<VkPresentModeKHR> presentModes(presentModeCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 369 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 370 | physicalDevice, mSurface, &presentModeCount, presentModes.data())); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 371 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 372 | // Select appropriate present mode based on vsync parameter. |
| 373 | // TODO(jmadill): More complete implementation, which allows for changing and more values. |
| 374 | const EGLint minSwapInterval = mState.config->minSwapInterval; |
| 375 | const EGLint maxSwapInterval = mState.config->maxSwapInterval; |
| 376 | ASSERT(minSwapInterval == 0 || minSwapInterval == 1); |
| 377 | ASSERT(maxSwapInterval == 0 || maxSwapInterval == 1); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 378 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 379 | VkPresentModeKHR swapchainPresentMode = |
| 380 | GetDesiredPresentMode(presentModes, minSwapInterval, maxSwapInterval); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 381 | |
| 382 | // Determine number of swapchain images. Aim for one more than the minimum. |
| 383 | uint32_t minImageCount = surfaceCaps.minImageCount + 1; |
| 384 | if (surfaceCaps.maxImageCount > 0 && minImageCount > surfaceCaps.maxImageCount) |
| 385 | { |
| 386 | minImageCount = surfaceCaps.maxImageCount; |
| 387 | } |
| 388 | |
| 389 | // Default to identity transform. |
| 390 | VkSurfaceTransformFlagBitsKHR preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; |
| 391 | if ((surfaceCaps.supportedTransforms & preTransform) == 0) |
| 392 | { |
| 393 | preTransform = surfaceCaps.currentTransform; |
| 394 | } |
| 395 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 396 | uint32_t surfaceFormatCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 397 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, |
| 398 | &surfaceFormatCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 399 | |
| 400 | std::vector<VkSurfaceFormatKHR> surfaceFormats(surfaceFormatCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 401 | ANGLE_VK_TRY(displayVk, |
| 402 | vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, &surfaceFormatCount, |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 403 | surfaceFormats.data())); |
| 404 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 405 | const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat); |
| 406 | VkFormat nativeFormat = format.vkTextureFormat; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 407 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 408 | if (surfaceFormatCount == 1u && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) |
| 409 | { |
| 410 | // This is fine. |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | bool foundFormat = false; |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 415 | for (const VkSurfaceFormatKHR &surfaceFormat : surfaceFormats) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 416 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 417 | if (surfaceFormat.format == nativeFormat) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 418 | { |
| 419 | foundFormat = true; |
| 420 | break; |
| 421 | } |
| 422 | } |
| 423 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 424 | ANGLE_VK_CHECK(displayVk, foundFormat, VK_ERROR_INITIALIZATION_FAILED); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 425 | } |
| 426 | |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 427 | VkCompositeAlphaFlagBitsKHR compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; |
| 428 | if ((surfaceCaps.supportedCompositeAlpha & compositeAlpha) == 0) |
| 429 | { |
| 430 | compositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR; |
| 431 | } |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 432 | ANGLE_VK_CHECK(displayVk, (surfaceCaps.supportedCompositeAlpha & compositeAlpha) != 0, |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 433 | VK_ERROR_INITIALIZATION_FAILED); |
| 434 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 435 | // We need transfer src for reading back from the backbuffer. |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 436 | VkImageUsageFlags imageUsageFlags = kSurfaceVKColorImageUsageFlags; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 437 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 438 | VkSwapchainCreateInfoKHR swapchainInfo = {}; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 439 | swapchainInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 440 | swapchainInfo.flags = 0; |
| 441 | swapchainInfo.surface = mSurface; |
| 442 | swapchainInfo.minImageCount = minImageCount; |
| 443 | swapchainInfo.imageFormat = nativeFormat; |
| 444 | swapchainInfo.imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
| 445 | swapchainInfo.imageExtent.width = width; |
| 446 | swapchainInfo.imageExtent.height = height; |
| 447 | swapchainInfo.imageArrayLayers = 1; |
| 448 | swapchainInfo.imageUsage = imageUsageFlags; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 449 | swapchainInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 450 | swapchainInfo.queueFamilyIndexCount = 0; |
| 451 | swapchainInfo.pQueueFamilyIndices = nullptr; |
| 452 | swapchainInfo.preTransform = preTransform; |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 453 | swapchainInfo.compositeAlpha = compositeAlpha; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 454 | swapchainInfo.presentMode = swapchainPresentMode; |
| 455 | swapchainInfo.clipped = VK_TRUE; |
| 456 | swapchainInfo.oldSwapchain = VK_NULL_HANDLE; |
| 457 | |
Jamie Madill | 6a89d22 | 2017-11-02 11:59:51 -0400 | [diff] [blame] | 458 | VkDevice device = renderer->getDevice(); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 459 | ANGLE_VK_TRY(displayVk, vkCreateSwapchainKHR(device, &swapchainInfo, nullptr, &mSwapchain)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 460 | |
| 461 | // Intialize the swapchain image views. |
| 462 | uint32_t imageCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 463 | ANGLE_VK_TRY(displayVk, vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 464 | |
| 465 | std::vector<VkImage> swapchainImages(imageCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 466 | ANGLE_VK_TRY(displayVk, |
| 467 | vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, swapchainImages.data())); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 468 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 469 | VkClearColorValue transparentBlack = {}; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 470 | transparentBlack.float32[0] = 0.0f; |
| 471 | transparentBlack.float32[1] = 0.0f; |
| 472 | transparentBlack.float32[2] = 0.0f; |
| 473 | transparentBlack.float32[3] = 0.0f; |
| 474 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 475 | mSwapchainImages.resize(imageCount); |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 476 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 477 | for (uint32_t imageIndex = 0; imageIndex < imageCount; ++imageIndex) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 478 | { |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 479 | SwapchainImage &member = mSwapchainImages[imageIndex]; |
| 480 | member.image.init2DWeakReference(swapchainImages[imageIndex], extents, format, 1); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 481 | ANGLE_TRY(member.image.initImageView(displayVk, gl::TextureType::_2D, |
Jamie Madill | eebe219 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 482 | VK_IMAGE_ASPECT_COLOR_BIT, gl::SwizzleState(), |
| 483 | &member.imageView, 1)); |
Jamie Madill | 25301b6 | 2017-10-28 20:59:31 -0400 | [diff] [blame] | 484 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 485 | // Allocate a command buffer for clearing our images to black. |
| 486 | vk::CommandBuffer *commandBuffer = nullptr; |
| 487 | ANGLE_TRY(member.image.recordCommands(displayVk, &commandBuffer)); |
| 488 | |
Jamie Madill | 25301b6 | 2017-10-28 20:59:31 -0400 | [diff] [blame] | 489 | // Set transfer dest layout, and clear the image to black. |
Luc Ferron | c20b950 | 2018-05-24 09:30:17 -0400 | [diff] [blame] | 490 | member.image.clearColor(transparentBlack, 0, 1, commandBuffer); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 493 | // Get the first available swapchain iamge. |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 494 | ANGLE_TRY(nextSwapchainImage(displayVk)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 495 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 496 | // Initialize depth/stencil if requested. |
| 497 | if (mState.config->depthStencilFormat != GL_NONE) |
| 498 | { |
| 499 | const vk::Format &dsFormat = renderer->getFormat(mState.config->depthStencilFormat); |
| 500 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 501 | const VkImageUsageFlags dsUsage = kSurfaceVKDepthStencilImageUsageFlags; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 502 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 503 | ANGLE_TRY(mDepthStencilImage.init(displayVk, gl::TextureType::_2D, extents, dsFormat, 1, |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 504 | dsUsage, 1)); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 505 | ANGLE_TRY(mDepthStencilImage.initMemory(displayVk, renderer->getMemoryProperties(), |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 506 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 507 | |
Luc Ferron | 5bdf8bd | 2018-06-20 09:51:37 -0400 | [diff] [blame] | 508 | const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(dsFormat.textureFormat()); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 509 | VkClearDepthStencilValue depthStencilClearValue = {1.0f, 0}; |
| 510 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 511 | // Clear the image. |
| 512 | vk::CommandBuffer *commandBuffer = nullptr; |
| 513 | ANGLE_TRY(mDepthStencilImage.recordCommands(displayVk, &commandBuffer)); |
Jamie Madill | 858c1cc | 2018-03-31 14:19:13 -0400 | [diff] [blame] | 514 | mDepthStencilImage.clearDepthStencil(aspect, depthStencilClearValue, commandBuffer); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 515 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 516 | ANGLE_TRY(mDepthStencilImage.initImageView(displayVk, gl::TextureType::_2D, aspect, |
Luc Ferron | 6641053 | 2018-04-20 12:47:45 -0400 | [diff] [blame] | 517 | gl::SwizzleState(), &mDepthStencilImageView, 1)); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 518 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 519 | // We will need to pass depth/stencil image views to the RenderTargetVk in the future. |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 520 | } |
| 521 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 522 | return angle::Result::Continue(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 523 | } |
| 524 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 525 | FramebufferImpl *WindowSurfaceVk::createDefaultFramebuffer(const gl::Context *context, |
| 526 | const gl::FramebufferState &state) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 527 | { |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 528 | RendererVk *renderer = vk::GetImpl(context)->getRenderer(); |
| 529 | return FramebufferVk::CreateDefaultFBO(renderer, state, this); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 530 | } |
| 531 | |
Courtney Goeltzenleuchter | f0d258c | 2018-09-11 09:37:48 -0600 | [diff] [blame] | 532 | egl::Error WindowSurfaceVk::swapWithDamage(const gl::Context *context, |
| 533 | EGLint * /*rects*/, |
| 534 | EGLint /*n_rects*/) |
| 535 | { |
| 536 | DisplayVk *displayVk = vk::GetImpl(context->getCurrentDisplay()); |
| 537 | angle::Result result = swapImpl(displayVk); |
| 538 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 539 | } |
| 540 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 541 | egl::Error WindowSurfaceVk::swap(const gl::Context *context) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 542 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 543 | DisplayVk *displayVk = vk::GetImpl(context->getCurrentDisplay()); |
| 544 | angle::Result result = swapImpl(displayVk); |
| 545 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 546 | } |
| 547 | |
| 548 | angle::Result WindowSurfaceVk::swapImpl(DisplayVk *displayVk) |
| 549 | { |
| 550 | RendererVk *renderer = displayVk->getRenderer(); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 551 | |
Jamie Madill | 49ac74b | 2017-12-21 14:42:33 -0500 | [diff] [blame] | 552 | vk::CommandBuffer *swapCommands = nullptr; |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 553 | ANGLE_TRY(mSwapchainImages[mCurrentSwapchainImageIndex].image.recordCommands(displayVk, |
| 554 | &swapCommands)); |
Jamie Madill | d482615 | 2017-09-21 11:18:59 -0400 | [diff] [blame] | 555 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 556 | SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex]; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 557 | |
Jamie Madill | 858c1cc | 2018-03-31 14:19:13 -0400 | [diff] [blame] | 558 | image.image.changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, |
| 559 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 560 | VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, swapCommands); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 561 | |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame^] | 562 | ANGLE_TRY(renderer->flush(displayVk)); |
| 563 | |
| 564 | // Ask the renderer what semaphore it signalled in the last flush. |
| 565 | const vk::Semaphore *commandsCompleteSemaphore = |
| 566 | renderer->getSubmitLastSignaledSemaphore(displayVk); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 567 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 568 | VkPresentInfoKHR presentInfo = {}; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 569 | presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame^] | 570 | presentInfo.waitSemaphoreCount = commandsCompleteSemaphore ? 1 : 0; |
| 571 | presentInfo.pWaitSemaphores = |
| 572 | commandsCompleteSemaphore ? commandsCompleteSemaphore->ptr() : nullptr; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 573 | presentInfo.swapchainCount = 1; |
| 574 | presentInfo.pSwapchains = &mSwapchain; |
| 575 | presentInfo.pImageIndices = &mCurrentSwapchainImageIndex; |
| 576 | presentInfo.pResults = nullptr; |
| 577 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 578 | ANGLE_VK_TRY(displayVk, vkQueuePresentKHR(renderer->getQueue(), &presentInfo)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 579 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 580 | // Get the next available swapchain image. |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 581 | ANGLE_TRY(nextSwapchainImage(displayVk)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 582 | |
Shahbaz Youssefi | 996628a | 2018-09-24 16:39:26 -0400 | [diff] [blame] | 583 | ANGLE_TRY(renderer->syncPipelineCacheVk(displayVk)); |
| 584 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 585 | return angle::Result::Continue(); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 586 | } |
| 587 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 588 | angle::Result WindowSurfaceVk::nextSwapchainImage(DisplayVk *displayVk) |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 589 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 590 | VkDevice device = displayVk->getDevice(); |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame^] | 591 | RendererVk *renderer = displayVk->getRenderer(); |
| 592 | |
| 593 | const vk::Semaphore *acquireNextImageSemaphore = nullptr; |
| 594 | ANGLE_TRY(renderer->allocateSubmitWaitSemaphore(displayVk, &acquireNextImageSemaphore)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 595 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 596 | ANGLE_VK_TRY(displayVk, vkAcquireNextImageKHR(device, mSwapchain, UINT64_MAX, |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame^] | 597 | acquireNextImageSemaphore->getHandle(), |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 598 | VK_NULL_HANDLE, &mCurrentSwapchainImageIndex)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 599 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 600 | SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex]; |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 601 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 602 | // Update RenderTarget pointers. |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 603 | mColorRenderTarget.updateSwapchainImage(&image.image, &image.imageView); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 604 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 605 | return angle::Result::Continue(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 606 | } |
| 607 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 608 | egl::Error WindowSurfaceVk::postSubBuffer(const gl::Context *context, |
| 609 | EGLint x, |
| 610 | EGLint y, |
| 611 | EGLint width, |
| 612 | EGLint height) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 613 | { |
| 614 | // TODO(jmadill) |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 615 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | egl::Error WindowSurfaceVk::querySurfacePointerANGLE(EGLint attribute, void **value) |
| 619 | { |
| 620 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 621 | return egl::EglBadCurrentSurface(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 622 | } |
| 623 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 624 | egl::Error WindowSurfaceVk::bindTexImage(const gl::Context *context, |
| 625 | gl::Texture *texture, |
| 626 | EGLint buffer) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 627 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 628 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 629 | } |
| 630 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 631 | egl::Error WindowSurfaceVk::releaseTexImage(const gl::Context *context, EGLint buffer) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 632 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 633 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 634 | } |
| 635 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 636 | egl::Error WindowSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 637 | EGLuint64KHR * /*msc*/, |
| 638 | EGLuint64KHR * /*sbc*/) |
| 639 | { |
| 640 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 641 | return egl::EglBadAccess(); |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 642 | } |
| 643 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 644 | void WindowSurfaceVk::setSwapInterval(EGLint interval) |
| 645 | { |
| 646 | } |
| 647 | |
| 648 | EGLint WindowSurfaceVk::getWidth() const |
| 649 | { |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 650 | return static_cast<EGLint>(mColorRenderTarget.getImageExtents().width); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | EGLint WindowSurfaceVk::getHeight() const |
| 654 | { |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 655 | return static_cast<EGLint>(mColorRenderTarget.getImageExtents().height); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | EGLint WindowSurfaceVk::isPostSubBufferSupported() const |
| 659 | { |
| 660 | // TODO(jmadill) |
| 661 | return EGL_FALSE; |
| 662 | } |
| 663 | |
| 664 | EGLint WindowSurfaceVk::getSwapBehavior() const |
| 665 | { |
| 666 | // TODO(jmadill) |
| 667 | return EGL_BUFFER_DESTROYED; |
| 668 | } |
| 669 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 670 | angle::Result WindowSurfaceVk::getAttachmentRenderTarget(const gl::Context *context, |
| 671 | GLenum binding, |
| 672 | const gl::ImageIndex &imageIndex, |
| 673 | FramebufferAttachmentRenderTarget **rtOut) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 674 | { |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 675 | if (binding == GL_BACK) |
| 676 | { |
| 677 | *rtOut = &mColorRenderTarget; |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | ASSERT(binding == GL_DEPTH || binding == GL_STENCIL || binding == GL_DEPTH_STENCIL); |
| 682 | *rtOut = &mDepthStencilRenderTarget; |
| 683 | } |
| 684 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 685 | return angle::Result::Continue(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 686 | } |
| 687 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 688 | angle::Result WindowSurfaceVk::getCurrentFramebuffer(vk::Context *context, |
| 689 | const vk::RenderPass &compatibleRenderPass, |
| 690 | vk::Framebuffer **framebufferOut) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 691 | { |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 692 | vk::Framebuffer ¤tFramebuffer = mSwapchainImages[mCurrentSwapchainImageIndex].framebuffer; |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 693 | |
| 694 | if (currentFramebuffer.valid()) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 695 | { |
| 696 | // Validation layers should detect if the render pass is really compatible. |
Jamie Madill | 5598148 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 697 | *framebufferOut = ¤tFramebuffer; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 698 | return angle::Result::Continue(); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 699 | } |
| 700 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 701 | VkFramebufferCreateInfo framebufferInfo = {}; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 702 | |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 703 | const gl::Extents &extents = mColorRenderTarget.getImageExtents(); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 704 | std::array<VkImageView, 2> imageViews = {{VK_NULL_HANDLE, mDepthStencilImageView.getHandle()}}; |
| 705 | |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 706 | framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 707 | framebufferInfo.flags = 0; |
| 708 | framebufferInfo.renderPass = compatibleRenderPass.getHandle(); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 709 | framebufferInfo.attachmentCount = (mDepthStencilImage.valid() ? 2u : 1u); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 710 | framebufferInfo.pAttachments = imageViews.data(); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 711 | framebufferInfo.width = static_cast<uint32_t>(extents.width); |
| 712 | framebufferInfo.height = static_cast<uint32_t>(extents.height); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 713 | framebufferInfo.layers = 1; |
| 714 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 715 | for (SwapchainImage &swapchainImage : mSwapchainImages) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 716 | { |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 717 | imageViews[0] = swapchainImage.imageView.getHandle(); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 718 | ANGLE_TRY(swapchainImage.framebuffer.init(context, framebufferInfo)); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 719 | } |
| 720 | |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 721 | ASSERT(currentFramebuffer.valid()); |
Jamie Madill | 5598148 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 722 | *framebufferOut = ¤tFramebuffer; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 723 | return angle::Result::Continue(); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 724 | } |
| 725 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 726 | angle::Result WindowSurfaceVk::initializeContents(const gl::Context *context, |
| 727 | const gl::ImageIndex &imageIndex) |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 728 | { |
| 729 | UNIMPLEMENTED(); |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 730 | return angle::Result::Continue(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 731 | } |
| 732 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 733 | } // namespace rx |