1 #ifndef _RRVERTEXPACKET_HPP
2 #define _RRVERTEXPACKET_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Reference Renderer
5 * -----------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Vertex packet and Vertex packet allocator
24 *//*--------------------------------------------------------------------*/
27 #include "rrGenericVector.hpp"
28 #include "tcuVector.hpp"
35 class VertexPacketAllocator;
37 /*--------------------------------------------------------------------*//*!
38 * \brief Vertex packet
40 * Vertex packet contains inputs and outputs for vertex shading.
42 * Inputs consist of per-vertex vertex and instance indices. Attribute
43 * list that can be accessed using those indices is provided as separate
46 * Outputs include position, optional point size, and list of generic
47 * outputs that shader can write to. Number of VS outputs is specified
50 * VertexPacket instance must be created by VertexPacketAllocator as
51 * outputs must be allocated memory after the instance.
52 *//*--------------------------------------------------------------------*/
56 int instanceNdx; //!< Instance index.
57 int vertexNdx; //!< Vertex index.
60 tcu::Vec4 position; //!< Transformed position - must be written always.
61 float pointSize; //!< Point size, required when rendering points.
62 int primitiveID; //!< Geometry shader output
64 GenericVec4 outputs[1]; //!< Generic vertex shader outputs - passed to subsequent shader stages. Array length is the number of outputs.
65 // --- DO NOT ADD ANY MEMBER VARIABLES AFTER OUTPUTS, OUTPUTS IS VARIABLE-SIZED --- //
68 // Allow creation and destruction only for Allocator
70 VertexPacket (const VertexPacket&); // disabled, non-copyable
73 // Assignment cannot work without knowing the output array length => prevent assignment
74 VertexPacket& operator= (const VertexPacket&); // disabled, non-copyable
77 friend class VertexPacketAllocator;
78 } DE_WARN_UNUSED_TYPE;
81 /*--------------------------------------------------------------------*//*!
82 * \brief Vertex packet allocator
84 * Allocates vertex packets.
86 * Vertex packet must have enough space allocated for its outputs.
88 * All memory allocated for vertex packets is released when VertexPacketAllocator
89 * is destroyed. Allocated vertex packets should not be accessed after
90 * allocator is destroyed.
92 * alloc and allocArray will throw bad_alloc if allocation fails.
93 *//*--------------------------------------------------------------------*/
94 class VertexPacketAllocator
97 VertexPacketAllocator (const size_t numberOfVertexOutputs);
98 ~VertexPacketAllocator (void);
100 std::vector<VertexPacket*> allocArray (size_t count); // throws bad_alloc
101 VertexPacket* alloc (void); // throws bad_alloc
103 inline size_t getNumVertexOutputs (void) const { return m_numberOfVertexOutputs; }
106 VertexPacketAllocator (const VertexPacketAllocator&); // disabled, non-copyable
107 VertexPacketAllocator& operator= (const VertexPacketAllocator&); // disabled, non-copyable
109 const size_t m_numberOfVertexOutputs;
110 std::vector<deInt8*> m_allocations;
111 std::vector<VertexPacket*> m_singleAllocPool;
112 } DE_WARN_UNUSED_TYPE;
116 #endif // _RRVERTEXPACKET_HPP