#ifndef ENGINE_INCLUDE_RENDERER_H_ #define ENGINE_INCLUDE_RENDERER_H_ #include #include #include #include "gfx_device.h" namespace engine { // A uniform struct that holds data of type T template struct UniformDescriptor { const gfx::DescriptorSetLayout* layout; const gfx::DescriptorSet* set; struct UniformBufferData { T data; } uniform_buffer_data; gfx::UniformBuffer* uniform_buffer; }; class Renderer { public: Renderer(const char* app_name, const char* app_version, SDL_Window* window, gfx::GraphicsSettings settings); ~Renderer(); GFXDevice* GetDevice() { return device_.get(); } const gfx::DescriptorSetLayout* GetGlobalSetLayout() { return global_uniform.layout; } const gfx::DescriptorSetLayout* GetFrameSetLayout() { return frame_uniform.layout; } const gfx::DescriptorSetLayout* GetMaterialSetLayout() { return material_set_layout; } std::unordered_map samplers; private: std::unique_ptr device_; // ALL vertex shaders must begin with: /* layout(set = 0, binding = 0) uniform GlobalSetUniformBuffer { mat4 proj; } globalSetUniformBuffer; layout(set = 1, binding = 0) uniform FrameSetUniformBuffer { mat4 view; } frameSetUniformBuffer; layout( push_constant ) uniform Constants { mat4 model; } constants; */ // ALL fragment shaders must begin with: /* layout(set = 2, binding = 0) uniform sampler2D materialSetSampler; */ // in vertex shader UniformDescriptor global_uniform; // rarely updates; set 0 UniformDescriptor frame_uniform; // updates once per frame; set 1 // in fragment shader const gfx::DescriptorSetLayout* material_set_layout; // set 2 }; } // namespace engine #endif