功能向RenderPipe集中

This commit is contained in:
2025-08-25 23:12:23 +08:00
parent 0f9f81d568
commit 9a0e6d7524
18 changed files with 50 additions and 54 deletions
+4 -22
View File
@@ -20,36 +20,18 @@ RenderPipe::~RenderPipe()
void RenderPipe::pushRenderable(RenderableConstPtr renderable)
{
m_queue.push_back(renderable);
m_renderableQueue.push_back(renderable);
}
RenderableConstPtr RenderPipe::getRenderable(size_t index) const
void RenderPipe::process(RenderTarget& renderTarget)
{
assert(index < m_queue.size());
if (index < m_queue.size())
{
return m_queue[index];
}
return nullptr;
}
void RenderPipe::build(const Scene& scene)
{
//Build render queue
scene.getRootSceneNode()->buildRenderQueue(fMatrix4::IDENTITY, *this);
}
void RenderPipe::process(AntiAliasingTech aaTech, UniformBuffer& uniformBuffer, RenderTarget& renderTarget)
{
m_aaTech = aaTech;
//Assembere input
InputAssemberStep IA;
IA.process(*this);
IA.process(m_renderableQueue);
//Vertex shader
VertexShaderStep VS;
VS.process(uniformBuffer, IA.m_nodes);
VS.process(m_uniformBuffer, IA.m_nodes);
//Pixel shader
PixelShaderStep PS;
@@ -3,12 +3,12 @@
DV_CORE_BEGIN_NAMESPACE
void InputAssemberStep::process(const RenderPipe& renderQueue)
void InputAssemberStep::process(const RenderableArray& renderableArray)
{
size_t counts = renderQueue.getRenderableCounts();
size_t counts = renderableArray.size();
for (size_t i = 0; i < counts; i++)
{
RenderableConstPtr renderable = renderQueue.getRenderable(i);
RenderableConstPtr renderable = renderableArray[i];
if (renderable)
{
Node node;
@@ -51,7 +51,7 @@ void CameraComponent::setCameraDefine(const CameraComponent::CameraDefine& camer
m_viewProjMatrix = matProj * matView;
}
void CameraComponent::render(const fMatrix4& transParent, RenderPipe& queue) const
void CameraComponent::buildRenderableQueue(const fMatrix4& transParent, RenderPipe& pipe) const
{
}
@@ -13,7 +13,7 @@ SceneComponent::~SceneComponent()
}
void SceneComponent::render(const fMatrix4& transParent, RenderPipe& queue) const
void SceneComponent::buildRenderableQueue(const fMatrix4& transParent, RenderPipe& pipe) const
{
}
@@ -24,7 +24,7 @@ void LightComponent::setLightDefine(const LightDefine& lightDefine)
m_define = lightDefine;
}
void LightComponent::render(const fMatrix4& transParent, RenderPipe& queue) const
void LightComponent::buildRenderableQueue(const fMatrix4& transParent, RenderPipe& pipe) const
{
}
@@ -27,9 +27,9 @@ void MeshComponent::setMesh(MeshConstPtr mesh)
m_mesh = mesh;
}
void MeshComponent::render(const fMatrix4& transParent, RenderPipe& queue) const
void MeshComponent::buildRenderableQueue(const fMatrix4& transParent, RenderPipe& pipe) const
{
SceneComponent::render(transParent, queue);
SceneComponent::buildRenderableQueue(transParent, pipe);
int32_t primitiveCounts = m_mesh->getPrimitiveCounts();
for (int32_t i = 0; i < primitiveCounts; i++)
@@ -37,7 +37,7 @@ void MeshComponent::render(const fMatrix4& transParent, RenderPipe& queue) const
Mesh::PrimitiveConstPtr primitivePtr = m_mesh->getPrimitive(i);
RenderablePtr renderable = std::make_shared<RenderableEntity>(primitivePtr, transParent);
queue.pushRenderable(renderable);
pipe.pushRenderable(renderable);
}
}
+5
View File
@@ -120,4 +120,9 @@ SceneNodePtr Scene::getRootSceneNode(void) const
return m_rootSceneNode;
}
void Scene::buildRenderableQueue(RenderPipe& pipe) const
{
getRootSceneNode()->buildRenderableQueue(fMatrix4::IDENTITY, pipe);
}
DV_CORE_END_NAMESPACE
+3 -3
View File
@@ -89,18 +89,18 @@ SceneComponentConstPtr SceneNode::getComponent(size_t index) const
return m_componentArray[index];
}
void SceneNode::buildRenderQueue(const fMatrix4& transParent, RenderPipe& queue)
void SceneNode::buildRenderableQueue(const fMatrix4& transParent, RenderPipe& pipe)
{
fMatrix4 transform = m_transform * transParent;
for (auto component : m_componentArray)
{
component->render(transform, queue);
component->buildRenderableQueue(transform, pipe);
}
for (auto child : m_childen)
{
child->buildRenderQueue(transform, queue);
child->buildRenderableQueue(transform, pipe);
}
}