OSDN Git Service

Make vertex registers members of routine classes.
[android-x86/external-swiftshader.git] / src / Shader / VertexRoutine.hpp
1 // SwiftShader Software Renderer
2 //
3 // Copyright(c) 2005-2013 TransGaming Inc.
4 //
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
6 // transcribed, stored in a retrieval system, translated into any human or computer
7 // language by any means, or disclosed to third parties without the explicit written
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
9 // or implied, including but not limited to any patent rights, are granted to you.
10 //
11
12 #ifndef sw_VertexRoutine_hpp
13 #define sw_VertexRoutine_hpp
14
15 #include "Renderer/Color.hpp"
16 #include "Renderer/VertexProcessor.hpp"
17 #include "ShaderCore.hpp"
18 #include "VertexShader.hpp"
19
20 namespace sw
21 {
22         class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)>
23         {
24         public:
25                 VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {}
26                 virtual ~VertexRoutinePrototype() {};
27
28         protected:
29                 const Pointer<Byte> vertex;
30                 const Pointer<Byte> batch;
31                 const Pointer<Byte> task;
32                 const Pointer<Byte> data;
33         };
34
35         class VertexRoutine : public VertexRoutinePrototype
36         {
37         public:
38                 VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader);
39                 virtual ~VertexRoutine();
40
41                 void generate();
42
43         protected:
44                 Pointer<Byte> constants;
45
46                 Int clipFlags;
47
48                 RegisterArray<16> v;   // Varying registers
49                 RegisterArray<12> o;   // Output registers
50
51                 const VertexProcessor::State &state;
52
53         private:
54                 virtual void pipeline() = 0;
55
56                 typedef VertexProcessor::State::Input Stream;
57
58                 Vector4f readStream(Pointer<Byte> &buffer, UInt &stride, const Stream &stream, const UInt &index);
59                 void readInput(UInt &index);
60                 void computeClipFlags();
61                 void postTransform();
62                 void writeCache(Pointer<Byte> &cacheLine);
63                 void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
64         };
65 }
66
67 #endif   // sw_VertexRoutine_hpp