HI All,
I have just merged the
GraphicsPipelineRefactor branch that I've been working on this week. The purpose of the work was to make it easier for users to figure out the settings available in each of the GraphicsPipelineStates.
Originally each of these settings class subclass from the respective Vulkan CreateInfo class VkGraphicsPipelineCreateInfo, the problem was that while this provided the ability to set the various settings the actual settings themselves were hidden away in the Vulkan info classes, so users would need to hunt down docs on them or the vulan_core.h header to just figure out what might be settable.
The new approach drops the inheritance from Vulkan info classes and instead implements the settings directly as public member variables, so the class now look like:
class VSG_DECLSPEC InputAssemblyState : public Inherit<GraphicsPipelineState, InputAssemblyState>
{
public:
InputAssemblyState();
InputAssemblyState(VkPrimitiveTopology primitiveTopology, VkBool32 primitiveRestart = VK_FALSE);
VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
VkBool32 primitiveRestartEnable = VK_FALSE;
void read(Input& input) override;
void write(Output& output) const override;
void apply(Context& context, VkGraphicsPipelineCreateInfo& pipelineInfo) const override;
protected:
virtual ~InputAssemblyState();
};
All available in C++ containers so it's easy to see what to set up and and easy to pass in the settings however you like.
As part of this work I also added TessellationState, RasterizationState and DynamicState so we can now set all the elements of a GraphicsPipeline via the VSG.
With the DynamicState class it opens the door to dynamically update elements like blending, viewports etc. within the subgraph graph below a BindGraphicsPipeline. This will require SetViewport etc. classes to be written to wrap up vkCmdSetViewport etc. I'll leave this for another day though.
As part of this work I also implement usage of the GraphicsPipelineState support in Visitor/ConstVisitor to enable ArrayState and UpdatePipeline to work without having to do a cast<> to a specific type. Using the visitor pattern is 20x faster than using even the new cast<> functionality so should help improve performance when doing things like compute bounds and intersection testing.
This work is the first step in me refactoring the way that the VSG integrates with Vulkan when passing data to Vulkan. The end goal is to make it clearer to VSG users what settings are available and present them in a convenient C++/scene graoh friendly form, with the VSG's backend mapping these settings across to the appropriate Vulkan objects.
The type, naming and ordering of all the variables will be kept consistent with the Vulkan classes/structs so if you look up InputAssembly online you'll find:
And the struct members:
VkPrimitiveTopology topology;
VkBool32 primitiveRestartEnable;
You'll find in the vsg::InputAssemblyState class:
VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
VkBool32 primitiveRestartEnable = VK_FALSE;
This work is now merged with VSG master.