MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / getBackbufferSurface

Method getBackbufferSurface

src/VulkanContext/VulkanWindowContext.cpp:515–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
516 BackbufferInfo* backbuffer = this->getAvailableBackbuffer();
517 SkASSERT(backbuffer);
518
519 // semaphores should be in unsignaled state
520 VkSemaphoreCreateInfo semaphoreInfo;
521 memset(&semaphoreInfo, 0, sizeof(VkSemaphoreCreateInfo));
522 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
523 semaphoreInfo.pNext = nullptr;
524 semaphoreInfo.flags = 0;
525 VkSemaphore semaphore;
526 SkDEBUGCODE(VkResult result = )GR_VK_CALL(fInterface, CreateSemaphore(fDevice, &semaphoreInfo,
527 nullptr, &semaphore));
528 SkASSERT(result == VK_SUCCESS);
529
530 // acquire the image
531 VkResult res = fAcquireNextImageKHR(fDevice, fSwapchain, UINT64_MAX,
532 semaphore, VK_NULL_HANDLE,
533 &backbuffer->fImageIndex);
534 if (VK_ERROR_SURFACE_LOST_KHR == res) {
535 // need to figure out how to create a new vkSurface without the platformData*
536 // maybe use attach somehow? but need a Window
537 GR_VK_CALL(fInterface, DestroySemaphore(fDevice, semaphore, nullptr));
538 return nullptr;
539 }
540 if (VK_ERROR_OUT_OF_DATE_KHR == res) {
541 // tear swapchain down and try again
542 if (!this->createSwapchain(-1, -1)) {
543 GR_VK_CALL(fInterface, DestroySemaphore(fDevice, semaphore, nullptr));
544 return nullptr;
545 }
546 backbuffer = this->getAvailableBackbuffer();
547
548 // acquire the image
549 res = fAcquireNextImageKHR(fDevice, fSwapchain, UINT64_MAX,
550 semaphore, VK_NULL_HANDLE,
551 &backbuffer->fImageIndex);
552
553 if (VK_SUCCESS != res) {
554 GR_VK_CALL(fInterface, DestroySemaphore(fDevice, semaphore, nullptr));
555 return nullptr;
556 }
557 }
558
559 SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get();
560
561 GrBackendSemaphore beSemaphore = GrBackendSemaphores::MakeVk(semaphore);
562
563 surface->wait(1, &beSemaphore);
564
565 return sk_ref_sp(surface);
566}
567
568void VulkanWindowContext::onSwapBuffers() {
569

Callers 2

SDL_AppInitFunction · 0.45
regular_drawFunction · 0.45

Calls 3

createSwapchainMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected