Program Listing for File GPU.hpp

Return to documentation for file (engine/include/Cacao/GPU.hpp)

#pragma once

#include <future>
#include <memory>

#include "DllHelper.hpp"

namespace Cacao {
    class CACAO_API CommandBuffer {
      public:
        //Preset command buffer generators will exist here eventually
      protected:
        CommandBuffer() {}
        virtual void Execute() = 0;
        virtual ~CommandBuffer() = default;
    };

    class CACAO_API GPUManager {
      public:
        static GPUManager& Get();

        GPUManager(const GPUManager&) = delete;
        GPUManager(GPUManager&&) = delete;
        GPUManager& operator=(const GPUManager&) = delete;
        GPUManager& operator=(GPUManager&&) = delete;

        void Start();

        void Stop();

        bool IsRunning() const {
            return running;
        }

        std::shared_future<void> Submit(CommandBuffer&& cmd);

        void SetVSync(bool newState);

        class Impl;
      private:
        std::unique_ptr<Impl> impl;
        friend class ImplAccessor;
        friend class PAL;

        bool running;

        GPUManager();
        ~GPUManager();
    };
}