I was digging around in the Vulkan backend for the Skia graphics API, found here, and I don't understand a piece of code.
Here's the smallest code example:
struct VulkanInterface : public SkRefCnt {
public:
VulkanInterface(VulkanGetProc getProc,
VkInstance instance,
VkDevice device,
uint32_t instanceVersion,
uint32_t physicalDeviceVersion,
const VulkanExtensions*);
/**
* The function pointers are in a struct so that we can have a compiler generated assignment
* operator.
*/
struct Functions {
VkPtr<PFN_vkCreateInstance> fCreateInstance;
VkPtr<PFN_vkDestroyInstance> fDestroyInstance;
// a ton more functions here
} fFunctions;
};
Why would you create a struct of function pointers in a class?
Why this extra layer of abstraction where you have to add fFunctions->
everywhere?
I know there's a comment with an explanation and I know what those words mean, but I don't understand the comment as a whole. I just need it broken down a little more. Thanks.