Program Listing for File GPU.hpp
↰ Return to documentation for file (engine/include/Cacao/GPU.hpp)
#pragma once
#include <future>
#include <functional>
#include <memory>
#include "Cacao/FrameProcessor.hpp"
#include "DllHelper.hpp"
#include "glm/glm.hpp"
namespace Cacao {
class CommandBuffer;
class CACAO_API GPUCommand {
public:
//TODO: Make the command generators
GPUCommand(const GPUCommand&) = delete;
GPUCommand& operator=(const GPUCommand&) = delete;
GPUCommand(GPUCommand&&);
GPUCommand& operator=(GPUCommand&&);
protected:
GPUCommand() {}
friend class CommandBuffer;
friend class FrameProcessor;
friend class PALModule;
std::function<void(CommandBuffer*)> apply;
};
class CACAO_API CommandBuffer {
public:
static std::unique_ptr<CommandBuffer> Create();
CommandBuffer(const CommandBuffer&) = delete;
CommandBuffer& operator=(const CommandBuffer&) = delete;
CommandBuffer(CommandBuffer&&) = delete;
CommandBuffer& operator=(CommandBuffer&&) = delete;
virtual void Add(GPUCommand&&) {};
virtual ~CommandBuffer() {};
protected:
CommandBuffer() {}
virtual void Execute() {};
std::function<void(CommandBuffer*)>&& GetCommandFn(GPUCommand&&);
};
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(std::unique_ptr<CommandBuffer> cmd);
void SetVSync(bool newState);
class Impl;
private:
std::unique_ptr<Impl> impl;
friend class ImplAccessor;
friend class PAL;
bool running;
GPUManager();
~GPUManager();
};
}