Adding cached depth renderpass
This commit is contained in:
@@ -12,60 +12,65 @@ constexpr uint64 MAX_TEXCOORDS = 8;
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(Mesh)
|
||||
struct MeshId
|
||||
{
|
||||
DECLARE_REF(Mesh)
|
||||
struct MeshId
|
||||
{
|
||||
uint64 id;
|
||||
std::strong_ordering operator<=>(const MeshId& other) const
|
||||
std::strong_ordering operator<=>(const MeshId &other) const
|
||||
{
|
||||
return id <=> other.id;
|
||||
return id <=> other.id;
|
||||
}
|
||||
bool operator==(const MeshId& other) const
|
||||
bool operator==(const MeshId &other) const
|
||||
{
|
||||
return id == other.id;
|
||||
return id == other.id;
|
||||
}
|
||||
};
|
||||
class VertexData
|
||||
{
|
||||
public:
|
||||
};
|
||||
class VertexData
|
||||
{
|
||||
public:
|
||||
struct InstanceData
|
||||
{
|
||||
Matrix4 transformMatrix;
|
||||
Matrix4 inverseTransformMatrix;
|
||||
Matrix4 transformMatrix;
|
||||
Matrix4 inverseTransformMatrix;
|
||||
};
|
||||
struct MeshData
|
||||
{
|
||||
AABB bounding;
|
||||
uint32 numMeshlets = 0;
|
||||
uint32 meshletOffset = 0;
|
||||
uint32 firstIndex = 0;
|
||||
uint32 numIndices = 0;
|
||||
AABB bounding;
|
||||
uint32 numMeshlets = 0;
|
||||
uint32 meshletOffset = 0;
|
||||
uint32 firstIndex = 0;
|
||||
uint32 numIndices = 0;
|
||||
};
|
||||
struct DrawCallOffsets
|
||||
{
|
||||
uint32 instanceOffset = 0;
|
||||
uint32 instanceOffset = 0;
|
||||
};
|
||||
|
||||
struct MeshletCullingInfo
|
||||
{
|
||||
uint64_t cull[256 / 64];
|
||||
};
|
||||
struct BatchedDrawCall
|
||||
{
|
||||
PMaterialInstance materialInstance;
|
||||
DrawCallOffsets offsets;
|
||||
Array<InstanceData> instanceData;
|
||||
Array<MeshData> instanceMeshData;
|
||||
PMaterialInstance materialInstance;
|
||||
DrawCallOffsets offsets;
|
||||
Array<InstanceData> instanceData;
|
||||
Array<MeshData> instanceMeshData;
|
||||
};
|
||||
struct MaterialData
|
||||
{
|
||||
PMaterial material;
|
||||
Array<BatchedDrawCall> instances;
|
||||
PMaterial material;
|
||||
Array<BatchedDrawCall> instances;
|
||||
};
|
||||
void resetMeshData();
|
||||
void updateMesh(PMesh mesh, Component::Transform& transform);
|
||||
void updateMesh(PMesh mesh, Component::Transform &transform);
|
||||
void createDescriptors();
|
||||
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
||||
MeshId allocateVertexData(uint64 numVertices);
|
||||
uint64 getMeshOffset(MeshId id);
|
||||
uint64 getMeshVertexCount(MeshId id);
|
||||
virtual void serializeMesh(MeshId id, uint64 numVertices, ArchiveBuffer& buffer) = 0;
|
||||
virtual void deserializeMesh(MeshId id, ArchiveBuffer& buffer) = 0;
|
||||
virtual void serializeMesh(MeshId id, uint64 numVertices, ArchiveBuffer &buffer) = 0;
|
||||
virtual void deserializeMesh(MeshId id, ArchiveBuffer &buffer) = 0;
|
||||
virtual void bindBuffers(Gfx::PRenderCommand command) = 0;
|
||||
virtual Gfx::PDescriptorLayout getVertexDataLayout() = 0;
|
||||
virtual Gfx::PDescriptorSet getVertexDataSet() = 0;
|
||||
@@ -73,26 +78,28 @@ public:
|
||||
Gfx::PIndexBuffer getIndexBuffer() { return indexBuffer; }
|
||||
Gfx::PDescriptorLayout getInstanceDataLayout() { return instanceDataLayout; }
|
||||
Gfx::PDescriptorSet getInstanceDataSet() { return descriptorSet; }
|
||||
const Array<MaterialData>& getMaterialData() const { return materialData; }
|
||||
const MeshData& getMeshData(MeshId id) { return meshData[id]; }
|
||||
const Array<MaterialData> &getMaterialData() const { return materialData; }
|
||||
const MeshData &getMeshData(MeshId id) { return meshData[id]; }
|
||||
uint64 getIndicesOffset(uint32 meshletIndex) { return meshlets[meshletIndex].indicesOffset; }
|
||||
static List<VertexData*> getList();
|
||||
static VertexData* findByTypeName(std::string name);
|
||||
uint64 getNumInstances() const { return instanceData.size(); }
|
||||
static List<VertexData *> getList();
|
||||
static VertexData *findByTypeName(std::string name);
|
||||
virtual void init(Gfx::PGraphics graphics);
|
||||
virtual void destroy();
|
||||
protected:
|
||||
|
||||
protected:
|
||||
virtual void resizeBuffers() = 0;
|
||||
virtual void updateBuffers() = 0;
|
||||
VertexData();
|
||||
struct MeshletDescription
|
||||
{
|
||||
AABB bounding;
|
||||
uint32 vertexCount;
|
||||
uint32 primitiveCount;
|
||||
uint32 vertexOffset;
|
||||
uint32 primitiveOffset;
|
||||
Vector color;
|
||||
uint32 indicesOffset = 0;
|
||||
AABB bounding;
|
||||
uint32 vertexCount;
|
||||
uint32 primitiveCount;
|
||||
uint32 vertexOffset;
|
||||
uint32 primitiveOffset;
|
||||
Vector color;
|
||||
uint32 indicesOffset = 0;
|
||||
};
|
||||
std::mutex materialDataLock;
|
||||
Array<MaterialData> materialData;
|
||||
@@ -110,9 +117,9 @@ protected:
|
||||
Gfx::OShaderBuffer meshletBuffer;
|
||||
Gfx::OShaderBuffer vertexIndicesBuffer;
|
||||
Gfx::OShaderBuffer primitiveIndicesBuffer;
|
||||
// temporary meshlet culling buffer, passed from task to mesh shader
|
||||
//Gfx::OShaderBuffer cullingBuffer;
|
||||
//Gfx::OShaderBuffer cullingOffsetBuffer;
|
||||
// Holds culling information for every meshlet for each instance
|
||||
Gfx::OShaderBuffer cullingBuffer;
|
||||
Gfx::OShaderBuffer cullingOffsetBuffer;
|
||||
// for legacy pipeline
|
||||
Gfx::OIndexBuffer indexBuffer;
|
||||
// Material data
|
||||
@@ -122,8 +129,8 @@ protected:
|
||||
Gfx::OShaderBuffer instanceMeshDataBuffer;
|
||||
Gfx::PDescriptorSet descriptorSet;
|
||||
uint64 idCounter;
|
||||
uint64 head;
|
||||
uint64 verticesAllocated;
|
||||
uint64 head;
|
||||
uint64 verticesAllocated;
|
||||
bool dirty;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user