Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 14 | |
| 15 | #ifndef sw_VertexRoutine_hpp |
| 16 | #define sw_VertexRoutine_hpp |
| 17 | |
| 18 | #include "Renderer/Color.hpp" |
| 19 | #include "Renderer/VertexProcessor.hpp" |
| 20 | #include "ShaderCore.hpp" |
| 21 | #include "VertexShader.hpp" |
| 22 | |
| 23 | namespace sw |
| 24 | { |
Nicolas Capens | d2fad90 | 2016-01-15 17:35:58 -0500 | [diff] [blame] | 25 | class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 26 | { |
Nicolas Capens | d2fad90 | 2016-01-15 17:35:58 -0500 | [diff] [blame] | 27 | public: |
| 28 | VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {} |
| 29 | virtual ~VertexRoutinePrototype() {}; |
| 30 | |
| 31 | protected: |
| 32 | const Pointer<Byte> vertex; |
| 33 | const Pointer<Byte> batch; |
| 34 | const Pointer<Byte> task; |
| 35 | const Pointer<Byte> data; |
| 36 | }; |
| 37 | |
| 38 | class VertexRoutine : public VertexRoutinePrototype |
| 39 | { |
| 40 | public: |
| 41 | VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader); |
| 42 | virtual ~VertexRoutine(); |
| 43 | |
| 44 | void generate(); |
| 45 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 46 | protected: |
Nicolas Capens | 7551ac6 | 2016-01-20 17:11:53 -0500 | [diff] [blame] | 47 | Pointer<Byte> constants; |
Nicolas Capens | 2ca1903 | 2016-01-15 16:54:13 -0500 | [diff] [blame] | 48 | |
Nicolas Capens | 7551ac6 | 2016-01-20 17:11:53 -0500 | [diff] [blame] | 49 | Int clipFlags; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 50 | |
Nicolas Capens | f0aef1a | 2016-05-18 14:44:21 -0400 | [diff] [blame] | 51 | RegisterArray<MAX_VERTEX_INPUTS> v; // Input registers |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 52 | RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers |
Nicolas Capens | 2ca1903 | 2016-01-15 16:54:13 -0500 | [diff] [blame] | 53 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 54 | const VertexProcessor::State &state; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 55 | |
Nicolas Capens | 2ca1903 | 2016-01-15 16:54:13 -0500 | [diff] [blame] | 56 | private: |
Nicolas Capens | b4fb367 | 2016-01-15 17:02:41 -0500 | [diff] [blame] | 57 | virtual void pipeline() = 0; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 58 | |
| 59 | typedef VertexProcessor::State::Input Stream; |
Nicolas Capens | 2ca1903 | 2016-01-15 16:54:13 -0500 | [diff] [blame] | 60 | |
Nicolas Capens | b4fb367 | 2016-01-15 17:02:41 -0500 | [diff] [blame] | 61 | Vector4f readStream(Pointer<Byte> &buffer, UInt &stride, const Stream &stream, const UInt &index); |
| 62 | void readInput(UInt &index); |
| 63 | void computeClipFlags(); |
| 64 | void postTransform(); |
| 65 | void writeCache(Pointer<Byte> &cacheLine); |
Nicolas Capens | 00bfa18 | 2016-05-20 21:30:54 -0700 | [diff] [blame] | 66 | void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine); |
| 67 | void transformFeedback(const Pointer<Byte> &vertex, const UInt &primitiveNumber, const UInt &indexInPrimitive); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 68 | }; |
| 69 | } |
| 70 | |
| 71 | #endif // sw_VertexRoutine_hpp |