1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef sw_VertexShader_hpp
16 #define sw_VertexShader_hpp
19 #include "Main/Config.hpp"
23 class VertexShader : public Shader
26 enum AttribType : unsigned char
32 ATTRIBTYPE_LAST = ATTRIBTYPE_UINT
35 explicit VertexShader(const VertexShader *vs = 0);
36 explicit VertexShader(const unsigned long *token);
38 virtual ~VertexShader();
40 static int validate(const unsigned long *const token); // Returns number of instructions if valid
41 bool containsTextureSampling() const;
43 void setInput(int inputIdx, const Semantic& semantic, AttribType attribType = ATTRIBTYPE_FLOAT);
44 void setOutput(int outputIdx, int nbComponents, const Semantic& semantic);
45 void setPositionRegister(int posReg);
46 void setPointSizeRegister(int ptSizeReg);
47 void declareInstanceId() { instanceIdDeclared = true; }
48 void declareVertexId() { vertexIdDeclared = true; }
50 const Semantic& getInput(int inputIdx) const;
51 const Semantic& getOutput(int outputIdx, int component) const;
52 AttribType getAttribType(int inputIndex) const;
53 int getPositionRegister() const { return positionRegister; }
54 int getPointSizeRegister() const { return pointSizeRegister; }
55 bool isInstanceIdDeclared() const { return instanceIdDeclared; }
56 bool isVertexIdDeclared() const { return vertexIdDeclared; }
62 void analyzeTextureSampling();
64 Semantic input[MAX_VERTEX_INPUTS];
65 Semantic output[MAX_VERTEX_OUTPUTS][4];
67 AttribType attribType[MAX_VERTEX_INPUTS];
70 int pointSizeRegister;
72 bool instanceIdDeclared;
73 bool vertexIdDeclared;
78 #endif // sw_VertexShader_hpp