-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Currently most Vulkan handle types are created through their parent handles:
var device = physicalDevice.CreateDevice(createInfo);With the exception being VkInstance since it is the starting point to using Vulkan:
var instance = new Instance(createInfo);The benefits of creating handle types through their parents are:
- It is guaranteed that the parent is from the same Vulkan instance or device
The downsides are:
- It is more intuitive to construct new instances of types through the
newkeyword - It can be confusing to understand from under which handle type a new handle should be created (for example, should ImageView be created through Image or Device - currently it's the former)
- There's an indirection involving an additional method call which may or may not be inlined
What if all the handle types were created through their constructors? That would convert the example above to the following:
var device = new Device(physicalDevice, createInfo);Additionally, handle types which can be bulk-created (such as vkCreateGraphicsPipelines) could be turned into a static method on the type:
Pipeline[] pipelines = Pipeline.New(device, pipelineCache, createInfos);Finally, there's the question if allocation operations (such as vkAllocateCommandBuffers) should also follow the previous example with method name replaced:
CommandBuffer[] cmdBuffers = CommandBuffer.Allocate(cmdPool, allocateInfo);Or be kept unchanged:
CommandBuffer[] cmdBuffers = cmdPool.AllocateBuffers(allocateInfo);