Add GrVkInterface constructor with sepereate instance/device proc getters.
Change-Id: I8498c711ee1fa1cded71e4a7a63317a4b125272b Reviewed-on: https://skia-review.googlesource.com/14277 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
9378732e89
commit
cc90174cc4
@ -52,6 +52,12 @@ public:
|
|||||||
VkDevice device,
|
VkDevice device,
|
||||||
uint32_t extensionFlags);
|
uint32_t extensionFlags);
|
||||||
|
|
||||||
|
GrVkInterface(const GetInstanceProc&,
|
||||||
|
const GetDeviceProc&,
|
||||||
|
VkInstance instance,
|
||||||
|
VkDevice device,
|
||||||
|
uint32_t extensionFlags);
|
||||||
|
|
||||||
// Validates that the GrVkInterface supports its advertised standard. This means the necessary
|
// Validates that the GrVkInterface supports its advertised standard. This means the necessary
|
||||||
// function pointers have been initialized for Vulkan version.
|
// function pointers have been initialized for Vulkan version.
|
||||||
bool validate(uint32_t extensionFlags) const;
|
bool validate(uint32_t extensionFlags) const;
|
||||||
|
@ -50,19 +50,15 @@ const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 8);
|
|||||||
const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndexPtr,
|
const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndexPtr,
|
||||||
CanPresentFn canPresent,
|
CanPresentFn canPresent,
|
||||||
GrVkInterface::GetProc getProc) {
|
GrVkInterface::GetProc getProc) {
|
||||||
|
if (!getProc) {
|
||||||
#ifdef SK_LINK_WITH_VULKAN
|
#ifdef SK_LINK_WITH_VULKAN
|
||||||
if (getProc == nullptr) {
|
return GrVkBackendContext::Create(vkGetInstanceProcAddr, vkGetDeviceProcAddr,
|
||||||
getProc = [](const char* proc_name,
|
presentQueueIndexPtr, canPresent);
|
||||||
VkInstance instance, VkDevice device) {
|
|
||||||
if (device != VK_NULL_HANDLE) {
|
|
||||||
return vkGetDeviceProcAddr(device, proc_name);
|
|
||||||
}
|
|
||||||
return vkGetInstanceProcAddr(instance, proc_name);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
SkASSERT(getProc != nullptr);
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
SkASSERT(getProc);
|
||||||
|
|
||||||
VkPhysicalDevice physDev;
|
VkPhysicalDevice physDev;
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
|
@ -12,6 +12,26 @@
|
|||||||
#define ACQUIRE_PROC(name, instance, device) fFunctions.f##name = \
|
#define ACQUIRE_PROC(name, instance, device) fFunctions.f##name = \
|
||||||
reinterpret_cast<PFN_vk##name>(getProc("vk"#name, instance, device));
|
reinterpret_cast<PFN_vk##name>(getProc("vk"#name, instance, device));
|
||||||
|
|
||||||
|
GrVkInterface::GetProc make_unified_getter(const GrVkInterface::GetInstanceProc& iproc,
|
||||||
|
const GrVkInterface::GetDeviceProc& dproc) {
|
||||||
|
return [&iproc, &dproc](const char* proc_name, VkInstance instance, VkDevice device) {
|
||||||
|
if (device != VK_NULL_HANDLE) {
|
||||||
|
return dproc(device, proc_name);
|
||||||
|
}
|
||||||
|
return iproc(instance, proc_name);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GrVkInterface::GrVkInterface(const GetInstanceProc& getInstanceProc,
|
||||||
|
const GetDeviceProc& getDeviceProc,
|
||||||
|
VkInstance instance,
|
||||||
|
VkDevice device,
|
||||||
|
uint32_t extensionFlags)
|
||||||
|
: GrVkInterface(make_unified_getter(getInstanceProc, getDeviceProc),
|
||||||
|
instance,
|
||||||
|
device,
|
||||||
|
extensionFlags) {}
|
||||||
|
|
||||||
GrVkInterface::GrVkInterface(GetProc getProc,
|
GrVkInterface::GrVkInterface(GetProc getProc,
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
|
Loading…
Reference in New Issue
Block a user