Redo of render paths
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class BasePass
|
||||
{
|
||||
public:
|
||||
BasePass();
|
||||
~BasePass();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -0,0 +1,10 @@
|
||||
target_sources(SeeleEngine
|
||||
PRIVATE
|
||||
BasePass.h
|
||||
BasePass.cpp
|
||||
DepthPrepass.h
|
||||
DepthPrepass.cpp
|
||||
MeshProcessor.h
|
||||
MeshProcessor.cpp
|
||||
VertexFactory.h
|
||||
VertexFactory.cpp)
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "MeshProcessor.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "VertexFactory.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
MeshProcessor::MeshProcessor(const PScene scene, Gfx::PGraphics graphics)
|
||||
: scene(scene)
|
||||
, graphics(graphics)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MeshProcessor::~MeshProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
void MeshProcessor::buildMeshDrawCommands(
|
||||
const MeshBatch& meshBatch,
|
||||
const PPrimitiveComponent primitiveComponent,
|
||||
PMaterial material,
|
||||
Gfx::PVertexShader vertexShader,
|
||||
Gfx::PControlShader controlShader,
|
||||
Gfx::PEvaluationShader evaluationShader,
|
||||
Gfx::PGeometryShader geometryShader,
|
||||
Gfx::PFragmentShader fragmentShader,
|
||||
bool positionOnly)
|
||||
{
|
||||
const PVertexFactory vertexFactory = meshBatch.vertexFactory;
|
||||
|
||||
GraphicsPipelineCreateInfo pipelineInitializer;
|
||||
pipelineInitializer.topology = meshBatch.topology;
|
||||
Gfx::PVertexDeclaration vertexDecl = positionOnly ? vertexFactory->getPositionDeclaration() : vertexFactory->getDeclaration();
|
||||
pipelineInitializer.vertexDeclaration = vertexDecl;
|
||||
pipelineInitializer.vertexShader = vertexShader;
|
||||
pipelineInitializer.controlShader = controlShader;
|
||||
pipelineInitializer.evalShader = evaluationShader;
|
||||
pipelineInitializer.geometryShader = geometryShader;
|
||||
pipelineInitializer.fragmentShader = fragmentShader;
|
||||
|
||||
VertexInputStreamArray vertexStreams;
|
||||
if(positionOnly)
|
||||
{
|
||||
vertexFactory->getPositionOnlyStream(vertexStreams);
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexFactory->getStreams(vertexStreams);
|
||||
}
|
||||
if(vertexShader != nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include "Graphics/MeshBatch.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class MeshProcessor
|
||||
{
|
||||
public:
|
||||
MeshProcessor(const PScene scene, Gfx::PGraphics graphics);
|
||||
virtual ~MeshProcessor();
|
||||
private:
|
||||
PScene scene;
|
||||
Gfx::PGraphics graphics;
|
||||
virtual void addMeshBatch(
|
||||
const MeshBatch& meshBatch,
|
||||
const PPrimitiveComponent primitiveComponent,
|
||||
int32 staticMeshId = -1) = 0;
|
||||
void buildMeshDrawCommands(
|
||||
const MeshBatch& meshBatch,
|
||||
const PPrimitiveComponent primitiveComponent,
|
||||
PMaterial material,
|
||||
Gfx::PVertexShader vertexShader,
|
||||
Gfx::PControlShader controlShader,
|
||||
Gfx::PEvaluationShader evaluationShader,
|
||||
Gfx::PGeometryShader geometryShader,
|
||||
Gfx::PFragmentShader fragmentShader,
|
||||
bool positionOnly);
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "VertexFactory.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
void VertexFactory::getStreams(VertexInputStreamArray& outVertexStreams) const
|
||||
{
|
||||
for(uint32 i = 0; i < streams.size(); ++i)
|
||||
{
|
||||
const Gfx::VertexStream& stream = streams[i];
|
||||
if(stream.vertexBuffer == nullptr)
|
||||
{
|
||||
outVertexStreams.add(VertexInputStream(i, 0, nullptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VertexFactory::getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const
|
||||
{
|
||||
for (uint32 i = 0; i < positionStream.size(); ++i)
|
||||
{
|
||||
const Gfx::VertexStream& stream = positionStream[i];
|
||||
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
struct VertexInputStream
|
||||
{
|
||||
uint32 streamIndex : 4;
|
||||
uint32 offset : 28;
|
||||
Gfx::PVertexBuffer vertexBuffer;
|
||||
|
||||
VertexInputStream()
|
||||
: streamIndex(0), offset(0), vertexBuffer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
VertexInputStream(uint32 streamIndex, uint32 offset, Gfx::PVertexBuffer vertexBuffer)
|
||||
: streamIndex(streamIndex), offset(offset), vertexBuffer(vertexBuffer)
|
||||
{
|
||||
assert(this->streamIndex == streamIndex && this->offset == offset);
|
||||
}
|
||||
|
||||
inline bool operator==(const VertexInputStream &rhs) const
|
||||
{
|
||||
if (streamIndex != rhs.streamIndex || offset != rhs.offset || vertexBuffer != rhs.vertexBuffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline bool operator!=(const VertexInputStream &rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
struct VertexStreamComponent
|
||||
{
|
||||
const Gfx::PVertexBuffer vertexBuffer = nullptr;
|
||||
|
||||
uint32 streamOffset = 0;
|
||||
|
||||
uint8 offset = 0;
|
||||
|
||||
uint8 stride;
|
||||
|
||||
Gfx::SeFormat type;
|
||||
|
||||
VertexStreamComponent()
|
||||
{
|
||||
}
|
||||
|
||||
VertexStreamComponent(const Gfx::PVertexBuffer vertexBuffer, uint32 offset, uint32 stride, Gfx::SeFormat type)
|
||||
: vertexBuffer(vertexBuffer)
|
||||
, streamOffset(0)
|
||||
, offset(offset)
|
||||
, stride(stride)
|
||||
, type(type)
|
||||
{
|
||||
}
|
||||
|
||||
VertexStreamComponent(const Gfx::PVertexBuffer vertexBuffer, uint32 streamOffset, uint32 offset, uint32 stride, Gfx::SeFormat type)
|
||||
: vertexBuffer(vertexBuffer)
|
||||
, streamOffset(streamOffset)
|
||||
, offset(offset)
|
||||
, stride(stride)
|
||||
, type(type)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef Array<VertexInputStream> VertexInputStreamArray;
|
||||
class VertexFactory
|
||||
{
|
||||
public:
|
||||
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:
|
||||
StaticArray<Gfx::VertexStream, 16> streams;
|
||||
StaticArray<Gfx::VertexStream, 16> positionStream;
|
||||
Gfx::PVertexDeclaration declaration;
|
||||
Gfx::PVertexDeclaration positionDeclaration;
|
||||
};
|
||||
DEFINE_REF(VertexFactory);
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user