engine/include/gfx_device.hpp

58 lines
1.8 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);
gfx::CommandBuffer* beginRender();
void finishRender(gfx::CommandBuffer* commandBuffer);
2022-10-22 12:15:25 +00:00
void cmdBindPipeline(gfx::CommandBuffer* commandBuffer, const gfx::Pipeline* pipeline);
void cmdBindDescriptorSetTexture(gfx::CommandBuffer* commandBuffer, uint32_t set, uint32_t binding, const gfx::Texture* texture);
void cmdBindDescriptorSetBuffer(gfx::CommandBuffer* commandBuffer, uint32_t set, uint32_t binding, const gfx::Texture* texture);
// creates the equivalent of an OpenGL shader program & vertex attrib configuration
2022-11-27 14:35:41 +00:00
gfx::Pipeline* createPipeline(const char* vertShaderPath, const char* fragShaderPath, const gfx::VertexFormat& vertexFormat, uint64_t uniformBufferSize, bool alphaBlending, bool backfaceCulling);
2022-10-23 23:19:07 +00:00
void destroyPipeline(const gfx::Pipeline* pipeline);
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
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
};
}