Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: tools/vulkan/VulkanTestContext.cpp

Issue 1920163004: Remove AttachmentInfo from VulkanViewer setup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore check Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/vulkan/VulkanTestContext.h ('k') | tools/vulkan/Window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkSurface.h" 10 #include "SkSurface.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 GET_DEV_PROC(QueuePresentKHR); 56 GET_DEV_PROC(QueuePresentKHR);
57 57
58 fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext)fBackendCo ntext.get()); 58 fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext)fBackendCo ntext.get());
59 59
60 fSurface = createVkSurface(instance, platformData); 60 fSurface = createVkSurface(instance, platformData);
61 if (VK_NULL_HANDLE == fSurface) { 61 if (VK_NULL_HANDLE == fSurface) {
62 fBackendContext.reset(nullptr); 62 fBackendContext.reset(nullptr);
63 return; 63 return;
64 } 64 }
65 65
66 // query to get the initial queue props size
67 uint32_t queueCount;
68 GR_VK_CALL(fBackendContext->fInterface,
69 GetPhysicalDeviceQueueFamilyProperties(fBackendContext->fPhysical Device, &queueCount,
70 nullptr));
71 SkASSERT(queueCount >= 1);
72
73 SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties));
74 // now get the actual queue props
75 VkQueueFamilyProperties* queueProps = (VkQueueFamilyProperties*)queuePropsAl loc.get();
76
77 GR_VK_CALL(fBackendContext->fInterface,
78 GetPhysicalDeviceQueueFamilyProperties(fBackendContext->fPhysical Device, &queueCount,
79 queueProps));
80
81 VkBool32 supported; 66 VkBool32 supported;
82 VkResult res = fGetPhysicalDeviceSurfaceSupportKHR(fBackendContext->fPhysica lDevice, 67 VkResult res = fGetPhysicalDeviceSurfaceSupportKHR(fBackendContext->fPhysica lDevice,
83 fPresentQueueIndex, fSurf ace, 68 fPresentQueueIndex, fSurf ace,
84 &supported); 69 &supported);
85 if (VK_SUCCESS != res) { 70 if (VK_SUCCESS != res) {
86 this->destroyContext(); 71 this->destroyContext();
87 return; 72 return;
88 } 73 }
89 74
90 if (!this->createSwapchain(-1, -1)) { 75 if (!this->createSwapchain(-1, -1)) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 VK_IMAGE_USAGE_TRANSFER_DST_BIT; 154 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
170 SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags); 155 SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags);
171 SkASSERT(caps.supportedTransforms & caps.currentTransform); 156 SkASSERT(caps.supportedTransforms & caps.currentTransform);
172 SkASSERT(caps.supportedCompositeAlpha & (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | 157 SkASSERT(caps.supportedCompositeAlpha & (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR |
173 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ); 158 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) );
174 VkCompositeAlphaFlagBitsKHR composite_alpha = 159 VkCompositeAlphaFlagBitsKHR composite_alpha =
175 (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ? 160 (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ?
176 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR : 161 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR :
177 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; 162 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
178 163
164 // Pick our surface format -- for now, the first one
165 VkFormat surfaceFormat = surfaceFormats[0].format;
166 VkColorSpaceKHR colorSpace = surfaceFormats[0].colorSpace;
167
179 // If mailbox mode is available, use it, as it is the lowest-latency non- 168 // If mailbox mode is available, use it, as it is the lowest-latency non-
180 // tearing mode. If not, fall back to FIFO which is always available. 169 // tearing mode. If not, fall back to FIFO which is always available.
181 VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR; 170 VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR;
182 for (uint32_t i = 0; i < presentModeCount; ++i) { 171 for (uint32_t i = 0; i < presentModeCount; ++i) {
183 // use mailbox 172 // use mailbox
184 if (VK_PRESENT_MODE_MAILBOX_KHR == presentModes[i]) { 173 if (VK_PRESENT_MODE_MAILBOX_KHR == presentModes[i]) {
185 mode = presentModes[i]; 174 mode = presentModes[i];
186 break; 175 break;
187 } 176 }
188 } 177 }
189 178
190 VkSwapchainCreateInfoKHR swapchainCreateInfo; 179 VkSwapchainCreateInfoKHR swapchainCreateInfo;
191 memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR)); 180 memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR));
192 swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; 181 swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
193 swapchainCreateInfo.surface = fSurface; 182 swapchainCreateInfo.surface = fSurface;
194 swapchainCreateInfo.minImageCount = imageCount; 183 swapchainCreateInfo.minImageCount = imageCount;
195 swapchainCreateInfo.imageFormat = surfaceFormats[0].format; // for now , use the first one 184 swapchainCreateInfo.imageFormat = surfaceFormat;
196 swapchainCreateInfo.imageColorSpace = surfaceFormats[0].colorSpace; 185 swapchainCreateInfo.imageColorSpace = colorSpace;
197 swapchainCreateInfo.imageExtent = extent; 186 swapchainCreateInfo.imageExtent = extent;
198 swapchainCreateInfo.imageArrayLayers = 1; 187 swapchainCreateInfo.imageArrayLayers = 1;
199 swapchainCreateInfo.imageUsage = usageFlags; 188 swapchainCreateInfo.imageUsage = usageFlags;
200 189
201 uint32_t queueFamilies[] = { fBackendContext->fGraphicsQueueIndex, fPresentQ ueueIndex }; 190 uint32_t queueFamilies[] = { fBackendContext->fGraphicsQueueIndex, fPresentQ ueueIndex };
202 if (fBackendContext->fGraphicsQueueIndex != fPresentQueueIndex) { 191 if (fBackendContext->fGraphicsQueueIndex != fPresentQueueIndex) {
203 swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; 192 swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
204 swapchainCreateInfo.queueFamilyIndexCount = 2; 193 swapchainCreateInfo.queueFamilyIndexCount = 2;
205 swapchainCreateInfo.pQueueFamilyIndices = queueFamilies; 194 swapchainCreateInfo.pQueueFamilyIndices = queueFamilies;
206 } else { 195 } else {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 &backbuffer->fRenderSemaphore, // pWaitSemaphores 559 &backbuffer->fRenderSemaphore, // pWaitSemaphores
571 1, // swapchainCount 560 1, // swapchainCount
572 &fSwapchain, // pSwapchains 561 &fSwapchain, // pSwapchains
573 &backbuffer->fImageIndex, // pImageIndices 562 &backbuffer->fImageIndex, // pImageIndices
574 NULL // pResults 563 NULL // pResults
575 }; 564 };
576 565
577 fQueuePresentKHR(fPresentQueue, &presentInfo); 566 fQueuePresentKHR(fPresentQueue, &presentInfo);
578 567
579 } 568 }
OLDNEW
« no previous file with comments | « tools/vulkan/VulkanTestContext.h ('k') | tools/vulkan/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698