#pragma once
#include <span>
#include <string>
#include <Eigen/Eigen>

#include "core/renderer/renderer_buffer.h"
#include "misc/color.h"

struct aorii_vertex_param {
    float param_a1;
    float param_a2;
    float param_a3;
    float param_a4;
    float param_b1;
    float param_b2;
    float param_b3;
    float param_b4;
    float param_c1;
    float param_c2;
    float param_c3;
    float param_c4;
};

struct aorii_vertex {
    Eigen::Vector2f position;
    Eigen::Vector2f uv;
    linear_color color;
    aorii_vertex_param param;
};
struct aorii_triangle {
    uint32_t index[3];
};
// struct aorii_constant_buffer {
//     Eigen::Matrix4f projection_matrix;
//     Eigen::Vector2f pos;
//     Eigen::Vector2f size;
//     float radius;
// };

class pipeline {
public:
    virtual ~pipeline() = default;

    virtual bool init();
    virtual void destroy();

    virtual void use() = 0;
    virtual void draw(uint32_t in_index_count) = 0;

    virtual void set_triangle(const std::span<const aorii_vertex>& in_vertexes, const std::span<const aorii_triangle>& in_triangles);
protected:
    renderer_buffer* vertex_buffer = nullptr;
    renderer_buffer* index_buffer = nullptr;
};

class custom_pipeline : public pipeline {
public:
private:

};

/**
 * 后期处理管线
 * 后期处理管线是一个特殊的管线，它只有一个计算着色器，并固定了输入输出
 * 输入最少有一个纹理，输出固定为一个纹理
 * 输入纹理为当前区域内的渲染结果，输出纹理为经过后期处理的渲染结果
 */
class post_process_pipeline {
public:
    virtual ~post_process_pipeline() = default;

    virtual void set_compute_shader(const std::string& shader_name) = 0;
    template<typename T>
    T* get_constant_buffer() {
        return static_cast<T*>(get_constant_buffer());
    }

    virtual void* get_constant_buffer() = 0;
private:

};
