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