Refactor UniformBuffers and DescriptorSets
- Refactor UniformBuffers to keep track of the uniforms it contains - Refactor DescriptorSets to initialize UniformsBuffers and keep track of all its bindings - DescriptorSets can now be created from the Pipeline - Add custom DescriptorSets to Renderer
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
#include "copium/buffer/Buffer.h"
|
||||
#include "copium/core/Vulkan.h"
|
||||
#include "copium/pipeline/ShaderBinding.h"
|
||||
#include "copium/util/Common.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
namespace Copium
|
||||
@@ -12,20 +14,22 @@ namespace Copium
|
||||
{
|
||||
CP_DELETE_COPY_AND_MOVE_CTOR(UniformBuffer);
|
||||
|
||||
ShaderBinding binding;
|
||||
std::vector<uint8_t> buffer;
|
||||
|
||||
public:
|
||||
UniformBuffer(Vulkan& vulkan, VkDeviceSize size);
|
||||
UniformBuffer(Vulkan& vulkan, ShaderBinding binding);
|
||||
|
||||
VkDescriptorBufferInfo GetDescriptorBufferInfo(int index) const;
|
||||
|
||||
template <typename T>
|
||||
void Update(const T& t);
|
||||
void Set(const std::string& str, const glm::mat3& data);
|
||||
void Set(const std::string& str, const glm::mat4& data);
|
||||
void Set(const std::string& str, const glm::vec2& data);
|
||||
void Set(const std::string& str, const glm::vec3& data);
|
||||
void Set(const std::string& str, const glm::vec4& data);
|
||||
void Set(const std::string& str, float data);
|
||||
void Set(const std::string& str, int data);
|
||||
|
||||
void Update();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void UniformBuffer::Update(const T& t)
|
||||
{
|
||||
CP_ASSERT(sizeof(T) == Buffer::GetSize(), "Update : Template size is not the same as buffer size %u != %u", sizeof(T), Buffer::GetSize());
|
||||
Buffer::Update((void*)&t, vulkan.GetSwapChain().GetFlightIndex());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user