#ifndef MATERIALTECHSET_H
#define MATERIALTECHSET_H

#include "d3dresource.h"
#include "materialpixelshader.h"

#include "QString"
#include "qobject.h"

struct MaterialStreamRouting
{
    quint8 source;
    quint8 dest;
};

struct D3DVertexDeclaration : D3DResource
{
};

struct MaterialVertexStreamRouting
{
    MaterialStreamRouting data[16];
    D3DVertexDeclaration *decl[15];
};

struct MaterialVertexDeclaration
{
    int streamCount;
    bool hasOptionalSource;
    MaterialVertexStreamRouting routing;
};

struct D3DVertexShader : D3DResource
{
};

struct GfxVertexShaderLoadDef
{
    qint32 cachedPartPtr;
    QVector<int> cachedPart;
    qint32 physicalPartPtr;
    QVector<int> physicalPart;
    int cachedPartSize;
    int physicalPartSize;
};

struct MaterialVertexShaderProgram
{
    std::shared_ptr<D3DVertexShader> vertexShader;
    GfxVertexShaderLoadDef loadDef;
};

struct MaterialVertexShader
{
    QString name;
    MaterialVertexShaderProgram prog;
};

struct MaterialArgumentCodeConst
{
    int index;
    int firstRow;
    int rowCount;
};

struct MaterialArgumentDef
{
    const float *literalConst;
    MaterialArgumentCodeConst codeConst;
    unsigned int codeSampler;
    unsigned int nameHash;
};

struct MaterialShaderArgument
{
    int type;
    int dest;
    MaterialArgumentDef u;
};

struct MaterialPass
{
    std::shared_ptr<MaterialVertexDeclaration> vertexDecl;
    QVector<std::shared_ptr<MaterialVertexShader>> vertexShaderArray;
    std::shared_ptr<MaterialVertexShader> vertexShader;
    std::shared_ptr<MaterialPixelShader> pixelShader;
    int perPrimArgCount;
    int perObjArgCount;
    int stableArgCount;
    int customSamplerFlags;
    int precompiledIndex;
    std::shared_ptr<MaterialShaderArgument> args;
};

struct MaterialTechnique
{
    QString *name;
    int flags;
    int passCount;
    QVector<std::shared_ptr<MaterialPass>> passArray;
};

struct MaterialTechSet
{
    QString name;
    int worldVertFormat;

    qint32 remappedPtr;
    std::shared_ptr<MaterialTechSet> remappedTechniqueSet;

    QVector<qint32> techPtrs;
    QVector<std::shared_ptr<MaterialTechnique>> techniques;
};

#endif // MATERIALTECHSET_H
