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 "ShaderCore.hpp" |
19 | #include "SpirvShader.hpp" |
20 | #include "Device/Color.hpp" |
21 | #include "Device/VertexProcessor.hpp" |
22 | |
23 | namespace vk |
24 | { |
25 | class PipelineLayout; |
26 | } // namespace vk |
27 | |
28 | namespace sw |
29 | { |
30 | class VertexRoutinePrototype : public VertexRoutineFunction |
31 | { |
32 | public: |
33 | VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {} |
34 | virtual ~VertexRoutinePrototype() {} |
35 | |
36 | protected: |
37 | Pointer<Byte> vertex; |
38 | Pointer<UInt> batch; |
39 | Pointer<Byte> task; |
40 | Pointer<Byte> data; |
41 | }; |
42 | |
43 | class VertexRoutine : public VertexRoutinePrototype |
44 | { |
45 | public: |
46 | VertexRoutine( |
47 | const VertexProcessor::State &state, |
48 | vk::PipelineLayout const *pipelineLayout, |
49 | SpirvShader const *spirvShader); |
50 | virtual ~VertexRoutine(); |
51 | |
52 | void generate(); |
53 | |
54 | protected: |
55 | Pointer<Byte> constants; |
56 | |
57 | Int clipFlags; |
58 | |
59 | SpirvRoutine routine; |
60 | |
61 | const VertexProcessor::State &state; |
62 | SpirvShader const * const spirvShader; |
63 | |
64 | private: |
65 | virtual void program(Pointer<UInt> &batch, UInt& vertexCount) = 0; |
66 | |
67 | typedef VertexProcessor::State::Input Stream; |
68 | |
69 | Vector4f readStream(Pointer<Byte> &buffer, UInt &stride, const Stream &stream, Pointer<UInt> &batch, |
70 | bool robustBufferAccess, UInt& robustnessSize, Int baseVertex); |
71 | void readInput(Pointer<UInt> &batch); |
72 | void computeClipFlags(); |
73 | void writeCache(Pointer<Byte> &vertexCache, Pointer<UInt> &tagCache, Pointer<UInt> &batch); |
74 | void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheEntry); |
75 | }; |
76 | } |
77 | |
78 | #endif // sw_VertexRoutine_hpp |
79 | |