#ifndef SVK_PIPELINES_HPP
#define SVK_PIPELINES_HPP

#include "svk_types.hpp"


struct VertexInputDescriptionHandler
{
	std::vector<VkVertexInputBindingDescription> bindingDescriptions;
	std::vector<VkVertexInputAttributeDescription> attributeDescriptions;

	void addBindingDescription(uint32_t const& binding, uint32_t const& stride);
	void addAttributeDescription(uint32_t const& location,
								 uint32_t const& binding,
								 VkFormat const& format,
								 uint32_t const& offset);
};

class PipelineBuilder{
public:
	std::vector<VkPipelineShaderStageCreateInfo> _shaderStages;
	VkPipelineInputAssemblyStateCreateInfo _inputAssembly;
	VkPipelineRasterizationStateCreateInfo _rasterizer;
	VkPipelineColorBlendAttachmentState _colorBlendAttachment;
	VkPipelineMultisampleStateCreateInfo _multisampling;
	VkPipelineLayout _pipelineLayout;
	VkPipelineDepthStencilStateCreateInfo _depthStencil;
	VkPipelineRenderingCreateInfo _renderInfo;
	VkPipelineViewportDepthClipControlCreateInfoEXT _depthClipControlInfo;
	bool _depthClipControlEnabled{false};
	VkFormat _colorAttachmentformat;

	PipelineBuilder()
	{
		clear();
	}

	void clear();
	void setShaders(VkShaderModule vertexShader, VkShaderModule fragmentShader);
	void setInputTopology(VkPrimitiveTopology topology);
	void setPolygonMode(VkPolygonMode mode);
	void setCullMode(VkCullModeFlags cullMode, VkFrontFace frontFace);
	void setMultisamplingNone();
	void disableBlending();
	void setColorAttachmentFormat(VkFormat format);
	void setDepthFormat(VkFormat format);
	void disableDepthtest();
	void enableDepthtest(bool depthWriteEnable, VkCompareOp op);
	void enableBlendingAdditive();
	void enableBlendingAlphablend();
	void enableDepthClipControl();
        void setStencil(bool enable, VkCompareOp compareOp, VkStencilOp failOp, VkStencilOp depthFailOp, VkStencilOp passOp, uint32_t ref);
        void disableAllColorChannels();

	void buildPipeline(VkDevice device,
					   VkPipeline& pipeline,
					   VertexInputDescriptionHandler const& handler);
};

#endif // SVK_PIPELINES_HPP
