void VulkanWindowContext::initializeContext(void* platformData, const DisplayParams& params) { fBackendContext.reset(GrVkBackendContext::Create(&fPresentQueueIndex, canPresent, platformData)); if (!(fBackendContext->fExtensions & kKHR_surface_GrVkExtensionFlag) || !(fBackendContext->fExtensions & kKHR_swapchain_GrVkExtensionFlag)) { fBackendContext.reset(nullptr); return; } VkInstance instance = fBackendContext->fInstance; VkDevice device = fBackendContext->fDevice; GET_PROC(DestroySurfaceKHR); GET_PROC(GetPhysicalDeviceSurfaceSupportKHR); GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR); GET_PROC(GetPhysicalDeviceSurfaceFormatsKHR); GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR); GET_DEV_PROC(CreateSwapchainKHR); GET_DEV_PROC(DestroySwapchainKHR); GET_DEV_PROC(GetSwapchainImagesKHR); GET_DEV_PROC(AcquireNextImageKHR); GET_DEV_PROC(QueuePresentKHR); fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext) fBackendContext.get()); fSurface = createVkSurface(instance, platformData); if (VK_NULL_HANDLE == fSurface) { fBackendContext.reset(nullptr); return; } VkBool32 supported; VkResult res = fGetPhysicalDeviceSurfaceSupportKHR(fBackendContext->fPhysicalDevice, fPresentQueueIndex, fSurface, &supported); if (VK_SUCCESS != res) { this->destroyContext(); return; } if (!this->createSwapchain(-1, -1, params)) { this->destroyContext(); return; } // create presentQueue vkGetDeviceQueue(fBackendContext->fDevice, fPresentQueueIndex, 0, &fPresentQueue); }
const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkDevice device, uint32_t extensionFlags) { GrVkInterface* interface = new GrVkInterface(); GrVkInterface::Functions* functions = &interface->fFunctions; GET_PROC_GLOBAL(CreateInstance); GET_PROC_GLOBAL(EnumerateInstanceExtensionProperties); GET_PROC_GLOBAL(EnumerateInstanceLayerProperties); GET_PROC(DestroyInstance); GET_PROC(EnumeratePhysicalDevices); GET_PROC(GetPhysicalDeviceFeatures); GET_PROC(GetPhysicalDeviceFormatProperties); GET_PROC(GetPhysicalDeviceImageFormatProperties); GET_PROC(GetPhysicalDeviceProperties); GET_PROC(GetPhysicalDeviceQueueFamilyProperties); GET_PROC(GetPhysicalDeviceMemoryProperties); GET_PROC(CreateDevice); GET_PROC(DestroyDevice); GET_PROC(EnumerateDeviceExtensionProperties); GET_PROC(EnumerateDeviceLayerProperties); GET_DEV_PROC(GetDeviceQueue); GET_DEV_PROC(QueueSubmit); GET_DEV_PROC(QueueWaitIdle); GET_DEV_PROC(DeviceWaitIdle); GET_DEV_PROC(AllocateMemory); GET_DEV_PROC(FreeMemory); GET_DEV_PROC(MapMemory); GET_DEV_PROC(UnmapMemory); GET_DEV_PROC(FlushMappedMemoryRanges); GET_DEV_PROC(InvalidateMappedMemoryRanges); GET_DEV_PROC(GetDeviceMemoryCommitment); GET_DEV_PROC(BindBufferMemory); GET_DEV_PROC(BindImageMemory); GET_DEV_PROC(GetBufferMemoryRequirements); GET_DEV_PROC(GetImageMemoryRequirements); GET_DEV_PROC(GetImageSparseMemoryRequirements); GET_PROC(GetPhysicalDeviceSparseImageFormatProperties); GET_DEV_PROC(QueueBindSparse); GET_DEV_PROC(CreateFence); GET_DEV_PROC(DestroyFence); GET_DEV_PROC(ResetFences); GET_DEV_PROC(GetFenceStatus); GET_DEV_PROC(WaitForFences); GET_DEV_PROC(CreateSemaphore); GET_DEV_PROC(DestroySemaphore); GET_DEV_PROC(CreateEvent); GET_DEV_PROC(DestroyEvent); GET_DEV_PROC(GetEventStatus); GET_DEV_PROC(SetEvent); GET_DEV_PROC(ResetEvent); GET_DEV_PROC(CreateQueryPool); GET_DEV_PROC(DestroyQueryPool); GET_DEV_PROC(GetQueryPoolResults); GET_DEV_PROC(CreateBuffer); GET_DEV_PROC(DestroyBuffer); GET_DEV_PROC(CreateBufferView); GET_DEV_PROC(DestroyBufferView); GET_DEV_PROC(CreateImage); GET_DEV_PROC(DestroyImage); GET_DEV_PROC(GetImageSubresourceLayout); GET_DEV_PROC(CreateImageView); GET_DEV_PROC(DestroyImageView); GET_DEV_PROC(CreateShaderModule); GET_DEV_PROC(DestroyShaderModule); GET_DEV_PROC(CreatePipelineCache); GET_DEV_PROC(DestroyPipelineCache); GET_DEV_PROC(GetPipelineCacheData); GET_DEV_PROC(MergePipelineCaches); GET_DEV_PROC(CreateGraphicsPipelines); GET_DEV_PROC(CreateComputePipelines); GET_DEV_PROC(DestroyPipeline); GET_DEV_PROC(CreatePipelineLayout); GET_DEV_PROC(DestroyPipelineLayout); GET_DEV_PROC(CreateSampler); GET_DEV_PROC(DestroySampler); GET_DEV_PROC(CreateDescriptorSetLayout); GET_DEV_PROC(DestroyDescriptorSetLayout); GET_DEV_PROC(CreateDescriptorPool); GET_DEV_PROC(DestroyDescriptorPool); GET_DEV_PROC(ResetDescriptorPool); GET_DEV_PROC(AllocateDescriptorSets); GET_DEV_PROC(FreeDescriptorSets); GET_DEV_PROC(UpdateDescriptorSets); GET_DEV_PROC(CreateFramebuffer); GET_DEV_PROC(DestroyFramebuffer); GET_DEV_PROC(CreateRenderPass); GET_DEV_PROC(DestroyRenderPass); GET_DEV_PROC(GetRenderAreaGranularity); GET_DEV_PROC(CreateCommandPool); GET_DEV_PROC(DestroyCommandPool); GET_DEV_PROC(ResetCommandPool); GET_DEV_PROC(AllocateCommandBuffers); GET_DEV_PROC(FreeCommandBuffers); GET_DEV_PROC(BeginCommandBuffer); GET_DEV_PROC(EndCommandBuffer); GET_DEV_PROC(ResetCommandBuffer); GET_DEV_PROC(CmdBindPipeline); GET_DEV_PROC(CmdSetViewport); GET_DEV_PROC(CmdSetScissor); GET_DEV_PROC(CmdSetLineWidth); GET_DEV_PROC(CmdSetDepthBias); GET_DEV_PROC(CmdSetBlendConstants); GET_DEV_PROC(CmdSetDepthBounds); GET_DEV_PROC(CmdSetStencilCompareMask); GET_DEV_PROC(CmdSetStencilWriteMask); GET_DEV_PROC(CmdSetStencilReference); GET_DEV_PROC(CmdBindDescriptorSets); GET_DEV_PROC(CmdBindIndexBuffer); GET_DEV_PROC(CmdBindVertexBuffers); GET_DEV_PROC(CmdDraw); GET_DEV_PROC(CmdDrawIndexed); GET_DEV_PROC(CmdDrawIndirect); GET_DEV_PROC(CmdDrawIndexedIndirect); GET_DEV_PROC(CmdDispatch); GET_DEV_PROC(CmdDispatchIndirect); GET_DEV_PROC(CmdCopyBuffer); GET_DEV_PROC(CmdCopyImage); GET_DEV_PROC(CmdBlitImage); GET_DEV_PROC(CmdCopyBufferToImage); GET_DEV_PROC(CmdCopyImageToBuffer); GET_DEV_PROC(CmdUpdateBuffer); GET_DEV_PROC(CmdFillBuffer); GET_DEV_PROC(CmdClearColorImage); GET_DEV_PROC(CmdClearDepthStencilImage); GET_DEV_PROC(CmdClearAttachments); GET_DEV_PROC(CmdResolveImage); GET_DEV_PROC(CmdSetEvent); GET_DEV_PROC(CmdResetEvent); GET_DEV_PROC(CmdWaitEvents); GET_DEV_PROC(CmdPipelineBarrier); GET_DEV_PROC(CmdBeginQuery); GET_DEV_PROC(CmdEndQuery); GET_DEV_PROC(CmdResetQueryPool); GET_DEV_PROC(CmdWriteTimestamp); GET_DEV_PROC(CmdCopyQueryPoolResults); GET_DEV_PROC(CmdPushConstants); GET_DEV_PROC(CmdBeginRenderPass); GET_DEV_PROC(CmdNextSubpass); GET_DEV_PROC(CmdEndRenderPass); GET_DEV_PROC(CmdExecuteCommands); if (extensionFlags & kEXT_debug_report_GrVkExtensionFlag) { GET_PROC(CreateDebugReportCallbackEXT); GET_PROC(DebugReportMessageEXT); GET_PROC(DestroyDebugReportCallbackEXT); } return interface; }