本文整理汇总了C++中GrContext::flushAndSignalSemaphores方法的典型用法代码示例。如果您正苦于以下问题:C++ GrContext::flushAndSignalSemaphores方法的具体用法?C++ GrContext::flushAndSignalSemaphores怎么用?C++ GrContext::flushAndSignalSemaphores使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrContext
的用法示例。
在下文中一共展示了GrContext::flushAndSignalSemaphores方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: surface_semaphore_test
void surface_semaphore_test(skiatest::Reporter* reporter,
const sk_gpu_test::ContextInfo& mainInfo,
const sk_gpu_test::ContextInfo& childInfo1,
const sk_gpu_test::ContextInfo& childInfo2,
bool flushContext) {
GrContext* mainCtx = mainInfo.grContext();
if (!mainCtx->caps()->fenceSyncSupport()) {
return;
}
const SkImageInfo ii = SkImageInfo::Make(MAIN_W, MAIN_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
sk_sp<SkSurface> mainSurface(SkSurface::MakeRenderTarget(mainCtx, SkBudgeted::kNo,
ii, 0, kTopLeft_GrSurfaceOrigin,
nullptr));
SkCanvas* mainCanvas = mainSurface->getCanvas();
mainCanvas->clear(SK_ColorBLUE);
SkAutoTArray<GrBackendSemaphore> semaphores(2);
#ifdef SK_VULKAN
if (kVulkan_GrBackend == mainInfo.backend()) {
// Initialize the secondary semaphore instead of having Ganesh create one internally
GrVkGpu* gpu = static_cast<GrVkGpu*>(mainCtx->contextPriv().getGpu());
const GrVkInterface* interface = gpu->vkInterface();
VkDevice device = gpu->device();
VkSemaphore vkSem;
VkSemaphoreCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0;
GR_VK_CALL_ERRCHECK(interface, CreateSemaphore(device, &createInfo, nullptr, &vkSem));
semaphores[1].initVulkan(vkSem);
}
#endif
if (flushContext) {
mainCtx->flushAndSignalSemaphores(2, semaphores.get());
} else {
mainSurface->flushAndSignalSemaphores(2, semaphores.get());
}
sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
GrBackendTexture backendTexture = mainImage->getBackendTexture(false);
draw_child(reporter, childInfo1, backendTexture, semaphores[0]);
#ifdef SK_VULKAN
if (kVulkan_GrBackend == mainInfo.backend()) {
// In Vulkan we need to make sure we are sending the correct VkImageLayout in with the
// backendImage. After the first child draw the layout gets changed to SHADER_READ, so
// we just manually set that here.
GrVkImageInfo vkInfo;
SkAssertResult(backendTexture.getVkImageInfo(&vkInfo));
vkInfo.updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
#endif
draw_child(reporter, childInfo2, backendTexture, semaphores[1]);
}