engine/include/gfx_device.h

81 lines
3.6 KiB
C
Raw Normal View History

2024-03-31 10:11:22 +00:00
#pragma once
2022-10-22 12:15:25 +00:00
2022-09-17 00:22:35 +00:00
#include <memory>
2023-05-01 13:13:35 +00:00
#include "gfx.h"
2023-04-29 14:22:25 +00:00
2024-03-31 10:11:22 +00:00
struct SDL_Window; // <SDL_video.h>
struct ImDrawData; // "imgui/imgui.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
2023-04-29 14:22:25 +00:00
class GFXDevice {
2024-06-04 22:31:22 +00:00
private:
struct Impl;
std::unique_ptr<Impl> pimpl;
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
public:
GFXDevice(const char* app_name, const char* app_version, SDL_Window* window, gfx::GraphicsSettings settings);
2024-03-31 10:11:22 +00:00
GFXDevice(const GFXDevice&) = delete;
2024-04-26 22:31:34 +00:00
2024-06-04 22:31:22 +00:00
~GFXDevice();
2023-10-01 10:38:27 +00:00
2024-06-04 22:31:22 +00:00
GFXDevice& operator=(const GFXDevice&) = delete;
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
void getViewportSize(uint32_t* w, uint32_t* h);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
void changePresentMode(gfx::PresentMode mode);
gfx::PresentMode getPresentMode();
2024-03-26 11:18:50 +00:00
2024-06-04 22:31:22 +00:00
void setupImguiBackend();
void shutdownImguiBackend();
void cmdRenderImguiDrawData(gfx::DrawBuffer* draw_buffer, ImDrawData* draw_data);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::DrawBuffer* beginRender(bool window_resized);
void finishRender(gfx::DrawBuffer* draw_buffer);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::DrawBuffer* beginShadowmapRender(gfx::Image* image);
void finishShadowmapRender(gfx::DrawBuffer* draw_buffer, gfx::Image* image);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
void cmdBindPipeline(gfx::DrawBuffer* draw_buffer, const gfx::Pipeline* pipeline);
void cmdBindVertexBuffer(gfx::DrawBuffer* draw_buffer, uint32_t binding, const gfx::Buffer* buffer);
void cmdBindIndexBuffer(gfx::DrawBuffer* draw_buffer, const gfx::Buffer* buffer);
void cmdDrawIndexed(gfx::DrawBuffer* draw_buffer, uint32_t index_count, uint32_t instance_count, uint32_t first_index, int32_t vertex_offset,
2024-03-31 10:11:22 +00:00
uint32_t first_instance);
2024-06-04 22:31:22 +00:00
void cmdDraw(gfx::DrawBuffer* drawBuffer, uint32_t vertex_count, uint32_t instance_count, uint32_t first_vertex, uint32_t first_instance);
void cmdPushConstants(gfx::DrawBuffer* draw_buffer, const gfx::Pipeline* pipeline, uint32_t offset, uint32_t size, const void* data);
void cmdBindDescriptorSet(gfx::DrawBuffer* draw_buffer, const gfx::Pipeline* pipeline, const gfx::DescriptorSet* set, uint32_t set_number);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::Pipeline* createPipeline(const gfx::PipelineInfo& info);
void destroyPipeline(const gfx::Pipeline* pipeline);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::DescriptorSetLayout* createDescriptorSetLayout(const std::vector<gfx::DescriptorSetLayoutBinding>& bindings);
void destroyDescriptorSetLayout(const gfx::DescriptorSetLayout* layout);
gfx::DescriptorSet* allocateDescriptorSet(const gfx::DescriptorSetLayout* layout);
void freeDescriptorSet(const gfx::DescriptorSet* set);
void updateDescriptorUniformBuffer(const gfx::DescriptorSet* set, uint32_t binding, const gfx::UniformBuffer* buffer, size_t offset, size_t range);
void updateDescriptorCombinedImageSampler(const gfx::DescriptorSet* set, uint32_t binding, const gfx::Image* image, const gfx::Sampler* sampler);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::UniformBuffer* createUniformBuffer(uint64_t size, const void* initial_data);
void destroyUniformBuffer(const gfx::UniformBuffer* descriptor_buffer);
void writeUniformBuffer(gfx::UniformBuffer* buffer, uint64_t offset, uint64_t size, const void* data);
2023-04-29 14:22:25 +00:00
2024-06-04 22:31:22 +00:00
gfx::Buffer* createBuffer(gfx::BufferType type, uint64_t size, const void* data);
void destroyBuffer(const gfx::Buffer* buffer);
2023-05-29 13:52:14 +00:00
2024-06-04 22:31:22 +00:00
gfx::Image* createImage(uint32_t w, uint32_t h, gfx::ImageFormat input_format, const void* image_data);
gfx::Image* createImageCubemap(uint32_t w, uint32_t h, gfx::ImageFormat input_format, const std::array<const void*, 6>& image_data);
gfx::Image* createImageShadowmap();
void destroyImage(const gfx::Image* image);
2022-09-19 17:33:56 +00:00
2024-06-04 22:31:22 +00:00
const gfx::Sampler* createSampler(const gfx::SamplerInfo& info);
void destroySampler(const gfx::Sampler* sampler);
2022-09-13 18:25:18 +00:00
2024-06-04 22:31:22 +00:00
uint64_t getFrameCount();
void logPerformanceInfo();
2022-10-27 22:06:56 +00:00
2024-06-04 22:31:22 +00:00
void waitIdle();
2023-04-29 14:22:25 +00:00
};
2022-09-13 18:25:18 +00:00
2024-04-13 11:11:36 +00:00
} // namespace engine