engine/include/gfx_device.hpp

67 lines
2.3 KiB
C++
Raw Normal View History

2022-09-13 18:25:18 +00:00
#pragma once
2022-10-22 12:15:25 +00:00
#include "gfx.hpp"
2022-09-17 00:22:35 +00:00
#include <memory>
2022-11-30 00:46:03 +00:00
struct SDL_Window; // <SDL_video.h>
2022-09-13 18:25:18 +00:00
2022-10-02 15:34:51 +00:00
namespace engine {
2022-09-13 18:25:18 +00:00
2022-11-30 00:46:03 +00:00
class GFXDevice {
2022-09-13 18:25:18 +00:00
2022-10-02 12:56:13 +00:00
public:
2023-02-19 13:55:08 +00:00
GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, gfx::GraphicsSettings settings);
2022-09-19 17:33:56 +00:00
2022-09-21 19:52:26 +00:00
GFXDevice(const GFXDevice&) = delete;
GFXDevice& operator=(const GFXDevice&) = delete;
~GFXDevice();
2022-09-13 18:25:18 +00:00
2022-10-27 22:06:56 +00:00
void getViewportSize(uint32_t *w, uint32_t *h);
2023-03-12 20:39:11 +00:00
gfx::DrawBuffer* beginRender();
void finishRender(gfx::DrawBuffer* drawBuffer);
void cmdBindPipeline(gfx::DrawBuffer* drawBuffer, const gfx::Pipeline* pipeline);
void cmdBindVertexBuffer(gfx::DrawBuffer* drawBuffer, uint32_t binding, const gfx::Buffer* buffer);
void cmdBindIndexBuffer(gfx::DrawBuffer* drawBuffer, const gfx::Buffer* buffer);
void cmdDrawIndexed(gfx::DrawBuffer* drawBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance);
2023-03-13 01:19:32 +00:00
void cmdBindDescriptorSet(gfx::DrawBuffer* drawBuffer, const gfx::Pipeline* pipeline, const gfx::DescriptorSet* set, uint32_t setNumber);
// creates the equivalent of an OpenGL shader program & vertex attrib configuration
2023-03-13 01:19:32 +00:00
gfx::Pipeline* createPipeline(const gfx::PipelineInfo& info);
2022-10-23 23:19:07 +00:00
void destroyPipeline(const gfx::Pipeline* pipeline);
2023-03-13 01:19:32 +00:00
gfx::DescriptorSetLayout* createDescriptorSetLayout();
void destroyDescriptorSetLayout(const gfx::DescriptorSetLayout* layout);
gfx::DescriptorSet* allocateDescriptorSet(const gfx::DescriptorSetLayout* layout);
void updateDescriptor(const gfx::DescriptorSet* set, uint32_t binding, const gfx::Buffer* buffer);
2023-01-05 13:21:33 +00:00
void updateUniformBuffer(const gfx::Pipeline* pipeline, const void* data, size_t size, uint32_t offset);
2022-10-31 16:21:07 +00:00
2023-03-13 01:19:32 +00:00
// Tries to create it on the GPU. Cannot be directly updated by the CPU.
2022-10-24 00:10:48 +00:00
gfx::Buffer* createBuffer(gfx::BufferType type, uint64_t size, const void* data);
void destroyBuffer(const gfx::Buffer* buffer);
2022-10-07 14:18:09 +00:00
2023-01-26 21:17:07 +00:00
gfx::Texture* createTexture(
const void* imageData,
uint32_t width,
uint32_t height,
gfx::TextureFilter minFilter,
gfx::TextureFilter magFilter,
gfx::MipmapSetting mipmapSetting,
bool useAnisotropy = false);
void destroyTexture(const gfx::Texture* texture);
// wait until all the active GPU queues have finished working
void waitIdle();
2022-09-13 18:25:18 +00:00
private:
struct Impl;
std::unique_ptr<Impl> pimpl;
2022-09-13 18:25:18 +00:00
};
}