#pragma once #define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS #include #include #include struct Shader; struct UniformBuffer; struct RenderPass; struct Texture; struct GraphicsPipeline { enum Type { eVERTEX, eGLTF, eBSP, eTERRAIN, eBOX, }; GraphicsPipeline(vk::Device dev, const std::vector& shaders, const vk::Extent2D& extent, const RenderPass& render_pass, vk::ArrayProxy bindings, const vk::VertexInputBindingDescription& vertex_binding, const std::vector& vertex_attrs, enum Type type = Type::eVERTEX, bool wireframe = false); /* everything needed for recreation */ vk::Device dev; const std::vector shaders; const vk::Extent2D extent; const RenderPass& render_pass; const vk::ArrayProxy bindings; const vk::VertexInputBindingDescription vertex_binding; const std::vector vertex_attrs; const Type type; vk::Pipeline pipeline; vk::PipelineLayout layout; vk::DescriptorSetLayout desc_layout; vk::DescriptorPool desc_pool; vk::DescriptorSet desc_set; /* pipeline creation info cached for rebuilding */ std::vector shader_info; std::vector vertex_bindings; vk::PipelineVertexInputStateCreateInfo vertex_input_info; vk::PipelineInputAssemblyStateCreateInfo input_asm_info; vk::PipelineTessellationStateCreateInfo tess_info; vk::PipelineRasterizationStateCreateInfo raster_info; vk::PipelineMultisampleStateCreateInfo multisample_info; vk::PipelineDepthStencilStateCreateInfo depth_stencil_info; vk::PipelineColorBlendAttachmentState color_blend_attachment; std::array blend_constants; vk::PipelineColorBlendStateCreateInfo color_blend_info; vk::Viewport viewport; vk::Rect2D scissor; vk::PipelineViewportStateCreateInfo viewport_info; vk::DynamicState dyn_states[2]; vk::PipelineDynamicStateCreateInfo dyn_info; vk::GraphicsPipelineCreateInfo pipeline_info; std::vector defunct_pipelines; inline operator vk::Pipeline&() { return pipeline; } /* create overload for every type of object we need to update */ void update(uint32_t binding, const UniformBuffer& uni); void update(uint32_t binding, const Texture& tex); void rebuild(bool wireframe); ~GraphicsPipeline(); };