1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Reference Renderer
3 * -----------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Primitive packet
22 *//*--------------------------------------------------------------------*/
23
24 #include "rrPrimitivePacket.hpp"
25
26 #include "rrVertexPacket.hpp"
27
28 namespace rr
29 {
30
GeometryEmitter(VertexPacketAllocator & vpalloc,size_t numVertices)31 GeometryEmitter::GeometryEmitter (VertexPacketAllocator& vpalloc, size_t numVertices)
32 : m_vpalloc (vpalloc)
33 , m_numEmitted (0)
34 , m_maxVertices (numVertices)
35 {
36 }
37
EmitVertex(const tcu::Vec4 & position,float pointSize,const GenericVec4 * varyings,int primitiveID)38 void GeometryEmitter::EmitVertex (const tcu::Vec4& position, float pointSize, const GenericVec4* varyings, int primitiveID)
39 {
40 VertexPacket* packet;
41
42 if (++m_numEmitted > m_maxVertices)
43 {
44 DE_FATAL("Undefined results, too many vertices emitted.");
45 return;
46 }
47
48 packet = m_vpalloc.alloc();
49
50 packet->position = position;
51 packet->pointSize = pointSize;
52 packet->primitiveID = primitiveID;
53
54 for (size_t ndx = 0; ndx < m_vpalloc.getNumVertexOutputs(); ++ndx)
55 packet->outputs[ndx] = varyings[ndx];
56
57 m_emitted.push_back(packet);
58 }
59
EndPrimitive(void)60 void GeometryEmitter::EndPrimitive (void)
61 {
62 m_numEmitted = 0;
63 m_emitted.push_back(DE_NULL);
64 }
65
moveEmittedTo(std::vector<VertexPacket * > & output)66 void GeometryEmitter::moveEmittedTo (std::vector<VertexPacket*>& output)
67 {
68 m_emitted.swap(output);
69 m_emitted.clear();
70 }
71
72 } // rr
73