14 VertexBinding(uint32_t b, uint32_t s,
bool instanced =
false, vk::VertexInputRate rate = vk::VertexInputRate::eVertex)
47 vk::ColorComponentFlags
color_write_mask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA;
81 vk::PrimitiveTopology
topology = vk::PrimitiveTopology::eTriangleList;
107 vk::CullModeFlags
cull_mode = vk::CullModeFlagBits::eBack;
158 vk::DynamicState::eViewport,
159 vk::DynamicState::eScissor
253 void cleanup(vk::Device device);
263 void bind(vk::CommandBuffer cmd);
272 std::span<vk::DescriptorSet> sets,
273 uint32_t first_set = 0);
284 vk::ShaderStageFlags stages,
285 uint32_t offset, uint32_t size,
291 template <typename T>
293 vk::ShaderStageFlags stages,
311 uint32_t first_binding,
312 std::span<vk::Buffer> buffers,
313 std::span<vk::DeviceSize> offsets);
320 vk::DeviceSize offset = 0,
321 uint32_t binding = 0);
332 vk::DeviceSize offset = 0,
333 vk::IndexType index_type = vk::IndexType::eUint32);
344 void set_viewport(vk::CommandBuffer cmd,
const vk::Viewport& viewport);
351 void set_scissor(vk::CommandBuffer cmd,
const vk::Rect2D& scissor);
362 float constant_factor,
383 void draw(vk::CommandBuffer cmd,
384 uint32_t vertex_count,
385 uint32_t instance_count = 1,
386 uint32_t first_vertex = 0,
387 uint32_t first_instance = 0);
399 uint32_t index_count,
400 uint32_t instance_count = 1,
401 uint32_t first_index = 0,
402 int32_t vertex_offset = 0,
403 uint32_t first_instance = 0);
415 vk::DeviceSize offset,
424 vk::DeviceSize offset,
467 std::vector<vk::VertexInputBindingDescription>& bindings,
468 std::vector<vk::VertexInputAttributeDescription>& attributes);
487 std::vector<vk::Viewport>& viewports,
488 std::vector<vk::Rect2D>& scissors);
513 std::vector<vk::PipelineColorBlendAttachmentState>& attachments);
bool validate_shaders(const GraphicsPipelineConfig &config)
Validate shader stages.
void cleanup(vk::Device device)
Cleanup pipeline resources.
void bind(vk::CommandBuffer cmd)
Bind pipeline to command buffer.
void set_line_width(vk::CommandBuffer cmd, float width)
Set line width (if dynamic)
void set_scissor(vk::CommandBuffer cmd, const vk::Rect2D &scissor)
Set scissor (if dynamic)
void bind_descriptor_sets(vk::CommandBuffer cmd, std::span< vk::DescriptorSet > sets, uint32_t first_set=0)
Bind descriptor sets.
GraphicsPipelineConfig m_config
vk::PipelineDepthStencilStateCreateInfo build_depth_stencil_state(const GraphicsPipelineConfig &config)
Build depth stencil state.
void draw(vk::CommandBuffer cmd, uint32_t vertex_count, uint32_t instance_count=1, uint32_t first_vertex=0, uint32_t first_instance=0)
Draw vertices.
void set_depth_bias(vk::CommandBuffer cmd, float constant_factor, float clamp, float slope_factor)
Set depth bias (if dynamic)
vk::PipelineInputAssemblyStateCreateInfo build_input_assembly_state(const GraphicsPipelineConfig &config)
Build input assembly state.
VKGraphicsPipeline & operator=(const VKGraphicsPipeline &)=delete
void bind_vertex_buffers(vk::CommandBuffer cmd, uint32_t first_binding, std::span< vk::Buffer > buffers, std::span< vk::DeviceSize > offsets)
Bind vertex buffers.
void set_blend_constants(vk::CommandBuffer cmd, const float constants[4])
Set blend constants (if dynamic)
void push_constants(vk::CommandBuffer cmd, vk::ShaderStageFlags stages, uint32_t offset, uint32_t size, const void *data)
Push constants.
const GraphicsPipelineConfig & get_config() const
Get shader reflections (for introspection)
vk::PipelineMultisampleStateCreateInfo build_multisample_state(const GraphicsPipelineConfig &config)
Build multisample state.
void bind_vertex_buffer(vk::CommandBuffer cmd, vk::Buffer buffer, vk::DeviceSize offset=0, uint32_t binding=0)
Bind single vertex buffer (common case)
vk::PipelineRasterizationStateCreateInfo build_rasterization_state(const GraphicsPipelineConfig &config)
Build rasterization state.
vk::PipelineVertexInputStateCreateInfo build_vertex_input_state(const GraphicsPipelineConfig &config, std::vector< vk::VertexInputBindingDescription > &bindings, std::vector< vk::VertexInputAttributeDescription > &attributes)
Build vertex input state from config.
vk::PipelineTessellationStateCreateInfo build_tessellation_state(const GraphicsPipelineConfig &config)
Build tessellation state.
bool create(vk::Device device, const GraphicsPipelineConfig &config)
Create graphics pipeline from configuration.
vk::PipelineLayout m_layout
vk::PipelineLayout get_layout() const
void push_constants_typed(vk::CommandBuffer cmd, vk::ShaderStageFlags stages, const T &data)
Typed push constants.
VKGraphicsPipeline(const VKGraphicsPipeline &)=delete
void set_viewport(vk::CommandBuffer cmd, const vk::Viewport &viewport)
Set viewport (if dynamic)
void draw_indexed_indirect(vk::CommandBuffer cmd, vk::Buffer buffer, vk::DeviceSize offset, uint32_t draw_count, uint32_t stride)
Draw indexed indirect.
vk::PipelineLayout create_pipeline_layout(vk::Device device, const GraphicsPipelineConfig &config)
Create pipeline layout from config.
void draw_indexed(vk::CommandBuffer cmd, uint32_t index_count, uint32_t instance_count=1, uint32_t first_index=0, int32_t vertex_offset=0, uint32_t first_instance=0)
Draw indexed vertices.
VKGraphicsPipeline()=default
vk::PipelineColorBlendStateCreateInfo build_color_blend_state(const GraphicsPipelineConfig &config, std::vector< vk::PipelineColorBlendAttachmentState > &attachments)
Build color blend state.
vk::PipelineDynamicStateCreateInfo build_dynamic_state(const GraphicsPipelineConfig &config)
Build dynamic state.
vk::PipelineViewportStateCreateInfo build_viewport_state(const GraphicsPipelineConfig &config, std::vector< vk::Viewport > &viewports, std::vector< vk::Rect2D > &scissors)
Build viewport state.
void bind_index_buffer(vk::CommandBuffer cmd, vk::Buffer buffer, vk::DeviceSize offset=0, vk::IndexType index_type=vk::IndexType::eUint32)
Bind index buffer.
void draw_indirect(vk::CommandBuffer cmd, vk::Buffer buffer, vk::DeviceSize offset, uint32_t draw_count, uint32_t stride)
Draw indirect (dispatch from GPU buffer)
Vulkan graphics pipeline wrapper.
vk::BlendOp alpha_blend_op
vk::BlendFactor dst_alpha_blend_factor
vk::BlendFactor src_alpha_blend_factor
vk::ColorComponentFlags color_write_mask
vk::BlendFactor dst_color_blend_factor
vk::BlendOp color_blend_op
vk::BlendFactor src_color_blend_factor
std::vector< ColorBlendAttachment > color_blend_attachments
bool use_vertex_shader_reflection
vk::StencilOpState front_stencil
float depth_bias_slope_factor
vk::StencilOpState back_stencil
vk::SampleCountFlagBits rasterization_samples
vk::CompareOp depth_compare_op
std::vector< vk::Format > color_attachment_formats
float depth_bias_constant_factor
static GraphicsPipelineConfig default_3d()
vk::PrimitiveTopology topology
std::shared_ptr< VKShaderModule > fragment_shader
vk::Rect2D static_scissor
void enable_back_face_culling()
uint32_t patch_control_points
static GraphicsPipelineConfig alpha_blended()
bool depth_bounds_test_enable
std::vector< vk::DynamicState > dynamic_states
vk::RenderPass render_pass
bool use_dynamic_rendering
vk::Viewport static_viewport
std::vector< vk::PushConstantRange > push_constant_ranges
void disable_depth_test()
void enable_additive_blending()
static GraphicsPipelineConfig additive_blended()
vk::PolygonMode polygon_mode
std::array< float, 4 > blend_constants
void enable_alpha_blending()
std::shared_ptr< VKShaderModule > vertex_shader
vk::Format stencil_attachment_format
std::vector< vk::DescriptorSetLayout > descriptor_set_layouts
std::vector< vk::SampleMask > sample_mask
bool rasterizer_discard_enable
bool alpha_to_coverage_enable
std::vector< VertexBinding > vertex_bindings
bool primitive_restart_enable
static GraphicsPipelineConfig depth_only()
vk::CullModeFlags cull_mode
std::vector< VertexAttribute > vertex_attributes
static GraphicsPipelineConfig default_2d()
std::shared_ptr< VKShaderModule > geometry_shader
bool sample_shading_enable
vk::Format depth_attachment_format
std::shared_ptr< VKShaderModule > tess_evaluation_shader
std::shared_ptr< VKShaderModule > tess_control_shader
Configuration for creating a graphics pipeline.
VertexAttribute()=default
VertexAttribute(uint32_t loc, uint32_t bind, vk::Format fmt, uint32_t off)
VertexBinding(uint32_t b, uint32_t s, bool instanced=false, vk::VertexInputRate rate=vk::VertexInputRate::eVertex)
vk::VertexInputRate input_rate