Loading logic moved to Asset classes

This commit is contained in:
Dynamitos
2020-06-08 01:44:47 +02:00
parent 356e6058fe
commit ab4a3b5e23
50 changed files with 966 additions and 558 deletions
@@ -15,9 +15,11 @@ MeshProcessor::~MeshProcessor()
{
}
void MeshProcessor::buildMeshDrawCommands(
void MeshProcessor::buildMeshDrawCommand(
const MeshBatch& meshBatch,
const PPrimitiveComponent primitiveComponent,
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
Gfx::PRenderCommand drawCommand,
PMaterial material,
Gfx::PVertexShader vertexShader,
Gfx::PControlShader controlShader,
@@ -37,6 +39,7 @@ void MeshProcessor::buildMeshDrawCommands(
pipelineInitializer.evalShader = evaluationShader;
pipelineInitializer.geometryShader = geometryShader;
pipelineInitializer.fragmentShader = fragmentShader;
pipelineInitializer.renderPass = renderPass;
VertexInputStreamArray vertexStreams;
if(positionOnly)
@@ -47,8 +50,12 @@ void MeshProcessor::buildMeshDrawCommands(
{
vertexFactory->getStreams(vertexStreams);
}
if(vertexShader != nullptr)
drawCommand->bindVertexBuffer(vertexStreams);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInitializer);
drawCommand->bindPipeline(pipeline);
for(auto element : meshBatch.elements)
{
}
drawCommand->bindIndexBuffer(element.indexBuffer);
drawCommand->draw(element);
}
}
@@ -18,9 +18,11 @@ private:
const MeshBatch& meshBatch,
const PPrimitiveComponent primitiveComponent,
int32 staticMeshId = -1) = 0;
void buildMeshDrawCommands(
void buildMeshDrawCommand(
const MeshBatch& meshBatch,
const PPrimitiveComponent primitiveComponent,
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
Gfx::PRenderCommand drawCommand,
PMaterial material,
Gfx::PVertexShader vertexShader,
Gfx::PControlShader controlShader,
@@ -1,7 +1,44 @@
#include "VertexFactory.h"
#include "Graphics/Mesh.h"
#include <memory>
using namespace Seele;
List<PVertexFactory> VertexFactory::registeredVertexFactories;
std::mutex VertexFactory::registeredVertexFactoryLock;
VertexFactory::VertexFactory()
{
std::scoped_lock lock(registeredVertexFactoryLock);
registeredVertexFactories.add(this);
}
VertexFactory::VertexFactory(MeshDescription description)
: declaration(description.declaration)
{
auto declStreams = declaration->getVertexStreams();
std::copy(declStreams.begin(), declStreams.end(), streams.begin());
uint32 positionStreamIndex = 0;
positionDeclaration = new Gfx::VertexDeclaration();
for (uint32 i = 0; i < declStreams.size(); i++)
{
if(description.layout[i] == VertexAttribute::POSITION)
{
positionStream[positionStreamIndex++] = declStreams[i];
positionDeclaration->addVertexStream(declStreams[i]);
}
}
std::scoped_lock lock(registeredVertexFactoryLock);
registeredVertexFactories.add(this);
}
VertexFactory::~VertexFactory()
{
registeredVertexFactories.remove(registeredVertexFactories.find(this));
}
void VertexFactory::getStreams(VertexInputStreamArray& outVertexStreams) const
{
for(uint32 i = 0; i < streams.size(); ++i)
@@ -35,7 +35,7 @@ struct VertexInputStream
}
};
struct VertexStreamComponent
/*struct VertexStreamComponent
{
const Gfx::PVertexBuffer vertexBuffer = nullptr;
@@ -68,21 +68,25 @@ struct VertexStreamComponent
, type(type)
{
}
};
};*/
typedef Array<VertexInputStream> VertexInputStreamArray;
struct MeshDescription;
DECLARE_REF(VertexFactory);
class VertexFactory
{
public:
VertexFactory()
{
}
VertexFactory();
VertexFactory(MeshDescription description);
~VertexFactory();
void getStreams(VertexInputStreamArray& outVertexStreams) const;
void getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const;
virtual bool supportsTesselation() { return false; }
Gfx::PVertexDeclaration getDeclaration() const {return declaration;}
Gfx::PVertexDeclaration getPositionDeclaration() const {return positionDeclaration;}
private:
static List<PVertexFactory> registeredVertexFactories;
static std::mutex registeredVertexFactoryLock;
StaticArray<Gfx::VertexStream, 16> streams;
StaticArray<Gfx::VertexStream, 16> positionStream;
Gfx::PVertexDeclaration declaration;