evan 2026.1.4
Evan
Loading...
Searching...
No Matches
GPUMaterial.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** GPUMaterial
6*/
7
8#pragma once
9
10#include "evan/EvanPlatform.hpp"
11
12#include <utility/graphic/material.hpp>
13
14#include <utility/logging/loggable.hpp>
15#include <utility/logging/default_logger.hpp>
16
17#include "evan/ADeviceBackend.hpp"
18#include "evan/DeviceContext.hpp"
19#include "evan/RenderSettings.hpp"
20
21#include "GPUTexture.hpp"
22
23namespace evan
24{
25 class Renderer;
26
43 protected utility::logging::Loggable<GPUMaterial,
44 utility::logging::DefaultLogger>
45 {
46 public:
79 GPUMaterial(std::shared_ptr<DeviceContext> deviceContext,
80 const Renderer &renderer,
81 const utility::graphic::Material &material,
82 uint32_t shaderID);
83
85
106 void destroy(VkDevice device);
107
132 void update(std::shared_ptr<DeviceContext> deviceContext,
133 const Renderer &renderer,
134 const utility::graphic::Material &material,
135 uint32_t shaderID);
136
155 const std::vector<VkDescriptorSet> &getDescriptorSets() const;
156
170 uint32_t getShaderID() const;
171
185 [[nodiscard]] BlendMode getBlendMode() const;
186
196 uint32_t getUploadedVersion() const;
197
198 protected:
234 void createDescriptorSets(VkDevice logicalDevice,
235 VkDescriptorSetLayout descriptorSetLayout,
236 VkDescriptorPool descriptorPool,
237 const std::vector<VkBuffer> &uniformBuffers);
238
246 void cleanup();
247
256 void freeDescriptorSets(VkDevice device);
257
262 std::vector<std::shared_ptr<GPUTexture>> _textures;
263
267 uint32_t _shaderID;
268
275 utility::graphic::AlphaMode _alphaMode =
276 utility::graphic::AlphaMode::Opaque;
277
281 std::vector<VkDescriptorSet> _descriptorSets;
282
288 VkDescriptorPool _descriptorPool = VK_NULL_HANDLE;
289
294 uint32_t _uploadedVersion = 0;
295
301 std::shared_ptr<DeviceContext> _deviceContext;
302
303 private:
304 uint32_t getBinding(GPUTexture::TextureType type);
305 };
306} // namespace evan
Represents a material in the rendering engine, encapsulating texture data, image views,...
void createDescriptorSets(VkDevice logicalDevice, VkDescriptorSetLayout descriptorSetLayout, VkDescriptorPool descriptorPool, const std::vector< VkBuffer > &uniformBuffers)
Creates Vulkan descriptor sets for the material, allowing shaders to access the material's texture da...
BlendMode getBlendMode() const
Retrieves the blend mode this material has to be drawn with.
const std::vector< VkDescriptorSet > & getDescriptorSets() const
Retrieves the Vulkan descriptor sets associated with this material.
void freeDescriptorSets(VkDevice device)
Frees the descriptor sets allocated for this material and clears the container.
uint32_t getUploadedVersion() const
Retrieves the version number of the uploaded material.
uint32_t getShaderID() const
Retrieves the unique shader ID associated with this material.
void update(std::shared_ptr< DeviceContext > deviceContext, const Renderer &renderer, const utility::graphic::Material &material, uint32_t shaderID)
Updates the GPUMaterial with new texture data and resources.
void cleanup()
Releases every Vulkan resource owned by this material.
std::vector< VkDescriptorSet > _descriptorSets
GPUMaterial(std::shared_ptr< DeviceContext > deviceContext, const Renderer &renderer, const utility::graphic::Material &material, uint32_t shaderID)
Constructs a GPUMaterial instance using the provided device context, renderer, and texture path.
utility::graphic::AlphaMode _alphaMode
void destroy(VkDevice device)
Destroys the Vulkan resources associated with the material.
std::vector< std::shared_ptr< GPUTexture > > _textures
uint32_t _uploadedVersion
VkDescriptorPool _descriptorPool
std::shared_ptr< DeviceContext > _deviceContext
TextureType
Enum class representing different types of textures that can be associated with a material,...
The Renderer class is responsible for managing the graphics pipeline, descriptor sets,...
Definition Renderer.hpp:64