1 // SwiftShader Software Renderer
3 // Copyright(c) 2005-2013 TransGaming Inc.
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.
12 #ifndef sw_VertexRoutine_hpp
13 #define sw_VertexRoutine_hpp
15 #include "Renderer/Color.hpp"
16 #include "Renderer/VertexProcessor.hpp"
17 #include "ShaderCore.hpp"
18 #include "VertexShader.hpp"
27 Registers(const VertexShader *shader) :
28 r(shader && shader->dynamicallyIndexedTemporaries),
29 v(shader && shader->dynamicallyIndexedInput),
30 o(shader && shader->dynamicallyIndexedOutput)
33 enableStack[0] = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
35 if(shader && shader->containsBreakInstruction())
37 enableBreak = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
40 if(shader && shader->containsContinueInstruction())
42 enableContinue = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
45 if(shader && shader->containsLeaveInstruction())
47 enableLeave = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
52 Pointer<Byte> constants;
57 RegisterArray<4096> r;
63 Array<Int, 4> increment;
64 Array<Int, 4> iteration;
67 Int stackIndex; // FIXME: Inc/decrement callStack
68 Array<UInt, 16> callStack;
71 Array<Int4, 1 + 24> enableStack;
78 VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader);
80 virtual ~VertexRoutine();
83 Routine *getRoutine();
86 const VertexProcessor::State &state;
87 const VertexShader *const shader;
90 virtual void pipeline(Registers &r) = 0;
92 typedef VertexProcessor::State::Input Stream;
94 Vector4f readStream(Registers &r, Pointer<Byte> &buffer, UInt &stride, const Stream &stream, const UInt &index);
95 void readInput(Registers &r, UInt &index);
96 void computeClipFlags(Registers &r);
97 void postTransform(Registers &r);
98 void writeCache(Pointer<Byte> &cacheLine, Registers &r);
99 void writeVertex(Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
105 #endif // sw_VertexRoutine_hpp