summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.h
blob: 91a0d8e9114929ec90f35df27dbbf08e3fa07a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (C) 2003-2009 Dolphin Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License 2.0 for more details.

// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/

// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/

#ifndef _VERTEXLOADER_H_
#define _VERTEXLOADER_H_

#include "Common.h"

#include "NativeVertexFormat.h"
#include "CPMemLoader.h"

class SetupUnit;

class SWVertexLoader
{
    u32 m_VertexSize;

    VAT* m_CurrentVat;
    
    TPipelineFunction m_positionLoader;
    TPipelineFunction m_normalLoader;
    TPipelineFunction m_colorLoader[2];
    TPipelineFunction m_texCoordLoader[8];

    InputVertexData m_Vertex;

    typedef void (*AttributeLoader)(SWVertexLoader*, InputVertexData*, u8);
    struct AttrLoaderCall
    {
        AttributeLoader loader;
        u8 index;
    };
    AttrLoaderCall m_AttributeLoaders[1+8+1+1+2+8];
    int m_NumAttributeLoaders;
    void AddAttributeLoader(AttributeLoader loader, u8 index=0);

    // attribute loader functions
    static void LoadPosMtx(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 unused);
    static void LoadTexMtx(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 index);
    static void LoadPosition(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 unused);
    static void LoadNormal(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 unused);
    static void LoadColor(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 index);
    static void LoadTexCoord(SWVertexLoader *vertexLoader, InputVertexData *vertex, u8 index);

    SetupUnit *m_SetupUnit;

	bool m_TexGenSpecialCase;

public:
    SWVertexLoader();
    ~SWVertexLoader();

    void SetFormat(u8 attributeIndex, u8 primitiveType);

    u32 GetVertexSize() { return m_VertexSize; }

    void LoadVertex();   

};

#endif