13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RRGENERICVECTOR_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RRGENERICVECTOR_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Reference Renderer 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ----------------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Generic vetor 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rr 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum GenericVecType 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GENERICVECTYPE_FLOAT = 0, 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GENERICVECTYPE_UINT32, 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GENERICVECTYPE_INT32, 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GENERICVECTYPE_LAST 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Generic vertex attrib 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Generic vertex attributes hold 4 32-bit scalar values that can be accessed 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * as floating-point or integer values. 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Aliasing rules must be adhered when accessing data (ie. writing as float 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * and reading as int has undefined result). 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GenericVec4 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry union 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 uData[4]; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 iData[4]; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float fData[4]; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } v; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline GenericVec4 (void) 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[0] = 0; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[1] = 0; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[2] = 0; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[3] = 0; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename ScalarType> 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GenericVec4 (const tcu::Vector<ScalarType, 4>& value) 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *this = value; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GenericVec4& operator= (const GenericVec4& value) 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[0] = value.v.iData[0]; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[1] = value.v.iData[1]; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[2] = value.v.iData[2]; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.iData[3] = value.v.iData[3]; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename ScalarType> 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GenericVec4& operator= (const tcu::Vector<ScalarType, 4>& value) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[0] = value[0]; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[1] = value[1]; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[2] = value[2]; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[3] = value[3]; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename ScalarType> 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline tcu::Vector<ScalarType, 4> get (void) const 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::Vector<ScalarType, 4>( 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[0], 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[1], 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[2], 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getAccess<ScalarType>()[3]); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename ScalarType> 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline ScalarType* getAccess (); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename ScalarType> 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline const ScalarType* getAccess () const; 10993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float* GenericVec4::getAccess<float> () 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.fData; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline const float* GenericVec4::getAccess<float> () const 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.fData; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint32* GenericVec4::getAccess<deUint32> () 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.uData; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline const deUint32* GenericVec4::getAccess<deUint32> () const 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.uData; 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deInt32* GenericVec4::getAccess<deInt32> () 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.iData; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<> 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline const deInt32* GenericVec4::getAccess<deInt32> () const 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.iData; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14901af60e03f051fb44046f80fdf45f1ebe1ffd5a4Pyry Haulos#endif // _RRGENERICVECTOR_HPP 150