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" |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 21 | #include "third_party/trace_event/trace_event.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 22 | |
| 23 | namespace rx |
| 24 | { |
| 25 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 26 | namespace |
| 27 | { |
| 28 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 29 | VkPresentModeKHR GetDesiredPresentMode(const std::vector<VkPresentModeKHR> &presentModes, |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 30 | EGLint interval) |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 31 | { |
| 32 | ASSERT(!presentModes.empty()); |
| 33 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 34 | // If v-sync is enabled, use FIFO, which throttles you to the display rate and is guaranteed to |
| 35 | // always be supported. |
| 36 | if (interval > 0) |
| 37 | { |
| 38 | return VK_PRESENT_MODE_FIFO_KHR; |
| 39 | } |
| 40 | |
| 41 | // Otherwise, choose either of the following, if available, in order specified here: |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 42 | // |
| 43 | // - Mailbox is similar to triple-buffering. |
| 44 | // - Immediate is similar to single-buffering. |
| 45 | // |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 46 | // If neither is supported, we fallback to FIFO. |
| 47 | |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 48 | bool mailboxAvailable = false; |
| 49 | bool immediateAvailable = false; |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 50 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 51 | for (VkPresentModeKHR presentMode : presentModes) |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 52 | { |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 53 | switch (presentMode) |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 54 | { |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 55 | case VK_PRESENT_MODE_MAILBOX_KHR: |
| 56 | mailboxAvailable = true; |
| 57 | break; |
| 58 | case VK_PRESENT_MODE_IMMEDIATE_KHR: |
| 59 | immediateAvailable = true; |
| 60 | break; |
| 61 | default: |
| 62 | break; |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 66 | // Note again that VK_PRESENT_MODE_FIFO_KHR is guaranteed to be available. |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 67 | return mailboxAvailable |
| 68 | ? VK_PRESENT_MODE_MAILBOX_KHR |
| 69 | : immediateAvailable ? VK_PRESENT_MODE_IMMEDIATE_KHR : VK_PRESENT_MODE_FIFO_KHR; |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 70 | } |
| 71 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 72 | constexpr VkImageUsageFlags kSurfaceVKImageUsageFlags = |
| 73 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 74 | constexpr VkImageUsageFlags kSurfaceVKColorImageUsageFlags = |
Shahbaz Youssefi | f83a28a | 2018-12-09 03:48:34 +0100 | [diff] [blame] | 75 | kSurfaceVKImageUsageFlags | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 76 | constexpr VkImageUsageFlags kSurfaceVKDepthStencilImageUsageFlags = |
| 77 | kSurfaceVKImageUsageFlags | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 78 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 79 | } // namespace |
| 80 | |
Shahbaz Youssefi | 29b4941 | 2019-01-07 14:03:06 -0500 | [diff] [blame] | 81 | OffscreenSurfaceVk::AttachmentImage::AttachmentImage() |
Geoff Lang | f3e823d | 2019-01-14 12:40:34 -0500 | [diff] [blame] | 82 | { |
| 83 | renderTarget.init(&image, &imageView, 0, nullptr); |
| 84 | } |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 85 | |
| 86 | OffscreenSurfaceVk::AttachmentImage::~AttachmentImage() = default; |
| 87 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 88 | angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *displayVk, |
| 89 | EGLint width, |
| 90 | EGLint height, |
| 91 | const vk::Format &vkFormat) |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 92 | { |
Geoff Lang | 38971fd | 2018-06-28 15:19:18 -0400 | [diff] [blame] | 93 | RendererVk *renderer = displayVk->getRenderer(); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 94 | |
| 95 | const angle::Format &textureFormat = vkFormat.textureFormat(); |
| 96 | bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0; |
| 97 | const VkImageUsageFlags usage = isDepthOrStencilFormat ? kSurfaceVKDepthStencilImageUsageFlags |
| 98 | : kSurfaceVKColorImageUsageFlags; |
| 99 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 100 | gl::Extents extents(std::max(static_cast<int>(width), 1), std::max(static_cast<int>(height), 1), |
| 101 | 1); |
Shahbaz Youssefi | b5ba549 | 2019-01-02 15:19:22 -0500 | [diff] [blame] | 102 | ANGLE_TRY(image.init(displayVk, gl::TextureType::_2D, extents, vkFormat, 1, usage, 1, 1)); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 103 | |
| 104 | VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 105 | ANGLE_TRY(image.initMemory(displayVk, renderer->getMemoryProperties(), flags)); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 106 | |
| 107 | VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat); |
| 108 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 109 | ANGLE_TRY(image.initImageView(displayVk, gl::TextureType::_2D, aspect, gl::SwizzleState(), |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 110 | &imageView, 1)); |
| 111 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 112 | return angle::Result::Continue; |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 113 | } |
| 114 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 115 | void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display) |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 116 | { |
| 117 | const DisplayVk *displayVk = vk::GetImpl(display); |
| 118 | RendererVk *renderer = displayVk->getRenderer(); |
| 119 | |
Geoff Lang | 08f8fa6 | 2019-01-10 14:25:47 -0500 | [diff] [blame] | 120 | image.releaseImage(renderer); |
| 121 | image.releaseStagingBuffer(renderer); |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 122 | renderer->releaseObject(renderer->getCurrentQueueSerial(), &imageView); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 123 | } |
| 124 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 125 | OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, |
| 126 | EGLint width, |
| 127 | EGLint height) |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 128 | : SurfaceImpl(surfaceState), mWidth(width), mHeight(height) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 129 | {} |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 130 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 131 | OffscreenSurfaceVk::~OffscreenSurfaceVk() {} |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 132 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 133 | egl::Error OffscreenSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 134 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 135 | DisplayVk *displayVk = vk::GetImpl(display); |
| 136 | angle::Result result = initializeImpl(displayVk); |
| 137 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 138 | } |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 139 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 140 | angle::Result OffscreenSurfaceVk::initializeImpl(DisplayVk *displayVk) |
| 141 | { |
| 142 | RendererVk *renderer = displayVk->getRenderer(); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 143 | const egl::Config *config = mState.config; |
| 144 | |
| 145 | if (config->renderTargetFormat != GL_NONE) |
| 146 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 147 | ANGLE_TRY(mColorAttachment.initialize(displayVk, mWidth, mHeight, |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 148 | renderer->getFormat(config->renderTargetFormat))); |
| 149 | } |
| 150 | |
| 151 | if (config->depthStencilFormat != GL_NONE) |
| 152 | { |
| 153 | ANGLE_TRY(mDepthStencilAttachment.initialize( |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 154 | displayVk, mWidth, mHeight, renderer->getFormat(config->depthStencilFormat))); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 155 | } |
| 156 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 157 | return angle::Result::Continue; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 158 | } |
| 159 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 160 | void OffscreenSurfaceVk::destroy(const egl::Display *display) |
| 161 | { |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 162 | mColorAttachment.destroy(display); |
| 163 | mDepthStencilAttachment.destroy(display); |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 164 | } |
| 165 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 166 | FramebufferImpl *OffscreenSurfaceVk::createDefaultFramebuffer(const gl::Context *context, |
| 167 | const gl::FramebufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 168 | { |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 169 | RendererVk *renderer = vk::GetImpl(context)->getRenderer(); |
| 170 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 171 | // Use a user FBO for an offscreen RT. |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 172 | return FramebufferVk::CreateUserFBO(renderer, state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 173 | } |
| 174 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 175 | egl::Error OffscreenSurfaceVk::swap(const gl::Context *context) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 176 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 177 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 178 | } |
| 179 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 180 | egl::Error OffscreenSurfaceVk::postSubBuffer(const gl::Context * /*context*/, |
| 181 | EGLint /*x*/, |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 182 | EGLint /*y*/, |
| 183 | EGLint /*width*/, |
| 184 | EGLint /*height*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 185 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 186 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 187 | } |
| 188 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 189 | egl::Error OffscreenSurfaceVk::querySurfacePointerANGLE(EGLint /*attribute*/, void ** /*value*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 190 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 191 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 192 | return egl::EglBadCurrentSurface(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 193 | } |
| 194 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 195 | egl::Error OffscreenSurfaceVk::bindTexImage(const gl::Context * /*context*/, |
| 196 | gl::Texture * /*texture*/, |
| 197 | EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 198 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 199 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 200 | } |
| 201 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 202 | egl::Error OffscreenSurfaceVk::releaseTexImage(const gl::Context * /*context*/, EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 203 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 204 | return egl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 205 | } |
| 206 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 207 | egl::Error OffscreenSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 208 | EGLuint64KHR * /*msc*/, |
| 209 | EGLuint64KHR * /*sbc*/) |
| 210 | { |
| 211 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 212 | return egl::EglBadAccess(); |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 215 | void OffscreenSurfaceVk::setSwapInterval(EGLint /*interval*/) {} |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 216 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 217 | EGLint OffscreenSurfaceVk::getWidth() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 218 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 219 | return mWidth; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 220 | } |
| 221 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 222 | EGLint OffscreenSurfaceVk::getHeight() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 223 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 224 | return mHeight; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 225 | } |
| 226 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 227 | EGLint OffscreenSurfaceVk::isPostSubBufferSupported() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 228 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 229 | return EGL_FALSE; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 230 | } |
| 231 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 232 | EGLint OffscreenSurfaceVk::getSwapBehavior() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 233 | { |
Tim Van Patten | c2ee2cc | 2019-01-11 10:39:15 -0700 | [diff] [blame] | 234 | return EGL_BUFFER_DESTROYED; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 235 | } |
| 236 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 237 | angle::Result OffscreenSurfaceVk::getAttachmentRenderTarget( |
| 238 | const gl::Context *context, |
| 239 | GLenum binding, |
| 240 | const gl::ImageIndex &imageIndex, |
| 241 | FramebufferAttachmentRenderTarget **rtOut) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 242 | { |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 243 | if (binding == GL_BACK) |
| 244 | { |
| 245 | *rtOut = &mColorAttachment.renderTarget; |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | ASSERT(binding == GL_DEPTH || binding == GL_STENCIL || binding == GL_DEPTH_STENCIL); |
| 250 | *rtOut = &mDepthStencilAttachment.renderTarget; |
| 251 | } |
| 252 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 253 | return angle::Result::Continue; |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 254 | } |
| 255 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 256 | angle::Result OffscreenSurfaceVk::initializeContents(const gl::Context *context, |
| 257 | const gl::ImageIndex &imageIndex) |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 258 | { |
| 259 | UNIMPLEMENTED(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 260 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 261 | } |
| 262 | |
Geoff Lang | f256339 | 2019-01-15 09:50:44 -0500 | [diff] [blame] | 263 | vk::ImageHelper *OffscreenSurfaceVk::getColorAttachmentImage() |
| 264 | { |
| 265 | return &mColorAttachment.image; |
| 266 | } |
| 267 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 268 | WindowSurfaceVk::SwapchainImage::SwapchainImage() = default; |
| 269 | WindowSurfaceVk::SwapchainImage::~SwapchainImage() = default; |
| 270 | |
| 271 | WindowSurfaceVk::SwapchainImage::SwapchainImage(SwapchainImage &&other) |
| 272 | : image(std::move(other.image)), |
| 273 | imageView(std::move(other.imageView)), |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 274 | framebuffer(std::move(other.framebuffer)) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 275 | {} |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 276 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 277 | WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, |
| 278 | EGLNativeWindowType window, |
| 279 | EGLint width, |
| 280 | EGLint height) |
| 281 | : SurfaceImpl(surfaceState), |
| 282 | mNativeWindowType(window), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 283 | mSurface(VK_NULL_HANDLE), |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 284 | mInstance(VK_NULL_HANDLE), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 285 | mSwapchain(VK_NULL_HANDLE), |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 286 | mSwapchainPresentMode(VK_PRESENT_MODE_FIFO_KHR), |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 287 | mDesiredSwapchainPresentMode(VK_PRESENT_MODE_FIFO_KHR), |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 288 | mMinImageCount(0), |
| 289 | mPreTransform(VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR), |
| 290 | mCompositeAlpha(VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR), |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 291 | mCurrentSwapchainImageIndex(0), |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 292 | mCurrentSwapHistoryIndex(0) |
Geoff Lang | f3e823d | 2019-01-14 12:40:34 -0500 | [diff] [blame] | 293 | { |
| 294 | mDepthStencilRenderTarget.init(&mDepthStencilImage, &mDepthStencilImageView, 0, nullptr); |
| 295 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 296 | |
| 297 | WindowSurfaceVk::~WindowSurfaceVk() |
| 298 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 299 | ASSERT(mSurface == VK_NULL_HANDLE); |
| 300 | ASSERT(mSwapchain == VK_NULL_HANDLE); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 301 | } |
| 302 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 303 | void WindowSurfaceVk::destroy(const egl::Display *display) |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 304 | { |
Geoff Lang | 38971fd | 2018-06-28 15:19:18 -0400 | [diff] [blame] | 305 | DisplayVk *displayVk = vk::GetImpl(display); |
| 306 | RendererVk *renderer = displayVk->getRenderer(); |
| 307 | VkDevice device = renderer->getDevice(); |
| 308 | VkInstance instance = renderer->getInstance(); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 309 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 310 | // We might not need to flush the pipe here. |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 311 | (void)renderer->finish(displayVk); |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 312 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 313 | releaseSwapchainImages(renderer); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 314 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 315 | for (SwapHistory &swap : mSwapHistory) |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 316 | { |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 317 | if (swap.swapchain != VK_NULL_HANDLE) |
| 318 | { |
| 319 | vkDestroySwapchainKHR(device, swap.swapchain, nullptr); |
| 320 | swap.swapchain = VK_NULL_HANDLE; |
| 321 | } |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 322 | } |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 323 | |
| 324 | if (mSwapchain) |
| 325 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 326 | vkDestroySwapchainKHR(device, mSwapchain, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 327 | mSwapchain = VK_NULL_HANDLE; |
| 328 | } |
| 329 | |
| 330 | if (mSurface) |
| 331 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 332 | vkDestroySurfaceKHR(instance, mSurface, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 333 | mSurface = VK_NULL_HANDLE; |
| 334 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 335 | } |
| 336 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 337 | egl::Error WindowSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 338 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 339 | DisplayVk *displayVk = vk::GetImpl(display); |
| 340 | angle::Result result = initializeImpl(displayVk); |
| 341 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 342 | } |
| 343 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 344 | angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 345 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 346 | RendererVk *renderer = displayVk->getRenderer(); |
| 347 | |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 348 | gl::Extents windowSize; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 349 | ANGLE_TRY(createSurfaceVk(displayVk, &windowSize)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 350 | |
| 351 | uint32_t presentQueue = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 352 | ANGLE_TRY(renderer->selectPresentQueueForSurface(displayVk, mSurface, &presentQueue)); |
Jamie Madill | c6dbc25 | 2018-04-30 19:07:56 -0400 | [diff] [blame] | 353 | ANGLE_UNUSED_VARIABLE(presentQueue); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 354 | |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 355 | const VkPhysicalDevice &physicalDevice = renderer->getPhysicalDevice(); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 356 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 357 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface, |
| 358 | &mSurfaceCaps)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 359 | |
| 360 | // Adjust width and height to the swapchain if necessary. |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 361 | uint32_t width = mSurfaceCaps.currentExtent.width; |
| 362 | uint32_t height = mSurfaceCaps.currentExtent.height; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 363 | |
| 364 | // 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] | 365 | ANGLE_VK_CHECK(displayVk, |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 366 | (mSurfaceCaps.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) != 0, |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 367 | VK_ERROR_INITIALIZATION_FAILED); |
| 368 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 369 | EGLAttrib attribWidth = mState.attributes.get(EGL_WIDTH, 0); |
| 370 | EGLAttrib attribHeight = mState.attributes.get(EGL_HEIGHT, 0); |
| 371 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 372 | if (mSurfaceCaps.currentExtent.width == 0xFFFFFFFFu) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 373 | { |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 374 | ASSERT(mSurfaceCaps.currentExtent.height == 0xFFFFFFFFu); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 375 | |
Michael Spang | 0029dfe | 2019-02-08 18:45:07 -0500 | [diff] [blame^] | 376 | width = (attribWidth != 0) ? static_cast<uint32_t>(attribWidth) : windowSize.width; |
| 377 | height = (attribHeight != 0) ? static_cast<uint32_t>(attribHeight) : windowSize.height; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 378 | } |
| 379 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 380 | gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 381 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 382 | uint32_t presentModeCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 383 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, mSurface, |
| 384 | &presentModeCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 385 | ASSERT(presentModeCount > 0); |
| 386 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 387 | mPresentModes.resize(presentModeCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 388 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfacePresentModesKHR( |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 389 | physicalDevice, mSurface, &presentModeCount, mPresentModes.data())); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 390 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 391 | // Select appropriate present mode based on vsync parameter. Default to 1 (FIFO), though it |
| 392 | // will get clamped to the min/max values specified at display creation time. |
| 393 | setSwapInterval(1); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 394 | |
| 395 | // Default to identity transform. |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 396 | mPreTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 397 | if ((mSurfaceCaps.supportedTransforms & mPreTransform) == 0) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 398 | { |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 399 | mPreTransform = mSurfaceCaps.currentTransform; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 400 | } |
| 401 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 402 | uint32_t surfaceFormatCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 403 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, |
| 404 | &surfaceFormatCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 405 | |
| 406 | std::vector<VkSurfaceFormatKHR> surfaceFormats(surfaceFormatCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 407 | ANGLE_VK_TRY(displayVk, |
| 408 | vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, &surfaceFormatCount, |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 409 | surfaceFormats.data())); |
| 410 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 411 | const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat); |
| 412 | VkFormat nativeFormat = format.vkTextureFormat; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 413 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 414 | if (surfaceFormatCount == 1u && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) |
| 415 | { |
| 416 | // This is fine. |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | bool foundFormat = false; |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 421 | for (const VkSurfaceFormatKHR &surfaceFormat : surfaceFormats) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 422 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 423 | if (surfaceFormat.format == nativeFormat) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 424 | { |
| 425 | foundFormat = true; |
| 426 | break; |
| 427 | } |
| 428 | } |
| 429 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 430 | ANGLE_VK_CHECK(displayVk, foundFormat, VK_ERROR_INITIALIZATION_FAILED); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 431 | } |
| 432 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 433 | mCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 434 | if ((mSurfaceCaps.supportedCompositeAlpha & mCompositeAlpha) == 0) |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 435 | { |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 436 | mCompositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR; |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 437 | } |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 438 | ANGLE_VK_CHECK(displayVk, (mSurfaceCaps.supportedCompositeAlpha & mCompositeAlpha) != 0, |
Yuly Novikov | 12da5e7 | 2018-01-23 18:34:53 -0500 | [diff] [blame] | 439 | VK_ERROR_INITIALIZATION_FAILED); |
| 440 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 441 | ANGLE_TRY(recreateSwapchain(displayVk, extents, mCurrentSwapHistoryIndex)); |
| 442 | |
| 443 | // Get the first available swapchain iamge. |
| 444 | return nextSwapchainImage(displayVk); |
| 445 | } |
| 446 | |
| 447 | angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk, |
| 448 | const gl::Extents &extents, |
| 449 | uint32_t swapHistoryIndex) |
| 450 | { |
| 451 | RendererVk *renderer = displayVk->getRenderer(); |
| 452 | VkDevice device = renderer->getDevice(); |
| 453 | |
| 454 | VkSwapchainKHR oldSwapchain = mSwapchain; |
| 455 | mSwapchain = VK_NULL_HANDLE; |
| 456 | |
| 457 | if (oldSwapchain) |
| 458 | { |
| 459 | // Note: the old swapchain must be destroyed regardless of whether creating the new |
| 460 | // swapchain succeeds. We can only destroy the swapchain once rendering to all its images |
| 461 | // have finished. We therefore store the handle to the swapchain being destroyed in the |
| 462 | // swap history (alongside the serial of the last submission) so it can be destroyed once we |
| 463 | // wait on that serial as part of the CPU throttling. |
| 464 | // |
| 465 | // TODO(syoussefi): the spec specifically allows multiple retired swapchains to exist: |
| 466 | // |
| 467 | // > Multiple retired swapchains can be associated with the same VkSurfaceKHR through |
| 468 | // > multiple uses of oldSwapchain that outnumber calls to vkDestroySwapchainKHR. |
| 469 | // |
| 470 | // However, a bug in the validation layers currently forces us to limit this to one retired |
| 471 | // swapchain. Once the issue is resolved, the following for loop can be removed. |
| 472 | // http://anglebug.com/3095 |
| 473 | for (SwapHistory &swap : mSwapHistory) |
| 474 | { |
| 475 | if (swap.swapchain != VK_NULL_HANDLE) |
| 476 | { |
| 477 | ANGLE_TRY(renderer->finishToSerial(displayVk, swap.serial)); |
| 478 | vkDestroySwapchainKHR(renderer->getDevice(), swap.swapchain, nullptr); |
| 479 | swap.swapchain = VK_NULL_HANDLE; |
| 480 | } |
| 481 | } |
| 482 | mSwapHistory[swapHistoryIndex].swapchain = oldSwapchain; |
| 483 | } |
| 484 | |
| 485 | releaseSwapchainImages(renderer); |
| 486 | |
| 487 | const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat); |
| 488 | VkFormat nativeFormat = format.vkTextureFormat; |
| 489 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 490 | // We need transfer src for reading back from the backbuffer. |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 491 | constexpr VkImageUsageFlags kImageUsageFlags = kSurfaceVKColorImageUsageFlags; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 492 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 493 | VkSwapchainCreateInfoKHR swapchainInfo = {}; |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 494 | swapchainInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 495 | swapchainInfo.flags = 0; |
| 496 | swapchainInfo.surface = mSurface; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 497 | swapchainInfo.minImageCount = mMinImageCount; |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 498 | swapchainInfo.imageFormat = nativeFormat; |
| 499 | swapchainInfo.imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 500 | // Note: Vulkan doesn't allow 0-width/height swapchains. |
| 501 | swapchainInfo.imageExtent.width = std::max(extents.width, 1); |
| 502 | swapchainInfo.imageExtent.height = std::max(extents.height, 1); |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 503 | swapchainInfo.imageArrayLayers = 1; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 504 | swapchainInfo.imageUsage = kImageUsageFlags; |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 505 | swapchainInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 506 | swapchainInfo.queueFamilyIndexCount = 0; |
| 507 | swapchainInfo.pQueueFamilyIndices = nullptr; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 508 | swapchainInfo.preTransform = mPreTransform; |
| 509 | swapchainInfo.compositeAlpha = mCompositeAlpha; |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 510 | swapchainInfo.presentMode = mDesiredSwapchainPresentMode; |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 511 | swapchainInfo.clipped = VK_TRUE; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 512 | swapchainInfo.oldSwapchain = oldSwapchain; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 513 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 514 | // TODO(syoussefi): Once EGL_SWAP_BEHAVIOR_PRESERVED_BIT is supported, the contents of the old |
| 515 | // swapchain need to carry over to the new one. http://anglebug.com/2942 |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 516 | ANGLE_VK_TRY(displayVk, vkCreateSwapchainKHR(device, &swapchainInfo, nullptr, &mSwapchain)); |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 517 | mSwapchainPresentMode = mDesiredSwapchainPresentMode; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 518 | |
| 519 | // Intialize the swapchain image views. |
| 520 | uint32_t imageCount = 0; |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 521 | ANGLE_VK_TRY(displayVk, vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, nullptr)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 522 | |
| 523 | std::vector<VkImage> swapchainImages(imageCount); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 524 | ANGLE_VK_TRY(displayVk, |
| 525 | vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, swapchainImages.data())); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 526 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 527 | VkClearColorValue transparentBlack = {}; |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 528 | transparentBlack.float32[0] = 0.0f; |
| 529 | transparentBlack.float32[1] = 0.0f; |
| 530 | transparentBlack.float32[2] = 0.0f; |
| 531 | transparentBlack.float32[3] = 0.0f; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 532 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 533 | mSwapchainImages.resize(imageCount); |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 534 | ANGLE_TRY(resizeSwapHistory(displayVk, imageCount)); |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 535 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 536 | for (uint32_t imageIndex = 0; imageIndex < imageCount; ++imageIndex) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 537 | { |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 538 | SwapchainImage &member = mSwapchainImages[imageIndex]; |
| 539 | member.image.init2DWeakReference(swapchainImages[imageIndex], extents, format, 1); |
Shahbaz Youssefi | f83a28a | 2018-12-09 03:48:34 +0100 | [diff] [blame] | 540 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 541 | ANGLE_TRY(member.image.initImageView(displayVk, gl::TextureType::_2D, |
Jamie Madill | eebe219 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 542 | VK_IMAGE_ASPECT_COLOR_BIT, gl::SwizzleState(), |
| 543 | &member.imageView, 1)); |
Jamie Madill | 25301b6 | 2017-10-28 20:59:31 -0400 | [diff] [blame] | 544 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 545 | // Allocate a command buffer for clearing our images to black. |
| 546 | vk::CommandBuffer *commandBuffer = nullptr; |
| 547 | ANGLE_TRY(member.image.recordCommands(displayVk, &commandBuffer)); |
| 548 | |
Jamie Madill | 25301b6 | 2017-10-28 20:59:31 -0400 | [diff] [blame] | 549 | // Set transfer dest layout, and clear the image to black. |
Luc Ferron | c20b950 | 2018-05-24 09:30:17 -0400 | [diff] [blame] | 550 | member.image.clearColor(transparentBlack, 0, 1, commandBuffer); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 551 | } |
| 552 | |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 553 | // Initialize depth/stencil if requested. |
| 554 | if (mState.config->depthStencilFormat != GL_NONE) |
| 555 | { |
| 556 | const vk::Format &dsFormat = renderer->getFormat(mState.config->depthStencilFormat); |
| 557 | |
Geoff Lang | 9e14164 | 2018-06-27 11:43:18 -0400 | [diff] [blame] | 558 | const VkImageUsageFlags dsUsage = kSurfaceVKDepthStencilImageUsageFlags; |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 559 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 560 | ANGLE_TRY(mDepthStencilImage.init(displayVk, gl::TextureType::_2D, extents, dsFormat, 1, |
Shahbaz Youssefi | b5ba549 | 2019-01-02 15:19:22 -0500 | [diff] [blame] | 561 | dsUsage, 1, 1)); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 562 | ANGLE_TRY(mDepthStencilImage.initMemory(displayVk, renderer->getMemoryProperties(), |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 563 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 564 | |
Luc Ferron | 5bdf8bd | 2018-06-20 09:51:37 -0400 | [diff] [blame] | 565 | const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(dsFormat.textureFormat()); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 566 | VkClearDepthStencilValue depthStencilClearValue = {1.0f, 0}; |
| 567 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 568 | // Clear the image. |
| 569 | vk::CommandBuffer *commandBuffer = nullptr; |
| 570 | ANGLE_TRY(mDepthStencilImage.recordCommands(displayVk, &commandBuffer)); |
Shahbaz Youssefi | d856ca4 | 2018-10-31 16:55:12 -0400 | [diff] [blame] | 571 | mDepthStencilImage.clearDepthStencil(aspect, aspect, depthStencilClearValue, commandBuffer); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 572 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 573 | ANGLE_TRY(mDepthStencilImage.initImageView(displayVk, gl::TextureType::_2D, aspect, |
Luc Ferron | 6641053 | 2018-04-20 12:47:45 -0400 | [diff] [blame] | 574 | gl::SwizzleState(), &mDepthStencilImageView, 1)); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 575 | |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 576 | // 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] | 577 | } |
| 578 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 579 | return angle::Result::Continue; |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 580 | } |
| 581 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 582 | angle::Result WindowSurfaceVk::checkForOutOfDateSwapchain(DisplayVk *displayVk, |
| 583 | uint32_t swapHistoryIndex, |
| 584 | bool presentOutOfDate) |
| 585 | { |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 586 | bool swapIntervalChanged = mSwapchainPresentMode != mDesiredSwapchainPresentMode; |
| 587 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 588 | // Check for window resize and recreate swapchain if necessary. |
| 589 | gl::Extents currentExtents; |
| 590 | ANGLE_TRY(getCurrentWindowSize(displayVk, ¤tExtents)); |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 591 | |
| 592 | gl::Extents swapchainExtents(getWidth(), getHeight(), 0); |
| 593 | |
| 594 | // If window size has changed, check with surface capabilities. It has been observed on |
| 595 | // Android that `getCurrentWindowSize()` returns 1920x1080 for example, while surface |
| 596 | // capabilities returns the size the surface was created with. |
| 597 | if (currentExtents != swapchainExtents) |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 598 | { |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 599 | const VkPhysicalDevice &physicalDevice = displayVk->getRenderer()->getPhysicalDevice(); |
| 600 | ANGLE_VK_TRY(displayVk, vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface, |
| 601 | &mSurfaceCaps)); |
| 602 | |
| 603 | uint32_t width = mSurfaceCaps.currentExtent.width; |
| 604 | uint32_t height = mSurfaceCaps.currentExtent.height; |
| 605 | |
| 606 | if (width != 0xFFFFFFFFu) |
| 607 | { |
| 608 | ASSERT(height != 0xFFFFFFFFu); |
| 609 | currentExtents.width = width; |
| 610 | currentExtents.height = height; |
| 611 | } |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 612 | } |
| 613 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 614 | // If anything has changed, recreate the swapchain. |
| 615 | if (presentOutOfDate || swapIntervalChanged || currentExtents != swapchainExtents) |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 616 | { |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 617 | ANGLE_TRY(recreateSwapchain(displayVk, currentExtents, swapHistoryIndex)); |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 618 | } |
| 619 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 620 | return angle::Result::Continue; |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | void WindowSurfaceVk::releaseSwapchainImages(RendererVk *renderer) |
| 624 | { |
| 625 | if (mDepthStencilImage.valid()) |
| 626 | { |
| 627 | Serial depthStencilSerial = mDepthStencilImage.getStoredQueueSerial(); |
| 628 | mDepthStencilImage.releaseImage(renderer); |
| 629 | mDepthStencilImage.releaseStagingBuffer(renderer); |
| 630 | |
| 631 | if (mDepthStencilImageView.valid()) |
| 632 | { |
| 633 | renderer->releaseObject(depthStencilSerial, &mDepthStencilImageView); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | for (SwapchainImage &swapchainImage : mSwapchainImages) |
| 638 | { |
| 639 | Serial imageSerial = swapchainImage.image.getStoredQueueSerial(); |
| 640 | |
| 641 | // We don't own the swapchain image handles, so we just remove our reference to it. |
| 642 | swapchainImage.image.resetImageWeakReference(); |
| 643 | swapchainImage.image.destroy(renderer->getDevice()); |
| 644 | |
| 645 | if (swapchainImage.imageView.valid()) |
| 646 | { |
| 647 | renderer->releaseObject(imageSerial, &swapchainImage.imageView); |
| 648 | } |
| 649 | |
| 650 | if (swapchainImage.framebuffer.valid()) |
| 651 | { |
| 652 | renderer->releaseObject(imageSerial, &swapchainImage.framebuffer); |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | mSwapchainImages.clear(); |
| 657 | } |
| 658 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 659 | FramebufferImpl *WindowSurfaceVk::createDefaultFramebuffer(const gl::Context *context, |
| 660 | const gl::FramebufferState &state) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 661 | { |
Jamie Madill | 639bc90 | 2018-07-18 17:08:27 -0400 | [diff] [blame] | 662 | RendererVk *renderer = vk::GetImpl(context)->getRenderer(); |
| 663 | return FramebufferVk::CreateDefaultFBO(renderer, state, this); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 664 | } |
| 665 | |
Courtney Goeltzenleuchter | f0d258c | 2018-09-11 09:37:48 -0600 | [diff] [blame] | 666 | egl::Error WindowSurfaceVk::swapWithDamage(const gl::Context *context, |
Ian Elliott | bcb7890 | 2018-12-19 11:46:29 -0700 | [diff] [blame] | 667 | EGLint *rects, |
| 668 | EGLint n_rects) |
Courtney Goeltzenleuchter | f0d258c | 2018-09-11 09:37:48 -0600 | [diff] [blame] | 669 | { |
| 670 | DisplayVk *displayVk = vk::GetImpl(context->getCurrentDisplay()); |
Ian Elliott | bcb7890 | 2018-12-19 11:46:29 -0700 | [diff] [blame] | 671 | angle::Result result = swapImpl(displayVk, rects, n_rects); |
Courtney Goeltzenleuchter | f0d258c | 2018-09-11 09:37:48 -0600 | [diff] [blame] | 672 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 673 | } |
| 674 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 675 | egl::Error WindowSurfaceVk::swap(const gl::Context *context) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 676 | { |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 677 | DisplayVk *displayVk = vk::GetImpl(context->getCurrentDisplay()); |
Ian Elliott | bcb7890 | 2018-12-19 11:46:29 -0700 | [diff] [blame] | 678 | angle::Result result = swapImpl(displayVk, nullptr, 0); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 679 | return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); |
| 680 | } |
| 681 | |
Ian Elliott | bcb7890 | 2018-12-19 11:46:29 -0700 | [diff] [blame] | 682 | angle::Result WindowSurfaceVk::swapImpl(DisplayVk *displayVk, EGLint *rects, EGLint n_rects) |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 683 | { |
| 684 | RendererVk *renderer = displayVk->getRenderer(); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 685 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 686 | // Throttle the submissions to avoid getting too far ahead of the GPU. |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 687 | { |
| 688 | TRACE_EVENT0("gpu.angle", "WindowSurfaceVk::swapImpl: Throttle CPU"); |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 689 | SwapHistory &swap = mSwapHistory[mCurrentSwapHistoryIndex]; |
| 690 | ANGLE_TRY(renderer->finishToSerial(displayVk, swap.serial)); |
| 691 | if (swap.swapchain != VK_NULL_HANDLE) |
| 692 | { |
| 693 | vkDestroySwapchainKHR(renderer->getDevice(), swap.swapchain, nullptr); |
| 694 | swap.swapchain = VK_NULL_HANDLE; |
| 695 | } |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 696 | } |
| 697 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 698 | SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex]; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 699 | |
Shahbaz Youssefi | 7dafe3e | 2019-01-28 11:39:15 -0500 | [diff] [blame] | 700 | vk::CommandBuffer *swapCommands = nullptr; |
| 701 | ANGLE_TRY(image.image.recordCommands(displayVk, &swapCommands)); |
| 702 | |
| 703 | image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, swapCommands); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 704 | |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 705 | ANGLE_TRY(renderer->flush(displayVk)); |
| 706 | |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 707 | // Remember the serial of the last submission. |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 708 | mSwapHistory[mCurrentSwapHistoryIndex].serial = renderer->getLastSubmittedQueueSerial(); |
| 709 | uint32_t currentSwapHistoryIndex = mCurrentSwapHistoryIndex; |
| 710 | ++mCurrentSwapHistoryIndex; |
| 711 | mCurrentSwapHistoryIndex = |
| 712 | mCurrentSwapHistoryIndex == mSwapHistory.size() ? 0 : mCurrentSwapHistoryIndex; |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 713 | |
| 714 | // Ask the renderer what semaphore it signaled in the last flush. |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 715 | const vk::Semaphore *commandsCompleteSemaphore = |
| 716 | renderer->getSubmitLastSignaledSemaphore(displayVk); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 717 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 718 | VkPresentInfoKHR presentInfo = {}; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 719 | presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 720 | presentInfo.waitSemaphoreCount = commandsCompleteSemaphore ? 1 : 0; |
| 721 | presentInfo.pWaitSemaphores = |
| 722 | commandsCompleteSemaphore ? commandsCompleteSemaphore->ptr() : nullptr; |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 723 | presentInfo.swapchainCount = 1; |
| 724 | presentInfo.pSwapchains = &mSwapchain; |
| 725 | presentInfo.pImageIndices = &mCurrentSwapchainImageIndex; |
| 726 | presentInfo.pResults = nullptr; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 727 | |
Ian Elliott | bcb7890 | 2018-12-19 11:46:29 -0700 | [diff] [blame] | 728 | VkPresentRegionsKHR presentRegions = {}; |
| 729 | if (renderer->getFeatures().supportsIncrementalPresent && (n_rects > 0)) |
| 730 | { |
| 731 | VkPresentRegionKHR presentRegion = {}; |
| 732 | std::vector<VkRectLayerKHR> vk_rects(n_rects); |
| 733 | EGLint *egl_rects = rects; |
| 734 | presentRegion.rectangleCount = n_rects; |
| 735 | for (EGLint rect = 0; rect < n_rects; rect++) |
| 736 | { |
| 737 | vk_rects[rect].offset.x = *egl_rects++; |
| 738 | vk_rects[rect].offset.y = *egl_rects++; |
| 739 | vk_rects[rect].extent.width = *egl_rects++; |
| 740 | vk_rects[rect].extent.height = *egl_rects++; |
| 741 | vk_rects[rect].layer = 0; |
| 742 | } |
| 743 | presentRegion.pRectangles = vk_rects.data(); |
| 744 | |
| 745 | presentRegions.sType = VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR; |
| 746 | presentRegions.pNext = nullptr; |
| 747 | presentRegions.swapchainCount = 1; |
| 748 | presentRegions.pRegions = &presentRegion; |
| 749 | |
| 750 | presentInfo.pNext = &presentRegions; |
| 751 | } |
| 752 | |
Shahbaz Youssefi | ab5acbd | 2019-01-23 13:58:09 -0500 | [diff] [blame] | 753 | VkResult result = vkQueuePresentKHR(renderer->getQueue(), &presentInfo); |
| 754 | |
| 755 | // If SUBOPTIMAL/OUT_OF_DATE is returned, it's ok, we just need to recreate the swapchain before |
| 756 | // continuing. |
| 757 | bool swapchainOutOfDate = result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_OUT_OF_DATE_KHR; |
| 758 | if (!swapchainOutOfDate) |
| 759 | { |
| 760 | ANGLE_VK_TRY(displayVk, result); |
| 761 | } |
| 762 | |
| 763 | ANGLE_TRY(checkForOutOfDateSwapchain(displayVk, currentSwapHistoryIndex, swapchainOutOfDate)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 764 | |
Shahbaz Youssefi | 6165602 | 2018-10-24 15:00:50 -0400 | [diff] [blame] | 765 | { |
| 766 | // Note: TRACE_EVENT0 is put here instead of inside the function to workaround this issue: |
| 767 | // http://anglebug.com/2927 |
| 768 | TRACE_EVENT0("gpu.angle", "nextSwapchainImage"); |
| 769 | // Get the next available swapchain image. |
| 770 | ANGLE_TRY(nextSwapchainImage(displayVk)); |
| 771 | } |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 772 | |
Shahbaz Youssefi | 996628a | 2018-09-24 16:39:26 -0400 | [diff] [blame] | 773 | ANGLE_TRY(renderer->syncPipelineCacheVk(displayVk)); |
| 774 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 775 | return angle::Result::Continue; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 776 | } |
| 777 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 778 | angle::Result WindowSurfaceVk::nextSwapchainImage(DisplayVk *displayVk) |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 779 | { |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 780 | VkDevice device = displayVk->getDevice(); |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 781 | RendererVk *renderer = displayVk->getRenderer(); |
| 782 | |
| 783 | const vk::Semaphore *acquireNextImageSemaphore = nullptr; |
| 784 | ANGLE_TRY(renderer->allocateSubmitWaitSemaphore(displayVk, &acquireNextImageSemaphore)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 785 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 786 | ANGLE_VK_TRY(displayVk, vkAcquireNextImageKHR(device, mSwapchain, UINT64_MAX, |
Shahbaz Youssefi | 3a48217 | 2018-10-11 10:34:44 -0400 | [diff] [blame] | 787 | acquireNextImageSemaphore->getHandle(), |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 788 | VK_NULL_HANDLE, &mCurrentSwapchainImageIndex)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 789 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 790 | SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex]; |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 791 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 792 | // Update RenderTarget pointers. |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 793 | mColorRenderTarget.updateSwapchainImage(&image.image, &image.imageView); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 794 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 795 | return angle::Result::Continue; |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 796 | } |
| 797 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 798 | angle::Result WindowSurfaceVk::resizeSwapHistory(DisplayVk *displayVk, size_t imageCount) |
| 799 | { |
| 800 | // The number of swapchain images can change if the present mode is changed. If that number is |
| 801 | // increased, we need to rearrange the history (which is a circular buffer) so it remains |
| 802 | // continuous. If it shrinks, we have to additionally make sure we clean up any old swapchains |
| 803 | // that can no longer fit in the history. |
| 804 | // |
| 805 | // Assume the following history buffer identified with serials: |
| 806 | // |
| 807 | // mCurrentSwapHistoryIndex |
| 808 | // V |
| 809 | // +----+----+----+ |
| 810 | // | 11 | 9 | 10 | |
| 811 | // +----+----+----+ |
| 812 | // |
| 813 | // When shrinking to size 2, we want to clean up 9, and rearrange to the following: |
| 814 | // |
| 815 | // mCurrentSwapHistoryIndex |
| 816 | // V |
| 817 | // +----+----+ |
| 818 | // | 10 | 11 | |
| 819 | // +----+----+ |
| 820 | // |
| 821 | // When expanding back to 3, we want to rearrange to the following: |
| 822 | // |
| 823 | // mCurrentSwapHistoryIndex |
| 824 | // V |
| 825 | // +----+----+----+ |
| 826 | // | 0 | 10 | 11 | |
| 827 | // +----+----+----+ |
| 828 | |
| 829 | if (mSwapHistory.size() == imageCount) |
| 830 | { |
| 831 | return angle::Result::Continue; |
| 832 | } |
| 833 | |
| 834 | RendererVk *renderer = displayVk->getRenderer(); |
| 835 | |
| 836 | // First, clean up anything that won't fit in the resized history. |
| 837 | if (imageCount < mSwapHistory.size()) |
| 838 | { |
| 839 | size_t toClean = mSwapHistory.size() - imageCount; |
| 840 | for (size_t i = 0; i < toClean; ++i) |
| 841 | { |
| 842 | size_t historyIndex = (mCurrentSwapHistoryIndex + i) % mSwapHistory.size(); |
| 843 | SwapHistory &swap = mSwapHistory[historyIndex]; |
| 844 | |
| 845 | ANGLE_TRY(renderer->finishToSerial(displayVk, swap.serial)); |
| 846 | if (swap.swapchain != VK_NULL_HANDLE) |
| 847 | { |
| 848 | vkDestroySwapchainKHR(renderer->getDevice(), swap.swapchain, nullptr); |
| 849 | swap.swapchain = VK_NULL_HANDLE; |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | // Now, move the history, from most recent to oldest (as much as fits), into a new vector. |
| 855 | std::vector<SwapHistory> resizedHistory(imageCount); |
| 856 | |
| 857 | size_t toCopy = std::min(imageCount, mSwapHistory.size()); |
| 858 | for (size_t i = 0; i < toCopy; ++i) |
| 859 | { |
| 860 | size_t historyIndex = |
| 861 | (mCurrentSwapHistoryIndex + mSwapHistory.size() - i - 1) % mSwapHistory.size(); |
| 862 | size_t resizedHistoryIndex = imageCount - i - 1; |
| 863 | resizedHistory[resizedHistoryIndex] = mSwapHistory[historyIndex]; |
| 864 | } |
| 865 | |
| 866 | // Set this as the new history. Note that after rearranging in either case, the oldest history |
| 867 | // is at index 0. |
| 868 | mSwapHistory = std::move(resizedHistory); |
| 869 | mCurrentSwapHistoryIndex = 0; |
| 870 | |
| 871 | return angle::Result::Continue; |
| 872 | } |
| 873 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 874 | egl::Error WindowSurfaceVk::postSubBuffer(const gl::Context *context, |
| 875 | EGLint x, |
| 876 | EGLint y, |
| 877 | EGLint width, |
| 878 | EGLint height) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 879 | { |
| 880 | // TODO(jmadill) |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 881 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | egl::Error WindowSurfaceVk::querySurfacePointerANGLE(EGLint attribute, void **value) |
| 885 | { |
| 886 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 887 | return egl::EglBadCurrentSurface(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 888 | } |
| 889 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 890 | egl::Error WindowSurfaceVk::bindTexImage(const gl::Context *context, |
| 891 | gl::Texture *texture, |
| 892 | EGLint buffer) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 893 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 894 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 895 | } |
| 896 | |
Geoff Lang | ccafa62 | 2018-05-02 13:07:53 -0400 | [diff] [blame] | 897 | egl::Error WindowSurfaceVk::releaseTexImage(const gl::Context *context, EGLint buffer) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 898 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 899 | return egl::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 900 | } |
| 901 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 902 | egl::Error WindowSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 903 | EGLuint64KHR * /*msc*/, |
| 904 | EGLuint64KHR * /*sbc*/) |
| 905 | { |
| 906 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 907 | return egl::EglBadAccess(); |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 908 | } |
| 909 | |
Shahbaz Youssefi | 3883311 | 2019-02-06 16:19:49 -0500 | [diff] [blame] | 910 | void WindowSurfaceVk::setSwapInterval(EGLint interval) |
| 911 | { |
| 912 | const EGLint minSwapInterval = mState.config->minSwapInterval; |
| 913 | const EGLint maxSwapInterval = mState.config->maxSwapInterval; |
| 914 | ASSERT(minSwapInterval == 0 || minSwapInterval == 1); |
| 915 | ASSERT(maxSwapInterval == 0 || maxSwapInterval == 1); |
| 916 | |
| 917 | interval = gl::clamp(interval, minSwapInterval, maxSwapInterval); |
| 918 | |
| 919 | mDesiredSwapchainPresentMode = GetDesiredPresentMode(mPresentModes, interval); |
| 920 | |
| 921 | // Determine the number of swapchain images: |
| 922 | // |
| 923 | // - On mailbox, we use minImageCount. The drivers may increase the number so that non-blocking |
| 924 | // mailbox actually makes sense. |
| 925 | // - On immediate, we use max(2, minImageCount). The vkQueuePresentKHR call immediately frees |
| 926 | // up the other image, so there is no point in having any more images. |
| 927 | // - On fifo, we use max(3, minImageCount). Triple-buffering allows us to present an image, |
| 928 | // have one in the queue and record in another. Note: on certain configurations (windows + |
| 929 | // nvidia + windowed mode), we could get away with a smaller number. |
| 930 | mMinImageCount = mSurfaceCaps.minImageCount; |
| 931 | if (mDesiredSwapchainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) |
| 932 | { |
| 933 | mMinImageCount = std::max(2u, mMinImageCount); |
| 934 | } |
| 935 | else if (mDesiredSwapchainPresentMode == VK_PRESENT_MODE_FIFO_KHR) |
| 936 | { |
| 937 | mMinImageCount = std::max(3u, mMinImageCount); |
| 938 | } |
| 939 | |
| 940 | // Make sure we don't exceed maxImageCount. |
| 941 | if (mSurfaceCaps.maxImageCount > 0 && mMinImageCount > mSurfaceCaps.maxImageCount) |
| 942 | { |
| 943 | mMinImageCount = mSurfaceCaps.maxImageCount; |
| 944 | } |
| 945 | |
| 946 | // On the next swap, if the desired present mode is different from the current one, the |
| 947 | // swapchain will be recreated. |
| 948 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 949 | |
| 950 | EGLint WindowSurfaceVk::getWidth() const |
| 951 | { |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 952 | return static_cast<EGLint>(mColorRenderTarget.getImageExtents().width); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | EGLint WindowSurfaceVk::getHeight() const |
| 956 | { |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 957 | return static_cast<EGLint>(mColorRenderTarget.getImageExtents().height); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | EGLint WindowSurfaceVk::isPostSubBufferSupported() const |
| 961 | { |
| 962 | // TODO(jmadill) |
| 963 | return EGL_FALSE; |
| 964 | } |
| 965 | |
| 966 | EGLint WindowSurfaceVk::getSwapBehavior() const |
| 967 | { |
| 968 | // TODO(jmadill) |
| 969 | return EGL_BUFFER_DESTROYED; |
| 970 | } |
| 971 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 972 | angle::Result WindowSurfaceVk::getAttachmentRenderTarget(const gl::Context *context, |
| 973 | GLenum binding, |
| 974 | const gl::ImageIndex &imageIndex, |
| 975 | FramebufferAttachmentRenderTarget **rtOut) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 976 | { |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 977 | if (binding == GL_BACK) |
| 978 | { |
| 979 | *rtOut = &mColorRenderTarget; |
| 980 | } |
| 981 | else |
| 982 | { |
| 983 | ASSERT(binding == GL_DEPTH || binding == GL_STENCIL || binding == GL_DEPTH_STENCIL); |
| 984 | *rtOut = &mDepthStencilRenderTarget; |
| 985 | } |
| 986 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 987 | return angle::Result::Continue; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 988 | } |
| 989 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 990 | angle::Result WindowSurfaceVk::getCurrentFramebuffer(vk::Context *context, |
| 991 | const vk::RenderPass &compatibleRenderPass, |
| 992 | vk::Framebuffer **framebufferOut) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 993 | { |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 994 | vk::Framebuffer ¤tFramebuffer = mSwapchainImages[mCurrentSwapchainImageIndex].framebuffer; |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 995 | |
| 996 | if (currentFramebuffer.valid()) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 997 | { |
| 998 | // Validation layers should detect if the render pass is really compatible. |
Jamie Madill | 5598148 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 999 | *framebufferOut = ¤tFramebuffer; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 1000 | return angle::Result::Continue; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1001 | } |
| 1002 | |
Shahbaz Youssefi | 06270c9 | 2018-10-03 17:00:25 -0400 | [diff] [blame] | 1003 | VkFramebufferCreateInfo framebufferInfo = {}; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1004 | |
Jamie Madill | bcf467f | 2018-05-23 09:46:00 -0400 | [diff] [blame] | 1005 | const gl::Extents &extents = mColorRenderTarget.getImageExtents(); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 1006 | std::array<VkImageView, 2> imageViews = {{VK_NULL_HANDLE, mDepthStencilImageView.getHandle()}}; |
| 1007 | |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1008 | framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1009 | framebufferInfo.flags = 0; |
| 1010 | framebufferInfo.renderPass = compatibleRenderPass.getHandle(); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 1011 | framebufferInfo.attachmentCount = (mDepthStencilImage.valid() ? 2u : 1u); |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 1012 | framebufferInfo.pAttachments = imageViews.data(); |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 1013 | framebufferInfo.width = static_cast<uint32_t>(extents.width); |
| 1014 | framebufferInfo.height = static_cast<uint32_t>(extents.height); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1015 | framebufferInfo.layers = 1; |
| 1016 | |
Jamie Madill | bc54342 | 2018-03-30 10:43:19 -0400 | [diff] [blame] | 1017 | for (SwapchainImage &swapchainImage : mSwapchainImages) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1018 | { |
Jamie Madill | f618c9e | 2018-02-15 14:45:40 -0500 | [diff] [blame] | 1019 | imageViews[0] = swapchainImage.imageView.getHandle(); |
Yuly Novikov | 2778029 | 2018-11-09 11:19:49 -0500 | [diff] [blame] | 1020 | ANGLE_VK_TRY(context, |
| 1021 | swapchainImage.framebuffer.init(context->getDevice(), framebufferInfo)); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1022 | } |
| 1023 | |
Jamie Madill | a9c60e9 | 2017-09-28 19:06:39 -0400 | [diff] [blame] | 1024 | ASSERT(currentFramebuffer.valid()); |
Jamie Madill | 5598148 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 1025 | *framebufferOut = ¤tFramebuffer; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 1026 | return angle::Result::Continue; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 1027 | } |
| 1028 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 1029 | angle::Result WindowSurfaceVk::initializeContents(const gl::Context *context, |
| 1030 | const gl::ImageIndex &imageIndex) |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 1031 | { |
| 1032 | UNIMPLEMENTED(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 1033 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 1034 | } |
| 1035 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 1036 | } // namespace rx |