1 #ifndef _RRGENERICVECTOR_HPP
2 #define _RRGENERICVECTOR_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 Generic vetor
24 *//*--------------------------------------------------------------------*/
27 #include "tcuVector.hpp"
34 GENERICVECTYPE_FLOAT = 0,
35 GENERICVECTYPE_UINT32,
41 /*--------------------------------------------------------------------*//*!
42 * \brief Generic vertex attrib
44 * Generic vertex attributes hold 4 32-bit scalar values that can be accessed
45 * as floating-point or integer values.
47 * Aliasing rules must be adhered when accessing data (ie. writing as float
48 * and reading as int has undefined result).
49 *//*--------------------------------------------------------------------*/
61 inline GenericVec4 (void)
69 template<typename ScalarType>
70 explicit GenericVec4 (const tcu::Vector<ScalarType, 4>& value)
75 GenericVec4& operator= (const GenericVec4& value)
77 v.iData[0] = value.v.iData[0];
78 v.iData[1] = value.v.iData[1];
79 v.iData[2] = value.v.iData[2];
80 v.iData[3] = value.v.iData[3];
84 template<typename ScalarType>
85 GenericVec4& operator= (const tcu::Vector<ScalarType, 4>& value)
87 getAccess<ScalarType>()[0] = value[0];
88 getAccess<ScalarType>()[1] = value[1];
89 getAccess<ScalarType>()[2] = value[2];
90 getAccess<ScalarType>()[3] = value[3];
94 template<typename ScalarType>
95 inline tcu::Vector<ScalarType, 4> get (void) const
97 return tcu::Vector<ScalarType, 4>(
98 getAccess<ScalarType>()[0],
99 getAccess<ScalarType>()[1],
100 getAccess<ScalarType>()[2],
101 getAccess<ScalarType>()[3]);
104 template<typename ScalarType>
105 inline ScalarType* getAccess ();
107 template<typename ScalarType>
108 inline const ScalarType* getAccess () const;
109 } DE_WARN_UNUSED_TYPE;
112 inline float* GenericVec4::getAccess<float> ()
118 inline const float* GenericVec4::getAccess<float> () const
124 inline deUint32* GenericVec4::getAccess<deUint32> ()
130 inline const deUint32* GenericVec4::getAccess<deUint32> () const
136 inline deInt32* GenericVec4::getAccess<deInt32> ()
142 inline const deInt32* GenericVec4::getAccess<deInt32> () const
149 #endif // _RRGENERICVECTOR_HPP