2020-06-02 11:46:18 +02:00
|
|
|
#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);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-08 01:44:47 +02:00
|
|
|
/*struct VertexStreamComponent
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-06-08 01:44:47 +02:00
|
|
|
};*/
|
2020-06-02 11:46:18 +02:00
|
|
|
|
|
|
|
|
typedef Array<VertexInputStream> VertexInputStreamArray;
|
2020-06-08 01:44:47 +02:00
|
|
|
struct MeshDescription;
|
|
|
|
|
DECLARE_REF(VertexFactory);
|
2020-06-02 11:46:18 +02:00
|
|
|
class VertexFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-08 01:44:47 +02:00
|
|
|
VertexFactory();
|
|
|
|
|
VertexFactory(MeshDescription description);
|
|
|
|
|
~VertexFactory();
|
2020-06-02 11:46:18 +02:00
|
|
|
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:
|
2020-06-08 01:44:47 +02:00
|
|
|
static List<PVertexFactory> registeredVertexFactories;
|
|
|
|
|
static std::mutex registeredVertexFactoryLock;
|
2020-06-02 11:46:18 +02:00
|
|
|
StaticArray<Gfx::VertexStream, 16> streams;
|
|
|
|
|
StaticArray<Gfx::VertexStream, 16> positionStream;
|
|
|
|
|
Gfx::PVertexDeclaration declaration;
|
|
|
|
|
Gfx::PVertexDeclaration positionDeclaration;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(VertexFactory);
|
|
|
|
|
} // namespace Seele
|