xref: /aosp_15_r20/external/deqp/framework/referencerenderer/rrPrimitivePacket.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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,
39                                  int primitiveID)
40 {
41     VertexPacket *packet;
42 
43     if (++m_numEmitted > m_maxVertices)
44     {
45         DE_FATAL("Undefined results, too many vertices emitted.");
46         return;
47     }
48 
49     packet = m_vpalloc.alloc();
50 
51     packet->position    = position;
52     packet->pointSize   = pointSize;
53     packet->primitiveID = primitiveID;
54 
55     for (size_t ndx = 0; ndx < m_vpalloc.getNumVertexOutputs(); ++ndx)
56         packet->outputs[ndx] = varyings[ndx];
57 
58     m_emitted.push_back(packet);
59 }
60 
EndPrimitive(void)61 void GeometryEmitter::EndPrimitive(void)
62 {
63     m_numEmitted = 0;
64     m_emitted.push_back(DE_NULL);
65 }
66 
moveEmittedTo(std::vector<VertexPacket * > & output)67 void GeometryEmitter::moveEmittedTo(std::vector<VertexPacket *> &output)
68 {
69     m_emitted.swap(output);
70     m_emitted.clear();
71 }
72 
73 } // namespace rr
74