Add additional Asset types

- Add Framebuffer Asset
- Add Pipeline Asset
- Add RenderTexture Asset
This commit is contained in:
Thraix
2023-04-22 21:00:34 +02:00
parent 0246e89039
commit 1731bb1dd5
34 changed files with 322 additions and 171 deletions
@@ -1,11 +1,51 @@
#include "copium/pipeline/Pipeline.h"
#include "copium/asset/AssetManager.h"
#include "copium/buffer/Framebuffer.h"
#include "copium/core/Vulkan.h"
#include "copium/pipeline/Shader.h"
#include "copium/renderer/RendererVertex.h"
#include "copium/mesh/VertexPassthrough.h"
#include "copium/mesh/Vertex.h"
#include "copium/util/FileSystem.h"
namespace Copium
{
Pipeline::Pipeline(const MetaFile& metaFile)
: shaderReflector{ShaderReflector{metaFile.GetMetaClass("Pipeline").GetValue("vert-filepath"), metaFile.GetMetaClass("Pipeline").GetValue("frag-filepath")}}
{
const MetaFileClass& metaFileClass = metaFile.GetMetaClass("Pipeline");
VkRenderPass renderPass;
if (metaFileClass.HasValue("framebuffer-uuid"))
{
Framebuffer& fb = AssetManager::LoadAsset<Framebuffer>(UUID{metaFileClass.GetValue("framebuffer-uuid")});
renderPass = fb.GetRenderPass();
framebuffer = fb;
}
else
{
renderPass = Vulkan::GetSwapChain().GetRenderPass();
}
PipelineCreator creator{renderPass, metaFileClass.GetValue("vert-filepath"), metaFileClass.GetValue("frag-filepath")};
std::string type = metaFileClass.GetValue("type");
if (type == "Renderer")
{
creator.SetVertexDescriptor(RendererVertex::GetDescriptor());
creator.SetDepthTest(false);
}
else if (type == "Passthrough")
{
creator.SetVertexDescriptor(VertexPassthrough::GetDescriptor());
creator.SetDepthTest(false);
}
else if (type == "Mesh")
{
creator.SetVertexDescriptor(Vertex::GetDescriptor());
}
InitializeDescriptorSetLayout(creator);
InitializePipeline(creator);
}
Pipeline::Pipeline(PipelineCreator creator)
: shaderReflector{creator.shaderReflector}
{
@@ -21,6 +61,10 @@ namespace Copium
{
vkDestroyDescriptorSetLayout(Vulkan::GetDevice(), descriptorSetLayout, nullptr);
}
if (framebuffer != NULL_ASSET_HANDLE)
{
AssetManager::UnloadAsset(framebuffer);
}
}
void Pipeline::Bind(const CommandBuffer& commandBuffer)
+5 -1
View File
@@ -1,5 +1,6 @@
#pragma once
#include "copium/asset/Asset.h"
#include "copium/buffer/CommandBuffer.h"
#include "copium/pipeline/DescriptorSet.h"
#include "copium/pipeline/PipelineCreator.h"
@@ -10,7 +11,7 @@
namespace Copium
{
class Pipeline final
class Pipeline final : public Asset
{
CP_DELETE_COPY_AND_MOVE_CTOR(Pipeline);
private:
@@ -19,8 +20,11 @@ namespace Copium
std::vector<VkDescriptorSet> boundDescriptorSets;
VkPipelineLayout pipelineLayout;
VkPipeline graphicsPipeline;
AssetHandle framebuffer;
public:
Pipeline(const MetaFile& metaFile);
Pipeline(PipelineCreator creator);
~Pipeline();
void Bind(const CommandBuffer& commandBuffer);