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 | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 13 | #include "libANGLE/Display.h" |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 14 | #include "libANGLE/Surface.h" |
| 15 | #include "libANGLE/renderer/vulkan/DisplayVk.h" |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 16 | #include "libANGLE/renderer/vulkan/FramebufferVk.h" |
| 17 | #include "libANGLE/renderer/vulkan/RendererVk.h" |
Jamie Madill | abaab23 | 2017-01-10 12:37:37 -0500 | [diff] [blame] | 18 | #include "libANGLE/renderer/vulkan/formatutilsvk.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 19 | |
| 20 | namespace rx |
| 21 | { |
| 22 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 23 | namespace |
| 24 | { |
| 25 | |
Jamie Madill | abaab23 | 2017-01-10 12:37:37 -0500 | [diff] [blame] | 26 | const vk::Format &GetVkFormatFromConfig(const egl::Config &config) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 27 | { |
| 28 | // TODO(jmadill): Properly handle format interpretation. |
Jamie Madill | abaab23 | 2017-01-10 12:37:37 -0500 | [diff] [blame] | 29 | return vk::Format::Get(GL_BGRA8_EXT); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 30 | } |
| 31 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 32 | VkPresentModeKHR GetDesiredPresentMode(const std::vector<VkPresentModeKHR> &presentModes, |
| 33 | EGLint minSwapInterval, |
| 34 | EGLint maxSwapInterval) |
| 35 | { |
| 36 | ASSERT(!presentModes.empty()); |
| 37 | |
| 38 | // Use FIFO mode for v-sync, since it throttles you to the display rate. Mailbox is more |
| 39 | // similar to triple-buffering. For now we hard-code Mailbox for perf tseting. |
| 40 | // TODO(jmadill): Properly select present mode and re-create display if changed. |
| 41 | VkPresentModeKHR bestChoice = VK_PRESENT_MODE_MAILBOX_KHR; |
| 42 | |
| 43 | for (auto presentMode : presentModes) |
| 44 | { |
| 45 | if (presentMode == bestChoice) |
| 46 | { |
| 47 | return bestChoice; |
| 48 | } |
| 49 | } |
| 50 | |
Jamie Madill | 98de826 | 2017-05-29 13:01:02 -0400 | [diff] [blame] | 51 | WARN() << "Present mode " << bestChoice << " not available. Falling back to " |
| 52 | << presentModes[0]; |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 53 | return presentModes[0]; |
| 54 | } |
| 55 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 56 | } // namespace |
| 57 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 58 | OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, |
| 59 | EGLint width, |
| 60 | EGLint height) |
| 61 | : SurfaceImpl(surfaceState), mWidth(width), mHeight(height) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 62 | { |
| 63 | } |
| 64 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 65 | OffscreenSurfaceVk::~OffscreenSurfaceVk() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 66 | { |
| 67 | } |
| 68 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 69 | egl::Error OffscreenSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 70 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 71 | return egl::Error(EGL_SUCCESS); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 72 | } |
| 73 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 74 | FramebufferImpl *OffscreenSurfaceVk::createDefaultFramebuffer(const gl::FramebufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 75 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 76 | // Use a user FBO for an offscreen RT. |
| 77 | return FramebufferVk::CreateUserFBO(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 78 | } |
| 79 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 80 | egl::Error OffscreenSurfaceVk::swap(const egl::Display *display) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 81 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 82 | return egl::Error(EGL_SUCCESS); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 83 | } |
| 84 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 85 | egl::Error OffscreenSurfaceVk::postSubBuffer(EGLint /*x*/, |
| 86 | EGLint /*y*/, |
| 87 | EGLint /*width*/, |
| 88 | EGLint /*height*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 89 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 90 | return egl::Error(EGL_SUCCESS); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 91 | } |
| 92 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 93 | egl::Error OffscreenSurfaceVk::querySurfacePointerANGLE(EGLint /*attribute*/, void ** /*value*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 94 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 95 | UNREACHABLE(); |
| 96 | return egl::Error(EGL_BAD_CURRENT_SURFACE); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 97 | } |
| 98 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 99 | egl::Error OffscreenSurfaceVk::bindTexImage(gl::Texture * /*texture*/, EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 100 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 101 | return egl::Error(EGL_SUCCESS); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 102 | } |
| 103 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 104 | egl::Error OffscreenSurfaceVk::releaseTexImage(EGLint /*buffer*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 105 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 106 | return egl::Error(EGL_SUCCESS); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 107 | } |
| 108 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 109 | egl::Error OffscreenSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 110 | EGLuint64KHR * /*msc*/, |
| 111 | EGLuint64KHR * /*sbc*/) |
| 112 | { |
| 113 | UNIMPLEMENTED(); |
| 114 | return egl::Error(EGL_BAD_ACCESS); |
| 115 | } |
| 116 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 117 | void OffscreenSurfaceVk::setSwapInterval(EGLint /*interval*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 118 | { |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 119 | } |
| 120 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 121 | EGLint OffscreenSurfaceVk::getWidth() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 122 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 123 | return mWidth; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 124 | } |
| 125 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 126 | EGLint OffscreenSurfaceVk::getHeight() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 127 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 128 | return mHeight; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 129 | } |
| 130 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 131 | EGLint OffscreenSurfaceVk::isPostSubBufferSupported() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 132 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 133 | return EGL_FALSE; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 134 | } |
| 135 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 136 | EGLint OffscreenSurfaceVk::getSwapBehavior() const |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 137 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 138 | return EGL_BUFFER_PRESERVED; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 139 | } |
| 140 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 141 | gl::Error OffscreenSurfaceVk::getAttachmentRenderTarget( |
Jamie Madill | 4fd95d5 | 2017-04-05 11:22:18 -0400 | [diff] [blame] | 142 | GLenum /*binding*/, |
| 143 | const gl::ImageIndex & /*imageIndex*/, |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 144 | FramebufferAttachmentRenderTarget ** /*rtOut*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 145 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 146 | UNREACHABLE(); |
| 147 | return gl::Error(GL_INVALID_OPERATION); |
| 148 | } |
| 149 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 150 | WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, |
| 151 | EGLNativeWindowType window, |
| 152 | EGLint width, |
| 153 | EGLint height) |
| 154 | : SurfaceImpl(surfaceState), |
| 155 | mNativeWindowType(window), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 156 | mSurface(VK_NULL_HANDLE), |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 157 | mInstance(VK_NULL_HANDLE), |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 158 | mSwapchain(VK_NULL_HANDLE), |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 159 | mRenderTarget(), |
| 160 | mCurrentSwapchainImageIndex(0) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 161 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 162 | mRenderTarget.extents.width = static_cast<GLint>(width); |
| 163 | mRenderTarget.extents.height = static_cast<GLint>(height); |
| 164 | mRenderTarget.extents.depth = 1; |
Jamie Madill | 4c26fc2 | 2017-02-24 11:04:10 -0500 | [diff] [blame] | 165 | mRenderTarget.resource = this; |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | WindowSurfaceVk::~WindowSurfaceVk() |
| 169 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 170 | ASSERT(mSurface == VK_NULL_HANDLE); |
| 171 | ASSERT(mSwapchain == VK_NULL_HANDLE); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 172 | } |
| 173 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 174 | void WindowSurfaceVk::destroy(const egl::Display *display) |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 175 | { |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 176 | const DisplayVk *displayVk = GetImplAs<DisplayVk>(display); |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 177 | RendererVk *rendererVk = displayVk->getRenderer(); |
| 178 | VkDevice device = rendererVk->getDevice(); |
| 179 | VkInstance instance = rendererVk->getInstance(); |
| 180 | |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 181 | rendererVk->finish(); |
| 182 | |
| 183 | mImageAvailableSemaphore.destroy(device); |
| 184 | mRenderingCompleteSemaphore.destroy(device); |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 185 | |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 186 | for (auto &imageView : mSwapchainImageViews) |
| 187 | { |
| 188 | imageView.destroy(device); |
| 189 | } |
| 190 | |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 191 | // Although we don't own the swapchain image handles, we need to keep our shutdown clean. |
| 192 | for (auto &image : mSwapchainImages) |
| 193 | { |
| 194 | image.reset(); |
| 195 | } |
| 196 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 197 | for (auto &framebuffer : mSwapchainFramebuffers) |
| 198 | { |
| 199 | framebuffer.destroy(device); |
| 200 | } |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 201 | |
| 202 | if (mSwapchain) |
| 203 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 204 | vkDestroySwapchainKHR(device, mSwapchain, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 205 | mSwapchain = VK_NULL_HANDLE; |
| 206 | } |
| 207 | |
| 208 | if (mSurface) |
| 209 | { |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 210 | vkDestroySurfaceKHR(instance, mSurface, nullptr); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 211 | mSurface = VK_NULL_HANDLE; |
| 212 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 213 | } |
| 214 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 215 | egl::Error WindowSurfaceVk::initialize(const egl::Display *display) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 216 | { |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 217 | const DisplayVk *displayVk = GetImplAs<DisplayVk>(display); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 218 | return initializeImpl(displayVk->getRenderer()).toEGL(EGL_BAD_SURFACE); |
| 219 | } |
| 220 | |
| 221 | vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer) |
| 222 | { |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 223 | gl::Extents windowSize; |
| 224 | ANGLE_TRY_RESULT(createSurfaceVk(renderer), windowSize); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 225 | |
| 226 | uint32_t presentQueue = 0; |
| 227 | ANGLE_TRY_RESULT(renderer->selectPresentQueueForSurface(mSurface), presentQueue); |
| 228 | |
| 229 | const auto &physicalDevice = renderer->getPhysicalDevice(); |
| 230 | |
| 231 | VkSurfaceCapabilitiesKHR surfaceCaps; |
| 232 | ANGLE_VK_TRY(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface, &surfaceCaps)); |
| 233 | |
| 234 | // Adjust width and height to the swapchain if necessary. |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 235 | uint32_t width = surfaceCaps.currentExtent.width; |
| 236 | uint32_t height = surfaceCaps.currentExtent.height; |
| 237 | |
| 238 | // TODO(jmadill): Support devices which don't support copy. We use this for ReadPixels. |
| 239 | ANGLE_VK_CHECK((surfaceCaps.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) != 0, |
| 240 | VK_ERROR_INITIALIZATION_FAILED); |
| 241 | |
| 242 | if (surfaceCaps.currentExtent.width == 0xFFFFFFFFu) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 243 | { |
| 244 | ASSERT(surfaceCaps.currentExtent.height == 0xFFFFFFFFu); |
| 245 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 246 | if (mRenderTarget.extents.width == 0) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 247 | { |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 248 | width = windowSize.width; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 249 | } |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 250 | if (mRenderTarget.extents.height == 0) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 251 | { |
Frank Henigman | 29f148b | 2016-11-23 21:05:36 -0500 | [diff] [blame] | 252 | height = windowSize.height; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 256 | mRenderTarget.extents.width = static_cast<int>(width); |
| 257 | mRenderTarget.extents.height = static_cast<int>(height); |
| 258 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 259 | uint32_t presentModeCount = 0; |
| 260 | ANGLE_VK_TRY(vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, mSurface, |
| 261 | &presentModeCount, nullptr)); |
| 262 | ASSERT(presentModeCount > 0); |
| 263 | |
| 264 | std::vector<VkPresentModeKHR> presentModes(presentModeCount); |
| 265 | ANGLE_VK_TRY(vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, mSurface, |
| 266 | &presentModeCount, presentModes.data())); |
| 267 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 268 | // Select appropriate present mode based on vsync parameter. |
| 269 | // TODO(jmadill): More complete implementation, which allows for changing and more values. |
| 270 | const EGLint minSwapInterval = mState.config->minSwapInterval; |
| 271 | const EGLint maxSwapInterval = mState.config->maxSwapInterval; |
| 272 | ASSERT(minSwapInterval == 0 || minSwapInterval == 1); |
| 273 | ASSERT(maxSwapInterval == 0 || maxSwapInterval == 1); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 274 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 275 | VkPresentModeKHR swapchainPresentMode = |
| 276 | GetDesiredPresentMode(presentModes, minSwapInterval, maxSwapInterval); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 277 | |
| 278 | // Determine number of swapchain images. Aim for one more than the minimum. |
| 279 | uint32_t minImageCount = surfaceCaps.minImageCount + 1; |
| 280 | if (surfaceCaps.maxImageCount > 0 && minImageCount > surfaceCaps.maxImageCount) |
| 281 | { |
| 282 | minImageCount = surfaceCaps.maxImageCount; |
| 283 | } |
| 284 | |
| 285 | // Default to identity transform. |
| 286 | VkSurfaceTransformFlagBitsKHR preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; |
| 287 | if ((surfaceCaps.supportedTransforms & preTransform) == 0) |
| 288 | { |
| 289 | preTransform = surfaceCaps.currentTransform; |
| 290 | } |
| 291 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 292 | uint32_t surfaceFormatCount = 0; |
| 293 | ANGLE_VK_TRY(vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, &surfaceFormatCount, |
| 294 | nullptr)); |
| 295 | |
| 296 | std::vector<VkSurfaceFormatKHR> surfaceFormats(surfaceFormatCount); |
| 297 | ANGLE_VK_TRY(vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, mSurface, &surfaceFormatCount, |
| 298 | surfaceFormats.data())); |
| 299 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 300 | mRenderTarget.format = &GetVkFormatFromConfig(*mState.config); |
| 301 | auto nativeFormat = mRenderTarget.format->native; |
| 302 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 303 | if (surfaceFormatCount == 1u && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) |
| 304 | { |
| 305 | // This is fine. |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | bool foundFormat = false; |
| 310 | for (const auto &surfaceFormat : surfaceFormats) |
| 311 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 312 | if (surfaceFormat.format == nativeFormat) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 313 | { |
| 314 | foundFormat = true; |
| 315 | break; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | ANGLE_VK_CHECK(foundFormat, VK_ERROR_INITIALIZATION_FAILED); |
| 320 | } |
| 321 | |
| 322 | VkSwapchainCreateInfoKHR swapchainInfo; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 323 | swapchainInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 324 | swapchainInfo.pNext = nullptr; |
| 325 | swapchainInfo.flags = 0; |
| 326 | swapchainInfo.surface = mSurface; |
| 327 | swapchainInfo.minImageCount = minImageCount; |
| 328 | swapchainInfo.imageFormat = nativeFormat; |
| 329 | swapchainInfo.imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
| 330 | swapchainInfo.imageExtent.width = width; |
| 331 | swapchainInfo.imageExtent.height = height; |
| 332 | swapchainInfo.imageArrayLayers = 1; |
| 333 | swapchainInfo.imageUsage = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 334 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 335 | swapchainInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 336 | swapchainInfo.queueFamilyIndexCount = 0; |
| 337 | swapchainInfo.pQueueFamilyIndices = nullptr; |
| 338 | swapchainInfo.preTransform = preTransform; |
| 339 | swapchainInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; |
| 340 | swapchainInfo.presentMode = swapchainPresentMode; |
| 341 | swapchainInfo.clipped = VK_TRUE; |
| 342 | swapchainInfo.oldSwapchain = VK_NULL_HANDLE; |
| 343 | |
| 344 | const auto &device = renderer->getDevice(); |
| 345 | ANGLE_VK_TRY(vkCreateSwapchainKHR(device, &swapchainInfo, nullptr, &mSwapchain)); |
| 346 | |
| 347 | // Intialize the swapchain image views. |
| 348 | uint32_t imageCount = 0; |
| 349 | ANGLE_VK_TRY(vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, nullptr)); |
| 350 | |
| 351 | std::vector<VkImage> swapchainImages(imageCount); |
| 352 | ANGLE_VK_TRY(vkGetSwapchainImagesKHR(device, mSwapchain, &imageCount, swapchainImages.data())); |
| 353 | |
| 354 | // CommandBuffer is a singleton in the Renderer. |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 355 | vk::CommandBuffer *commandBuffer = nullptr; |
| 356 | ANGLE_TRY(renderer->getStartedCommandBuffer(&commandBuffer)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 357 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 358 | VkClearColorValue transparentBlack; |
| 359 | transparentBlack.float32[0] = 0.0f; |
| 360 | transparentBlack.float32[1] = 0.0f; |
| 361 | transparentBlack.float32[2] = 0.0f; |
| 362 | transparentBlack.float32[3] = 0.0f; |
| 363 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 364 | mSwapchainImages.resize(imageCount); |
| 365 | mSwapchainImageViews.resize(imageCount); |
| 366 | |
| 367 | for (uint32_t imageIndex = 0; imageIndex < imageCount; ++imageIndex) |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 368 | { |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 369 | VkImage swapchainImage = swapchainImages[imageIndex]; |
| 370 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 371 | VkImageViewCreateInfo imageViewInfo; |
| 372 | imageViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 373 | imageViewInfo.pNext = nullptr; |
| 374 | imageViewInfo.flags = 0; |
| 375 | imageViewInfo.image = swapchainImage; |
| 376 | imageViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 377 | imageViewInfo.format = nativeFormat; |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 378 | imageViewInfo.components.r = VK_COMPONENT_SWIZZLE_R; |
| 379 | imageViewInfo.components.g = VK_COMPONENT_SWIZZLE_G; |
| 380 | imageViewInfo.components.b = VK_COMPONENT_SWIZZLE_B; |
| 381 | imageViewInfo.components.a = VK_COMPONENT_SWIZZLE_A; |
| 382 | imageViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 383 | imageViewInfo.subresourceRange.baseMipLevel = 0; |
| 384 | imageViewInfo.subresourceRange.levelCount = 1; |
| 385 | imageViewInfo.subresourceRange.baseArrayLayer = 0; |
| 386 | imageViewInfo.subresourceRange.layerCount = 1; |
| 387 | |
| 388 | vk::Image image(swapchainImage); |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 389 | vk::ImageView imageView; |
| 390 | ANGLE_TRY(imageView.init(device, imageViewInfo)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 391 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 392 | // Set transfer dest layout, and clear the image to black. |
| 393 | image.changeLayoutTop(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 394 | commandBuffer); |
| 395 | commandBuffer->clearSingleColorImage(image, transparentBlack); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 396 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 397 | mSwapchainImages[imageIndex].retain(device, std::move(image)); |
| 398 | mSwapchainImageViews[imageIndex].retain(device, std::move(imageView)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 399 | } |
| 400 | |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 401 | ANGLE_TRY(renderer->submitAndFinishCommandBuffer(commandBuffer)); |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 402 | |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 403 | ANGLE_TRY(mImageAvailableSemaphore.init(device)); |
| 404 | ANGLE_TRY(mRenderingCompleteSemaphore.init(device)); |
| 405 | |
| 406 | // Get the first available swapchain iamge. |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 407 | ANGLE_TRY(nextSwapchainImage(renderer)); |
| 408 | |
Jamie Madill | 4d0bf55 | 2016-12-28 15:45:24 -0500 | [diff] [blame] | 409 | return vk::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | FramebufferImpl *WindowSurfaceVk::createDefaultFramebuffer(const gl::FramebufferState &state) |
| 413 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 414 | return FramebufferVk::CreateDefaultFBO(state, this); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 415 | } |
| 416 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 417 | egl::Error WindowSurfaceVk::swap(const egl::Display *display) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 418 | { |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 419 | const DisplayVk *displayVk = GetImplAs<DisplayVk>(display); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 420 | return swapImpl(displayVk->getRenderer()).toEGL(EGL_BAD_ALLOC); |
| 421 | } |
| 422 | |
| 423 | vk::Error WindowSurfaceVk::swapImpl(RendererVk *renderer) |
| 424 | { |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 425 | vk::CommandBuffer *currentCB = nullptr; |
| 426 | ANGLE_TRY(renderer->getStartedCommandBuffer(¤tCB)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 427 | |
| 428 | auto *image = &mSwapchainImages[mCurrentSwapchainImageIndex]; |
| 429 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 430 | image->changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, |
| 431 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 432 | VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, currentCB); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 433 | |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 434 | ANGLE_TRY(renderer->submitCommandsWithSync(currentCB, mImageAvailableSemaphore, |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 435 | mRenderingCompleteSemaphore)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 436 | |
| 437 | VkPresentInfoKHR presentInfo; |
| 438 | presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 439 | presentInfo.pNext = nullptr; |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 440 | presentInfo.waitSemaphoreCount = 1; |
| 441 | presentInfo.pWaitSemaphores = mRenderingCompleteSemaphore.ptr(); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 442 | presentInfo.swapchainCount = 1; |
| 443 | presentInfo.pSwapchains = &mSwapchain; |
| 444 | presentInfo.pImageIndices = &mCurrentSwapchainImageIndex; |
| 445 | presentInfo.pResults = nullptr; |
| 446 | |
| 447 | ANGLE_VK_TRY(vkQueuePresentKHR(renderer->getQueue(), &presentInfo)); |
| 448 | |
Jamie Madill | f0eafe1 | 2017-02-21 15:03:50 -0500 | [diff] [blame] | 449 | // Get the next available swapchain image. |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 450 | ANGLE_TRY(nextSwapchainImage(renderer)); |
| 451 | |
| 452 | return vk::NoError(); |
| 453 | } |
| 454 | |
| 455 | vk::Error WindowSurfaceVk::nextSwapchainImage(RendererVk *renderer) |
| 456 | { |
| 457 | VkDevice device = renderer->getDevice(); |
| 458 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 459 | ANGLE_VK_TRY(vkAcquireNextImageKHR(device, mSwapchain, std::numeric_limits<uint64_t>::max(), |
Jamie Madill | e918de2 | 2017-04-12 10:21:11 -0400 | [diff] [blame] | 460 | mImageAvailableSemaphore.getHandle(), VK_NULL_HANDLE, |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 461 | &mCurrentSwapchainImageIndex)); |
| 462 | |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 463 | // Update RenderTarget pointers. |
| 464 | mRenderTarget.image = &mSwapchainImages[mCurrentSwapchainImageIndex]; |
| 465 | mRenderTarget.imageView = &mSwapchainImageViews[mCurrentSwapchainImageIndex]; |
| 466 | |
| 467 | return vk::NoError(); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | egl::Error WindowSurfaceVk::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) |
| 471 | { |
| 472 | // TODO(jmadill) |
| 473 | return egl::Error(EGL_SUCCESS); |
| 474 | } |
| 475 | |
| 476 | egl::Error WindowSurfaceVk::querySurfacePointerANGLE(EGLint attribute, void **value) |
| 477 | { |
| 478 | UNREACHABLE(); |
| 479 | return egl::Error(EGL_BAD_CURRENT_SURFACE); |
| 480 | } |
| 481 | |
| 482 | egl::Error WindowSurfaceVk::bindTexImage(gl::Texture *texture, EGLint buffer) |
| 483 | { |
| 484 | return egl::Error(EGL_SUCCESS); |
| 485 | } |
| 486 | |
| 487 | egl::Error WindowSurfaceVk::releaseTexImage(EGLint buffer) |
| 488 | { |
| 489 | return egl::Error(EGL_SUCCESS); |
| 490 | } |
| 491 | |
Stanislav Chiknavaryan | ee218f2 | 2017-03-22 15:39:13 -0700 | [diff] [blame] | 492 | egl::Error WindowSurfaceVk::getSyncValues(EGLuint64KHR * /*ust*/, |
| 493 | EGLuint64KHR * /*msc*/, |
| 494 | EGLuint64KHR * /*sbc*/) |
| 495 | { |
| 496 | UNIMPLEMENTED(); |
| 497 | return egl::Error(EGL_BAD_ACCESS); |
| 498 | } |
| 499 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 500 | void WindowSurfaceVk::setSwapInterval(EGLint interval) |
| 501 | { |
| 502 | } |
| 503 | |
| 504 | EGLint WindowSurfaceVk::getWidth() const |
| 505 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 506 | return static_cast<EGLint>(mRenderTarget.extents.width); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | EGLint WindowSurfaceVk::getHeight() const |
| 510 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 511 | return static_cast<EGLint>(mRenderTarget.extents.height); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | EGLint WindowSurfaceVk::isPostSubBufferSupported() const |
| 515 | { |
| 516 | // TODO(jmadill) |
| 517 | return EGL_FALSE; |
| 518 | } |
| 519 | |
| 520 | EGLint WindowSurfaceVk::getSwapBehavior() const |
| 521 | { |
| 522 | // TODO(jmadill) |
| 523 | return EGL_BUFFER_DESTROYED; |
| 524 | } |
| 525 | |
Jamie Madill | 4fd95d5 | 2017-04-05 11:22:18 -0400 | [diff] [blame] | 526 | gl::Error WindowSurfaceVk::getAttachmentRenderTarget(GLenum /*binding*/, |
| 527 | const gl::ImageIndex & /*target*/, |
| 528 | FramebufferAttachmentRenderTarget **rtOut) |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 529 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 530 | *rtOut = &mRenderTarget; |
| 531 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 532 | } |
| 533 | |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 534 | gl::ErrorOrResult<vk::Framebuffer *> WindowSurfaceVk::getCurrentFramebuffer( |
| 535 | VkDevice device, |
| 536 | const vk::RenderPass &compatibleRenderPass) |
| 537 | { |
| 538 | if (!mSwapchainFramebuffers.empty()) |
| 539 | { |
| 540 | // Validation layers should detect if the render pass is really compatible. |
| 541 | return &mSwapchainFramebuffers[mCurrentSwapchainImageIndex]; |
| 542 | } |
| 543 | |
| 544 | VkFramebufferCreateInfo framebufferInfo; |
| 545 | |
| 546 | // TODO(jmadill): Depth/Stencil attachments. |
| 547 | framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 548 | framebufferInfo.pNext = nullptr; |
| 549 | framebufferInfo.flags = 0; |
| 550 | framebufferInfo.renderPass = compatibleRenderPass.getHandle(); |
| 551 | framebufferInfo.attachmentCount = 1u; |
| 552 | framebufferInfo.pAttachments = nullptr; |
| 553 | framebufferInfo.width = static_cast<uint32_t>(mRenderTarget.extents.width); |
| 554 | framebufferInfo.height = static_cast<uint32_t>(mRenderTarget.extents.height); |
| 555 | framebufferInfo.layers = 1; |
| 556 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 557 | mSwapchainFramebuffers.resize(mSwapchainImageViews.size()); |
| 558 | for (size_t imageIndex = 0; imageIndex < mSwapchainFramebuffers.size(); ++imageIndex) |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 559 | { |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 560 | const auto &imageView = mSwapchainImageViews[imageIndex]; |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 561 | VkImageView imageViewHandle = imageView.getHandle(); |
| 562 | framebufferInfo.pAttachments = &imageViewHandle; |
| 563 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 564 | vk::Framebuffer framebuffer; |
| 565 | ANGLE_TRY(framebuffer.init(device, framebufferInfo)); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 566 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 567 | mSwapchainFramebuffers[imageIndex].retain(device, std::move(framebuffer)); |
Jamie Madill | ab9f9c3 | 2017-01-17 17:47:34 -0500 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | // We should only initialize framebuffers on the first swap. |
| 571 | ASSERT(mCurrentSwapchainImageIndex == 0u); |
| 572 | return &mSwapchainFramebuffers[mCurrentSwapchainImageIndex]; |
| 573 | } |
| 574 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 575 | } // namespace rx |