diff options
author | 2017-04-24 16:49:05 -0400 | |
---|---|---|
committer | 2017-04-24 21:29:44 +0000 | |
commit | c1889823de68ffd2ef08b5c1969d41c98034ec6a (patch) | |
tree | 5c917abacf7b4db4b18630bde0be2e963d329d50 /include | |
parent | bb05f70b4be231d6d643d21cad43d06dcb7638a7 (diff) |
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 <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/vk/GrVkBackendContext.h | 14 | ||||
-rw-r--r-- | include/gpu/vk/GrVkInterface.h | 7 |
2 files changed, 21 insertions, 0 deletions
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<PFN_vkVoidFunction(VkInstance, const char*)>; + + // This is typically vkGetDeviceProcAddr. + using GetDeviceProc = std::function<PFN_vkVoidFunction(VkDevice, const char*)>; + GrVkInterface(GetProc getProc, VkInstance instance, VkDevice device, |