Redo of render paths

This commit is contained in:
Dynamitos
2020-06-02 11:46:18 +02:00
parent bb5b48698a
commit 356e6058fe
121 changed files with 3890 additions and 572 deletions
+97
View File
@@ -0,0 +1,97 @@
#pragma once
namespace Seele
{
DECLARE_NAME_REF(Gfx, VertexBuffer);
DECLARE_NAME_REF(Gfx, IndexBuffer);
DECLARE_NAME_REF(Gfx, UniformBuffer);
DECLARE_REF(Material);
DECLARE_REF(VertexFactory);
struct MeshBatchElement
{
public:
Gfx::PUniformBuffer uniformBuffer;
Gfx::PIndexBuffer indexBuffer;
union
{
uint32* instanceRuns;
};
uint32 firstIndex;
uint32 numPrimitives;
uint32 numInstances;
uint32 baseVertexIndex;
uint32 minVertexIndex;
uint32 maxVertexIndex;
uint8 isInstanced : 1;
Gfx::PVertexBuffer indirectArgsBuffer;
MeshBatchElement()
: uniformBuffer(nullptr)
, indexBuffer(nullptr)
, indirectArgsBuffer(nullptr)
, firstIndex(0)
, numPrimitives(0)
, numInstances(1)
, baseVertexIndex(0)
, minVertexIndex(0)
, maxVertexIndex(0)
{}
};
struct MeshBatch
{
Array<MeshBatchElement> elements;
uint8 useReverseCulling : 1;
uint8 isBackfaceCullingDisabled : 1;
uint8 isCastingShadow : 1;
uint8 useWireframe : 1;
const Gfx::SePrimitiveTopology topology;
const PVertexFactory vertexFactory;
const PMaterial material;
inline int32 getNumPrimitives() const
{
int32 count = 0;
for(uint32 index = 0; index < elements.size(); ++index)
{
if(elements[index].isInstanced && elements[index].instanceRuns)
{
for(uint32 run = 0; run < elements[index].numInstances; ++run)
{
count += elements[index].numPrimitives * (elements[index].instanceRuns[run * 2 + 1] - elements[index].instanceRuns[run * 2] - 1);
}
}
else
{
count += elements[index].numPrimitives * elements[index].numInstances;
}
}
return count;
}
MeshBatch()
: useReverseCulling(false)
, isBackfaceCullingDisabled(false)
, isCastingShadow(true)
, useWireframe(false)
, vertexFactory(nullptr)
, material(nullptr)
, topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
{
elements.add();
}
};
DECLARE_REF(PrimitiveComponent);
struct StaticMeshBatch : public MeshBatch
{
uint32 index;
PPrimitiveComponent primitiveComponent;
};
} // namespace Seele