13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSVERTEXARRAYTESTS_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSVERTEXARRAYTESTS_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module 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 Vertex array and buffer tests 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestCase.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deFloat16.h" 348ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi#include "deMath.h" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuFloat.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuPixelFormat.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContext.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace sglr 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceContextBuffers; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceContext; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Context; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // sglr 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Array 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Target 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note [mika] Are these actualy used somewhere? 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGET_ELEMENT_ARRAY = 0, 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGET_ARRAY, 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGET_LAST 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum InputType 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_FLOAT = 0, 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_FIXED, 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_DOUBLE, 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_BYTE, 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_SHORT, 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_UNSIGNED_BYTE, 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_UNSIGNED_SHORT, 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_INT, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_UNSIGNED_INT, 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_HALF, 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_UNSIGNED_INT_2_10_10_10, 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_INT_2_10_10_10, 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INPUTTYPE_LAST 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum OutputType 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_FLOAT = 0, 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_VEC2, 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_VEC3, 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_VEC4, 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_INT, 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_UINT, 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_IVEC2, 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_IVEC3, 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_IVEC4, 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_UVEC2, 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_UVEC3, 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_UVEC4, 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OUTPUTTYPE_LAST 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Usage 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_DYNAMIC_DRAW = 0, 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STATIC_DRAW, 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STREAM_DRAW, 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STREAM_READ, 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STREAM_COPY, 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STATIC_READ, 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_STATIC_COPY, 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_DYNAMIC_READ, 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_DYNAMIC_COPY, 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry USAGE_LAST 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Storage 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STORAGE_USER = 0, 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STORAGE_BUFFER, 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STORAGE_LAST 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Primitive 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVE_POINTS = 0, 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVE_TRIANGLES, 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVE_TRIANGLE_FAN, 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVE_TRIANGLE_STRIP, 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVE_LAST 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string targetToString (Target target); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string inputTypeToString (InputType type); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string outputTypeToString (OutputType type); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string usageTypeToString (Usage usage); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string storageToString (Storage storage); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string primitiveToString (Primitive primitive); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static int inputTypeSize (InputType type); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~Array (void) {} 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void data (Target target, int size, const char* data, Usage usage) = 0; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void subdata (Target target, int offset, int size, const char* data) = 0; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void bind (int attribNdx, int offset, int size, InputType inType, OutputType outType, bool normalized, int stride) = 0; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void unBind (void) = 0; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool isBound (void) const = 0; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getComponentCount (void) const = 0; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Target getTarget (void) const = 0; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual InputType getInputType (void) const = 0; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual OutputType getOutputType (void) const = 0; 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Storage getStorageType (void) const = 0; 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool getNormalized (void) const = 0; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getStride (void) const = 0; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getAttribNdx (void) const = 0; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void setAttribNdx (int attribNdx) = 0; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ContextArray : public Array 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ContextArray (Storage storage, sglr::Context& context); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ContextArray (void); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void data (Target target, int size, const char* data, Usage usage); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void subdata (Target target, int offset, int size, const char* data); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void bind (int attribNdx, int offset, int size, InputType inType, OutputType outType, bool normalized, int stride); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void bindIndexArray (Array::Target storage); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void unBind (void) { m_bound = false; } 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool isBound (void) const { return m_bound; } 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getComponentCount (void) const { return m_componentCount; } 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Array::Target getTarget (void) const { return m_target; } 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Array::InputType getInputType (void) const { return m_inputType; } 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Array::OutputType getOutputType (void) const { return m_outputType; } 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Array::Storage getStorageType (void) const { return m_storage; } 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool getNormalized (void) const { return m_normalize; } 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getStride (void) const { return m_stride; } 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getAttribNdx (void) const { return m_attribNdx; } 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void setAttribNdx (int attribNdx) { m_attribNdx = attribNdx; } 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void glBind (deUint32 loc); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static deUint32 targetToGL (Array::Target target); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static deUint32 usageToGL (Array::Usage usage); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static deUint32 inputTypeToGL (Array::InputType type); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string outputTypeToGLType (Array::OutputType type); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static deUint32 primitiveToGL (Array::Primitive primitive); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Storage m_storage; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& m_ctx; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_glBuffer; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_bound; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_attribNdx; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_size; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry char* m_data; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_componentCount; 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Target m_target; 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType m_inputType; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OutputType m_outputType; 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_normalize; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_stride; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_offset; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ContextArrayPack 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ContextArrayPack (glu::RenderContext& renderCtx, sglr::Context& drawContext); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ContextArrayPack (void); 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Array* getArray (int i); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getArrayCount (void); 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void newArray (Array::Storage storage); 224a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos virtual void render (Array::Primitive primitive, int firstVertex, int vertexCount, bool useVao, float coordScale, float colorScale); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Surface& getSurface (void) const { return m_screen; } 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 228a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos void updateProgram (void); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& m_ctx; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<ContextArray*> m_arrays; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ShaderProgram* m_program; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface m_screen; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GLValue 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<class Type> 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class WrappedType 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static WrappedType<Type> create (Type value) { WrappedType<Type> v; v.m_value = value; return v; } 2458ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi static WrappedType<Type> fromFloat (float value) { WrappedType<Type> v; v.m_value = (Type)value; return v; } 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Type getValue (void) const { return m_value; } 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 248c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry inline WrappedType<Type> operator+ (const WrappedType<Type>& other) const { return WrappedType<Type>::create((Type)(m_value + other.getValue())); } 249c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry inline WrappedType<Type> operator* (const WrappedType<Type>& other) const { return WrappedType<Type>::create((Type)(m_value * other.getValue())); } 250c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry inline WrappedType<Type> operator/ (const WrappedType<Type>& other) const { return WrappedType<Type>::create((Type)(m_value / other.getValue())); } 2518ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedType<Type> operator% (const WrappedType<Type>& other) const { return WrappedType<Type>::create((Type)(m_value % other.getValue())); } 252c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry inline WrappedType<Type> operator- (const WrappedType<Type>& other) const { return WrappedType<Type>::create((Type)(m_value - other.getValue())); } 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline WrappedType<Type>& operator+= (const WrappedType<Type>& other) { m_value += other.getValue(); return *this; } 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline WrappedType<Type>& operator*= (const WrappedType<Type>& other) { m_value *= other.getValue(); return *this; } 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline WrappedType<Type>& operator/= (const WrappedType<Type>& other) { m_value /= other.getValue(); return *this; } 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline WrappedType<Type>& operator-= (const WrappedType<Type>& other) { m_value -= other.getValue(); return *this; } 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator== (const WrappedType<Type>& other) const { return m_value == other.m_value; } 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator!= (const WrappedType<Type>& other) const { return m_value != other.m_value; } 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator< (const WrappedType<Type>& other) const { return m_value < other.m_value; } 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator> (const WrappedType<Type>& other) const { return m_value > other.m_value; } 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator<= (const WrappedType<Type>& other) const { return m_value <= other.m_value; } 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator>= (const WrappedType<Type>& other) const { return m_value >= other.m_value; } 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 266a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos inline operator Type (void) const { return m_value; } 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<class T> 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline T to (void) const { return (T)m_value; } 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry private: 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Type m_value; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2738ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi template<class Type> 2748ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi class WrappedFloatType 2758ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi { 2768ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi public: 2778ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi static WrappedFloatType<Type> create (Type value) { WrappedFloatType<Type> v; v.m_value = value; return v; } 2788ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi static WrappedFloatType<Type> fromFloat (float value) { WrappedFloatType<Type> v; v.m_value = (Type)value; return v; } 2798ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline Type getValue (void) const { return m_value; } 2808ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi 2818ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type> operator+ (const WrappedFloatType<Type>& other) const { return WrappedFloatType<Type>::create((Type)(m_value + other.getValue())); } 2828ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type> operator* (const WrappedFloatType<Type>& other) const { return WrappedFloatType<Type>::create((Type)(m_value * other.getValue())); } 2838ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type> operator/ (const WrappedFloatType<Type>& other) const { return WrappedFloatType<Type>::create((Type)(m_value / other.getValue())); } 2848ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type> operator% (const WrappedFloatType<Type>& other) const { return WrappedFloatType<Type>::create((Type)(deMod(m_value, other.getValue()))); } 2858ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type> operator- (const WrappedFloatType<Type>& other) const { return WrappedFloatType<Type>::create((Type)(m_value - other.getValue())); } 2868ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi 2878ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type>& operator+= (const WrappedFloatType<Type>& other) { m_value += other.getValue(); return *this; } 2888ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type>& operator*= (const WrappedFloatType<Type>& other) { m_value *= other.getValue(); return *this; } 2898ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type>& operator/= (const WrappedFloatType<Type>& other) { m_value /= other.getValue(); return *this; } 2908ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline WrappedFloatType<Type>& operator-= (const WrappedFloatType<Type>& other) { m_value -= other.getValue(); return *this; } 2918ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi 2928ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator== (const WrappedFloatType<Type>& other) const { return m_value == other.m_value; } 2938ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator!= (const WrappedFloatType<Type>& other) const { return m_value != other.m_value; } 2948ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator< (const WrappedFloatType<Type>& other) const { return m_value < other.m_value; } 2958ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator> (const WrappedFloatType<Type>& other) const { return m_value > other.m_value; } 2968ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator<= (const WrappedFloatType<Type>& other) const { return m_value <= other.m_value; } 2978ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline bool operator>= (const WrappedFloatType<Type>& other) const { return m_value >= other.m_value; } 2988ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi 2998ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline operator Type (void) const { return m_value; } 3008ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi template<class T> 3018ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline T to (void) const { return (T)m_value; } 3028ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi private: 3038ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi Type m_value; 3048ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi }; 3058ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi 3068ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deInt16> Short; 3078ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deUint16> Ushort; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3098ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deInt8> Byte; 3108ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deUint8> Ubyte; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3128ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedFloatType<float> Float; 3138ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedFloatType<double> Double; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3158ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deInt32> Int; 3168ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi typedef WrappedType<deUint32> Uint; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class Half 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static Half create (float value) { Half h; h.m_value = floatToHalf(value); return h; } 3228ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi static Half fromFloat (float value) { Half h; h.m_value = floatToHalf(value); return h; } 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline deFloat16 getValue (void) const { return m_value; } 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half operator+ (const Half& other) const { return create(halfToFloat(m_value) + halfToFloat(other.getValue())); } 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half operator* (const Half& other) const { return create(halfToFloat(m_value) * halfToFloat(other.getValue())); } 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half operator/ (const Half& other) const { return create(halfToFloat(m_value) / halfToFloat(other.getValue())); } 3288ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline Half operator% (const Half& other) const { return create(deFloatMod(halfToFloat(m_value), halfToFloat(other.getValue()))); } 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half operator- (const Half& other) const { return create(halfToFloat(m_value) - halfToFloat(other.getValue())); } 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half& operator+= (const Half& other) { m_value = floatToHalf(halfToFloat(other.getValue()) + halfToFloat(m_value)); return *this; } 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half& operator*= (const Half& other) { m_value = floatToHalf(halfToFloat(other.getValue()) * halfToFloat(m_value)); return *this; } 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half& operator/= (const Half& other) { m_value = floatToHalf(halfToFloat(other.getValue()) / halfToFloat(m_value)); return *this; } 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Half& operator-= (const Half& other) { m_value = floatToHalf(halfToFloat(other.getValue()) - halfToFloat(m_value)); return *this; } 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator== (const Half& other) const { return m_value == other.m_value; } 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator!= (const Half& other) const { return m_value != other.m_value; } 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator< (const Half& other) const { return halfToFloat(m_value) < halfToFloat(other.m_value); } 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator> (const Half& other) const { return halfToFloat(m_value) > halfToFloat(other.m_value); } 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator<= (const Half& other) const { return halfToFloat(m_value) <= halfToFloat(other.m_value); } 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator>= (const Half& other) const { return halfToFloat(m_value) >= halfToFloat(other.m_value); } 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<class T> 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline T to (void) const { return (T)halfToFloat(m_value); } 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline static deFloat16 floatToHalf (float f); 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline static float halfToFloat (deFloat16 h); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry private: 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deFloat16 m_value; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class Fixed 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static Fixed create (deInt32 value) { Fixed v; v.m_value = value; return v; } 3568ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi static Fixed fromFloat (float value) { Fixed v; v.m_value = (deInt32)(value * 32768.0f); return v; } 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline deInt32 getValue (void) const { return m_value; } 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed operator+ (const Fixed& other) const { return create(m_value + other.getValue()); } 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed operator* (const Fixed& other) const { return create(m_value * other.getValue()); } 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed operator/ (const Fixed& other) const { return create(m_value / other.getValue()); } 3628ed28c1e05f2325dc4b20c8f471067b29188c82fMika Isojärvi inline Fixed operator% (const Fixed& other) const { return create(m_value % other.getValue()); } 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed operator- (const Fixed& other) const { return create(m_value - other.getValue()); } 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed& operator+= (const Fixed& other) { m_value += other.getValue(); return *this; } 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed& operator*= (const Fixed& other) { m_value *= other.getValue(); return *this; } 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed& operator/= (const Fixed& other) { m_value /= other.getValue(); return *this; } 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline Fixed& operator-= (const Fixed& other) { m_value -= other.getValue(); return *this; } 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator== (const Fixed& other) const { return m_value == other.m_value; } 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator!= (const Fixed& other) const { return m_value != other.m_value; } 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator< (const Fixed& other) const { return m_value < other.m_value; } 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator> (const Fixed& other) const { return m_value > other.m_value; } 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator<= (const Fixed& other) const { return m_value <= other.m_value; } 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator>= (const Fixed& other) const { return m_value >= other.m_value; } 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 377a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos inline operator deInt32 (void) const { return m_value; } 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<class T> 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline T to (void) const { return (T)m_value; } 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry private: 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 m_value; 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [mika] This is pretty messy 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue (void) : type(Array::INPUTTYPE_LAST) {} 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Float value) : type(Array::INPUTTYPE_FLOAT), fl(value) {} 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Fixed value) : type(Array::INPUTTYPE_FIXED), fi(value) {} 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Byte value) : type(Array::INPUTTYPE_BYTE), b(value) {} 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Ubyte value) : type(Array::INPUTTYPE_UNSIGNED_BYTE), ub(value) {} 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Short value) : type(Array::INPUTTYPE_SHORT), s(value) {} 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Ushort value) : type(Array::INPUTTYPE_UNSIGNED_SHORT), us(value) {} 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Int value) : type(Array::INPUTTYPE_INT), i(value) {} 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Uint value) : type(Array::INPUTTYPE_UNSIGNED_INT), ui(value) {} 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Half value) : type(Array::INPUTTYPE_HALF), h(value) {} 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry explicit GLValue (Double value) : type(Array::INPUTTYPE_DOUBLE), d(value) {} 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float toFloat (void) const; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static GLValue getMaxValue (Array::InputType type); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static GLValue getMinValue (Array::InputType type); 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType type; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry union 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Float fl; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Fixed fi; 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Double d; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Byte b; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Ubyte ub; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Short s; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Ushort us; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Int i; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Uint ui; 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Half h; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexArrayTest : public tcu::TestCase 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VertexArrayTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name ,const char* desc); 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~VertexArrayTest (void); 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void); 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VertexArrayTest (const VertexArrayTest& other); 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VertexArrayTest& operator= (const VertexArrayTest& other); 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void compare (void); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers* m_refBuffers; 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext* m_refContext; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context* m_glesContext; 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ContextArrayPack* m_glArrayPack; 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ContextArrayPack* m_rrArrayPack; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_isOk; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_maxDiffRed; 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_maxDiffGreen; 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_maxDiffBlue; 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiVertexArrayTest : public VertexArrayTest 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class Spec 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class ArraySpec 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ArraySpec (Array::InputType inputType, Array::OutputType outputType, Array::Storage storage, Array::Usage usage, int componetCount, int offset, int stride, bool normalize, GLValue min, GLValue max); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType inputType; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OutputType outputType; 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Storage storage; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Usage usage; 463a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos int componentCount; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offset; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int stride; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool normalize; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue min; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue max; 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 471a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos std::string getName (void) const; 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string getDesc (void) const; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Primitive primitive; 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int drawCount; //!<Number of primitives to draw 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int first; 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<ArraySpec> arrays; 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const Spec& spec, const char* name, const char* desc); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~MultiVertexArrayTest (void); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual IterateResult iterate (void); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isUnalignedBufferOffsetTest (void) const; 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isUnalignedBufferStrideTest (void) const; 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Spec m_spec; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deFloat16 GLValue::Half::floatToHalf (float f) 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // No denorm support. 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Float<deUint16, 5, 10, 15, tcu::FLOAT_HAS_SIGN> v(f); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!v.isNaN() && !v.isInf()); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v.bits(); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float GLValue::Half::halfToFloat (deFloat16 h) 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::Float16((deUint16)h).asFloat(); 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSVERTEXARRAYTESTS_HPP 510