blob: 4aec45fa39684e0443a5d12a43eaa3c23d02de5a [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman66b8ab22014-05-06 15:57:45 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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 Bauman66b8ab22014-05-06 15:57:45 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
John Bauman66b8ab22014-05-06 15:57:45 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// 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 Bauman66b8ab22014-05-06 15:57:45 -040014
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
23namespace sw
24{
Nicolas Capensd2fad902016-01-15 17:35:58 -050025 class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)>
John Bauman66b8ab22014-05-06 15:57:45 -040026 {
Nicolas Capensd2fad902016-01-15 17:35:58 -050027 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 Bauman66b8ab22014-05-06 15:57:45 -040046 protected:
Nicolas Capens7551ac62016-01-20 17:11:53 -050047 Pointer<Byte> constants;
Nicolas Capens2ca19032016-01-15 16:54:13 -050048
Nicolas Capens7551ac62016-01-20 17:11:53 -050049 Int clipFlags;
John Bauman66b8ab22014-05-06 15:57:45 -040050
Nicolas Capensf0aef1a2016-05-18 14:44:21 -040051 RegisterArray<MAX_VERTEX_INPUTS> v; // Input registers
Nicolas Capensec0936c2016-05-18 12:32:02 -040052 RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers
Nicolas Capens2ca19032016-01-15 16:54:13 -050053
John Bauman66b8ab22014-05-06 15:57:45 -040054 const VertexProcessor::State &state;
John Bauman66b8ab22014-05-06 15:57:45 -040055
Nicolas Capens2ca19032016-01-15 16:54:13 -050056 private:
Nicolas Capensb4fb3672016-01-15 17:02:41 -050057 virtual void pipeline() = 0;
John Bauman66b8ab22014-05-06 15:57:45 -040058
59 typedef VertexProcessor::State::Input Stream;
Nicolas Capens2ca19032016-01-15 16:54:13 -050060
Nicolas Capensb4fb3672016-01-15 17:02:41 -050061 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 Capens00bfa182016-05-20 21:30:54 -070066 void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
67 void transformFeedback(const Pointer<Byte> &vertex, const UInt &primitiveNumber, const UInt &indexInPrimitive);
John Bauman66b8ab22014-05-06 15:57:45 -040068 };
69}
70
71#endif // sw_VertexRoutine_hpp