#ifndef PIPELINE_STAGE_HPP_
#define PIPELINE_STAGE_HPP_

#include <AverageTimeTracker/AverageTimeTracker.hpp>
#include <Vk/QueryPool/QueryPool.hpp>
#include <Vk/CommandBuffer/CommandBuffer.hpp>
#include <memory>
#include <string>

/**
 * @brief Describes a stage in the rendering pipeline.
 * 
 * A stage is a set of commands which fall under one logical "step", and are timed as a group.
 * The debug screen shows the duration of each stage, alongside its name.
 */
class PipelineStage
{
private:
    std::unique_ptr<Vk::QueryPool> queryPool;
    bool queryDone = false;

public:
    const std::string label;
    AverageTimeTracker timeTracker;

    virtual ~PipelineStage() = default;

    PipelineStage(const std::string &label);

    /**
     * @brief Called at the beginning of a frame.
     */
    virtual void initFrame() = 0;

    /**
     * @brief Record the commands comprising this stage.
     */
    virtual void recordStageCommands(Vk::CommandBuffer &cmdbuf) = 0;

    /**
     * @brief Encode the execution of this stage into the speicfied primary buffer.
     */
    void encodeInto(Vk::CommandBuffer &primary);
};

#endif