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

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

Issue 1873453002: Some more improvements/fixes to the VulkanViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 8 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/Application.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 queueProps)); 59 queueProps));
60 60
61 // iterate to find the present queue 61 // iterate to find the present queue
62 fPresentQueueIndex = -1; 62 fPresentQueueIndex = -1;
63 for (uint32_t i = 0; i < queueCount; i++) { 63 for (uint32_t i = 0; i < queueCount; i++) {
64 if ((queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) && canPresent(i)) { 64 if ((queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) && canPresent(i)) {
65 fPresentQueueIndex = i; 65 fPresentQueueIndex = i;
66 break; 66 break;
67 } 67 }
68 } 68 }
69 SkASSERT(0 <= fPresentQueueIndex && fPresentQueueIndex < queueCount); 69 SkASSERT(fPresentQueueIndex < queueCount);
70 70
71 VkBool32 supported; 71 VkBool32 supported;
72 VkResult res = GR_VK_CALL(fBackendContext->fInterface, 72 VkResult res = GR_VK_CALL(fBackendContext->fInterface,
73 GetPhysicalDeviceSurfaceSupportKHR(fBackendContext ->fPhysicalDevice, 73 GetPhysicalDeviceSurfaceSupportKHR(fBackendContext ->fPhysicalDevice,
74 fPresentQueueIn dex, 74 fPresentQueueIn dex,
75 fSurface, 75 fSurface,
76 &supported)); 76 &supported));
77 if (VK_SUCCESS != res) { 77 if (VK_SUCCESS != res) {
78 this->destroyContext(); 78 this->destroyContext();
79 return; 79 return;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 VK_IMAGE_USAGE_TRANSFER_DST_BIT; 177 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
178 SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags); 178 SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags);
179 SkASSERT(caps.supportedTransforms & caps.currentTransform); 179 SkASSERT(caps.supportedTransforms & caps.currentTransform);
180 SkASSERT(caps.supportedCompositeAlpha & (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | 180 SkASSERT(caps.supportedCompositeAlpha & (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR |
181 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ); 181 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) );
182 VkCompositeAlphaFlagBitsKHR composite_alpha = 182 VkCompositeAlphaFlagBitsKHR composite_alpha =
183 (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ? 183 (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ?
184 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR : 184 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR :
185 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; 185 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
186 186
187 // FIFO is the only mode universally supported 187 // If mailbox mode is available, use it, as it is the lowest-latency non-
188 // tearing mode. If not, fall back to FIFO which is always available.
188 VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR; 189 VkPresentModeKHR mode = VK_PRESENT_MODE_FIFO_KHR;
189 bool vsync = false;
190 for (uint32_t i = 0; i < presentModeCount; ++i) { 190 for (uint32_t i = 0; i < presentModeCount; ++i) {
191 if ((vsync && VK_PRESENT_MODE_MAILBOX_KHR == presentModes[i]) || 191 // use mailbox
192 (!vsync && VK_PRESENT_MODE_IMMEDIATE_KHR == presentModes[i])) { 192 if (VK_PRESENT_MODE_MAILBOX_KHR == presentModes[i]) {
193 mode = presentModes[i]; 193 mode = presentModes[i];
194 break;
194 } 195 }
195 } 196 }
196 197
197 VkSwapchainCreateInfoKHR swapchainCreateInfo; 198 VkSwapchainCreateInfoKHR swapchainCreateInfo;
198 memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR)); 199 memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR));
199 swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; 200 swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
200 swapchainCreateInfo.surface = fSurface; 201 swapchainCreateInfo.surface = fSurface;
201 swapchainCreateInfo.minImageCount = imageCount; 202 swapchainCreateInfo.minImageCount = imageCount;
202 swapchainCreateInfo.imageFormat = surfaceFormats[0].format; // for now , use the first one 203 swapchainCreateInfo.imageFormat = surfaceFormats[0].format; // for now , use the first one
203 swapchainCreateInfo.imageColorSpace = surfaceFormats[0].colorSpace; 204 swapchainCreateInfo.imageColorSpace = surfaceFormats[0].colorSpace;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // acquire the image 441 // acquire the image
441 VkResult res = GR_VK_CALL(fBackendContext->fInterface, 442 VkResult res = GR_VK_CALL(fBackendContext->fInterface,
442 AcquireNextImageKHR(fBackendContext->fDevice, 443 AcquireNextImageKHR(fBackendContext->fDevice,
443 fSwapchain, 444 fSwapchain,
444 UINT64_MAX, 445 UINT64_MAX,
445 backbuffer->fAcquireSemaphore, 446 backbuffer->fAcquireSemaphore,
446 VK_NULL_HANDLE, 447 VK_NULL_HANDLE,
447 &backbuffer->fImageIndex)); 448 &backbuffer->fImageIndex));
448 if (VK_ERROR_SURFACE_LOST_KHR == res) { 449 if (VK_ERROR_SURFACE_LOST_KHR == res) {
449 // need to figure out how to create a new vkSurface without the platform Data* 450 // need to figure out how to create a new vkSurface without the platform Data*
451 // maybe use attach somehow? but need a Window
450 return nullptr; 452 return nullptr;
451 } 453 }
452 if (VK_ERROR_OUT_OF_DATE_KHR == res || VK_ERROR_SURFACE_LOST_KHR == res) { 454 if (VK_ERROR_OUT_OF_DATE_KHR == res) {
453 // tear swapchain down and try again 455 // tear swapchain down and try again
454 if (!this->createSwapchain(0, 0)) { 456 if (!this->createSwapchain(0, 0)) {
455 return nullptr; 457 return nullptr;
456 } 458 }
457 459
458 // acquire the image 460 // acquire the image
459 res = GR_VK_CALL(fBackendContext->fInterface, 461 res = GR_VK_CALL(fBackendContext->fInterface,
460 AcquireNextImageKHR(fBackendContext->fDevice, 462 AcquireNextImageKHR(fBackendContext->fDevice,
461 fSwapchain, 463 fSwapchain,
462 UINT64_MAX, 464 UINT64_MAX,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 1, // swapchainCount 597 1, // swapchainCount
596 &fSwapchain, // pSwapchains 598 &fSwapchain, // pSwapchains
597 &backbuffer->fImageIndex, // pImageIndices 599 &backbuffer->fImageIndex, // pImageIndices
598 NULL // pResults 600 NULL // pResults
599 }; 601 };
600 602
601 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, 603 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface,
602 QueuePresentKHR(fPresentQueue, &presentInfo)); 604 QueuePresentKHR(fPresentQueue, &presentInfo));
603 605
604 } 606 }
OLDNEW
« no previous file with comments | « tools/vulkan/Application.h ('k') | tools/vulkan/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698