OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrRenderTarget.h" | 10 #include "GrRenderTarget.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 , fSurfaces(nullptr) | 34 , fSurfaces(nullptr) |
35 , fCommandPool(VK_NULL_HANDLE) | 35 , fCommandPool(VK_NULL_HANDLE) |
36 , fBackbuffers(nullptr) { | 36 , fBackbuffers(nullptr) { |
37 | 37 |
38 // any config code here (particularly for msaa)? | 38 // any config code here (particularly for msaa)? |
39 | 39 |
40 this->initializeContext(platformData, params); | 40 this->initializeContext(platformData, params); |
41 } | 41 } |
42 | 42 |
43 void VulkanWindowContext::initializeContext(void* platformData, const DisplayPar
ams& params) { | 43 void VulkanWindowContext::initializeContext(void* platformData, const DisplayPar
ams& params) { |
| 44 fBackendContext.reset(GrVkBackendContext::Create(&fPresentQueueIndex, canPre
sent, |
| 45 platformData)); |
44 | 46 |
45 fBackendContext.reset(GrVkBackendContext::Create(&fPresentQueueIndex, canPre
sent)); | |
46 if (!(fBackendContext->fExtensions & kKHR_surface_GrVkExtensionFlag) || | 47 if (!(fBackendContext->fExtensions & kKHR_surface_GrVkExtensionFlag) || |
47 !(fBackendContext->fExtensions & kKHR_swapchain_GrVkExtensionFlag)) { | 48 !(fBackendContext->fExtensions & kKHR_swapchain_GrVkExtensionFlag)) { |
48 fBackendContext.reset(nullptr); | 49 fBackendContext.reset(nullptr); |
49 return; | 50 return; |
50 } | 51 } |
51 | 52 |
52 VkInstance instance = fBackendContext->fInstance; | 53 VkInstance instance = fBackendContext->fInstance; |
53 VkDevice device = fBackendContext->fDevice; | 54 VkDevice device = fBackendContext->fDevice; |
54 GET_PROC(DestroySurfaceKHR); | 55 GET_PROC(DestroySurfaceKHR); |
55 GET_PROC(GetPhysicalDeviceSurfaceSupportKHR); | 56 GET_PROC(GetPhysicalDeviceSurfaceSupportKHR); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 extent.width = caps.minImageExtent.width; | 141 extent.width = caps.minImageExtent.width; |
141 } else if (extent.width > caps.maxImageExtent.width) { | 142 } else if (extent.width > caps.maxImageExtent.width) { |
142 extent.width = caps.maxImageExtent.width; | 143 extent.width = caps.maxImageExtent.width; |
143 } | 144 } |
144 // clamp height | 145 // clamp height |
145 if (extent.height < caps.minImageExtent.height) { | 146 if (extent.height < caps.minImageExtent.height) { |
146 extent.height = caps.minImageExtent.height; | 147 extent.height = caps.minImageExtent.height; |
147 } else if (extent.height > caps.maxImageExtent.height) { | 148 } else if (extent.height > caps.maxImageExtent.height) { |
148 extent.height = caps.maxImageExtent.height; | 149 extent.height = caps.maxImageExtent.height; |
149 } | 150 } |
| 151 |
150 fWidth = (int)extent.width; | 152 fWidth = (int)extent.width; |
151 fHeight = (int)extent.height; | 153 fHeight = (int)extent.height; |
152 | 154 |
153 uint32_t imageCount = caps.minImageCount + 2; | 155 uint32_t imageCount = caps.minImageCount + 2; |
154 if (caps.maxImageCount > 0 && imageCount > caps.maxImageCount) { | 156 if (caps.maxImageCount > 0 && imageCount > caps.maxImageCount) { |
155 // Application must settle for fewer images than desired: | 157 // Application must settle for fewer images than desired: |
156 imageCount = caps.maxImageCount; | 158 imageCount = caps.maxImageCount; |
157 } | 159 } |
158 | 160 |
159 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | 161 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 &fSwapchain, // pSwapchains | 594 &fSwapchain, // pSwapchains |
593 &backbuffer->fImageIndex, // pImageIndices | 595 &backbuffer->fImageIndex, // pImageIndices |
594 NULL // pResults | 596 NULL // pResults |
595 }; | 597 }; |
596 | 598 |
597 fQueuePresentKHR(fPresentQueue, &presentInfo); | 599 fQueuePresentKHR(fPresentQueue, &presentInfo); |
598 | 600 |
599 } | 601 } |
600 | 602 |
601 } //namespace sk_app | 603 } //namespace sk_app |
OLD | NEW |