Cleanup Renderer
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "copium/buffer/CommandBuffer.h"
|
||||
#include "copium/buffer/IndexBuffer.h"
|
||||
#include "copium/buffer/VertexBuffer.h"
|
||||
#include "copium/buffer/RendererVertexBuffer.h"
|
||||
#include "copium/core/Vulkan.h"
|
||||
#include "copium/pipeline/Pipeline.h"
|
||||
#include "copium/pipeline/PipelineCreator.h"
|
||||
#include "copium/renderer/DrawCall.h"
|
||||
#include "copium/sampler/Texture2D.h"
|
||||
#include "copium/util/Common.h"
|
||||
|
||||
@@ -17,25 +17,6 @@ namespace Copium
|
||||
class Renderer
|
||||
{
|
||||
CP_DELETE_COPY_AND_MOVE_CTOR(Renderer);
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
glm::vec2 position;
|
||||
glm::vec3 color;
|
||||
glm::vec2 texCoord;
|
||||
int8_t texIndex;
|
||||
|
||||
static VertexDescriptor GetDescriptor()
|
||||
{
|
||||
VertexDescriptor descriptor{};
|
||||
descriptor.AddAttribute(0, 0, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, position), sizeof(Vertex));
|
||||
descriptor.AddAttribute(0, 1, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, color), sizeof(Vertex));
|
||||
descriptor.AddAttribute(0, 2, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, texCoord), sizeof(Vertex));
|
||||
descriptor.AddAttribute(0, 3, VK_FORMAT_R8_SINT, offsetof(Vertex, texIndex), sizeof(Vertex));
|
||||
return descriptor;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
Vulkan& vulkan;
|
||||
|
||||
@@ -43,19 +24,16 @@ namespace Copium
|
||||
IndexBuffer ibo;
|
||||
Texture2D emptyTexture;
|
||||
std::unique_ptr<Pipeline> graphicsPipeline;
|
||||
std::vector<std::unique_ptr<Buffer>> vbos;
|
||||
std::vector<std::unique_ptr<DescriptorSet>> descriptorSets;
|
||||
std::vector<std::unique_ptr<DrawCall>> drawCalls;
|
||||
|
||||
// Temporary data during a render
|
||||
CommandBuffer* currentCommandBuffer;
|
||||
Buffer* currentVertexBuffer;
|
||||
DescriptorSet* currentDescriptorSet;
|
||||
DrawCall* currentDrawCall;
|
||||
std::vector<const Sampler*> samplers;
|
||||
int vboIndex;
|
||||
int vertexCount;
|
||||
int indexCount;
|
||||
int drawCallIndex;
|
||||
int quadCount;
|
||||
int textureCount;
|
||||
void* mappedVertexBuffer;
|
||||
int texturesUsed;
|
||||
public:
|
||||
Renderer(Vulkan& vulkan, VkRenderPass renderPass, DescriptorPool& descriptorPool);
|
||||
|
||||
@@ -65,11 +43,13 @@ namespace Copium
|
||||
void Begin(CommandBuffer& commandBuffer);
|
||||
void End();
|
||||
private:
|
||||
void InitializeIndexBuffer();
|
||||
void InitializeGraphicsPipeline(VkRenderPass renderPass);
|
||||
|
||||
int AllocateSampler(const Sampler& sampler);
|
||||
void AllocateQuad();
|
||||
void Flush();
|
||||
void NextVertexBuffer();
|
||||
void NextDrawCall();
|
||||
|
||||
void AddVertex(const glm::vec2& position, const glm::vec3& color, int texindex, const glm::vec2& texCoord);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user