1// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2// 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 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 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. 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 23namespace sw 24{ 25 class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> 26 { 27 public: 28 VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {} 29 virtual ~VertexRoutinePrototype() {}; 30 31 protected: 32 Pointer<Byte> vertex; 33 Pointer<Byte> batch; 34 Pointer<Byte> task; 35 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 46 protected: 47 Pointer<Byte> constants; 48 49 Int clipFlags; 50 51 RegisterArray<MAX_VERTEX_INPUTS> v; // Input registers 52 RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers 53 54 const VertexProcessor::State &state; 55 56 private: 57 virtual void pipeline(UInt &index) = 0; 58 59 typedef VertexProcessor::State::Input Stream; 60 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); 66 void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine); 67 void transformFeedback(const Pointer<Byte> &vertex, const UInt &primitiveNumber, const UInt &indexInPrimitive); 68 }; 69} 70 71#endif // sw_VertexRoutine_hpp 72