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