Files
RedScarfEngine/graphics/src/pipeline_builder.h
T

111 lines
3.7 KiB
C

/**
* @file pipeline_builder.h
* @author Piotr Krygier (everyonecancode@gmail.com)
* @brief Builder for vulkan pipeline
* @version 0.1
* @date 2024-03-01
*
* @copyright Copyright (c) 2024
*
*/
#ifndef PIPELINE_BUILDER_H
#define PIPELINE_BUILDER_H
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#include "graphics_context.h"
#include "utilities/commons.h"
#include "utilities/linked_list.h"
#include "utilities/stack.h"
#define MAX_SHADER_STAGES 12U
struct pipeline_t;
struct pipeline_infos_list_t;
/**
* @brief Initialize pipeline builder
*
* @param[out] pipeline Pipeline to initialize. Must be NULL
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipeline_builder_init(struct pipeline_t** pipeline);
/**
* @brief Add shader stages to pipeline
*
* @param[in] context Graphics context handle
* @param[in] pipeline Pipeline to build
* @param[in] shader_path Path to the shader file
* @param[in] shader_stage Shader stage to add
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipeline_add_shader_stage(struct graphics_context_t* context, struct pipeline_t* pipeline,
const char* shader_path, const VkShaderStageFlagBits shader_stage);
/**
* @brief Add vertex input binding to pipeline
*
* @param[in] pipeline Pipeline to build
* @param[in] binding Binding point for vertex data
* @param[in] stride Stride between vertex data elements in bytes
* @param[in] input_rate Input rate for vertex data
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipeline_add_vertex_input_binding(struct pipeline_t* pipeline, const uint8_t binding, const uint8_t stride,
const VkVertexInputRate input_rate);
/**
* @brief Add vertex attribute to shader in pipeline
*
* @param[in] pipeline Pipeline to build
* @param[in] binding Binding point for vertex data
* @param[in] location Location of the attribute in shader
* @param[in] format Format of the attribute
* @param[in] offset Offset of the attribute in bytes
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipeline_add_vertex_input_attribute(struct pipeline_t* pipeline, const uint8_t binding,
const uint8_t location, const VkFormat format, const uint8_t offset);
/**
* @brief Add dynamic state to pipeline
*
* @param[in] pipeline Pipeline to build
* @param[in] dynamic_state Dynamic state to add
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipeline_add_dynamic_state(struct pipeline_t* pipeline, const VkDynamicState dynamic_state);
/**
* @brief Build pipeline from added components. This function should be called after adding all necessary components.
* After call, pipeline is ready to be used and all added components are cleared, ready for next pipeline to be built.
*
* param[in/out] context Graphics context handle
* @param[in] pipeline Pipelines list to build
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t pipelines_build(struct graphics_context_t* context, struct pipeline_infos_list_t* pipelines);
/**
* @brief Add pipeline to list of pipelines
*
* @param[in] context Graphics context handle
* @param[in] pipeline Pipeline to add
* @param[out] pipeline_info List of pipelines infos, where new info should be added
* @return RSE_SUCCESS on success, error code otherwise
*/
rse_err_t add_pipeline(const struct graphics_context_t* context, struct pipeline_t* pipeline,
struct pipeline_infos_list_t** pipelines);
/**
* @brief Destroy all pipelines
*
* @param[in] context Graphics context handle
*/
void destroy_pipelines(struct graphics_context_t* context);
#endif /* PIPELINE_BUILDER_H */