Files
Seele/src/Engine/Graphics/VertexShaderInput.h
T

68 lines
2.1 KiB
C++
Raw Normal View History

2020-06-02 11:46:18 +02:00
#pragma once
#include "MinimalEngine.h"
#include "GraphicsEnums.h"
#include "GraphicsResources.h"
2020-06-02 11:46:18 +02:00
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);
}
};
typedef Array<VertexInputStream> VertexInputStreamArray;
2020-06-08 01:44:47 +02:00
struct MeshDescription;
DECLARE_REF(VertexShaderInput);
class VertexShaderInput
2020-06-02 11:46:18 +02:00
{
public:
VertexShaderInput(std::string name);
VertexShaderInput(MeshDescription description, std::string name);
~VertexShaderInput();
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;}
std::string getName() const { return name; }
std::string getCode() const { return code; }
2020-06-02 11:46:18 +02:00
private:
static List<PVertexShaderInput> registeredInputs;
static std::mutex registeredInputsLock;
Array<Gfx::VertexAttribute> layout;
2020-06-02 11:46:18 +02:00
StaticArray<Gfx::VertexStream, 16> streams;
StaticArray<Gfx::VertexStream, 16> positionStreams;
2020-06-02 11:46:18 +02:00
Gfx::PVertexDeclaration declaration;
Gfx::PVertexDeclaration positionDeclaration;
std::string name;
std::string code;
2020-06-02 11:46:18 +02:00
};
DEFINE_REF(VertexShaderInput);
2020-06-02 11:46:18 +02:00
} // namespace Seele