1*35238bceSAndroid Build Coastguard Worker #ifndef _GLSVERTEXARRAYTESTS_HPP
2*35238bceSAndroid Build Coastguard Worker #define _GLSVERTEXARRAYTESTS_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL (ES) Module
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 array and buffer tests
24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestCase.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuVector.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deFloat16.h"
34*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
35*35238bceSAndroid Build Coastguard Worker #include "tcuFloat.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "tcuPixelFormat.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "sglrContext.hpp"
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker namespace sglr
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker
42*35238bceSAndroid Build Coastguard Worker class ReferenceContextBuffers;
43*35238bceSAndroid Build Coastguard Worker class ReferenceContext;
44*35238bceSAndroid Build Coastguard Worker class Context;
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker } // namespace sglr
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker namespace deqp
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace gls
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker
53*35238bceSAndroid Build Coastguard Worker class Array
54*35238bceSAndroid Build Coastguard Worker {
55*35238bceSAndroid Build Coastguard Worker public:
56*35238bceSAndroid Build Coastguard Worker enum Target
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker // \note [mika] Are these actualy used somewhere?
59*35238bceSAndroid Build Coastguard Worker TARGET_ELEMENT_ARRAY = 0,
60*35238bceSAndroid Build Coastguard Worker TARGET_ARRAY,
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker TARGET_LAST
63*35238bceSAndroid Build Coastguard Worker };
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker enum InputType
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker INPUTTYPE_FLOAT = 0,
68*35238bceSAndroid Build Coastguard Worker INPUTTYPE_FIXED,
69*35238bceSAndroid Build Coastguard Worker INPUTTYPE_DOUBLE,
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker INPUTTYPE_BYTE,
72*35238bceSAndroid Build Coastguard Worker INPUTTYPE_SHORT,
73*35238bceSAndroid Build Coastguard Worker
74*35238bceSAndroid Build Coastguard Worker INPUTTYPE_UNSIGNED_BYTE,
75*35238bceSAndroid Build Coastguard Worker INPUTTYPE_UNSIGNED_SHORT,
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker INPUTTYPE_INT,
78*35238bceSAndroid Build Coastguard Worker INPUTTYPE_UNSIGNED_INT,
79*35238bceSAndroid Build Coastguard Worker INPUTTYPE_HALF,
80*35238bceSAndroid Build Coastguard Worker INPUTTYPE_UNSIGNED_INT_2_10_10_10,
81*35238bceSAndroid Build Coastguard Worker INPUTTYPE_INT_2_10_10_10,
82*35238bceSAndroid Build Coastguard Worker
83*35238bceSAndroid Build Coastguard Worker INPUTTYPE_LAST
84*35238bceSAndroid Build Coastguard Worker };
85*35238bceSAndroid Build Coastguard Worker
86*35238bceSAndroid Build Coastguard Worker enum OutputType
87*35238bceSAndroid Build Coastguard Worker {
88*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_FLOAT = 0,
89*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_VEC2,
90*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_VEC3,
91*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_VEC4,
92*35238bceSAndroid Build Coastguard Worker
93*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_INT,
94*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_UINT,
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_IVEC2,
97*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_IVEC3,
98*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_IVEC4,
99*35238bceSAndroid Build Coastguard Worker
100*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_UVEC2,
101*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_UVEC3,
102*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_UVEC4,
103*35238bceSAndroid Build Coastguard Worker
104*35238bceSAndroid Build Coastguard Worker OUTPUTTYPE_LAST
105*35238bceSAndroid Build Coastguard Worker };
106*35238bceSAndroid Build Coastguard Worker
107*35238bceSAndroid Build Coastguard Worker enum Usage
108*35238bceSAndroid Build Coastguard Worker {
109*35238bceSAndroid Build Coastguard Worker USAGE_DYNAMIC_DRAW = 0,
110*35238bceSAndroid Build Coastguard Worker USAGE_STATIC_DRAW,
111*35238bceSAndroid Build Coastguard Worker USAGE_STREAM_DRAW,
112*35238bceSAndroid Build Coastguard Worker
113*35238bceSAndroid Build Coastguard Worker USAGE_STREAM_READ,
114*35238bceSAndroid Build Coastguard Worker USAGE_STREAM_COPY,
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker USAGE_STATIC_READ,
117*35238bceSAndroid Build Coastguard Worker USAGE_STATIC_COPY,
118*35238bceSAndroid Build Coastguard Worker
119*35238bceSAndroid Build Coastguard Worker USAGE_DYNAMIC_READ,
120*35238bceSAndroid Build Coastguard Worker USAGE_DYNAMIC_COPY,
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker USAGE_LAST
123*35238bceSAndroid Build Coastguard Worker };
124*35238bceSAndroid Build Coastguard Worker
125*35238bceSAndroid Build Coastguard Worker enum Storage
126*35238bceSAndroid Build Coastguard Worker {
127*35238bceSAndroid Build Coastguard Worker STORAGE_USER = 0,
128*35238bceSAndroid Build Coastguard Worker STORAGE_BUFFER,
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker STORAGE_LAST
131*35238bceSAndroid Build Coastguard Worker };
132*35238bceSAndroid Build Coastguard Worker
133*35238bceSAndroid Build Coastguard Worker enum Primitive
134*35238bceSAndroid Build Coastguard Worker {
135*35238bceSAndroid Build Coastguard Worker PRIMITIVE_POINTS = 0,
136*35238bceSAndroid Build Coastguard Worker PRIMITIVE_TRIANGLES,
137*35238bceSAndroid Build Coastguard Worker PRIMITIVE_TRIANGLE_FAN,
138*35238bceSAndroid Build Coastguard Worker PRIMITIVE_TRIANGLE_STRIP,
139*35238bceSAndroid Build Coastguard Worker
140*35238bceSAndroid Build Coastguard Worker PRIMITIVE_LAST
141*35238bceSAndroid Build Coastguard Worker };
142*35238bceSAndroid Build Coastguard Worker
143*35238bceSAndroid Build Coastguard Worker static std::string targetToString(Target target);
144*35238bceSAndroid Build Coastguard Worker static std::string inputTypeToString(InputType type);
145*35238bceSAndroid Build Coastguard Worker static std::string outputTypeToString(OutputType type);
146*35238bceSAndroid Build Coastguard Worker static std::string usageTypeToString(Usage usage);
147*35238bceSAndroid Build Coastguard Worker static std::string storageToString(Storage storage);
148*35238bceSAndroid Build Coastguard Worker static std::string primitiveToString(Primitive primitive);
149*35238bceSAndroid Build Coastguard Worker static int inputTypeSize(InputType type);
150*35238bceSAndroid Build Coastguard Worker
~Array(void)151*35238bceSAndroid Build Coastguard Worker virtual ~Array(void)
152*35238bceSAndroid Build Coastguard Worker {
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker virtual void data(Target target, int size, const char *data, Usage usage) = 0;
155*35238bceSAndroid Build Coastguard Worker virtual void subdata(Target target, int offset, int size, const char *data) = 0;
156*35238bceSAndroid Build Coastguard Worker virtual void bind(int attribNdx, int offset, int size, InputType inType, OutputType outType, bool normalized,
157*35238bceSAndroid Build Coastguard Worker int stride) = 0;
158*35238bceSAndroid Build Coastguard Worker virtual void unBind(void) = 0;
159*35238bceSAndroid Build Coastguard Worker
160*35238bceSAndroid Build Coastguard Worker virtual bool isBound(void) const = 0;
161*35238bceSAndroid Build Coastguard Worker virtual int getComponentCount(void) const = 0;
162*35238bceSAndroid Build Coastguard Worker virtual Target getTarget(void) const = 0;
163*35238bceSAndroid Build Coastguard Worker virtual InputType getInputType(void) const = 0;
164*35238bceSAndroid Build Coastguard Worker virtual OutputType getOutputType(void) const = 0;
165*35238bceSAndroid Build Coastguard Worker virtual Storage getStorageType(void) const = 0;
166*35238bceSAndroid Build Coastguard Worker virtual bool getNormalized(void) const = 0;
167*35238bceSAndroid Build Coastguard Worker virtual int getStride(void) const = 0;
168*35238bceSAndroid Build Coastguard Worker virtual int getAttribNdx(void) const = 0;
169*35238bceSAndroid Build Coastguard Worker virtual void setAttribNdx(int attribNdx) = 0;
170*35238bceSAndroid Build Coastguard Worker };
171*35238bceSAndroid Build Coastguard Worker
172*35238bceSAndroid Build Coastguard Worker class ContextArray : public Array
173*35238bceSAndroid Build Coastguard Worker {
174*35238bceSAndroid Build Coastguard Worker public:
175*35238bceSAndroid Build Coastguard Worker ContextArray(Storage storage, sglr::Context &context);
176*35238bceSAndroid Build Coastguard Worker virtual ~ContextArray(void);
177*35238bceSAndroid Build Coastguard Worker virtual void data(Target target, int size, const char *data, Usage usage);
178*35238bceSAndroid Build Coastguard Worker virtual void subdata(Target target, int offset, int size, const char *data);
179*35238bceSAndroid Build Coastguard Worker virtual void bind(int attribNdx, int offset, int size, InputType inType, OutputType outType, bool normalized,
180*35238bceSAndroid Build Coastguard Worker int stride);
181*35238bceSAndroid Build Coastguard Worker virtual void bindIndexArray(Array::Target storage);
unBind(void)182*35238bceSAndroid Build Coastguard Worker virtual void unBind(void)
183*35238bceSAndroid Build Coastguard Worker {
184*35238bceSAndroid Build Coastguard Worker m_bound = false;
185*35238bceSAndroid Build Coastguard Worker }
isBound(void) const186*35238bceSAndroid Build Coastguard Worker virtual bool isBound(void) const
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker return m_bound;
189*35238bceSAndroid Build Coastguard Worker }
190*35238bceSAndroid Build Coastguard Worker
getComponentCount(void) const191*35238bceSAndroid Build Coastguard Worker virtual int getComponentCount(void) const
192*35238bceSAndroid Build Coastguard Worker {
193*35238bceSAndroid Build Coastguard Worker return m_componentCount;
194*35238bceSAndroid Build Coastguard Worker }
getTarget(void) const195*35238bceSAndroid Build Coastguard Worker virtual Array::Target getTarget(void) const
196*35238bceSAndroid Build Coastguard Worker {
197*35238bceSAndroid Build Coastguard Worker return m_target;
198*35238bceSAndroid Build Coastguard Worker }
getInputType(void) const199*35238bceSAndroid Build Coastguard Worker virtual Array::InputType getInputType(void) const
200*35238bceSAndroid Build Coastguard Worker {
201*35238bceSAndroid Build Coastguard Worker return m_inputType;
202*35238bceSAndroid Build Coastguard Worker }
getOutputType(void) const203*35238bceSAndroid Build Coastguard Worker virtual Array::OutputType getOutputType(void) const
204*35238bceSAndroid Build Coastguard Worker {
205*35238bceSAndroid Build Coastguard Worker return m_outputType;
206*35238bceSAndroid Build Coastguard Worker }
getStorageType(void) const207*35238bceSAndroid Build Coastguard Worker virtual Array::Storage getStorageType(void) const
208*35238bceSAndroid Build Coastguard Worker {
209*35238bceSAndroid Build Coastguard Worker return m_storage;
210*35238bceSAndroid Build Coastguard Worker }
getNormalized(void) const211*35238bceSAndroid Build Coastguard Worker virtual bool getNormalized(void) const
212*35238bceSAndroid Build Coastguard Worker {
213*35238bceSAndroid Build Coastguard Worker return m_normalize;
214*35238bceSAndroid Build Coastguard Worker }
getStride(void) const215*35238bceSAndroid Build Coastguard Worker virtual int getStride(void) const
216*35238bceSAndroid Build Coastguard Worker {
217*35238bceSAndroid Build Coastguard Worker return m_stride;
218*35238bceSAndroid Build Coastguard Worker }
getAttribNdx(void) const219*35238bceSAndroid Build Coastguard Worker virtual int getAttribNdx(void) const
220*35238bceSAndroid Build Coastguard Worker {
221*35238bceSAndroid Build Coastguard Worker return m_attribNdx;
222*35238bceSAndroid Build Coastguard Worker }
setAttribNdx(int attribNdx)223*35238bceSAndroid Build Coastguard Worker virtual void setAttribNdx(int attribNdx)
224*35238bceSAndroid Build Coastguard Worker {
225*35238bceSAndroid Build Coastguard Worker m_attribNdx = attribNdx;
226*35238bceSAndroid Build Coastguard Worker }
227*35238bceSAndroid Build Coastguard Worker
228*35238bceSAndroid Build Coastguard Worker void glBind(uint32_t loc);
229*35238bceSAndroid Build Coastguard Worker static uint32_t targetToGL(Array::Target target);
230*35238bceSAndroid Build Coastguard Worker static uint32_t usageToGL(Array::Usage usage);
231*35238bceSAndroid Build Coastguard Worker static uint32_t inputTypeToGL(Array::InputType type);
232*35238bceSAndroid Build Coastguard Worker static std::string outputTypeToGLType(Array::OutputType type);
233*35238bceSAndroid Build Coastguard Worker static uint32_t primitiveToGL(Array::Primitive primitive);
234*35238bceSAndroid Build Coastguard Worker
235*35238bceSAndroid Build Coastguard Worker private:
236*35238bceSAndroid Build Coastguard Worker Storage m_storage;
237*35238bceSAndroid Build Coastguard Worker sglr::Context &m_ctx;
238*35238bceSAndroid Build Coastguard Worker uint32_t m_glBuffer;
239*35238bceSAndroid Build Coastguard Worker
240*35238bceSAndroid Build Coastguard Worker bool m_bound;
241*35238bceSAndroid Build Coastguard Worker int m_attribNdx;
242*35238bceSAndroid Build Coastguard Worker int m_size;
243*35238bceSAndroid Build Coastguard Worker char *m_data;
244*35238bceSAndroid Build Coastguard Worker int m_componentCount;
245*35238bceSAndroid Build Coastguard Worker Array::Target m_target;
246*35238bceSAndroid Build Coastguard Worker Array::InputType m_inputType;
247*35238bceSAndroid Build Coastguard Worker Array::OutputType m_outputType;
248*35238bceSAndroid Build Coastguard Worker bool m_normalize;
249*35238bceSAndroid Build Coastguard Worker int m_stride;
250*35238bceSAndroid Build Coastguard Worker int m_offset;
251*35238bceSAndroid Build Coastguard Worker };
252*35238bceSAndroid Build Coastguard Worker
253*35238bceSAndroid Build Coastguard Worker class ContextArrayPack
254*35238bceSAndroid Build Coastguard Worker {
255*35238bceSAndroid Build Coastguard Worker public:
256*35238bceSAndroid Build Coastguard Worker ContextArrayPack(glu::RenderContext &renderCtx, sglr::Context &drawContext);
257*35238bceSAndroid Build Coastguard Worker virtual ~ContextArrayPack(void);
258*35238bceSAndroid Build Coastguard Worker virtual Array *getArray(int i);
259*35238bceSAndroid Build Coastguard Worker virtual int getArrayCount(void);
260*35238bceSAndroid Build Coastguard Worker virtual void newArray(Array::Storage storage);
261*35238bceSAndroid Build Coastguard Worker virtual void render(Array::Primitive primitive, int firstVertex, int vertexCount, bool useVao, float coordScale,
262*35238bceSAndroid Build Coastguard Worker float colorScale);
263*35238bceSAndroid Build Coastguard Worker
getSurface(void) const264*35238bceSAndroid Build Coastguard Worker const tcu::Surface &getSurface(void) const
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker return m_screen;
267*35238bceSAndroid Build Coastguard Worker }
268*35238bceSAndroid Build Coastguard Worker
269*35238bceSAndroid Build Coastguard Worker private:
270*35238bceSAndroid Build Coastguard Worker void updateProgram(void);
271*35238bceSAndroid Build Coastguard Worker glu::RenderContext &m_renderCtx;
272*35238bceSAndroid Build Coastguard Worker sglr::Context &m_ctx;
273*35238bceSAndroid Build Coastguard Worker
274*35238bceSAndroid Build Coastguard Worker std::vector<ContextArray *> m_arrays;
275*35238bceSAndroid Build Coastguard Worker sglr::ShaderProgram *m_program;
276*35238bceSAndroid Build Coastguard Worker tcu::Surface m_screen;
277*35238bceSAndroid Build Coastguard Worker };
278*35238bceSAndroid Build Coastguard Worker
279*35238bceSAndroid Build Coastguard Worker class GLValue
280*35238bceSAndroid Build Coastguard Worker {
281*35238bceSAndroid Build Coastguard Worker public:
282*35238bceSAndroid Build Coastguard Worker template <class Type>
283*35238bceSAndroid Build Coastguard Worker class WrappedType
284*35238bceSAndroid Build Coastguard Worker {
285*35238bceSAndroid Build Coastguard Worker public:
create(Type value)286*35238bceSAndroid Build Coastguard Worker static WrappedType<Type> create(Type value)
287*35238bceSAndroid Build Coastguard Worker {
288*35238bceSAndroid Build Coastguard Worker WrappedType<Type> v;
289*35238bceSAndroid Build Coastguard Worker v.m_value = value;
290*35238bceSAndroid Build Coastguard Worker return v;
291*35238bceSAndroid Build Coastguard Worker }
fromFloat(float value)292*35238bceSAndroid Build Coastguard Worker static WrappedType<Type> fromFloat(float value)
293*35238bceSAndroid Build Coastguard Worker {
294*35238bceSAndroid Build Coastguard Worker WrappedType<Type> v;
295*35238bceSAndroid Build Coastguard Worker v.m_value = (Type)value;
296*35238bceSAndroid Build Coastguard Worker return v;
297*35238bceSAndroid Build Coastguard Worker }
getValue(void) const298*35238bceSAndroid Build Coastguard Worker inline Type getValue(void) const
299*35238bceSAndroid Build Coastguard Worker {
300*35238bceSAndroid Build Coastguard Worker return m_value;
301*35238bceSAndroid Build Coastguard Worker }
302*35238bceSAndroid Build Coastguard Worker
operator +(const WrappedType<Type> & other) const303*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> operator+(const WrappedType<Type> &other) const
304*35238bceSAndroid Build Coastguard Worker {
305*35238bceSAndroid Build Coastguard Worker return WrappedType<Type>::create((Type)(m_value + other.getValue()));
306*35238bceSAndroid Build Coastguard Worker }
operator *(const WrappedType<Type> & other) const307*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> operator*(const WrappedType<Type> &other) const
308*35238bceSAndroid Build Coastguard Worker {
309*35238bceSAndroid Build Coastguard Worker return WrappedType<Type>::create((Type)(m_value * other.getValue()));
310*35238bceSAndroid Build Coastguard Worker }
operator /(const WrappedType<Type> & other) const311*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> operator/(const WrappedType<Type> &other) const
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker return WrappedType<Type>::create((Type)(m_value / other.getValue()));
314*35238bceSAndroid Build Coastguard Worker }
operator %(const WrappedType<Type> & other) const315*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> operator%(const WrappedType<Type> &other) const
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker return WrappedType<Type>::create((Type)(m_value % other.getValue()));
318*35238bceSAndroid Build Coastguard Worker }
operator -(const WrappedType<Type> & other) const319*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> operator-(const WrappedType<Type> &other) const
320*35238bceSAndroid Build Coastguard Worker {
321*35238bceSAndroid Build Coastguard Worker return WrappedType<Type>::create((Type)(m_value - other.getValue()));
322*35238bceSAndroid Build Coastguard Worker }
323*35238bceSAndroid Build Coastguard Worker
operator +=(const WrappedType<Type> & other)324*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> &operator+=(const WrappedType<Type> &other)
325*35238bceSAndroid Build Coastguard Worker {
326*35238bceSAndroid Build Coastguard Worker m_value += other.getValue();
327*35238bceSAndroid Build Coastguard Worker return *this;
328*35238bceSAndroid Build Coastguard Worker }
operator *=(const WrappedType<Type> & other)329*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> &operator*=(const WrappedType<Type> &other)
330*35238bceSAndroid Build Coastguard Worker {
331*35238bceSAndroid Build Coastguard Worker m_value *= other.getValue();
332*35238bceSAndroid Build Coastguard Worker return *this;
333*35238bceSAndroid Build Coastguard Worker }
operator /=(const WrappedType<Type> & other)334*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> &operator/=(const WrappedType<Type> &other)
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker m_value /= other.getValue();
337*35238bceSAndroid Build Coastguard Worker return *this;
338*35238bceSAndroid Build Coastguard Worker }
operator -=(const WrappedType<Type> & other)339*35238bceSAndroid Build Coastguard Worker inline WrappedType<Type> &operator-=(const WrappedType<Type> &other)
340*35238bceSAndroid Build Coastguard Worker {
341*35238bceSAndroid Build Coastguard Worker m_value -= other.getValue();
342*35238bceSAndroid Build Coastguard Worker return *this;
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker
operator ==(const WrappedType<Type> & other) const345*35238bceSAndroid Build Coastguard Worker inline bool operator==(const WrappedType<Type> &other) const
346*35238bceSAndroid Build Coastguard Worker {
347*35238bceSAndroid Build Coastguard Worker return m_value == other.m_value;
348*35238bceSAndroid Build Coastguard Worker }
operator !=(const WrappedType<Type> & other) const349*35238bceSAndroid Build Coastguard Worker inline bool operator!=(const WrappedType<Type> &other) const
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker return m_value != other.m_value;
352*35238bceSAndroid Build Coastguard Worker }
operator <(const WrappedType<Type> & other) const353*35238bceSAndroid Build Coastguard Worker inline bool operator<(const WrappedType<Type> &other) const
354*35238bceSAndroid Build Coastguard Worker {
355*35238bceSAndroid Build Coastguard Worker return m_value < other.m_value;
356*35238bceSAndroid Build Coastguard Worker }
operator >(const WrappedType<Type> & other) const357*35238bceSAndroid Build Coastguard Worker inline bool operator>(const WrappedType<Type> &other) const
358*35238bceSAndroid Build Coastguard Worker {
359*35238bceSAndroid Build Coastguard Worker return m_value > other.m_value;
360*35238bceSAndroid Build Coastguard Worker }
operator <=(const WrappedType<Type> & other) const361*35238bceSAndroid Build Coastguard Worker inline bool operator<=(const WrappedType<Type> &other) const
362*35238bceSAndroid Build Coastguard Worker {
363*35238bceSAndroid Build Coastguard Worker return m_value <= other.m_value;
364*35238bceSAndroid Build Coastguard Worker }
operator >=(const WrappedType<Type> & other) const365*35238bceSAndroid Build Coastguard Worker inline bool operator>=(const WrappedType<Type> &other) const
366*35238bceSAndroid Build Coastguard Worker {
367*35238bceSAndroid Build Coastguard Worker return m_value >= other.m_value;
368*35238bceSAndroid Build Coastguard Worker }
369*35238bceSAndroid Build Coastguard Worker
operator Type(void) const370*35238bceSAndroid Build Coastguard Worker inline operator Type(void) const
371*35238bceSAndroid Build Coastguard Worker {
372*35238bceSAndroid Build Coastguard Worker return m_value;
373*35238bceSAndroid Build Coastguard Worker }
374*35238bceSAndroid Build Coastguard Worker template <class T>
to(void) const375*35238bceSAndroid Build Coastguard Worker inline T to(void) const
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker return (T)m_value;
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker private:
381*35238bceSAndroid Build Coastguard Worker Type m_value;
382*35238bceSAndroid Build Coastguard Worker };
383*35238bceSAndroid Build Coastguard Worker
384*35238bceSAndroid Build Coastguard Worker template <class Type>
385*35238bceSAndroid Build Coastguard Worker class WrappedFloatType
386*35238bceSAndroid Build Coastguard Worker {
387*35238bceSAndroid Build Coastguard Worker public:
create(Type value)388*35238bceSAndroid Build Coastguard Worker static WrappedFloatType<Type> create(Type value)
389*35238bceSAndroid Build Coastguard Worker {
390*35238bceSAndroid Build Coastguard Worker WrappedFloatType<Type> v;
391*35238bceSAndroid Build Coastguard Worker v.m_value = value;
392*35238bceSAndroid Build Coastguard Worker return v;
393*35238bceSAndroid Build Coastguard Worker }
fromFloat(float value)394*35238bceSAndroid Build Coastguard Worker static WrappedFloatType<Type> fromFloat(float value)
395*35238bceSAndroid Build Coastguard Worker {
396*35238bceSAndroid Build Coastguard Worker WrappedFloatType<Type> v;
397*35238bceSAndroid Build Coastguard Worker v.m_value = (Type)value;
398*35238bceSAndroid Build Coastguard Worker return v;
399*35238bceSAndroid Build Coastguard Worker }
getValue(void) const400*35238bceSAndroid Build Coastguard Worker inline Type getValue(void) const
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker return m_value;
403*35238bceSAndroid Build Coastguard Worker }
404*35238bceSAndroid Build Coastguard Worker
operator +(const WrappedFloatType<Type> & other) const405*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> operator+(const WrappedFloatType<Type> &other) const
406*35238bceSAndroid Build Coastguard Worker {
407*35238bceSAndroid Build Coastguard Worker return WrappedFloatType<Type>::create((Type)(m_value + other.getValue()));
408*35238bceSAndroid Build Coastguard Worker }
operator *(const WrappedFloatType<Type> & other) const409*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> operator*(const WrappedFloatType<Type> &other) const
410*35238bceSAndroid Build Coastguard Worker {
411*35238bceSAndroid Build Coastguard Worker return WrappedFloatType<Type>::create((Type)(m_value * other.getValue()));
412*35238bceSAndroid Build Coastguard Worker }
operator /(const WrappedFloatType<Type> & other) const413*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> operator/(const WrappedFloatType<Type> &other) const
414*35238bceSAndroid Build Coastguard Worker {
415*35238bceSAndroid Build Coastguard Worker return WrappedFloatType<Type>::create((Type)(m_value / other.getValue()));
416*35238bceSAndroid Build Coastguard Worker }
operator %(const WrappedFloatType<Type> & other) const417*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> operator%(const WrappedFloatType<Type> &other) const
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker return WrappedFloatType<Type>::create((Type)(deMod(m_value, other.getValue())));
420*35238bceSAndroid Build Coastguard Worker }
operator -(const WrappedFloatType<Type> & other) const421*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> operator-(const WrappedFloatType<Type> &other) const
422*35238bceSAndroid Build Coastguard Worker {
423*35238bceSAndroid Build Coastguard Worker return WrappedFloatType<Type>::create((Type)(m_value - other.getValue()));
424*35238bceSAndroid Build Coastguard Worker }
425*35238bceSAndroid Build Coastguard Worker
operator +=(const WrappedFloatType<Type> & other)426*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> &operator+=(const WrappedFloatType<Type> &other)
427*35238bceSAndroid Build Coastguard Worker {
428*35238bceSAndroid Build Coastguard Worker m_value += other.getValue();
429*35238bceSAndroid Build Coastguard Worker return *this;
430*35238bceSAndroid Build Coastguard Worker }
operator *=(const WrappedFloatType<Type> & other)431*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> &operator*=(const WrappedFloatType<Type> &other)
432*35238bceSAndroid Build Coastguard Worker {
433*35238bceSAndroid Build Coastguard Worker m_value *= other.getValue();
434*35238bceSAndroid Build Coastguard Worker return *this;
435*35238bceSAndroid Build Coastguard Worker }
operator /=(const WrappedFloatType<Type> & other)436*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> &operator/=(const WrappedFloatType<Type> &other)
437*35238bceSAndroid Build Coastguard Worker {
438*35238bceSAndroid Build Coastguard Worker m_value /= other.getValue();
439*35238bceSAndroid Build Coastguard Worker return *this;
440*35238bceSAndroid Build Coastguard Worker }
operator -=(const WrappedFloatType<Type> & other)441*35238bceSAndroid Build Coastguard Worker inline WrappedFloatType<Type> &operator-=(const WrappedFloatType<Type> &other)
442*35238bceSAndroid Build Coastguard Worker {
443*35238bceSAndroid Build Coastguard Worker m_value -= other.getValue();
444*35238bceSAndroid Build Coastguard Worker return *this;
445*35238bceSAndroid Build Coastguard Worker }
446*35238bceSAndroid Build Coastguard Worker
operator ==(const WrappedFloatType<Type> & other) const447*35238bceSAndroid Build Coastguard Worker inline bool operator==(const WrappedFloatType<Type> &other) const
448*35238bceSAndroid Build Coastguard Worker {
449*35238bceSAndroid Build Coastguard Worker return m_value == other.m_value;
450*35238bceSAndroid Build Coastguard Worker }
operator !=(const WrappedFloatType<Type> & other) const451*35238bceSAndroid Build Coastguard Worker inline bool operator!=(const WrappedFloatType<Type> &other) const
452*35238bceSAndroid Build Coastguard Worker {
453*35238bceSAndroid Build Coastguard Worker return m_value != other.m_value;
454*35238bceSAndroid Build Coastguard Worker }
operator <(const WrappedFloatType<Type> & other) const455*35238bceSAndroid Build Coastguard Worker inline bool operator<(const WrappedFloatType<Type> &other) const
456*35238bceSAndroid Build Coastguard Worker {
457*35238bceSAndroid Build Coastguard Worker return m_value < other.m_value;
458*35238bceSAndroid Build Coastguard Worker }
operator >(const WrappedFloatType<Type> & other) const459*35238bceSAndroid Build Coastguard Worker inline bool operator>(const WrappedFloatType<Type> &other) const
460*35238bceSAndroid Build Coastguard Worker {
461*35238bceSAndroid Build Coastguard Worker return m_value > other.m_value;
462*35238bceSAndroid Build Coastguard Worker }
operator <=(const WrappedFloatType<Type> & other) const463*35238bceSAndroid Build Coastguard Worker inline bool operator<=(const WrappedFloatType<Type> &other) const
464*35238bceSAndroid Build Coastguard Worker {
465*35238bceSAndroid Build Coastguard Worker return m_value <= other.m_value;
466*35238bceSAndroid Build Coastguard Worker }
operator >=(const WrappedFloatType<Type> & other) const467*35238bceSAndroid Build Coastguard Worker inline bool operator>=(const WrappedFloatType<Type> &other) const
468*35238bceSAndroid Build Coastguard Worker {
469*35238bceSAndroid Build Coastguard Worker return m_value >= other.m_value;
470*35238bceSAndroid Build Coastguard Worker }
471*35238bceSAndroid Build Coastguard Worker
operator Type(void) const472*35238bceSAndroid Build Coastguard Worker inline operator Type(void) const
473*35238bceSAndroid Build Coastguard Worker {
474*35238bceSAndroid Build Coastguard Worker return m_value;
475*35238bceSAndroid Build Coastguard Worker }
476*35238bceSAndroid Build Coastguard Worker template <class T>
to(void) const477*35238bceSAndroid Build Coastguard Worker inline T to(void) const
478*35238bceSAndroid Build Coastguard Worker {
479*35238bceSAndroid Build Coastguard Worker return (T)m_value;
480*35238bceSAndroid Build Coastguard Worker }
481*35238bceSAndroid Build Coastguard Worker
482*35238bceSAndroid Build Coastguard Worker private:
483*35238bceSAndroid Build Coastguard Worker Type m_value;
484*35238bceSAndroid Build Coastguard Worker };
485*35238bceSAndroid Build Coastguard Worker
486*35238bceSAndroid Build Coastguard Worker typedef WrappedType<int16_t> Short;
487*35238bceSAndroid Build Coastguard Worker typedef WrappedType<uint16_t> Ushort;
488*35238bceSAndroid Build Coastguard Worker
489*35238bceSAndroid Build Coastguard Worker typedef WrappedType<int8_t> Byte;
490*35238bceSAndroid Build Coastguard Worker typedef WrappedType<uint8_t> Ubyte;
491*35238bceSAndroid Build Coastguard Worker
492*35238bceSAndroid Build Coastguard Worker typedef WrappedFloatType<float> Float;
493*35238bceSAndroid Build Coastguard Worker typedef WrappedFloatType<double> Double;
494*35238bceSAndroid Build Coastguard Worker
495*35238bceSAndroid Build Coastguard Worker typedef WrappedType<int32_t> Int;
496*35238bceSAndroid Build Coastguard Worker typedef WrappedType<uint32_t> Uint;
497*35238bceSAndroid Build Coastguard Worker
498*35238bceSAndroid Build Coastguard Worker class Half
499*35238bceSAndroid Build Coastguard Worker {
500*35238bceSAndroid Build Coastguard Worker public:
create(float value)501*35238bceSAndroid Build Coastguard Worker static Half create(float value)
502*35238bceSAndroid Build Coastguard Worker {
503*35238bceSAndroid Build Coastguard Worker Half h;
504*35238bceSAndroid Build Coastguard Worker h.m_value = floatToHalf(value);
505*35238bceSAndroid Build Coastguard Worker return h;
506*35238bceSAndroid Build Coastguard Worker }
fromFloat(float value)507*35238bceSAndroid Build Coastguard Worker static Half fromFloat(float value)
508*35238bceSAndroid Build Coastguard Worker {
509*35238bceSAndroid Build Coastguard Worker Half h;
510*35238bceSAndroid Build Coastguard Worker h.m_value = floatToHalf(value);
511*35238bceSAndroid Build Coastguard Worker return h;
512*35238bceSAndroid Build Coastguard Worker }
getValue(void) const513*35238bceSAndroid Build Coastguard Worker inline deFloat16 getValue(void) const
514*35238bceSAndroid Build Coastguard Worker {
515*35238bceSAndroid Build Coastguard Worker return m_value;
516*35238bceSAndroid Build Coastguard Worker }
517*35238bceSAndroid Build Coastguard Worker
operator +(const Half & other) const518*35238bceSAndroid Build Coastguard Worker inline Half operator+(const Half &other) const
519*35238bceSAndroid Build Coastguard Worker {
520*35238bceSAndroid Build Coastguard Worker return create(halfToFloat(m_value) + halfToFloat(other.getValue()));
521*35238bceSAndroid Build Coastguard Worker }
operator *(const Half & other) const522*35238bceSAndroid Build Coastguard Worker inline Half operator*(const Half &other) const
523*35238bceSAndroid Build Coastguard Worker {
524*35238bceSAndroid Build Coastguard Worker return create(halfToFloat(m_value) * halfToFloat(other.getValue()));
525*35238bceSAndroid Build Coastguard Worker }
operator /(const Half & other) const526*35238bceSAndroid Build Coastguard Worker inline Half operator/(const Half &other) const
527*35238bceSAndroid Build Coastguard Worker {
528*35238bceSAndroid Build Coastguard Worker return create(halfToFloat(m_value) / halfToFloat(other.getValue()));
529*35238bceSAndroid Build Coastguard Worker }
operator %(const Half & other) const530*35238bceSAndroid Build Coastguard Worker inline Half operator%(const Half &other) const
531*35238bceSAndroid Build Coastguard Worker {
532*35238bceSAndroid Build Coastguard Worker return create(deFloatMod(halfToFloat(m_value), halfToFloat(other.getValue())));
533*35238bceSAndroid Build Coastguard Worker }
operator -(const Half & other) const534*35238bceSAndroid Build Coastguard Worker inline Half operator-(const Half &other) const
535*35238bceSAndroid Build Coastguard Worker {
536*35238bceSAndroid Build Coastguard Worker return create(halfToFloat(m_value) - halfToFloat(other.getValue()));
537*35238bceSAndroid Build Coastguard Worker }
538*35238bceSAndroid Build Coastguard Worker
operator +=(const Half & other)539*35238bceSAndroid Build Coastguard Worker inline Half &operator+=(const Half &other)
540*35238bceSAndroid Build Coastguard Worker {
541*35238bceSAndroid Build Coastguard Worker m_value = floatToHalf(halfToFloat(other.getValue()) + halfToFloat(m_value));
542*35238bceSAndroid Build Coastguard Worker return *this;
543*35238bceSAndroid Build Coastguard Worker }
operator *=(const Half & other)544*35238bceSAndroid Build Coastguard Worker inline Half &operator*=(const Half &other)
545*35238bceSAndroid Build Coastguard Worker {
546*35238bceSAndroid Build Coastguard Worker m_value = floatToHalf(halfToFloat(other.getValue()) * halfToFloat(m_value));
547*35238bceSAndroid Build Coastguard Worker return *this;
548*35238bceSAndroid Build Coastguard Worker }
operator /=(const Half & other)549*35238bceSAndroid Build Coastguard Worker inline Half &operator/=(const Half &other)
550*35238bceSAndroid Build Coastguard Worker {
551*35238bceSAndroid Build Coastguard Worker m_value = floatToHalf(halfToFloat(other.getValue()) / halfToFloat(m_value));
552*35238bceSAndroid Build Coastguard Worker return *this;
553*35238bceSAndroid Build Coastguard Worker }
operator -=(const Half & other)554*35238bceSAndroid Build Coastguard Worker inline Half &operator-=(const Half &other)
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker m_value = floatToHalf(halfToFloat(other.getValue()) - halfToFloat(m_value));
557*35238bceSAndroid Build Coastguard Worker return *this;
558*35238bceSAndroid Build Coastguard Worker }
559*35238bceSAndroid Build Coastguard Worker
operator ==(const Half & other) const560*35238bceSAndroid Build Coastguard Worker inline bool operator==(const Half &other) const
561*35238bceSAndroid Build Coastguard Worker {
562*35238bceSAndroid Build Coastguard Worker return m_value == other.m_value;
563*35238bceSAndroid Build Coastguard Worker }
operator !=(const Half & other) const564*35238bceSAndroid Build Coastguard Worker inline bool operator!=(const Half &other) const
565*35238bceSAndroid Build Coastguard Worker {
566*35238bceSAndroid Build Coastguard Worker return m_value != other.m_value;
567*35238bceSAndroid Build Coastguard Worker }
operator <(const Half & other) const568*35238bceSAndroid Build Coastguard Worker inline bool operator<(const Half &other) const
569*35238bceSAndroid Build Coastguard Worker {
570*35238bceSAndroid Build Coastguard Worker return halfToFloat(m_value) < halfToFloat(other.m_value);
571*35238bceSAndroid Build Coastguard Worker }
operator >(const Half & other) const572*35238bceSAndroid Build Coastguard Worker inline bool operator>(const Half &other) const
573*35238bceSAndroid Build Coastguard Worker {
574*35238bceSAndroid Build Coastguard Worker return halfToFloat(m_value) > halfToFloat(other.m_value);
575*35238bceSAndroid Build Coastguard Worker }
operator <=(const Half & other) const576*35238bceSAndroid Build Coastguard Worker inline bool operator<=(const Half &other) const
577*35238bceSAndroid Build Coastguard Worker {
578*35238bceSAndroid Build Coastguard Worker return halfToFloat(m_value) <= halfToFloat(other.m_value);
579*35238bceSAndroid Build Coastguard Worker }
operator >=(const Half & other) const580*35238bceSAndroid Build Coastguard Worker inline bool operator>=(const Half &other) const
581*35238bceSAndroid Build Coastguard Worker {
582*35238bceSAndroid Build Coastguard Worker return halfToFloat(m_value) >= halfToFloat(other.m_value);
583*35238bceSAndroid Build Coastguard Worker }
584*35238bceSAndroid Build Coastguard Worker
585*35238bceSAndroid Build Coastguard Worker template <class T>
to(void) const586*35238bceSAndroid Build Coastguard Worker inline T to(void) const
587*35238bceSAndroid Build Coastguard Worker {
588*35238bceSAndroid Build Coastguard Worker return (T)halfToFloat(m_value);
589*35238bceSAndroid Build Coastguard Worker }
590*35238bceSAndroid Build Coastguard Worker
591*35238bceSAndroid Build Coastguard Worker inline static deFloat16 floatToHalf(float f);
592*35238bceSAndroid Build Coastguard Worker inline static float halfToFloat(deFloat16 h);
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker private:
595*35238bceSAndroid Build Coastguard Worker deFloat16 m_value;
596*35238bceSAndroid Build Coastguard Worker };
597*35238bceSAndroid Build Coastguard Worker
598*35238bceSAndroid Build Coastguard Worker class Fixed
599*35238bceSAndroid Build Coastguard Worker {
600*35238bceSAndroid Build Coastguard Worker public:
create(int32_t value)601*35238bceSAndroid Build Coastguard Worker static Fixed create(int32_t value)
602*35238bceSAndroid Build Coastguard Worker {
603*35238bceSAndroid Build Coastguard Worker Fixed v;
604*35238bceSAndroid Build Coastguard Worker v.m_value = value;
605*35238bceSAndroid Build Coastguard Worker return v;
606*35238bceSAndroid Build Coastguard Worker }
fromFloat(float value)607*35238bceSAndroid Build Coastguard Worker static Fixed fromFloat(float value)
608*35238bceSAndroid Build Coastguard Worker {
609*35238bceSAndroid Build Coastguard Worker Fixed v;
610*35238bceSAndroid Build Coastguard Worker v.m_value = (int32_t)value;
611*35238bceSAndroid Build Coastguard Worker return v;
612*35238bceSAndroid Build Coastguard Worker }
getValue(void) const613*35238bceSAndroid Build Coastguard Worker inline int32_t getValue(void) const
614*35238bceSAndroid Build Coastguard Worker {
615*35238bceSAndroid Build Coastguard Worker return m_value;
616*35238bceSAndroid Build Coastguard Worker }
617*35238bceSAndroid Build Coastguard Worker
operator +(const Fixed & other) const618*35238bceSAndroid Build Coastguard Worker inline Fixed operator+(const Fixed &other) const
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker return create(m_value + other.getValue());
621*35238bceSAndroid Build Coastguard Worker }
operator *(const Fixed & other) const622*35238bceSAndroid Build Coastguard Worker inline Fixed operator*(const Fixed &other) const
623*35238bceSAndroid Build Coastguard Worker {
624*35238bceSAndroid Build Coastguard Worker return create(m_value * other.getValue());
625*35238bceSAndroid Build Coastguard Worker }
operator /(const Fixed & other) const626*35238bceSAndroid Build Coastguard Worker inline Fixed operator/(const Fixed &other) const
627*35238bceSAndroid Build Coastguard Worker {
628*35238bceSAndroid Build Coastguard Worker return create(m_value / other.getValue());
629*35238bceSAndroid Build Coastguard Worker }
operator %(const Fixed & other) const630*35238bceSAndroid Build Coastguard Worker inline Fixed operator%(const Fixed &other) const
631*35238bceSAndroid Build Coastguard Worker {
632*35238bceSAndroid Build Coastguard Worker return create(m_value % other.getValue());
633*35238bceSAndroid Build Coastguard Worker }
operator -(const Fixed & other) const634*35238bceSAndroid Build Coastguard Worker inline Fixed operator-(const Fixed &other) const
635*35238bceSAndroid Build Coastguard Worker {
636*35238bceSAndroid Build Coastguard Worker return create(m_value - other.getValue());
637*35238bceSAndroid Build Coastguard Worker }
638*35238bceSAndroid Build Coastguard Worker
operator +=(const Fixed & other)639*35238bceSAndroid Build Coastguard Worker inline Fixed &operator+=(const Fixed &other)
640*35238bceSAndroid Build Coastguard Worker {
641*35238bceSAndroid Build Coastguard Worker m_value += other.getValue();
642*35238bceSAndroid Build Coastguard Worker return *this;
643*35238bceSAndroid Build Coastguard Worker }
operator *=(const Fixed & other)644*35238bceSAndroid Build Coastguard Worker inline Fixed &operator*=(const Fixed &other)
645*35238bceSAndroid Build Coastguard Worker {
646*35238bceSAndroid Build Coastguard Worker m_value *= other.getValue();
647*35238bceSAndroid Build Coastguard Worker return *this;
648*35238bceSAndroid Build Coastguard Worker }
operator /=(const Fixed & other)649*35238bceSAndroid Build Coastguard Worker inline Fixed &operator/=(const Fixed &other)
650*35238bceSAndroid Build Coastguard Worker {
651*35238bceSAndroid Build Coastguard Worker m_value /= other.getValue();
652*35238bceSAndroid Build Coastguard Worker return *this;
653*35238bceSAndroid Build Coastguard Worker }
operator -=(const Fixed & other)654*35238bceSAndroid Build Coastguard Worker inline Fixed &operator-=(const Fixed &other)
655*35238bceSAndroid Build Coastguard Worker {
656*35238bceSAndroid Build Coastguard Worker m_value -= other.getValue();
657*35238bceSAndroid Build Coastguard Worker return *this;
658*35238bceSAndroid Build Coastguard Worker }
659*35238bceSAndroid Build Coastguard Worker
operator ==(const Fixed & other) const660*35238bceSAndroid Build Coastguard Worker inline bool operator==(const Fixed &other) const
661*35238bceSAndroid Build Coastguard Worker {
662*35238bceSAndroid Build Coastguard Worker return m_value == other.m_value;
663*35238bceSAndroid Build Coastguard Worker }
operator !=(const Fixed & other) const664*35238bceSAndroid Build Coastguard Worker inline bool operator!=(const Fixed &other) const
665*35238bceSAndroid Build Coastguard Worker {
666*35238bceSAndroid Build Coastguard Worker return m_value != other.m_value;
667*35238bceSAndroid Build Coastguard Worker }
operator <(const Fixed & other) const668*35238bceSAndroid Build Coastguard Worker inline bool operator<(const Fixed &other) const
669*35238bceSAndroid Build Coastguard Worker {
670*35238bceSAndroid Build Coastguard Worker return m_value < other.m_value;
671*35238bceSAndroid Build Coastguard Worker }
operator >(const Fixed & other) const672*35238bceSAndroid Build Coastguard Worker inline bool operator>(const Fixed &other) const
673*35238bceSAndroid Build Coastguard Worker {
674*35238bceSAndroid Build Coastguard Worker return m_value > other.m_value;
675*35238bceSAndroid Build Coastguard Worker }
operator <=(const Fixed & other) const676*35238bceSAndroid Build Coastguard Worker inline bool operator<=(const Fixed &other) const
677*35238bceSAndroid Build Coastguard Worker {
678*35238bceSAndroid Build Coastguard Worker return m_value <= other.m_value;
679*35238bceSAndroid Build Coastguard Worker }
operator >=(const Fixed & other) const680*35238bceSAndroid Build Coastguard Worker inline bool operator>=(const Fixed &other) const
681*35238bceSAndroid Build Coastguard Worker {
682*35238bceSAndroid Build Coastguard Worker return m_value >= other.m_value;
683*35238bceSAndroid Build Coastguard Worker }
684*35238bceSAndroid Build Coastguard Worker
operator int32_t(void) const685*35238bceSAndroid Build Coastguard Worker inline operator int32_t(void) const
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker return m_value;
688*35238bceSAndroid Build Coastguard Worker }
689*35238bceSAndroid Build Coastguard Worker template <class T>
to(void) const690*35238bceSAndroid Build Coastguard Worker inline T to(void) const
691*35238bceSAndroid Build Coastguard Worker {
692*35238bceSAndroid Build Coastguard Worker return (T)m_value;
693*35238bceSAndroid Build Coastguard Worker }
694*35238bceSAndroid Build Coastguard Worker
695*35238bceSAndroid Build Coastguard Worker private:
696*35238bceSAndroid Build Coastguard Worker int32_t m_value;
697*35238bceSAndroid Build Coastguard Worker };
698*35238bceSAndroid Build Coastguard Worker
699*35238bceSAndroid Build Coastguard Worker // \todo [mika] This is pretty messy
GLValue(void)700*35238bceSAndroid Build Coastguard Worker GLValue(void) : type(Array::INPUTTYPE_LAST)
701*35238bceSAndroid Build Coastguard Worker {
702*35238bceSAndroid Build Coastguard Worker }
GLValue(Float value)703*35238bceSAndroid Build Coastguard Worker explicit GLValue(Float value) : type(Array::INPUTTYPE_FLOAT), fl(value)
704*35238bceSAndroid Build Coastguard Worker {
705*35238bceSAndroid Build Coastguard Worker }
GLValue(Fixed value)706*35238bceSAndroid Build Coastguard Worker explicit GLValue(Fixed value) : type(Array::INPUTTYPE_FIXED), fi(value)
707*35238bceSAndroid Build Coastguard Worker {
708*35238bceSAndroid Build Coastguard Worker }
GLValue(Byte value)709*35238bceSAndroid Build Coastguard Worker explicit GLValue(Byte value) : type(Array::INPUTTYPE_BYTE), b(value)
710*35238bceSAndroid Build Coastguard Worker {
711*35238bceSAndroid Build Coastguard Worker }
GLValue(Ubyte value)712*35238bceSAndroid Build Coastguard Worker explicit GLValue(Ubyte value) : type(Array::INPUTTYPE_UNSIGNED_BYTE), ub(value)
713*35238bceSAndroid Build Coastguard Worker {
714*35238bceSAndroid Build Coastguard Worker }
GLValue(Short value)715*35238bceSAndroid Build Coastguard Worker explicit GLValue(Short value) : type(Array::INPUTTYPE_SHORT), s(value)
716*35238bceSAndroid Build Coastguard Worker {
717*35238bceSAndroid Build Coastguard Worker }
GLValue(Ushort value)718*35238bceSAndroid Build Coastguard Worker explicit GLValue(Ushort value) : type(Array::INPUTTYPE_UNSIGNED_SHORT), us(value)
719*35238bceSAndroid Build Coastguard Worker {
720*35238bceSAndroid Build Coastguard Worker }
GLValue(Int value)721*35238bceSAndroid Build Coastguard Worker explicit GLValue(Int value) : type(Array::INPUTTYPE_INT), i(value)
722*35238bceSAndroid Build Coastguard Worker {
723*35238bceSAndroid Build Coastguard Worker }
GLValue(Uint value)724*35238bceSAndroid Build Coastguard Worker explicit GLValue(Uint value) : type(Array::INPUTTYPE_UNSIGNED_INT), ui(value)
725*35238bceSAndroid Build Coastguard Worker {
726*35238bceSAndroid Build Coastguard Worker }
GLValue(Half value)727*35238bceSAndroid Build Coastguard Worker explicit GLValue(Half value) : type(Array::INPUTTYPE_HALF), h(value)
728*35238bceSAndroid Build Coastguard Worker {
729*35238bceSAndroid Build Coastguard Worker }
GLValue(Double value)730*35238bceSAndroid Build Coastguard Worker explicit GLValue(Double value) : type(Array::INPUTTYPE_DOUBLE), d(value)
731*35238bceSAndroid Build Coastguard Worker {
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker
734*35238bceSAndroid Build Coastguard Worker float toFloat(void) const;
735*35238bceSAndroid Build Coastguard Worker
736*35238bceSAndroid Build Coastguard Worker static GLValue getMaxValue(Array::InputType type);
737*35238bceSAndroid Build Coastguard Worker static GLValue getMinValue(Array::InputType type);
738*35238bceSAndroid Build Coastguard Worker
739*35238bceSAndroid Build Coastguard Worker Array::InputType type;
740*35238bceSAndroid Build Coastguard Worker
741*35238bceSAndroid Build Coastguard Worker union
742*35238bceSAndroid Build Coastguard Worker {
743*35238bceSAndroid Build Coastguard Worker Float fl;
744*35238bceSAndroid Build Coastguard Worker Fixed fi;
745*35238bceSAndroid Build Coastguard Worker Double d;
746*35238bceSAndroid Build Coastguard Worker Byte b;
747*35238bceSAndroid Build Coastguard Worker Ubyte ub;
748*35238bceSAndroid Build Coastguard Worker Short s;
749*35238bceSAndroid Build Coastguard Worker Ushort us;
750*35238bceSAndroid Build Coastguard Worker Int i;
751*35238bceSAndroid Build Coastguard Worker Uint ui;
752*35238bceSAndroid Build Coastguard Worker Half h;
753*35238bceSAndroid Build Coastguard Worker };
754*35238bceSAndroid Build Coastguard Worker };
755*35238bceSAndroid Build Coastguard Worker
756*35238bceSAndroid Build Coastguard Worker class VertexArrayTest : public tcu::TestCase
757*35238bceSAndroid Build Coastguard Worker {
758*35238bceSAndroid Build Coastguard Worker public:
759*35238bceSAndroid Build Coastguard Worker VertexArrayTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name, const char *desc);
760*35238bceSAndroid Build Coastguard Worker virtual ~VertexArrayTest(void);
761*35238bceSAndroid Build Coastguard Worker virtual void init(void);
762*35238bceSAndroid Build Coastguard Worker virtual void deinit(void);
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker protected:
765*35238bceSAndroid Build Coastguard Worker VertexArrayTest(const VertexArrayTest &other);
766*35238bceSAndroid Build Coastguard Worker VertexArrayTest &operator=(const VertexArrayTest &other);
767*35238bceSAndroid Build Coastguard Worker
768*35238bceSAndroid Build Coastguard Worker void compare(void);
769*35238bceSAndroid Build Coastguard Worker
770*35238bceSAndroid Build Coastguard Worker glu::RenderContext &m_renderCtx;
771*35238bceSAndroid Build Coastguard Worker
772*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers *m_refBuffers;
773*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext *m_refContext;
774*35238bceSAndroid Build Coastguard Worker sglr::Context *m_glesContext;
775*35238bceSAndroid Build Coastguard Worker
776*35238bceSAndroid Build Coastguard Worker ContextArrayPack *m_glArrayPack;
777*35238bceSAndroid Build Coastguard Worker ContextArrayPack *m_rrArrayPack;
778*35238bceSAndroid Build Coastguard Worker bool m_isOk;
779*35238bceSAndroid Build Coastguard Worker
780*35238bceSAndroid Build Coastguard Worker int m_maxDiffRed;
781*35238bceSAndroid Build Coastguard Worker int m_maxDiffGreen;
782*35238bceSAndroid Build Coastguard Worker int m_maxDiffBlue;
783*35238bceSAndroid Build Coastguard Worker };
784*35238bceSAndroid Build Coastguard Worker
785*35238bceSAndroid Build Coastguard Worker class MultiVertexArrayTest : public VertexArrayTest
786*35238bceSAndroid Build Coastguard Worker {
787*35238bceSAndroid Build Coastguard Worker public:
788*35238bceSAndroid Build Coastguard Worker class Spec
789*35238bceSAndroid Build Coastguard Worker {
790*35238bceSAndroid Build Coastguard Worker public:
791*35238bceSAndroid Build Coastguard Worker class ArraySpec
792*35238bceSAndroid Build Coastguard Worker {
793*35238bceSAndroid Build Coastguard Worker public:
794*35238bceSAndroid Build Coastguard Worker ArraySpec(Array::InputType inputType, Array::OutputType outputType, Array::Storage storage,
795*35238bceSAndroid Build Coastguard Worker Array::Usage usage, int componetCount, int offset, int stride, bool normalize, GLValue min,
796*35238bceSAndroid Build Coastguard Worker GLValue max);
797*35238bceSAndroid Build Coastguard Worker
798*35238bceSAndroid Build Coastguard Worker Array::InputType inputType;
799*35238bceSAndroid Build Coastguard Worker Array::OutputType outputType;
800*35238bceSAndroid Build Coastguard Worker Array::Storage storage;
801*35238bceSAndroid Build Coastguard Worker Array::Usage usage;
802*35238bceSAndroid Build Coastguard Worker int componentCount;
803*35238bceSAndroid Build Coastguard Worker int offset;
804*35238bceSAndroid Build Coastguard Worker int stride;
805*35238bceSAndroid Build Coastguard Worker bool normalize;
806*35238bceSAndroid Build Coastguard Worker GLValue min;
807*35238bceSAndroid Build Coastguard Worker GLValue max;
808*35238bceSAndroid Build Coastguard Worker };
809*35238bceSAndroid Build Coastguard Worker
810*35238bceSAndroid Build Coastguard Worker std::string getName(void) const;
811*35238bceSAndroid Build Coastguard Worker std::string getDesc(void) const;
812*35238bceSAndroid Build Coastguard Worker
813*35238bceSAndroid Build Coastguard Worker Array::Primitive primitive;
814*35238bceSAndroid Build Coastguard Worker int drawCount; //!<Number of primitives to draw
815*35238bceSAndroid Build Coastguard Worker int first;
816*35238bceSAndroid Build Coastguard Worker
817*35238bceSAndroid Build Coastguard Worker std::vector<ArraySpec> arrays;
818*35238bceSAndroid Build Coastguard Worker };
819*35238bceSAndroid Build Coastguard Worker
820*35238bceSAndroid Build Coastguard Worker MultiVertexArrayTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const Spec &spec, const char *name,
821*35238bceSAndroid Build Coastguard Worker const char *desc);
822*35238bceSAndroid Build Coastguard Worker virtual ~MultiVertexArrayTest(void);
823*35238bceSAndroid Build Coastguard Worker virtual IterateResult iterate(void);
824*35238bceSAndroid Build Coastguard Worker
825*35238bceSAndroid Build Coastguard Worker private:
826*35238bceSAndroid Build Coastguard Worker bool isUnalignedBufferOffsetTest(void) const;
827*35238bceSAndroid Build Coastguard Worker bool isUnalignedBufferStrideTest(void) const;
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker Spec m_spec;
830*35238bceSAndroid Build Coastguard Worker int m_iteration;
831*35238bceSAndroid Build Coastguard Worker };
832*35238bceSAndroid Build Coastguard Worker
floatToHalf(float f)833*35238bceSAndroid Build Coastguard Worker inline deFloat16 GLValue::Half::floatToHalf(float f)
834*35238bceSAndroid Build Coastguard Worker {
835*35238bceSAndroid Build Coastguard Worker // No denorm support.
836*35238bceSAndroid Build Coastguard Worker tcu::Float<uint16_t, 5, 10, 15, tcu::FLOAT_HAS_SIGN> v(f);
837*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!v.isNaN() && !v.isInf());
838*35238bceSAndroid Build Coastguard Worker return v.bits();
839*35238bceSAndroid Build Coastguard Worker }
840*35238bceSAndroid Build Coastguard Worker
halfToFloat(deFloat16 h)841*35238bceSAndroid Build Coastguard Worker inline float GLValue::Half::halfToFloat(deFloat16 h)
842*35238bceSAndroid Build Coastguard Worker {
843*35238bceSAndroid Build Coastguard Worker return tcu::Float16((uint16_t)h).asFloat();
844*35238bceSAndroid Build Coastguard Worker }
845*35238bceSAndroid Build Coastguard Worker
846*35238bceSAndroid Build Coastguard Worker } // namespace gls
847*35238bceSAndroid Build Coastguard Worker } // namespace deqp
848*35238bceSAndroid Build Coastguard Worker
849*35238bceSAndroid Build Coastguard Worker #endif // _GLSVERTEXARRAYTESTS_HPP
850