From c1889823de68ffd2ef08b5c1969d41c98034ec6a Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 24 Apr 2017 16:49:05 -0400 Subject: Add new GrVkBackendContext::Create explicitly requiring vk proc getters Also remove the feature of GrVkGpu that creates the instance/device if the client doesn't provide one. Change-Id: Ie617313b6c684ed355333a475b80d0aae7e3a026 Reviewed-on: https://skia-review.googlesource.com/14261 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- include/gpu/vk/GrVkBackendContext.h | 14 ++++++++++++++ include/gpu/vk/GrVkInterface.h | 7 +++++++ 2 files changed, 21 insertions(+) (limited to 'include') diff --git a/include/gpu/vk/GrVkBackendContext.h b/include/gpu/vk/GrVkBackendContext.h index 5ae7b31656..5838caa323 100644 --- a/include/gpu/vk/GrVkBackendContext.h +++ b/include/gpu/vk/GrVkBackendContext.h @@ -58,6 +58,20 @@ struct GrVkBackendContext : public SkRefCnt { CanPresentFn = CanPresentFn(), GrVkInterface::GetProc getProc = nullptr); + static const GrVkBackendContext* Create(const GrVkInterface::GetInstanceProc& getInstanceProc, + const GrVkInterface::GetDeviceProc& getDeviceProc, + uint32_t* presentQueueIndex = nullptr, + CanPresentFn canPresent = CanPresentFn()) { + auto getProc = [&getInstanceProc, &getDeviceProc](const char* proc_name, + VkInstance instance, VkDevice device) { + if (device != VK_NULL_HANDLE) { + return getDeviceProc(device, proc_name); + } + return getInstanceProc(instance, proc_name); + }; + return Create(presentQueueIndex, canPresent, getProc); + } + ~GrVkBackendContext() override; }; diff --git a/include/gpu/vk/GrVkInterface.h b/include/gpu/vk/GrVkInterface.h index dca47ffc4c..1a381bdbe7 100644 --- a/include/gpu/vk/GrVkInterface.h +++ b/include/gpu/vk/GrVkInterface.h @@ -40,6 +40,13 @@ public: VkInstance, // instance or VK_NULL_HANDLE VkDevice // device or VK_NULL_HANDLE )>; + + // This is typically vkGetInstanceProcAddr. + using GetInstanceProc = std::function; + + // This is typically vkGetDeviceProcAddr. + using GetDeviceProc = std::function; + GrVkInterface(GetProc getProc, VkInstance instance, VkDevice device, -- cgit v1.2.3