20 #ifndef ANTKEEPER_GL_PIPELINE_HPP
21 #define ANTKEEPER_GL_PIPELINE_HPP
40 namespace app {
class sdl_window_manager; }
84 void bind_vertex_buffers(std::uint32_t first_binding, std::span<const vertex_buffer* const> buffers, std::span<const std::size_t> offsets, std::span<const std::size_t> strides);
120 void set_viewport(std::uint32_t first_viewport, std::span<const viewport> viewports);
132 void set_scissor(std::uint32_t first_scissor, std::span<const scissor_region> scissors);
349 void draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance);
362 void draw_indexed(std::uint32_t index_count, std::uint32_t instance_count, std::uint32_t first_index, std::int32_t vertex_offset, std::uint32_t first_instance);
385 return m_default_framebuffer_dimensions;
391 return m_max_viewports;
397 return m_max_sampler_anisotropy;
406 void defaut_framebuffer_resized(std::uint32_t width, std::uint32_t height) noexcept;
408 void fetch_vertex_input_state();
409 void fetch_input_assembly_state();
410 void fetch_viewport_state();
411 void fetch_rasterization_state();
412 void fetch_depth_stencil_state();
413 void fetch_color_blend_state();
414 void fetch_clear_value();
416 std::uint32_t m_max_viewports{1};
417 float m_max_sampler_anisotropy{0.0f};
418 std::array<std::uint32_t, 2> m_default_framebuffer_dimensions{0, 0};
420 pipeline_vertex_input_state m_vertex_input_state;
421 pipeline_input_assembly_state m_input_assembly_state;
422 pipeline_viewport_state m_viewport_state;
423 pipeline_rasterization_state m_rasterization_state;
424 pipeline_depth_stencil_state m_depth_stencil_state;
425 pipeline_color_blend_state m_color_blend_state;
426 clear_value m_clear_value;
428 const framebuffer* m_framebuffer{};
429 const shader_program* m_shader_program{};
430 const vertex_array* m_vertex_array{};
Graphics pipeline interface.
void set_stencil_op(std::uint8_t face_mask, stencil_op fail_op, stencil_op pass_op, stencil_op depth_fail_op, gl::compare_op compare_op)
Sets the stencil operations.
void set_primitive_topology(primitive_topology topology)
Sets the primitive topology to use for drawing.
void clear_attachments(std::uint8_t mask, const clear_value &value)
Clears the color, depth, or stencil buffers of current attachments.
void set_fill_mode(fill_mode mode)
Sets the polygon rasterization mode.
void bind_shader_program(const gl::shader_program *shader_program)
Sets the vertex input.
void set_color_write_mask(std::uint8_t mask)
Sets the color write mask.
void set_blend_constants(const std::array< float, 4 > &blend_constants)
Sets the values of the blend constants.
void bind_framebuffer(const gl::framebuffer *framebuffer)
Sets the vertex input.
constexpr float get_max_sampler_anisotropy() const noexcept
Returns the maximum supported degree of sampler anisotropy.
void set_primitive_restart_enabled(bool enabled)
Controls whether a special vertex index value is treated as restarting the assembly of primitives.
void set_stencil_write_mask(std::uint8_t face_mask, std::uint32_t write_mask)
Sets the stencil write mask.
void set_depth_clamp_enabled(bool enabled)
Controls whether depth clamping is enabled.
void set_depth_bias_factors(float constant_factor, float slope_factor)
Sets depth bias factors.
void set_color_blend_enabled(bool enabled)
Controls whether blending is enabled for the corresponding color attachment.
void set_scissor_test_enabled(bool enabled)
Enables or disables scissor testing.
void set_point_size(float size)
Sets the the diameter of rasterized points.
constexpr std::uint32_t get_max_viewports() const noexcept
Returns the maximum number of supported viewports.
void set_cull_mode(cull_mode mode)
Sets the triangle culling mode.
void set_front_face(front_face face)
Sets the front-facing triangle orientation.
void set_stencil_test_enabled(bool enabled)
Controls whether stencil testing is enabled.
void set_viewport(std::uint32_t first_viewport, std::span< const viewport > viewports)
Sets one or more viewports.
void set_provoking_vertex_mode(provoking_vertex_mode mode)
Sets the vertex to be used as the source of data for flat-shaded varyings.
void draw_indexed(std::uint32_t index_count, std::uint32_t instance_count, std::uint32_t first_index, std::int32_t vertex_offset, std::uint32_t first_instance)
Draws primitives with indexed vertices.
void set_depth_bias_enabled(bool enabled)
Controls whether to bias fragment depth values.
void set_depth_write_enabled(bool enabled)
Controls whether depth writes are enabled.
void set_logic_op(gl::logic_op logic_op)
Selects which logical operation to apply.
void set_scissor(std::uint32_t first_scissor, std::span< const scissor_region > scissors)
Sets one or more scissor regions.
void set_stencil_reference(std::uint8_t face_mask, std::uint32_t reference)
Sets the stencil reference value.
void bind_vertex_buffers(std::uint32_t first_binding, std::span< const vertex_buffer *const > buffers, std::span< const std::size_t > offsets, std::span< const std::size_t > strides)
Binds vertex buffers.
pipeline()
Constructs a pipeline.
void set_color_blend_equation(const color_blend_equation &equation)
Sets the color blend factors and operations.
void set_logic_op_enabled(bool enabled)
Controls whether whether logical operations are enabled.
void set_depth_compare_op(gl::compare_op compare_op)
Sets the depth comparison operator.
void draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance)
Draws primitives.
constexpr const std::array< std::uint32_t, 2 > & get_default_framebuffer_dimensions() const noexcept
Returns the dimensions of the default framebuffer.
void set_depth_test_enabled(bool enabled)
Controls whether depth testing is enabled.
void bind_vertex_array(const vertex_array *array)
Binds a vertex array.
void set_rasterizer_discard_enabled(bool enabled)
Controls whether primitives are discarded before the rasterization stage.
void set_line_width(float width)
Sets the width of rasterized lines.
void set_stencil_compare_mask(std::uint8_t face_mask, std::uint32_t compare_mask)
Sets the stencil compare mask.
Shader program which can be linked to shader objects and executed.
Vertex arrays describes how vertex input attributes are stored in vertex buffers.
Graphics library interface.
cull_mode
Triangle culling mode.
front_face
Polygon front-facing orientation.
provoking_vertex_mode
Vertex to be used as the source of data for flat-shaded varyings.
stencil_op
Stencil comparison functions.
primitive_topology
Primitive topologies.
logic_op
Framebuffer logical operations.
fill_mode
Polygon rasterization mode.
compare_op
Comparison operators.
Color blend factors and operations.