62 std::shared_ptr<VKShaderModule> vertex_shader =
nullptr;
63 std::shared_ptr<VKShaderModule> fragment_shader =
nullptr;
64 std::shared_ptr<VKShaderModule> geometry_shader =
nullptr;
65 std::shared_ptr<VKShaderModule> tess_control_shader =
nullptr;
66 std::shared_ptr<VKShaderModule> tess_evaluation_shader =
nullptr;
67 std::shared_ptr<VKShaderModule> mesh_shader =
nullptr;
68 std::shared_ptr<VKShaderModule> task_shader =
nullptr;
70 bool use_mesh_shading {};
79 bool use_vertex_shader_reflection =
true;
85 vk::PrimitiveTopology
topology = vk::PrimitiveTopology::eTriangleList;
86 bool primitive_restart_enable =
false;
92 uint32_t patch_control_points = 3;
98 bool dynamic_viewport =
true;
99 bool dynamic_scissor =
true;
101 vk::Viewport static_viewport {};
102 vk::Rect2D static_scissor {};
108 bool depth_clamp_enable =
false;
109 bool rasterizer_discard_enable =
false;
110 vk::PolygonMode polygon_mode = vk::PolygonMode::eFill;
111 vk::CullModeFlags cull_mode = vk::CullModeFlagBits::eBack;
112 vk::FrontFace front_face = vk::FrontFace::eCounterClockwise;
114 bool depth_bias_enable =
false;
115 float depth_bias_constant_factor = 0.0f;
116 float depth_bias_clamp = 0.0f;
117 float depth_bias_slope_factor = 0.0f;
119 float line_width = 1.0f;
125 vk::SampleCountFlagBits rasterization_samples = vk::SampleCountFlagBits::e1;
126 bool sample_shading_enable =
false;
127 float min_sample_shading = 1.0f;
129 bool alpha_to_coverage_enable =
false;
130 bool alpha_to_one_enable =
false;
136 bool depth_test_enable =
true;
137 bool depth_write_enable =
true;
138 vk::CompareOp depth_compare_op = vk::CompareOp::eLess;
139 bool depth_bounds_test_enable =
false;
140 float min_depth_bounds = 0.0f;
141 float max_depth_bounds = 1.0f;
143 bool stencil_test_enable =
false;
144 vk::StencilOpState front_stencil {};
145 vk::StencilOpState back_stencil {};
151 bool logic_op_enable =
false;
152 vk::LogicOp logic_op = vk::LogicOp::eCopy;
155 std::array<float, 4> blend_constants = { 0.0f, 0.0f, 0.0f, 0.0f };
161 std::vector<vk::DynamicState> dynamic_states = {
162 vk::DynamicState::eViewport,
163 vk::DynamicState::eScissor
178 vk::Format depth_attachment_format = vk::Format::eUndefined;
179 vk::Format stencil_attachment_format = vk::Format::eUndefined;
185 vk::PipelineCache cache =
nullptr;
197 void enable_alpha_blending();
198 void enable_additive_blending();
199 void disable_depth_test();
200 void enable_wireframe();
201 void enable_back_face_culling();
202 void disable_culling();
253 void cleanup(vk::Device
device);
263 void bind(vk::CommandBuffer
cmd);
271 void bind_descriptor_sets(vk::CommandBuffer
cmd,
272 std::span<vk::DescriptorSet> sets,
273 uint32_t first_set = 0);
283 void push_constants(vk::CommandBuffer
cmd,
284 vk::ShaderStageFlags stages,
291 template <typename T>
292 void push_constants_typed(vk::CommandBuffer
cmd,
293 vk::ShaderStageFlags stages,
296 push_constants(
cmd, stages, 0,
sizeof(T), &data);
310 void bind_vertex_buffers(vk::CommandBuffer
cmd,
311 uint32_t first_binding,
312 std::span<vk::Buffer> buffers,
313 std::span<vk::DeviceSize> offsets);
318 void bind_vertex_buffer(vk::CommandBuffer
cmd,
320 vk::DeviceSize
offset = 0,
321 uint32_t binding = 0);
330 void bind_index_buffer(vk::CommandBuffer
cmd,
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);
356 void set_line_width(vk::CommandBuffer
cmd,
float width);
361 void set_depth_bias(vk::CommandBuffer
cmd,
362 float constant_factor,
369 void set_blend_constants(vk::CommandBuffer
cmd,
const float constants[4]);
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);
398 void draw_indexed(vk::CommandBuffer
cmd,
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);
413 void draw_indirect(vk::CommandBuffer
cmd,
422 void draw_indexed_indirect(vk::CommandBuffer
cmd,
431 void drawMeshTasks(vk::CommandBuffer
cmd,
432 uint32_t groupCountX,
433 uint32_t groupCountY = 1,
434 uint32_t groupCountZ = 1);
439 void drawMeshTasksIndirect(vk::CommandBuffer
cmd,
449 [[nodiscard]] vk::Pipeline
get()
const {
return m_pipeline; }
450 [[nodiscard]] vk::PipelineLayout
get_layout()
const {
return m_layout; }
451 [[nodiscard]]
bool is_valid()
const {
return m_pipeline !=
nullptr; }
470 vk::PipelineLayout create_pipeline_layout(
482 vk::PipelineVertexInputStateCreateInfo build_vertex_input_state(
484 std::vector<vk::VertexInputBindingDescription>& bindings,
485 std::vector<vk::VertexInputAttributeDescription>&
attributes);
490 vk::PipelineInputAssemblyStateCreateInfo build_input_assembly_state(
496 vk::PipelineTessellationStateCreateInfo build_tessellation_state(
502 vk::PipelineViewportStateCreateInfo build_viewport_state(
504 std::vector<vk::Viewport>& viewports,
505 std::vector<vk::Rect2D>& scissors);
510 vk::PipelineRasterizationStateCreateInfo build_rasterization_state(
516 vk::PipelineMultisampleStateCreateInfo build_multisample_state(
522 vk::PipelineDepthStencilStateCreateInfo build_depth_stencil_state(
528 vk::PipelineColorBlendStateCreateInfo build_color_blend_state(
530 std::vector<vk::PipelineColorBlendAttachmentState>& attachments);
535 vk::PipelineDynamicStateCreateInfo build_dynamic_state(