Reworking VertexData

This commit is contained in:
Dynamitos
2023-10-24 15:01:09 +02:00
parent a47f17481b
commit 28e5c9ff01
61 changed files with 1157 additions and 1144 deletions
+27 -80
View File
@@ -2,6 +2,7 @@
#include "Graphics/Graphics.h"
#include "Window/Window.h"
#include "Component/Camera.h"
#include "Component/Mesh.h"
#include "Actor/CameraActor.h"
#include "Math/Vector.h"
#include "RenderGraph.h"
@@ -9,69 +10,8 @@
using namespace Seele;
BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PGraphics graphics)
: MeshProcessor(graphics)
// , translucentBasePass(translucentBasePass)
//, cachedPrimitiveIndex(0)
{
}
BasePassMeshProcessor::~BasePassMeshProcessor()
{
}
void BasePassMeshProcessor::processMeshBatch(
const MeshBatch& batch,
Gfx::PViewport target,
Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout baseLayout,
Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet> descriptorSets,
int32 /*staticMeshId*/)
{
PMaterialInterface material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput->getType());
if(collection == nullptr)
{
material->createShaders(graphics, Gfx::RenderPassType::BasePass, vertexInput->getType());
collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput->getType());
}
assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
Gfx::PPipelineLayout pipelineLayout = graphics->createPipelineLayout(baseLayout);
pipelineLayout->addDescriptorLayout(BasePass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[BasePass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
buildMeshDrawCommand(batch,
renderPass,
pipelineLayout,
renderCommand,
descriptorSets,
collection->vertexShader,
collection->controlShader,
collection->evalutionShader,
collection->geometryShader,
collection->fragmentShader,
false);
}
std::scoped_lock lock(commandLock);
renderCommands.add(renderCommand);
//co_return;
}
BasePass::BasePass(Gfx::PGraphics graphics)
: RenderPass(graphics)
, processor(new BasePassMeshProcessor(graphics))
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
, descriptorSets(4)
{
UniformBufferCreateInfo uniformInitializer;
@@ -80,11 +20,11 @@ BasePass::BasePass(Gfx::PGraphics graphics)
lightLayout = graphics->createDescriptorLayout("LightLayout");
// Directional Lights
lightLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
lightLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
// Point Lights
lightLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
lightLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
// Point Lights
lightLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
lightLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
lightLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
// Light Index List
lightLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
// Light Grid
@@ -103,25 +43,32 @@ BasePass::BasePass(Gfx::PGraphics graphics)
basePassLayout->addDescriptorLayout(INDEX_VIEW_PARAMS, viewLayout);
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
primitiveLayout = graphics->createDescriptorLayout("PrimitiveLayout");
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
primitiveLayout->create();
basePassLayout->addDescriptorLayout(INDEX_SCENE_DATA, primitiveLayout);
basePassLayout->addPushConstants(Gfx::SePushConstantRange{
.stageFlags = (Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT),
.offset = 0,
.size = sizeof(uint32),
});
sceneLayout = graphics->createDescriptorLayout("SceneLayout");
sceneLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
sceneLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
sceneLayout->create();
basePassLayout->addDescriptorLayout(INDEX_SCENE_DATA, sceneLayout);
//basePassLayout->addPushConstants(Gfx::SePushConstantRange{
// .stageFlags = (Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT),
// .offset = 0,
// .size = sizeof(uint32),
//});
}
BasePass::~BasePass()
{
{
}
void BasePass::readScene()
{
Array<InstanceData> instances;
scene->view<Component::Transform, Component::Mesh>([]
(const Component::Transform& transform, const Component::Mesh& mesh) {
});
}
void BasePass::beginFrame(const Component::Camera& cam)
{
processor->clearCommands();
primitiveLayout->reset();
BulkResourceData uniformUpdate;
viewParams.viewMatrix = cam.getViewMatrix();
@@ -134,7 +81,7 @@ void BasePass::beginFrame(const Component::Camera& cam)
viewLayout->reset();
lightLayout->reset();
descriptorSets[INDEX_SCENE_DATA] = primitiveLayout->allocateDescriptorSet();
descriptorSets[INDEX_SCENE_DATA] = sceneLayout->allocateDescriptorSet();
descriptorSets[INDEX_SCENE_DATA]->updateBuffer(0, passData.sceneDataBuffer);
descriptorSets[INDEX_SCENE_DATA]->writeChanges();
descriptorSets[INDEX_LIGHT_ENV] = lightLayout->allocateDescriptorSet();
+4 -35
View File
@@ -1,44 +1,16 @@
#pragma once
#include "MinimalEngine.h"
#include "MeshProcessor.h"
#include "RenderPass.h"
namespace Seele
{
class BasePassMeshProcessor : public MeshProcessor
{
public:
BasePassMeshProcessor(Gfx::PGraphics graphics);
virtual ~BasePassMeshProcessor();
virtual void processMeshBatch(
const MeshBatch& batch,
Gfx::PViewport target,
Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout pipelineLayout,
Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet> descriptorSets,
int32 staticMeshId = -1) override;
private:
//Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
//uint8 translucentBasePass;
//uint32 cachedPrimitiveIndex;
};
DEFINE_REF(BasePassMeshProcessor)
DECLARE_REF(CameraActor)
struct BasePassData
{
Array<MeshBatch> staticDrawList;
Gfx::PShaderBuffer sceneDataBuffer;
LightEnv lightEnv;
};
class BasePass : public RenderPass<BasePassData>
class BasePass : public RenderPass
{
public:
BasePass(Gfx::PGraphics graphics);
BasePass(BasePass&& other) = default;
BasePass(Gfx::PGraphics graphics, PScene scene);
virtual ~BasePass();
BasePass& operator=(BasePass&& other) = default;
virtual void readScene() override;
virtual void beginFrame(const Component::Camera& cam) override;
virtual void render() override;
virtual void endFrame() override;
@@ -48,7 +20,6 @@ public:
private:
Gfx::PRenderTargetAttachment colorAttachment;
Gfx::PTexture2D depthBuffer;
UPBasePassMeshProcessor processor;
Array<Gfx::PDescriptorSet> descriptorSets;
PCameraActor source;
@@ -66,9 +37,7 @@ private:
static constexpr uint32 INDEX_MATERIAL = 2;
// Set 3: primitive scene data
static constexpr uint32 INDEX_SCENE_DATA = 3;
Gfx::PDescriptorLayout primitiveLayout;
Gfx::PUniformBuffer primitiveUniformBuffer;
friend class BasePassMeshProcessor;
Gfx::PDescriptorLayout sceneLayout;
};
DEFINE_REF(BasePass)
} // namespace Seele
@@ -8,8 +8,6 @@ target_sources(Engine
DepthPrepass.cpp
LightCullingPass.h
LightCullingPass.cpp
MeshProcessor.h
MeshProcessor.cpp
RenderGraph.h
RenderGraphResources.h
RenderGraphResources.cpp
@@ -28,7 +26,6 @@ target_sources(Engine
DebugPass.h
DepthPrepass.h
LightCullingPass.h
MeshProcessor.h
RenderGraph.h
RenderGraphResources.h
RenderPass.h
+1 -5
View File
@@ -9,11 +9,7 @@ namespace Seele
DECLARE_REF(CameraActor)
DECLARE_REF(Scene)
DECLARE_REF(Viewport)
struct DebugPassData
{
Array<DebugVertex> vertices;
};
class DebugPass : public RenderPass<DebugPassData>
class DebugPass : public RenderPass
{
public:
DebugPass(Gfx::PGraphics graphics);
+38 -84
View File
@@ -2,77 +2,16 @@
#include "Graphics/Graphics.h"
#include "Window/Window.h"
#include "Component/Camera.h"
#include "Component/Mesh.h"
#include "Actor/CameraActor.h"
#include "Math/Vector.h"
#include "RenderGraph.h"
#include "Material/MaterialInterface.h"
using namespace Seele;
DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(Gfx::PGraphics graphics)
: MeshProcessor(graphics)
{
}
DepthPrepassMeshProcessor::~DepthPrepassMeshProcessor()
{
}
void DepthPrepassMeshProcessor::processMeshBatch(
const MeshBatch& batch,
Gfx::PViewport target,
Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout baseLayout,
Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet> descriptorSets,
int32 /*staticMeshId*/)
{
//std::cout << "Depth void started" << std::endl;
PMaterialInterface material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::DepthPrepass, vertexInput->getType());
if (collection == nullptr)
{
material->createShaders(graphics, Gfx::RenderPassType::DepthPrepass, vertexInput->getType());
collection = material->getShaders(Gfx::RenderPassType::DepthPrepass, vertexInput->getType());
}
assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
Gfx::PPipelineLayout pipelineLayout = graphics->createPipelineLayout(baseLayout);
pipelineLayout->addDescriptorLayout(DepthPrepass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[DepthPrepass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
buildMeshDrawCommand(batch,
// primitiveComponent,
renderPass,
pipelineLayout,
renderCommand,
descriptorSets,
collection->vertexShader,
collection->controlShader,
collection->evalutionShader,
collection->geometryShader,
collection->fragmentShader,
true);
}
std::scoped_lock lock(commandLock);
renderCommands.add(renderCommand);
//std::cout << "Finished depth job" << std::endl;
//co_return;
}
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics)
: RenderPass(graphics)
, processor(new DepthPrepassMeshProcessor(graphics))
, descriptorSets(3)
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
, descriptorSets(4)
{
UniformBufferCreateInfo uniformInitializer;
@@ -86,16 +25,6 @@ DepthPrepass::DepthPrepass(Gfx::PGraphics graphics)
viewParamBuffer = graphics->createUniformBuffer(uniformInitializer);
viewLayout->create();
depthPrepassLayout->addDescriptorLayout(INDEX_VIEW_PARAMS, viewLayout);
primitiveLayout = graphics->createDescriptorLayout("PrimitiveLayout");
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
primitiveLayout->create();
depthPrepassLayout->addDescriptorLayout(INDEX_SCENE_DATA, primitiveLayout);
depthPrepassLayout->addPushConstants(Gfx::SePushConstantRange{
.stageFlags = (Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT),
.offset = 0,
.size = sizeof(uint32),
});
}
DepthPrepass::~DepthPrepass()
@@ -104,8 +33,6 @@ DepthPrepass::~DepthPrepass()
void DepthPrepass::beginFrame(const Component::Camera& cam)
{
processor->clearCommands();
primitiveLayout->reset();
BulkResourceData uniformUpdate;
viewParams.viewMatrix = cam.getViewMatrix();
@@ -116,12 +43,10 @@ void DepthPrepass::beginFrame(const Component::Camera& cam)
uniformUpdate.data = (uint8*)&viewParams;
viewParamBuffer->updateContents(uniformUpdate);
viewLayout->reset();
descriptorSets[INDEX_SCENE_DATA] = primitiveLayout->allocateDescriptorSet();
descriptorSets[INDEX_SCENE_DATA]->updateBuffer(0, passData.sceneDataBuffer);
descriptorSets[INDEX_SCENE_DATA]->writeChanges();
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
//std::cout << "DepthPrepass beginFrame()" << std::endl;
//co_return;
}
@@ -133,11 +58,39 @@ void DepthPrepass::render()
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
graphics->beginRenderPass(renderPass);
for (const auto& meshBatch : passData.staticDrawList)
for (VertexData* vertexData : VertexData::getList())
{
processor->processMeshBatch(meshBatch, viewport, renderPass, depthPrepassLayout, primitiveLayout, descriptorSets);
const auto& materials = vertexData->getMaterialData();
for (const auto& [_, materialData] : materials)
{
// Create Pipeline(Material, VertexData)
// Descriptors:
// ViewData => global, static
// Material => per material
// VertexData => per meshtype
// SceneData => per topology
Gfx::PRenderCommand command = graphics->createRenderCommand("DepthRender");
Gfx::PPipelineLayout layout = graphics->createPipelineLayout(depthPrepassLayout);
layout->addDescriptorLayout(INDEX_MATERIAL, materialData.material->getDescriptorLayout());
layout->addDescriptorLayout(INDEX_VERTEX_DATA, vertexData->getVertexDataLayout());
layout->addDescriptorLayout(INDEX_SCENE_DATA, vertexData->getInstanceDataLayout());
layout->create();
GraphicsPipelineCreateInfo pipelineInfo;
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInfo);
command->bindPipeline(pipeline);
vertexData->bindBuffers(command);
descriptorSets[INDEX_VERTEX_DATA] = vertexData->getVertexDataSet();
for (const auto&[_, instance]: materialData.instances)
{
descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet();
descriptorSets[INDEX_SCENE_DATA] = instance.descriptorSet;
command->bindDescriptor(descriptorSets);
command->dispatch(instance.numMeshes, 1, 1);
}
}
}
graphics->executeCommands(processor->getRenderCommands());
graphics->endRenderPass();
//std::cout << "DepthPrepass render()" << std::endl;
//co_return;
@@ -175,5 +128,6 @@ void DepthPrepass::modifyRenderPassMacros(Map<const char*, const char*>& defines
{
defines["INDEX_VIEW_PARAMS"] = "0";
defines["INDEX_MATERIAL"] = "1";
defines["INDEX_SCENE_DATA"] = "2";
defines["INDEX_VERTEX_DATA"] = "2";
defines["INDEX_SCENE_DATA"] = "3";
}
+9 -35
View File
@@ -1,40 +1,14 @@
#pragma once
#include "MinimalEngine.h"
#include "MeshProcessor.h"
#include "RenderPass.h"
namespace Seele
{
class DepthPrepassMeshProcessor : public MeshProcessor
class DepthPrepass : public RenderPass
{
public:
DepthPrepassMeshProcessor(Gfx::PGraphics graphics);
virtual ~DepthPrepassMeshProcessor();
virtual void processMeshBatch(
const MeshBatch& batch,
Gfx::PViewport target,
Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout pipelineLayout,
Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet> descriptorSets,
int32 staticMeshId = -1) override;
private:
};
DEFINE_REF(DepthPrepassMeshProcessor)
struct DepthPrepassData
{
Array<MeshBatch> staticDrawList;
Gfx::PShaderBuffer sceneDataBuffer;
};
class DepthPrepass : public RenderPass<DepthPrepassData>
{
public:
DepthPrepass(Gfx::PGraphics graphics);
DepthPrepass(DepthPrepass&& other) = default;
DepthPrepass(Gfx::PGraphics graphics, PScene scene);
~DepthPrepass();
DepthPrepass& operator=(DepthPrepass& other) = default;
virtual void beginFrame(const Component::Camera& cam) override;
virtual void render() override;
virtual void endFrame() override;
@@ -44,9 +18,9 @@ public:
private:
Gfx::PRenderTargetAttachment depthAttachment;
Gfx::PTexture2D depthBuffer;
UPDepthPrepassMeshProcessor processor;
Array<Gfx::PDescriptorSet> descriptorSets;
Gfx::PPipelineLayout depthPrepassLayout;
// Set 0: viewParameter
static constexpr uint32 INDEX_VIEW_PARAMS = 0;
@@ -54,11 +28,11 @@ private:
Gfx::PUniformBuffer viewParamBuffer;
// Set 1: materials, generated
static constexpr uint32 INDEX_MATERIAL = 1;
// Set 2: primitive scene data
static constexpr uint32 INDEX_SCENE_DATA = 2;
Gfx::PDescriptorLayout primitiveLayout;
Gfx::PUniformBuffer primitiveUniformBuffer;
friend class DepthPrepassMeshProcessor;
// Set 2: vertices, from VertexData
static constexpr uint32 INDEX_VERTEX_DATA = 2;
// Set 3: mesh data, either index buffer or meshlet data
static constexpr uint32 INDEX_SCENE_DATA = 3;
Gfx::PDescriptorLayout sceneDataLayout;
};
DEFINE_REF(DepthPrepass)
} // namespace Seele
@@ -12,7 +12,7 @@ struct LightCullingPassData
{
LightEnv lightEnv;
};
class LightCullingPass : public RenderPass<LightCullingPassData>
class LightCullingPass : public RenderPass
{
public:
LightCullingPass(Gfx::PGraphics graphics);
@@ -1,82 +0,0 @@
#include "MeshProcessor.h"
#include "Graphics/Graphics.h"
#include "Graphics/VertexShaderInput.h"
#include "Graphics/Vulkan/VulkanGraphicsResources.h"
using namespace Seele;
MeshProcessor::MeshProcessor(Gfx::PGraphics graphics)
: graphics(graphics)
{
}
MeshProcessor::~MeshProcessor()
{
}
void MeshProcessor::buildMeshDrawCommand(
const MeshBatch& meshBatch,
// const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout pipelineLayout,
Gfx::PRenderCommand drawCommand,
const Array<Gfx::PDescriptorSet>& descriptors,
Gfx::PVertexShader vertexShader,
Gfx::PControlShader controlShader,
Gfx::PEvaluationShader evaluationShader,
Gfx::PGeometryShader geometryShader,
Gfx::PFragmentShader fragmentShader,
bool positionOnly)
{
const PVertexShaderInput vertexInput = meshBatch.vertexInput;
GraphicsPipelineCreateInfo pipelineInitializer;
pipelineInitializer.topology = meshBatch.topology;
pipelineInitializer.vertexShader = vertexShader;
pipelineInitializer.controlShader = controlShader;
pipelineInitializer.evalShader = evaluationShader;
pipelineInitializer.geometryShader = geometryShader;
pipelineInitializer.fragmentShader = fragmentShader;
pipelineInitializer.renderPass = renderPass;
pipelineInitializer.pipelineLayout = pipelineLayout;
VertexInputStreamArray vertexStreams;
if(positionOnly)
{
vertexInput->getPositionOnlyStream(vertexStreams);
pipelineInitializer.vertexDeclaration = vertexInput->getPositionDeclaration();
}
else
{
vertexInput->getStreams(vertexStreams);
pipelineInitializer.vertexDeclaration = vertexInput->getDeclaration();
}
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInitializer);
drawCommand->bindPipeline(pipeline);
drawCommand->bindVertexBuffer(vertexStreams);
drawCommand->bindDescriptor(descriptors);
for(const auto& element : meshBatch.elements)
{
drawCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(uint32), &element.sceneDataIndex);
if(element.indexBuffer != nullptr)
{
drawCommand->bindIndexBuffer(element.indexBuffer);
drawCommand->draw(element);
}
else
{
drawCommand->draw(vertexStreams[0].vertexBuffer->getNumVertices(), 1, 0, 0);
}
}
}
Array<Gfx::PRenderCommand> MeshProcessor::getRenderCommands()
{
return renderCommands;
}
void MeshProcessor::clearCommands()
{
renderCommands.clear();
}
@@ -1,43 +0,0 @@
#pragma once
#include "MinimalEngine.h"
#include "Scene/Scene.h"
#include "Graphics/GraphicsResources.h"
#include "Graphics/MeshBatch.h"
namespace Seele
{
class MeshProcessor
{
public:
MeshProcessor(Gfx::PGraphics graphics);
virtual ~MeshProcessor();
Array<Gfx::PRenderCommand> getRenderCommands();
void clearCommands();
protected:
PScene scene;
Gfx::PGraphics graphics;
virtual void processMeshBatch(
const MeshBatch& batch,
Gfx::PViewport target,
Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout pipelineLayout,
Gfx::PDescriptorLayout primitiveLayout,
Array<Gfx::PDescriptorSet> descriptorSets,
int32 staticMeshId = -1) = 0;
void buildMeshDrawCommand(
const MeshBatch& meshBatch,
// const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
Gfx::PPipelineLayout pipelineLayout,
Gfx::PRenderCommand drawCommand,
const Array<Gfx::PDescriptorSet>& descriptors,
Gfx::PVertexShader vertexShader,
Gfx::PControlShader controlShader,
Gfx::PEvaluationShader evaluationShader,
Gfx::PGeometryShader geometryShader,
Gfx::PFragmentShader fragmentShader,
bool positionOnly);
std::mutex commandLock;
Array<Gfx::PRenderCommand> renderCommands;
};
} // namespace Seele
+22 -8
View File
@@ -3,24 +3,25 @@
#include "Math/Math.h"
#include "RenderGraphResources.h"
#include "Component/Camera.h"
#include "Graphics/TopologyData.h"
#include "Scene/Scene.h"
#include "Material/MaterialInstance.h"
#include "Graphics/VertexData.h"
namespace Seele
{
DECLARE_NAME_REF(Gfx, Viewport)
DECLARE_NAME_REF(Gfx, Graphics)
DECLARE_NAME_REF(Gfx, RenderPass)
template<typename RenderPassDataType>
class RenderPass
{
public:
RenderPass(Gfx::PGraphics graphics)
RenderPass(Gfx::PGraphics graphics, PScene scene)
: graphics(graphics)
, scene(scene)
{}
virtual ~RenderPass()
{}
void updateViewFrame(RenderPassDataType viewFrame) {
passData = std::move(viewFrame);
}
virtual void beginFrame(const Component::Camera& cam) = 0;
virtual void render() = 0;
virtual void endFrame() = 0;
@@ -41,13 +42,26 @@ protected:
Vector2 screenDimensions;
Vector2 pad0;
} viewParams;
struct DrawListId
{
DrawListId(PMaterialInstance mat, PVertexData vertex)
{
id = mat->getBaseMaterial()->getName();
}
std::strong_ordering operator<=>(const DrawListId& other) const
{
return id <=> other.id;
}
std::string id;
};
Map<DrawListId, DrawListInfo> drawList;
PRenderGraphResources resources;
RenderPassDataType passData;
Gfx::PRenderPass renderPass;
Gfx::PGraphics graphics;
Gfx::PViewport viewport;
PScene scene;
};
template<typename RP, typename T>
concept RenderPassType = std::derived_from<RP, RenderPass<T>>;
template<typename RP>
concept RenderPassType = std::derived_from<RP, RenderPass>;
} // namespace Seele
@@ -8,11 +8,7 @@ namespace Seele
DECLARE_REF(CameraActor)
DECLARE_REF(Scene)
DECLARE_REF(Viewport)
struct SkyboxPassData
{
Component::Skybox skybox;
};
class SkyboxRenderPass : public RenderPass<SkyboxPassData>
class SkyboxRenderPass : public RenderPass
{
public:
SkyboxRenderPass(Gfx::PGraphics graphics);
+1 -6
View File
@@ -17,12 +17,7 @@ struct TextRender
Vector2 position;
float scale;
};
struct TextPassData
{
Array<TextRender> texts;
};
class TextPass : public RenderPass<TextPassData>
class TextPass : public RenderPass
{
public:
TextPass(Gfx::PGraphics graphics);