1/*-------------------------------------------------------------------------
2 * drawElements Internal Test Module
3 * ---------------------------------
4 *
5 * Copyright 2015 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Texture format tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "ditTextureFormatTests.hpp"
25#include "tcuTestLog.hpp"
26
27#include "rrRenderer.hpp"
28#include "tcuTextureUtil.hpp"
29#include "tcuVectorUtil.hpp"
30#include "tcuFormatUtil.hpp"
31
32#include "deRandom.hpp"
33#include "deArrayUtil.hpp"
34#include "deStringUtil.hpp"
35#include "deUniquePtr.hpp"
36
37#include <sstream>
38
39namespace dit
40{
41
42namespace
43{
44
45using std::string;
46using std::vector;
47
48using tcu::TestLog;
49using tcu::TextureFormat;
50using tcu::TextureChannelClass;
51using tcu::TextureAccessType;
52using tcu::PixelBufferAccess;
53using tcu::ConstPixelBufferAccess;
54using tcu::Vector;
55using tcu::IVec3;
56
57// Test data
58
59static const deUint8 s_snormInt8In[] =
60{
61	0x1b, 0x23, 0xc5, 0x09,
62	0xb4, 0xbf, 0xbf, 0x24,
63	0x1a, 0x8a, 0xdb, 0x96,
64	0xc0, 0xa1, 0xde, 0x78,
65};
66static const deUint32 s_snormInt8FloatRef[] =
67{
68	0x3e59b367, 0x3e8d1a34, 0xbeeddbb7, 0x3d912245,
69	0xbf193265, 0xbf03060c, 0xbf03060c, 0x3e912245,
70	0x3e51a347, 0xbf6ddbb7, 0xbe952a55, 0xbf55ab57,
71	0xbf010204, 0xbf3f7efe, 0xbe891224, 0x3f71e3c8,
72};
73static const deUint32 s_snormInt8UintRef[] =
74{
75	0x0000001b, 0x00000023, 0xffffffc5, 0x00000009,
76	0xffffffb4, 0xffffffbf, 0xffffffbf, 0x00000024,
77	0x0000001a, 0xffffff8a, 0xffffffdb, 0xffffff96,
78	0xffffffc0, 0xffffffa1, 0xffffffde, 0x00000078,
79};
80static const deUint32 s_snormInt8IntRef[] =
81{
82	0x0000001b, 0x00000023, 0xffffffc5, 0x00000009,
83	0xffffffb4, 0xffffffbf, 0xffffffbf, 0x00000024,
84	0x0000001a, 0xffffff8a, 0xffffffdb, 0xffffff96,
85	0xffffffc0, 0xffffffa1, 0xffffffde, 0x00000078,
86};
87
88static const deUint8 s_snormInt16In[] =
89{
90	0xa0, 0xe9, 0xaa, 0x30,
91	0x16, 0x61, 0x37, 0xa2,
92	0x23, 0x4c, 0x46, 0xac,
93	0x8b, 0xf9, 0x36, 0x3e,
94	0x92, 0x7c, 0x96, 0x81,
95	0xc5, 0xb2, 0x95, 0x6e,
96	0x4f, 0x1e, 0xbc, 0x49,
97	0x14, 0x6c, 0x3c, 0x61,
98};
99static const deUint32 s_snormInt16FloatRef[] =
100{
101	0xbe330166, 0x3ec2a985, 0x3f422d84, 0xbf3b9377,
102	0x3f184731, 0xbf27754f, 0xbd4ea19d, 0x3ef8d9f2,
103	0x3f7925f2, 0xbf7cd5fa, 0xbf1a7735, 0x3f5d2bba,
104	0x3e7279e5, 0x3f137927, 0x3f5829b0, 0x3f427985,
105};
106static const deUint32 s_snormInt16UintRef[] =
107{
108	0xffffe9a0, 0x000030aa, 0x00006116, 0xffffa237,
109	0x00004c23, 0xffffac46, 0xfffff98b, 0x00003e36,
110	0x00007c92, 0xffff8196, 0xffffb2c5, 0x00006e95,
111	0x00001e4f, 0x000049bc, 0x00006c14, 0x0000613c,
112};
113static const deUint32 s_snormInt16IntRef[] =
114{
115	0xffffe9a0, 0x000030aa, 0x00006116, 0xffffa237,
116	0x00004c23, 0xffffac46, 0xfffff98b, 0x00003e36,
117	0x00007c92, 0xffff8196, 0xffffb2c5, 0x00006e95,
118	0x00001e4f, 0x000049bc, 0x00006c14, 0x0000613c,
119};
120
121static const deUint8 s_snormInt32In[] =
122{
123	0xba, 0x2c, 0x02, 0xea,
124	0x75, 0x59, 0x74, 0x48,
125	0x32, 0xad, 0xb0, 0xda,
126	0x0b, 0xf7, 0x6f, 0x49,
127	0x98, 0x9b, 0x76, 0x66,
128	0x79, 0x7d, 0x69, 0x33,
129	0xb5, 0x74, 0x61, 0xa4,
130	0x4c, 0xcd, 0x5c, 0x20,
131	0xc3, 0xba, 0x90, 0xfc,
132	0xe3, 0x17, 0xd0, 0x89,
133	0x28, 0x61, 0x5d, 0xb0,
134	0x5d, 0xc9, 0xad, 0xc9,
135	0xfc, 0x8c, 0x48, 0x3c,
136	0x11, 0x13, 0x40, 0x27,
137	0xe4, 0x88, 0x27, 0x4f,
138	0x52, 0xa2, 0x54, 0x50,
139};
140static const deUint32 s_snormInt32FloatRef[] =
141{
142	0xbe2fee9a, 0x3f10e8b3, 0xbe953d4b, 0x3f12dfee,
143	0x3f4ced37, 0x3ecda5f6, 0xbf373d17, 0x3e817335,
144	0xbcdbd14f, 0xbf6c5fd0, 0xbf1f453e, 0xbed948db,
145	0x3ef12234, 0x3e9d004c, 0x3f1e4f12, 0x3f20a945,
146};
147static const deUint32 s_snormInt32UintRef[] =
148{
149	0xea022cba, 0x48745975, 0xdab0ad32, 0x496ff70b,
150	0x66769b98, 0x33697d79, 0xa46174b5, 0x205ccd4c,
151	0xfc90bac3, 0x89d017e3, 0xb05d6128, 0xc9adc95d,
152	0x3c488cfc, 0x27401311, 0x4f2788e4, 0x5054a252,
153};
154static const deUint32 s_snormInt32IntRef[] =
155{
156	0xea022cba, 0x48745975, 0xdab0ad32, 0x496ff70b,
157	0x66769b98, 0x33697d79, 0xa46174b5, 0x205ccd4c,
158	0xfc90bac3, 0x89d017e3, 0xb05d6128, 0xc9adc95d,
159	0x3c488cfc, 0x27401311, 0x4f2788e4, 0x5054a252,
160};
161
162static const deUint8 s_unormInt8In[] =
163{
164	0x90, 0xa0, 0xa9, 0x26,
165	0x24, 0xc4, 0xa1, 0xa5,
166	0xdb, 0x0e, 0x09, 0x7a,
167	0x7f, 0x3d, 0xf2, 0x1f,
168};
169static const deUint32 s_unormInt8FloatRef[] =
170{
171	0x3f109091, 0x3f20a0a1, 0x3f29a9aa, 0x3e189899,
172	0x3e109091, 0x3f44c4c5, 0x3f21a1a2, 0x3f25a5a6,
173	0x3f5bdbdc, 0x3d60e0e1, 0x3d109091, 0x3ef4f4f5,
174	0x3efefeff, 0x3e74f4f5, 0x3f72f2f3, 0x3df8f8f9,
175};
176static const deUint32 s_unormInt8UintRef[] =
177{
178	0x00000090, 0x000000a0, 0x000000a9, 0x00000026,
179	0x00000024, 0x000000c4, 0x000000a1, 0x000000a5,
180	0x000000db, 0x0000000e, 0x00000009, 0x0000007a,
181	0x0000007f, 0x0000003d, 0x000000f2, 0x0000001f,
182};
183static const deUint32 s_unormInt8IntRef[] =
184{
185	0x00000090, 0x000000a0, 0x000000a9, 0x00000026,
186	0x00000024, 0x000000c4, 0x000000a1, 0x000000a5,
187	0x000000db, 0x0000000e, 0x00000009, 0x0000007a,
188	0x0000007f, 0x0000003d, 0x000000f2, 0x0000001f,
189};
190
191static const deUint8 s_unormInt16In[] =
192{
193	0xb6, 0x85, 0xf0, 0x1a,
194	0xbc, 0x76, 0x5b, 0x59,
195	0xf8, 0x74, 0x80, 0x6c,
196	0xb1, 0x80, 0x4a, 0xdc,
197	0xeb, 0x61, 0xa3, 0x12,
198	0xf6, 0x65, 0x6b, 0x25,
199	0x29, 0xe0, 0xe3, 0x0d,
200	0x3a, 0xac, 0xa7, 0x97,
201};
202static const deUint32 s_unormInt16FloatRef[] =
203{
204	0x3f05b686, 0x3dd780d8, 0x3eed78ed, 0x3eb2b6b3,
205	0x3ee9f0ea, 0x3ed900d9, 0x3f00b181, 0x3f5c4adc,
206	0x3ec3d6c4, 0x3d951895, 0x3ecbeccc, 0x3e15ac96,
207	0x3f6029e0, 0x3d5e30de, 0x3f2c3aac, 0x3f17a798,
208};
209static const deUint32 s_unormInt16UintRef[] =
210{
211	0x000085b6, 0x00001af0, 0x000076bc, 0x0000595b,
212	0x000074f8, 0x00006c80, 0x000080b1, 0x0000dc4a,
213	0x000061eb, 0x000012a3, 0x000065f6, 0x0000256b,
214	0x0000e029, 0x00000de3, 0x0000ac3a, 0x000097a7,
215};
216static const deUint32 s_unormInt16IntRef[] =
217{
218	0x000085b6, 0x00001af0, 0x000076bc, 0x0000595b,
219	0x000074f8, 0x00006c80, 0x000080b1, 0x0000dc4a,
220	0x000061eb, 0x000012a3, 0x000065f6, 0x0000256b,
221	0x0000e029, 0x00000de3, 0x0000ac3a, 0x000097a7,
222};
223
224static const deUint8 s_unormInt24In[] =
225{
226	0xea, 0x65, 0x31, 0xb3,
227	0x53, 0x62, 0x02, 0xf1,
228	0xda, 0x3c, 0xaf, 0x31,
229	0x35, 0xd6, 0x1f, 0xe4,
230	0xfa, 0x3b, 0xb9, 0x48,
231	0x73, 0x9a, 0xde, 0x6b,
232	0x3e, 0xa5, 0x15, 0x90,
233	0x95, 0xc2, 0x56, 0x8b,
234	0xd2, 0x14, 0xd5, 0xe5,
235	0xd0, 0x7b, 0x9f, 0x74,
236	0x79, 0x58, 0x86, 0xa9,
237	0xc0, 0xdf, 0xb6, 0xb4,
238};
239static const deUint32 s_unormInt24FloatRef[] =
240{
241	0x3e4597a9, 0x3ec4a767, 0x3f5af103, 0x3e46bcf1,
242	0x3dfeb1a9, 0x3e6feb91, 0x3ee69173, 0x3ed7bd35,
243	0x3dad29f1, 0x3f429591, 0x3f528b57, 0x3f65d515,
244	0x3f1f7bd1, 0x3eb0f2e9, 0x3f40a987, 0x3f34b6e0,
245};
246static const deUint32 s_unormInt24UintRef[] =
247{
248	0x003165ea, 0x006253b3, 0x00daf102, 0x0031af3c,
249	0x001fd635, 0x003bfae4, 0x007348b9, 0x006bde9a,
250	0x0015a53e, 0x00c29590, 0x00d28b56, 0x00e5d514,
251	0x009f7bd0, 0x00587974, 0x00c0a986, 0x00b4b6df,
252};
253static const deUint32 s_unormInt24IntRef[] =
254{
255	0x003165ea, 0x006253b3, 0x00daf102, 0x0031af3c,
256	0x001fd635, 0x003bfae4, 0x007348b9, 0x006bde9a,
257	0x0015a53e, 0x00c29590, 0x00d28b56, 0x00e5d514,
258	0x009f7bd0, 0x00587974, 0x00c0a986, 0x00b4b6df,
259};
260
261static const deUint8 s_unormInt32In[] =
262{
263	0x45, 0x7d, 0xe1, 0x55,
264	0xd2, 0xcb, 0xc5, 0x17,
265	0x64, 0x87, 0x84, 0x50,
266	0x37, 0x60, 0x54, 0xa1,
267	0xa8, 0x7e, 0xea, 0x98,
268	0x1a, 0xd1, 0xb4, 0x70,
269	0x2d, 0xcb, 0xff, 0x13,
270	0x3d, 0xd7, 0x3c, 0xe4,
271	0x94, 0xd6, 0xb4, 0xf7,
272	0x01, 0x58, 0x32, 0x9d,
273	0x91, 0x2b, 0x49, 0x1f,
274	0xd0, 0xca, 0x3d, 0x05,
275	0x14, 0x5a, 0x95, 0xd0,
276	0xfd, 0x64, 0x33, 0xd3,
277	0x73, 0x87, 0xa5, 0xf9,
278	0x6d, 0xc8, 0x39, 0x03,
279};
280static const deUint32 s_unormInt32FloatRef[] =
281{
282	0x3eabc2fb, 0x3dbe2e5f, 0x3ea1090f, 0x3f215460,
283	0x3f18ea7f, 0x3ee169a2, 0x3d9ffe59, 0x3f643cd7,
284	0x3f77b4d7, 0x3f1d3258, 0x3dfa495d, 0x3ca7b95a,
285	0x3f50955a, 0x3f533365, 0x3f79a587, 0x3c4e721b,
286};
287static const deUint32 s_unormInt32UintRef[] =
288{
289	0x55e17d45, 0x17c5cbd2, 0x50848764, 0xa1546037,
290	0x98ea7ea8, 0x70b4d11a, 0x13ffcb2d, 0xe43cd73d,
291	0xf7b4d694, 0x9d325801, 0x1f492b91, 0x053dcad0,
292	0xd0955a14, 0xd33364fd, 0xf9a58773, 0x0339c86d,
293};
294static const deUint32 s_unormInt32IntRef[] =
295{
296	0x55e17d45, 0x17c5cbd2, 0x50848764, 0xa1546037,
297	0x98ea7ea8, 0x70b4d11a, 0x13ffcb2d, 0xe43cd73d,
298	0xf7b4d694, 0x9d325801, 0x1f492b91, 0x053dcad0,
299	0xd0955a14, 0xd33364fd, 0xf9a58773, 0x0339c86d,
300};
301
302static const deUint8 s_unormByte44In[] =
303{
304	0xdb, 0xa8, 0x29, 0x2d,
305};
306static const deUint32 s_unormByte44FloatRef[] =
307{
308	0x3f5dddde, 0x3f3bbbbc, 0x00000000, 0x3f800000,
309	0x3f2aaaab, 0x3f088889, 0x00000000, 0x3f800000,
310	0x3e088889, 0x3f19999a, 0x00000000, 0x3f800000,
311	0x3e088889, 0x3f5dddde, 0x00000000, 0x3f800000,
312};
313static const deUint32 s_unormByte44IntRef[] =
314{
315	0x0000000d, 0x0000000b, 0x00000000, 0x00000001,
316	0x0000000a, 0x00000008, 0x00000000, 0x00000001,
317	0x00000002, 0x00000009, 0x00000000, 0x00000001,
318	0x00000002, 0x0000000d, 0x00000000, 0x00000001,
319};
320static const deUint32 s_unsignedByte44FloatRef[] =
321{
322	0x41500000, 0x41300000, 0x00000000, 0x3f800000,
323	0x41200000, 0x41000000, 0x00000000, 0x3f800000,
324	0x40000000, 0x41100000, 0x00000000, 0x3f800000,
325	0x40000000, 0x41500000, 0x00000000, 0x3f800000,
326};
327
328static const deUint8 s_unormShort565In[] =
329{
330	0xea, 0x7e, 0xcc, 0x28,
331	0x38, 0xce, 0x8f, 0x16,
332};
333static const deUint32 s_unormShort565FloatRef[] =
334{
335	0x3ef7bdef, 0x3f5f7df8, 0x3ea5294a, 0x3f800000,
336	0x3e25294a, 0x3dc30c31, 0x3ec6318c, 0x3f800000,
337	0x3f4e739d, 0x3f471c72, 0x3f46318c, 0x3f800000,
338	0x3d842108, 0x3f534d35, 0x3ef7bdef, 0x3f800000,
339};
340static const deUint32 s_unormShort565IntRef[] =
341{
342	0x0000000f, 0x00000037, 0x0000000a, 0x00000001,
343	0x00000005, 0x00000006, 0x0000000c, 0x00000001,
344	0x00000019, 0x00000031, 0x00000018, 0x00000001,
345	0x00000002, 0x00000034, 0x0000000f, 0x00000001,
346};
347static const deUint32 s_unsignedShort565FloatRef[] =
348{
349	0x41700000, 0x425c0000, 0x41200000, 0x3f800000,
350	0x40a00000, 0x40c00000, 0x41400000, 0x3f800000,
351	0x41c80000, 0x42440000, 0x41c00000, 0x3f800000,
352	0x40000000, 0x42500000, 0x41700000, 0x3f800000,
353};
354
355static const deUint8 s_unormShort555In[] =
356{
357	0x02, 0xea, 0x89, 0x13,
358	0x94, 0x5a, 0x5b, 0x60,
359};
360static const deUint32 s_unormShort555FloatRef[] =
361{
362	0x3f56b5ad, 0x3f042108, 0x3d842108, 0x3f800000,
363	0x3e042108, 0x3f6739ce, 0x3e94a529, 0x3f800000,
364	0x3f35ad6b, 0x3f25294a, 0x3f25294a, 0x3f800000,
365	0x3f46318c, 0x3d842108, 0x3f5ef7be, 0x3f800000,
366};
367static const deUint32 s_unormShort555IntRef[] =
368{
369	0x0000001a, 0x00000010, 0x00000002, 0x00000001,
370	0x00000004, 0x0000001c, 0x00000009, 0x00000001,
371	0x00000016, 0x00000014, 0x00000014, 0x00000001,
372	0x00000018, 0x00000002, 0x0000001b, 0x00000001,
373};
374
375static const deUint8 s_unormShort4444In[] =
376{
377	0x19, 0xdb, 0xa8, 0xa8,
378	0x72, 0x29, 0xb4, 0x2d,
379};
380static const deUint32 s_unormShort4444FloatRef[] =
381{
382	0x3f5dddde, 0x3f3bbbbc, 0x3d888889, 0x3f19999a,
383	0x3f2aaaab, 0x3f088889, 0x3f2aaaab, 0x3f088889,
384	0x3e088889, 0x3f19999a, 0x3eeeeeef, 0x3e088889,
385	0x3e088889, 0x3f5dddde, 0x3f3bbbbc, 0x3e888889,
386};
387static const deUint32 s_unormShort4444IntRef[] =
388{
389	0x0000000d, 0x0000000b, 0x00000001, 0x00000009,
390	0x0000000a, 0x00000008, 0x0000000a, 0x00000008,
391	0x00000002, 0x00000009, 0x00000007, 0x00000002,
392	0x00000002, 0x0000000d, 0x0000000b, 0x00000004,
393};
394static const deUint32 s_unsignedShort4444FloatRef[] =
395{
396	0x41500000, 0x41300000, 0x3f800000, 0x41100000,
397	0x41200000, 0x41000000, 0x41200000, 0x41000000,
398	0x40000000, 0x41100000, 0x40e00000, 0x40000000,
399	0x40000000, 0x41500000, 0x41300000, 0x40800000,
400};
401
402static const deUint8 s_unormShort5551In[] =
403{
404	0x13, 0x89, 0x6f, 0x3c,
405	0xae, 0xe9, 0xf2, 0xd9,
406};
407static const deUint32 s_unormShort5551FloatRef[] =
408{
409	0x3f0c6319, 0x3e042108, 0x3e94a529, 0x3f800000,
410	0x3e6739ce, 0x3f0c6319, 0x3f3def7c, 0x3f800000,
411	0x3f6f7bdf, 0x3e46318c, 0x3f3def7c, 0x00000000,
412	0x3f5ef7be, 0x3e6739ce, 0x3f4e739d, 0x00000000,
413};
414static const deUint32 s_unormShort5551IntRef[] =
415{
416	0x00000011, 0x00000004, 0x00000009, 0x00000001,
417	0x00000007, 0x00000011, 0x00000017, 0x00000001,
418	0x0000001d, 0x00000006, 0x00000017, 0x00000000,
419	0x0000001b, 0x00000007, 0x00000019, 0x00000000,
420};
421static const deUint32 s_unsignedShort5551FloatRef[] =
422{
423	0x41880000, 0x40800000, 0x41100000, 0x3f800000,
424	0x40e00000, 0x41880000, 0x41b80000, 0x3f800000,
425	0x41e80000, 0x40c00000, 0x41b80000, 0x00000000,
426	0x41d80000, 0x40e00000, 0x41c80000, 0x00000000,
427};
428
429static const deUint8 s_unormShort1555In[] =
430{
431	0xf8, 0xc5, 0x1f, 0x6c,
432	0xf0, 0x2f, 0xf2, 0x95,
433};
434static const deUint32 s_unormShort1555FloatRef[] =
435{
436	0x3f800000, 0x3f0c6319, 0x3ef7bdef, 0x3f46318c,
437	0x00000000, 0x3f5ef7be, 0x00000000, 0x3f800000,
438	0x00000000, 0x3eb5ad6b, 0x3f800000, 0x3f042108,
439	0x3f800000, 0x3e25294a, 0x3ef7bdef, 0x3f14a529,
440};
441static const deUint32 s_unormShort1555IntRef[] =
442{
443	0x00000001, 0x00000011, 0x0000000f, 0x00000018,
444	0x00000000, 0x0000001b, 0x00000000, 0x0000001f,
445	0x00000000, 0x0000000b, 0x0000001f, 0x00000010,
446	0x00000001, 0x00000005, 0x0000000f, 0x00000012,
447};
448
449static const deUint8 s_unormInt101010In[] =
450{
451	0x81, 0xb3, 0x67, 0x51,
452	0xa9, 0x00, 0x34, 0xc5,
453	0xf0, 0x2f, 0xf2, 0x95,
454	0xf8, 0xc5, 0x1f, 0x6c,
455};
456static const deUint32 s_unormInt101010FloatRef[] =
457{
458	0x3ea2a8aa, 0x3f1ee7ba, 0x3e60380e, 0x3f800000,
459	0x3f45314c, 0x3f50340d, 0x3d282a0b, 0x3f800000,
460	0x3f15e579, 0x3f48b22d, 0x3f7f3fd0, 0x3f800000,
461	0x3ed8360e, 0x3efe3f90, 0x3ebf2fcc, 0x3f800000,
462};
463static const deUint32 s_unormInt101010IntRef[] =
464{
465	0x00000145, 0x0000027b, 0x000000e0, 0x00000001,
466	0x00000314, 0x00000340, 0x0000002a, 0x00000001,
467	0x00000257, 0x00000322, 0x000003fc, 0x00000001,
468	0x000001b0, 0x000001fc, 0x0000017e, 0x00000001,
469};
470
471static const deUint8 s_unormInt1010102RevIn[] =
472{
473	0xfd, 0xc6, 0xf5, 0xc4,
474	0x32, 0xa8, 0xfd, 0x7d,
475	0xe7, 0x3f, 0x10, 0xd0,
476	0x86, 0x0d, 0x66, 0xd0,
477};
478static const deUint32 s_unormInt1010102RevFloatRef[] =
479{
480	0x3f3f6fdc, 0x3eb8ae2c, 0x3d9e278a, 0x3f800000,
481	0x3d48320d, 0x3f5ab6ae, 0x3f77fdff, 0x3eaaaaab,
482	0x3f79fe80, 0x3c703c0f, 0x3e80a028, 0x3f800000,
483	0x3ec330cc, 0x3ec1b06c, 0x3e8320c8, 0x3f800000,
484};
485static const deUint32 s_unormInt1010102RevIntRef[] =
486{
487	0x000002fd, 0x00000171, 0x0000004f, 0x00000003,
488	0x00000032, 0x0000036a, 0x000003df, 0x00000001,
489	0x000003e7, 0x0000000f, 0x00000101, 0x00000003,
490	0x00000186, 0x00000183, 0x00000106, 0x00000003,
491};
492static const deUint32 s_snormInt1010102RevFloatRef[] =
493{
494	0xbf01c0e0, 0x3f38dc6e, 0x3e1e4f28, 0xbf800000,
495	0x3dc86432, 0xbe964b26, 0xbd844221, 0x3f800000,
496	0xbd486432, 0x3cf0783c, 0x3f00c060, 0xbf800000,
497	0x3f4361b1, 0x3f41e0f0, 0x3f0341a1, 0xbf800000,
498};
499static const deUint32 s_snormInt1010102RevIntRef[] =
500{
501	0xfffffefd, 0x00000171, 0x0000004f, 0xffffffff,
502	0x00000032, 0xffffff6a, 0xffffffdf, 0x00000001,
503	0xffffffe7, 0x0000000f, 0x00000101, 0xffffffff,
504	0x00000186, 0x00000183, 0x00000106, 0xffffffff,
505};
506
507static const deUint8 s_unsignedInt1010102RevIn[] =
508{
509	0xb8, 0x4c, 0xfd, 0x00,
510	0x65, 0x7f, 0xb2, 0x4e,
511	0x11, 0x3e, 0x03, 0x23,
512	0xae, 0xc9, 0xdd, 0xa2,
513};
514static const deUint32 s_unsignedInt1010102RevFloatRef[] =
515{
516	0x43380000, 0x4454c000, 0x41700000, 0x00000000,
517	0x44594000, 0x431f0000, 0x436b0000, 0x3f800000,
518	0x44044000, 0x434f0000, 0x440c0000, 0x00000000,
519	0x43d70000, 0x445c8000, 0x440b4000, 0x40000000,
520};
521static const deUint32 s_unsignedInt1010102RevIntRef[] =
522{
523	0x000000b8, 0x00000353, 0x0000000f, 0x00000000,
524	0x00000365, 0x0000009f, 0x000000eb, 0x00000001,
525	0x00000211, 0x000000cf, 0x00000230, 0x00000000,
526	0x000001ae, 0x00000372, 0x0000022d, 0x00000002,
527};
528static const deUint32 s_signedInt1010102RevFloatRef[] =
529{
530	0x43380000, 0x4f7fffff, 0x41700000, 0x00000000,
531	0x4f7fffff, 0x431f0000, 0x436b0000, 0x3f800000,
532	0x4f7ffffe, 0x434f0000, 0x4f7ffffe, 0x00000000,
533	0x43d70000, 0x4f7fffff, 0x4f7ffffe, 0x4f800000,
534};
535static const deUint32 s_signedInt1010102RevIntRef[] =
536{
537	0x000000b8, 0xffffff53, 0x0000000f, 0x00000000,
538	0xffffff65, 0x0000009f, 0x000000eb, 0x00000001,
539	0xfffffe11, 0x000000cf, 0xfffffe30, 0x00000000,
540	0x000001ae, 0xffffff72, 0xfffffe2d, 0xfffffffe,
541};
542
543static const deUint8 s_unsignedInt11f11f10fRevIn[] =
544{
545	0x8e, 0x1b, 0x81, 0x45,
546	0xcf, 0x47, 0x50, 0x29,
547	0xff, 0x5e, 0x8e, 0x93,
548	0x95, 0x07, 0x45, 0x4a,
549};
550static const deUint32 s_unsignedInt11f11f10fRevFloatRef[] =
551{
552	0x3f1c0000, 0x380c0000, 0x3c580000, 0x3f800000,
553	0x7fffffff, 0x3c100000, 0x3a940000, 0x3f800000,
554	0x45fe0000, 0x3b960000, 0x41380000, 0x3f800000,
555	0x472a0000, 0x39400000, 0x3ca40000, 0x3f800000,
556};
557
558static const deUint8 s_unsignedInt999E5RevIn[] =
559{
560	0x88, 0x8b, 0x50, 0x34,
561	0x2b, 0x2f, 0xe2, 0x92,
562	0x95, 0x7f, 0xeb, 0x18,
563	0x6b, 0xe2, 0x27, 0x30,
564};
565static const deUint32 s_unsignedInt999E5RevFloatRef[] =
566{
567	0x3ac40000, 0x398a0000, 0x3a8a0000, 0x3f800000,
568	0x40958000, 0x408b8000, 0x40380000, 0x3f800000,
569	0x394a8000, 0x395f8000, 0x37e80000, 0x3f800000,
570	0x39d60000, 0x3af88000, 0x38100000, 0x3f800000,
571};
572
573static const deUint8 s_unsignedInt1688In[] =
574{
575	0x02, 0x50, 0x91, 0x85,
576	0xcc, 0xe2, 0xfd, 0xc8,
577	0x62, 0xeb, 0x0f, 0xe6,
578	0x95, 0x27, 0x26, 0x24,
579};
580static const deUint32 s_unsignedInt1688FloatRef[] =
581{
582	0x3f059186, 0x00000000, 0x00000000, 0x3f800000,
583	0x3f48fdc9, 0x00000000, 0x00000000, 0x3f800000,
584	0x3f660fe6, 0x00000000, 0x00000000, 0x3f800000,
585	0x3e109891, 0x00000000, 0x00000000, 0x3f800000,
586};
587static const deUint32 s_unsignedInt1688UintRef[] =
588{
589	0x00000002, 0x00000000, 0x00000000, 0x00000001,
590	0x000000cc, 0x00000000, 0x00000000, 0x00000001,
591	0x00000062, 0x00000000, 0x00000000, 0x00000001,
592	0x00000095, 0x00000000, 0x00000000, 0x00000001,
593};
594
595static const deUint8 s_unsignedInt248In[] =
596{
597	0xea, 0x7e, 0xcc, 0x28,
598	0x38, 0xce, 0x8f, 0x16,
599	0x3e, 0x4f, 0xe2, 0xfd,
600	0x74, 0x5e, 0xf2, 0x30,
601};
602static const deUint32 s_unsignedInt248FloatRef[] =
603{
604	0x3e2331f9, 0x00000000, 0x00000000, 0x3f800000,
605	0x3db47e71, 0x00000000, 0x00000000, 0x3f800000,
606	0x3f7de250, 0x00000000, 0x00000000, 0x3f800000,
607	0x3e43c979, 0x00000000, 0x00000000, 0x3f800000,
608};
609static const deUint32 s_unsignedInt248UintRef[] =
610{
611	0x000000ea, 0x00000000, 0x00000000, 0x00000001,
612	0x00000038, 0x00000000, 0x00000000, 0x00000001,
613	0x0000003e, 0x00000000, 0x00000000, 0x00000001,
614	0x00000074, 0x00000000, 0x00000000, 0x00000001,
615};
616
617static const deUint8 s_unsignedInt248RevIn[] =
618{
619	0x7e, 0xcc, 0x28, 0xea,
620	0xce, 0x8f, 0x16, 0x38,
621	0x4f, 0xe2, 0xfd, 0x3e,
622	0x5e, 0xf2, 0x30, 0x74,
623};
624static const deUint32 s_unsignedInt248RevFloatRef[] =
625{
626	0x3e2331f9, 0x00000000, 0x00000000, 0x3f800000,
627	0x3db47e71, 0x00000000, 0x00000000, 0x3f800000,
628	0x3f7de250, 0x00000000, 0x00000000, 0x3f800000,
629	0x3e43c979, 0x00000000, 0x00000000, 0x3f800000,
630};
631static const deUint32 s_unsignedInt248RevUintRef[] =
632{
633	0x000000ea, 0x00000000, 0x00000000, 0x00000001,
634	0x00000038, 0x00000000, 0x00000000, 0x00000001,
635	0x0000003e, 0x00000000, 0x00000000, 0x00000001,
636	0x00000074, 0x00000000, 0x00000000, 0x00000001,
637};
638
639static const deUint8 s_signedInt8In[] =
640{
641	0x3a, 0x5b, 0x6d, 0x6a,
642	0x44, 0x56, 0x6b, 0x21,
643	0x6a, 0x0b, 0x24, 0xd9,
644	0xd4, 0xb4, 0xda, 0x97,
645};
646static const deUint32 s_signedInt8FloatRef[] =
647{
648	0x42680000, 0x42b60000, 0x42da0000, 0x42d40000,
649	0x42880000, 0x42ac0000, 0x42d60000, 0x42040000,
650	0x42d40000, 0x41300000, 0x42100000, 0xc21c0000,
651	0xc2300000, 0xc2980000, 0xc2180000, 0xc2d20000,
652};
653static const deUint32 s_signedInt8UintRef[] =
654{
655	0x0000003a, 0x0000005b, 0x0000006d, 0x0000006a,
656	0x00000044, 0x00000056, 0x0000006b, 0x00000021,
657	0x0000006a, 0x0000000b, 0x00000024, 0xffffffd9,
658	0xffffffd4, 0xffffffb4, 0xffffffda, 0xffffff97,
659};
660static const deUint32 s_signedInt8IntRef[] =
661{
662	0x0000003a, 0x0000005b, 0x0000006d, 0x0000006a,
663	0x00000044, 0x00000056, 0x0000006b, 0x00000021,
664	0x0000006a, 0x0000000b, 0x00000024, 0xffffffd9,
665	0xffffffd4, 0xffffffb4, 0xffffffda, 0xffffff97,
666};
667
668static const deUint8 s_signedInt16In[] =
669{
670	0xf1, 0xdd, 0xcd, 0xc3,
671	0x1c, 0xb6, 0x6f, 0x74,
672	0x19, 0x13, 0x25, 0xed,
673	0x16, 0xce, 0x0d, 0x0f,
674	0x5c, 0xf4, 0x3c, 0xa3,
675	0x6d, 0x25, 0x65, 0x6d,
676	0xae, 0x5d, 0x88, 0xfa,
677	0x86, 0x3e, 0x6a, 0x91,
678};
679static const deUint32 s_signedInt16FloatRef[] =
680{
681	0xc6083c00, 0xc670cc00, 0xc693c800, 0x46e8de00,
682	0x4598c800, 0xc596d800, 0xc647a800, 0x4570d000,
683	0xc53a4000, 0xc6b98800, 0x4615b400, 0x46daca00,
684	0x46bb5c00, 0xc4af0000, 0x467a1800, 0xc6dd2c00,
685};
686static const deUint32 s_signedInt16UintRef[] =
687{
688	0xffffddf1, 0xffffc3cd, 0xffffb61c, 0x0000746f,
689	0x00001319, 0xffffed25, 0xffffce16, 0x00000f0d,
690	0xfffff45c, 0xffffa33c, 0x0000256d, 0x00006d65,
691	0x00005dae, 0xfffffa88, 0x00003e86, 0xffff916a,
692};
693static const deUint32 s_signedInt16IntRef[] =
694{
695	0xffffddf1, 0xffffc3cd, 0xffffb61c, 0x0000746f,
696	0x00001319, 0xffffed25, 0xffffce16, 0x00000f0d,
697	0xfffff45c, 0xffffa33c, 0x0000256d, 0x00006d65,
698	0x00005dae, 0xfffffa88, 0x00003e86, 0xffff916a,
699};
700
701static const deUint8 s_signedInt32In[] =
702{
703	0xc6, 0x7e, 0x50, 0x2a,
704	0xec, 0x0f, 0x9b, 0x44,
705	0x4d, 0xa9, 0x77, 0x0d,
706	0x69, 0x4c, 0xd3, 0x76,
707	0xf0, 0xb7, 0xde, 0x6b,
708	0x4e, 0xe2, 0xb1, 0x58,
709	0xa8, 0x9c, 0xfc, 0x6d,
710	0x75, 0x8f, 0x3c, 0x7f,
711	0xf3, 0x19, 0x14, 0x97,
712	0xf0, 0x87, 0x5c, 0x11,
713	0x95, 0x32, 0xab, 0x7a,
714	0x03, 0x2b, 0xdf, 0x52,
715	0x68, 0x84, 0xd9, 0x91,
716	0xec, 0x2a, 0xf1, 0xd0,
717	0xf7, 0x73, 0x8f, 0x0a,
718	0x62, 0xd2, 0x76, 0xfd,
719};
720static const deUint32 s_signedInt32FloatRef[] =
721{
722	0x4e2941fb, 0x4e893620, 0x4d577a95, 0x4eeda699,
723	0x4ed7bd70, 0x4eb163c5, 0x4edbf939, 0x4efe791f,
724	0xced1d7cc, 0x4d8ae440, 0x4ef55665, 0x4ea5be56,
725	0xcedc4cf7, 0xce3c3b54, 0x4d28f73f, 0xcc224b68,
726};
727static const deUint32 s_signedInt32UintRef[] =
728{
729	0x2a507ec6, 0x449b0fec, 0x0d77a94d, 0x76d34c69,
730	0x6bdeb7f0, 0x58b1e24e, 0x6dfc9ca8, 0x7f3c8f75,
731	0x971419f3, 0x115c87f0, 0x7aab3295, 0x52df2b03,
732	0x91d98468, 0xd0f12aec, 0x0a8f73f7, 0xfd76d262,
733};
734static const deUint32 s_signedInt32IntRef[] =
735{
736	0x2a507ec6, 0x449b0fec, 0x0d77a94d, 0x76d34c69,
737	0x6bdeb7f0, 0x58b1e24e, 0x6dfc9ca8, 0x7f3c8f75,
738	0x971419f3, 0x115c87f0, 0x7aab3295, 0x52df2b03,
739	0x91d98468, 0xd0f12aec, 0x0a8f73f7, 0xfd76d262,
740};
741
742static const deUint8 s_unsignedInt8In[] =
743{
744	0x68, 0xa6, 0x99, 0x6e,
745	0x13, 0x90, 0x0f, 0x40,
746	0x34, 0x76, 0x05, 0x9a,
747	0x6c, 0x9c, 0x1d, 0x6a,
748};
749static const deUint32 s_unsignedInt8FloatRef[] =
750{
751	0x42d00000, 0x43260000, 0x43190000, 0x42dc0000,
752	0x41980000, 0x43100000, 0x41700000, 0x42800000,
753	0x42500000, 0x42ec0000, 0x40a00000, 0x431a0000,
754	0x42d80000, 0x431c0000, 0x41e80000, 0x42d40000,
755};
756static const deUint32 s_unsignedInt8UintRef[] =
757{
758	0x00000068, 0x000000a6, 0x00000099, 0x0000006e,
759	0x00000013, 0x00000090, 0x0000000f, 0x00000040,
760	0x00000034, 0x00000076, 0x00000005, 0x0000009a,
761	0x0000006c, 0x0000009c, 0x0000001d, 0x0000006a,
762};
763static const deUint32 s_unsignedInt8IntRef[] =
764{
765	0x00000068, 0x000000a6, 0x00000099, 0x0000006e,
766	0x00000013, 0x00000090, 0x0000000f, 0x00000040,
767	0x00000034, 0x00000076, 0x00000005, 0x0000009a,
768	0x0000006c, 0x0000009c, 0x0000001d, 0x0000006a,
769};
770
771static const deUint8 s_unsignedInt16In[] =
772{
773	0xa5, 0x62, 0x98, 0x7c,
774	0x13, 0x21, 0xc8, 0xf4,
775	0x78, 0x0b, 0x9f, 0xc2,
776	0x92, 0x1c, 0xa9, 0x25,
777	0x86, 0xea, 0x1f, 0x1c,
778	0x41, 0xf7, 0xe2, 0x2e,
779	0x38, 0x69, 0xf2, 0x6d,
780	0x01, 0xec, 0x7f, 0xc5,
781};
782static const deUint32 s_unsignedInt16FloatRef[] =
783{
784	0x46c54a00, 0x46f93000, 0x46044c00, 0x4774c800,
785	0x45378000, 0x47429f00, 0x45e49000, 0x4616a400,
786	0x476a8600, 0x45e0f800, 0x47774100, 0x463b8800,
787	0x46d27000, 0x46dbe400, 0x476c0100, 0x47457f00,
788};
789static const deUint32 s_unsignedInt16UintRef[] =
790{
791	0x000062a5, 0x00007c98, 0x00002113, 0x0000f4c8,
792	0x00000b78, 0x0000c29f, 0x00001c92, 0x000025a9,
793	0x0000ea86, 0x00001c1f, 0x0000f741, 0x00002ee2,
794	0x00006938, 0x00006df2, 0x0000ec01, 0x0000c57f,
795};
796static const deUint32 s_unsignedInt16IntRef[] =
797{
798	0x000062a5, 0x00007c98, 0x00002113, 0x0000f4c8,
799	0x00000b78, 0x0000c29f, 0x00001c92, 0x000025a9,
800	0x0000ea86, 0x00001c1f, 0x0000f741, 0x00002ee2,
801	0x00006938, 0x00006df2, 0x0000ec01, 0x0000c57f,
802};
803
804static const deUint8 s_unsignedInt24In[] =
805{
806	0xa8, 0x11, 0x00, 0xc8,
807	0xe5, 0x07, 0xd3, 0x6d,
808	0x0a, 0xc7, 0xe4, 0x42,
809	0x2d, 0xf7, 0x5d, 0x9c,
810	0x2e, 0x18, 0xfd, 0xa4,
811	0x9e, 0x90, 0x0c, 0x31,
812	0x06, 0x04, 0xc4, 0xc2,
813	0xde, 0xfe, 0x7c, 0x1d,
814	0x57, 0x37, 0x4a, 0xf2,
815	0xe2, 0xf3, 0x74, 0x8e,
816	0x8f, 0xd6, 0x73, 0xc4,
817	0x91, 0xa0, 0x49, 0xe3,
818};
819static const deUint32 s_unsignedInt24FloatRef[] =
820{
821	0x458d4000, 0x48fcb900, 0x4926dd30, 0x4a85c98e,
822	0x4abbee5a, 0x49c174e0, 0x4b1ea4fd, 0x4a443240,
823	0x4b440406, 0x4b7edec2, 0x4aae3af8, 0x4b724a37,
824	0x4ae9e7c4, 0x4b568f8e, 0x4b11c473, 0x4b6349a0,
825};
826static const deUint32 s_unsignedInt24UintRef[] =
827{
828	0x000011a8, 0x0007e5c8, 0x000a6dd3, 0x0042e4c7,
829	0x005df72d, 0x00182e9c, 0x009ea4fd, 0x00310c90,
830	0x00c40406, 0x00fedec2, 0x00571d7c, 0x00f24a37,
831	0x0074f3e2, 0x00d68f8e, 0x0091c473, 0x00e349a0,
832};
833static const deUint32 s_unsignedInt24IntRef[] =
834{
835	0x000011a8, 0x0007e5c8, 0x000a6dd3, 0x0042e4c7,
836	0x005df72d, 0x00182e9c, 0x009ea4fd, 0x00310c90,
837	0x00c40406, 0x00fedec2, 0x00571d7c, 0x00f24a37,
838	0x0074f3e2, 0x00d68f8e, 0x0091c473, 0x00e349a0,
839};
840
841static const deUint8 s_unsignedInt32In[] =
842{
843	0x90, 0xb0, 0x00, 0xa8,
844	0xd8, 0x42, 0x5b, 0xae,
845	0x40, 0x70, 0x38, 0x2a,
846	0x92, 0x76, 0xd8, 0x70,
847	0x04, 0x0d, 0x67, 0x87,
848	0x9c, 0xdd, 0xb1, 0xeb,
849	0xfc, 0x37, 0xe6, 0x40,
850	0x24, 0x9c, 0x6a, 0x0f,
851	0x09, 0x0e, 0xb6, 0x2f,
852	0x31, 0x95, 0x43, 0x22,
853	0x24, 0xde, 0x70, 0x2a,
854	0x05, 0xa2, 0x84, 0x38,
855	0x16, 0x9f, 0x65, 0x0e,
856	0xb2, 0x99, 0x84, 0x6d,
857	0xef, 0x86, 0x94, 0xf0,
858	0x25, 0x9d, 0xf9, 0x67,
859};
860static const deUint32 s_unsignedInt32FloatRef[] =
861{
862	0x4f2800b1, 0x4f2e5b43, 0x4e28e1c1, 0x4ee1b0ed,
863	0x4f07670d, 0x4f6bb1de, 0x4e81cc70, 0x4d76a9c2,
864	0x4e3ed838, 0x4e090e55, 0x4e29c379, 0x4e621288,
865	0x4d6659f1, 0x4edb0933, 0x4f709487, 0x4ecff33a,
866};
867static const deUint32 s_unsignedInt32UintRef[] =
868{
869	0xa800b090, 0xae5b42d8, 0x2a387040, 0x70d87692,
870	0x87670d04, 0xebb1dd9c, 0x40e637fc, 0x0f6a9c24,
871	0x2fb60e09, 0x22439531, 0x2a70de24, 0x3884a205,
872	0x0e659f16, 0x6d8499b2, 0xf09486ef, 0x67f99d25,
873};
874static const deUint32 s_unsignedInt32IntRef[] =
875{
876	0xa800b090, 0xae5b42d8, 0x2a387040, 0x70d87692,
877	0x87670d04, 0xebb1dd9c, 0x40e637fc, 0x0f6a9c24,
878	0x2fb60e09, 0x22439531, 0x2a70de24, 0x3884a205,
879	0x0e659f16, 0x6d8499b2, 0xf09486ef, 0x67f99d25,
880};
881
882static const deUint8 s_halfFloatIn[] =
883{
884	0x2b, 0x74, 0x6a, 0x5d,
885	0x1c, 0xb2, 0x9a, 0x4d,
886	0xad, 0x55, 0x22, 0x01,
887	0xce, 0x2d, 0x97, 0x0d,
888	0x71, 0x31, 0x42, 0x2b,
889	0xeb, 0x26, 0xc7, 0x16,
890	0x94, 0xd2, 0x22, 0x79,
891	0x89, 0xbd, 0xff, 0xbc,
892};
893static const deUint32 s_halfFloatFloatRef[] =
894{
895	0x46856000, 0x43ad4000, 0xbe438000, 0x41b34000,
896	0x42b5a000, 0x37910000, 0x3db9c000, 0x39b2e000,
897	0x3e2e2000, 0x3d684000, 0x3cdd6000, 0x3ad8e000,
898	0xc2528000, 0x47244000, 0xbfb12000, 0xbf9fe000,
899};
900static const deUint32 s_halfFloatUintRef[] =
901{
902	0x000042b0, 0x0000015a, 0x00000000, 0x00000016,
903	0x0000005a, 0x00000000, 0x00000000, 0x00000000,
904	0x00000000, 0x00000000, 0x00000000, 0x00000000,
905	0xffffffcc, 0x0000a440, 0xffffffff, 0xffffffff,
906};
907static const deUint32 s_halfFloatIntRef[] =
908{
909	0x000042b0, 0x0000015a, 0x00000000, 0x00000016,
910	0x0000005a, 0x00000000, 0x00000000, 0x00000000,
911	0x00000000, 0x00000000, 0x00000000, 0x00000000,
912	0xffffffcc, 0x0000a440, 0xffffffff, 0xffffffff,
913};
914
915static const deUint8 s_floatIn[] =
916{
917	0x92, 0xac, 0x68, 0x36,
918	0x9f, 0x42, 0x0b, 0x6e,
919	0x67, 0xcf, 0x0f, 0x20,
920	0x22, 0x6c, 0xe4, 0x0f,
921	0xb3, 0x72, 0xc8, 0x8a,
922	0x4b, 0x99, 0xc3, 0xb0,
923	0xbd, 0x78, 0x5c, 0x16,
924	0x1c, 0xce, 0xb7, 0x4e,
925	0x15, 0xdf, 0x37, 0xfd,
926	0xeb, 0x32, 0xe9, 0x47,
927	0x68, 0x1a, 0xaa, 0xd0,
928	0xb9, 0xba, 0x77, 0xe7,
929	0x81, 0x0a, 0x42, 0x5a,
930	0xb0, 0x5a, 0xee, 0x06,
931	0x77, 0xb4, 0x7b, 0x57,
932	0xf5, 0x35, 0xac, 0x56,
933};
934static const deUint32 s_floatFloatRef[] =
935{
936	0x3668ac92, 0x6e0b429f, 0x200fcf67, 0x0fe46c22,
937	0x8ac872b3, 0xb0c3994b, 0x165c78bd, 0x4eb7ce1c,
938	0xfd37df15, 0x47e932eb, 0xd0aa1a68, 0xe777bab9,
939	0x5a420a81, 0x06ee5ab0, 0x577bb477, 0x56ac35f5,
940};
941static const deUint32 s_floatUintRef[] =
942{
943	0x00000000, 0x80000000, 0x00000000, 0x00000000,
944	0x00000000, 0x00000000, 0x00000000, 0x5be70e00,
945	0x80000000, 0x0001d265, 0x80000000, 0x80000000,
946	0x80000000, 0x00000000, 0x80000000, 0x80000000,
947};
948static const deUint32 s_floatIntRef[] =
949{
950	0x00000000, 0x80000000, 0x00000000, 0x00000000,
951	0x00000000, 0x00000000, 0x00000000, 0x5be70e00,
952	0x80000000, 0x0001d265, 0x80000000, 0x80000000,
953	0x80000000, 0x00000000, 0x80000000, 0x80000000,
954};
955
956static const deUint8 s_float64In[] =
957{
958	0xbd, 0xb6, 0xc3, 0xd2,
959	0xf6, 0x62, 0x29, 0xd9,
960	0x2f, 0xc2, 0x46, 0x18,
961	0x6b, 0x0d, 0x0a, 0x53,
962	0x6d, 0x0c, 0xf3, 0x80,
963	0xbd, 0xa9, 0x12, 0x89,
964	0x6b, 0x9f, 0x3d, 0xdd,
965	0xb3, 0x91, 0xee, 0xf5,
966	0x92, 0xac, 0x68, 0x36,
967	0x9f, 0x42, 0x0b, 0x6e,
968	0x67, 0xcf, 0x0f, 0x20,
969	0x22, 0x6c, 0xe4, 0x0f,
970	0xb3, 0x72, 0xc8, 0x8a,
971	0x4b, 0x99, 0xc3, 0xb0,
972	0xbd, 0x78, 0x5c, 0x16,
973	0x1c, 0xce, 0xb7, 0x4e,
974	0x15, 0xdf, 0x37, 0xfd,
975	0xeb, 0x32, 0xe9, 0x47,
976	0x68, 0x1a, 0xaa, 0xd0,
977	0xb9, 0xba, 0x77, 0xe7,
978	0x81, 0x0a, 0x42, 0x5a,
979	0xb0, 0x5a, 0xee, 0x06,
980	0x77, 0xb4, 0x7b, 0x57,
981	0xf5, 0x35, 0xac, 0x56,
982	0x2b, 0x74, 0x6a, 0x5d,
983	0x1c, 0xb2, 0x9a, 0x4d,
984	0xad, 0x55, 0x22, 0x01,
985	0xce, 0x2d, 0x97, 0x0d,
986	0x71, 0x31, 0x42, 0x2b,
987	0xeb, 0x26, 0xc7, 0x16,
988	0x94, 0xd2, 0x22, 0x79,
989	0x89, 0xbd, 0xff, 0xbc,
990};
991static const deUint32 s_float64FloatRef[] =
992{
993	0xff800000, 0x7f800000, 0x80000000, 0xff800000,
994	0x7f800000, 0x00000000, 0x80000000, 0x7f800000,
995	0x7f499760, 0xff800000, 0x00000000, 0x7f800000,
996	0x7f800000, 0x00000000, 0x00000000, 0xa7fdec4c,
997};
998static const deUint32 s_float64IntRef[] =
999{
1000	0x80000000, 0x80000000, 0x00000000, 0x80000000,
1001	0x80000000, 0x00000000, 0x00000000, 0x80000000,
1002	0x80000000, 0x80000000, 0x00000000, 0x80000000,
1003	0x80000000, 0x00000000, 0x00000000, 0x00000000,
1004};
1005
1006static const deUint8 s_floatUnsignedInt248RevIn[] =
1007{
1008	0xbd, 0xb6, 0xc3, 0xd2,
1009	0xf6, 0x62, 0x29, 0xd9,
1010	0x2f, 0xc2, 0x46, 0x18,
1011	0x6b, 0x0d, 0x0a, 0x53,
1012	0x6d, 0x0c, 0xf3, 0x80,
1013	0xbd, 0xa9, 0x12, 0x89,
1014	0x6b, 0x9f, 0x3d, 0xdd,
1015	0xb3, 0x91, 0xee, 0xf5,
1016};
1017static const deUint32 s_floatUnsignedInt248RevFloatRef[] =
1018{
1019	0xd2c3b6bd, 0x00000000, 0x00000000, 0x3f800000,
1020	0x1846c22f, 0x00000000, 0x00000000, 0x3f800000,
1021	0x80f30c6d, 0x00000000, 0x00000000, 0x3f800000,
1022	0xdd3d9f6b, 0x00000000, 0x00000000, 0x3f800000,
1023};
1024static const deUint32 s_floatUnsignedInt248RevUintRef[] =
1025{
1026	0x000000f6, 0x00000000, 0x00000000, 0x00000001,
1027	0x0000006b, 0x00000000, 0x00000000, 0x00000001,
1028	0x000000bd, 0x00000000, 0x00000000, 0x00000001,
1029	0x000000b3, 0x00000000, 0x00000000, 0x00000001,
1030};
1031
1032static const deUint8 s_unormShort10In[] =
1033{
1034	0x80, 0x84, 0x40, 0x3b,
1035	0x40, 0xfd, 0x80, 0x1a,
1036	0x80, 0x0c, 0x80, 0x15,
1037	0x40, 0x11, 0x80, 0xc3,
1038	0x80, 0xc8, 0x80, 0xd5,
1039	0xc0, 0xf9, 0x00, 0x0a,
1040	0xc0, 0x39, 0x40, 0xd5,
1041	0xc0, 0x4d, 0xc0, 0x26
1042};
1043static const deUint32 s_unormShort10FloatRef[] =
1044{
1045	0x3f04a128, 0x3e6d3b4f,
1046	0x3f7d7f60, 0x3dd4350d,
1047	0x3d48320d, 0x3dac2b0b,
1048	0x3d8a2289, 0x3f43b0ec,
1049	0x3f48b22d, 0x3f55b56d,
1050	0x3f79fe80, 0x3d20280a,
1051	0x3e6739ce, 0x3f55755d,
1052	0x3e9ba6ea, 0x3e1b26ca
1053};
1054static const deUint32 s_unormShort10UintRef[] =
1055{
1056	0x212, 0x0ed, 0x3f5, 0x06a,
1057	0x032, 0x056, 0x045, 0x30e,
1058	0x322, 0x356, 0x3e7, 0x028,
1059	0x0e7, 0x355, 0x137, 0x09b,
1060};
1061static const deUint32 s_unormShort10IntRef[] =
1062{
1063	0x212, 0x0ed, 0x3f5, 0x06a,
1064	0x032, 0x056, 0x045, 0x30e,
1065	0x322, 0x356, 0x3e7, 0x028,
1066	0x0e7, 0x355, 0x137, 0x09b,
1067};
1068
1069static const deUint8 s_unormShort12In[] =
1070{
1071	0x30, 0x46, 0xf0, 0x38,
1072	0x90, 0x85, 0xf0, 0x88,
1073	0x90, 0x92, 0x30, 0x5d,
1074	0x30, 0x3a, 0x00, 0xc9,
1075	0x00, 0x64, 0xb0, 0x9b,
1076	0x20, 0x71, 0xd0, 0x5b,
1077	0xa0, 0xc5, 0x70, 0x27,
1078	0x30, 0x0b, 0xa0, 0x53
1079};
1080static const deUint32 s_unormShort12FloatRef[] =
1081{
1082	0x3e8c68c7, 0x3e63ce3d,
1083	0x3f05985a, 0x3f08f890,
1084	0x3f12992a, 0x3eba6ba7,
1085	0x3e68ce8d, 0x3f490c91,
1086	0x3ec80c81, 0x3f1bb9bc,
1087	0x3ee24e25, 0x3eb7ab7b,
1088	0x3f45ac5b, 0x3e1dc9dd,
1089	0x3d330b31, 0x3ea74a75
1090};
1091static const deUint32 s_unormShort12UintRef[] =
1092{
1093	0x463, 0x38f,
1094	0x859, 0x88f,
1095	0x929, 0x5d3,
1096	0x3a3, 0xc90,
1097	0x640, 0x9bb,
1098	0x712, 0x5bd,
1099	0xc5a, 0x277,
1100	0x0b3, 0x53a
1101};
1102static const deUint32 s_unormShort12IntRef[] =
1103{
1104	0x463, 0x38f,
1105	0x859, 0x88f,
1106	0x929, 0x5d3,
1107	0x3a3, 0xc90,
1108	0x640, 0x9bb,
1109	0x712, 0x5bd,
1110	0xc5a, 0x277,
1111	0x0b3, 0x53a
1112};
1113
1114// \todo [2015-10-12 pyry] Collapse duplicate ref arrays
1115
1116static const struct
1117{
1118	const deUint8*		input;
1119	const int			inputSize;
1120	const deUint32*		floatRef;
1121	const deUint32*		intRef;
1122	const deUint32*		uintRef;
1123} s_formatData[] =
1124{
1125	{ s_snormInt8In,				DE_LENGTH_OF_ARRAY(s_snormInt8In),					s_snormInt8FloatRef,				s_snormInt8IntRef,				s_snormInt8UintRef				},
1126	{ s_snormInt16In,				DE_LENGTH_OF_ARRAY(s_snormInt16In),					s_snormInt16FloatRef,				s_snormInt16IntRef,				s_snormInt16UintRef				},
1127	{ s_snormInt32In,				DE_LENGTH_OF_ARRAY(s_snormInt32In),					s_snormInt32FloatRef,				s_snormInt32IntRef,				s_snormInt32UintRef				},
1128	{ s_unormInt8In,				DE_LENGTH_OF_ARRAY(s_unormInt8In),					s_unormInt8FloatRef,				s_unormInt8IntRef,				s_unormInt8UintRef				},
1129	{ s_unormInt16In,				DE_LENGTH_OF_ARRAY(s_unormInt16In),					s_unormInt16FloatRef,				s_unormInt16IntRef,				s_unormInt16UintRef				},
1130	{ s_unormInt24In,				DE_LENGTH_OF_ARRAY(s_unormInt24In),					s_unormInt24FloatRef,				s_unormInt24IntRef,				s_unormInt24UintRef				},
1131	{ s_unormInt32In,				DE_LENGTH_OF_ARRAY(s_unormInt32In),					s_unormInt32FloatRef,				s_unormInt32IntRef,				s_unormInt32UintRef				},
1132	{ s_unormByte44In,				DE_LENGTH_OF_ARRAY(s_unormByte44In),				s_unormByte44FloatRef,				s_unormByte44IntRef,			s_unormByte44IntRef				},
1133	{ s_unormShort565In,			DE_LENGTH_OF_ARRAY(s_unormShort565In),				s_unormShort565FloatRef,			s_unormShort565IntRef,			s_unormShort565IntRef,			},
1134	{ s_unormShort555In,			DE_LENGTH_OF_ARRAY(s_unormShort555In),				s_unormShort555FloatRef,			s_unormShort555IntRef,			s_unormShort555IntRef,			},
1135	{ s_unormShort4444In,			DE_LENGTH_OF_ARRAY(s_unormShort4444In),				s_unormShort4444FloatRef,			s_unormShort4444IntRef,			s_unormShort4444IntRef,			},
1136	{ s_unormShort5551In,			DE_LENGTH_OF_ARRAY(s_unormShort5551In),				s_unormShort5551FloatRef,			s_unormShort5551IntRef,			s_unormShort5551IntRef,			},
1137	{ s_unormShort1555In,			DE_LENGTH_OF_ARRAY(s_unormShort1555In),				s_unormShort1555FloatRef,			s_unormShort1555IntRef,			s_unormShort1555IntRef,			},
1138	{ s_unormInt101010In,			DE_LENGTH_OF_ARRAY(s_unormInt101010In),				s_unormInt101010FloatRef,			s_unormInt101010IntRef,			s_unormInt101010IntRef			},
1139
1140	// \note Same input data & int reference used for {U,S}NORM_INT_1010102_REV
1141	{ s_unormInt1010102RevIn,		DE_LENGTH_OF_ARRAY(s_unormInt1010102RevIn),			s_snormInt1010102RevFloatRef,		s_snormInt1010102RevIntRef,		s_snormInt1010102RevIntRef		},
1142	{ s_unormInt1010102RevIn,		DE_LENGTH_OF_ARRAY(s_unormInt1010102RevIn),			s_unormInt1010102RevFloatRef,		s_unormInt1010102RevIntRef,		s_unormInt1010102RevIntRef		},
1143
1144	// \note UNSIGNED_BYTE_* and UNSIGNED_SHORT_* re-use input data and integer reference values from UNORM_* cases
1145	{ s_unormByte44In,				DE_LENGTH_OF_ARRAY(s_unormByte44In),				s_unsignedByte44FloatRef,			s_unormByte44IntRef,			s_unormByte44IntRef				},
1146	{ s_unormShort565In,			DE_LENGTH_OF_ARRAY(s_unormShort565In),				s_unsignedShort565FloatRef,			s_unormShort565IntRef,			s_unormShort565IntRef,			},
1147	{ s_unormShort4444In,			DE_LENGTH_OF_ARRAY(s_unormShort4444In),				s_unsignedShort4444FloatRef,		s_unormShort4444IntRef,			s_unormShort4444IntRef,			},
1148	{ s_unormShort5551In,			DE_LENGTH_OF_ARRAY(s_unormShort5551In),				s_unsignedShort5551FloatRef,		s_unormShort5551IntRef,			s_unormShort5551IntRef,			},
1149
1150	// \note (UN)SIGNED_INT_1010102_REV formats use same input data
1151	{ s_unsignedInt1010102RevIn,	DE_LENGTH_OF_ARRAY(s_unsignedInt1010102RevIn),		s_signedInt1010102RevFloatRef,		s_signedInt1010102RevIntRef,	s_signedInt1010102RevIntRef		},
1152	{ s_unsignedInt1010102RevIn,	DE_LENGTH_OF_ARRAY(s_unsignedInt1010102RevIn),		s_unsignedInt1010102RevFloatRef,	s_unsignedInt1010102RevIntRef,	s_unsignedInt1010102RevIntRef	},
1153
1154	{ s_unsignedInt11f11f10fRevIn,	DE_LENGTH_OF_ARRAY(s_unsignedInt11f11f10fRevIn),	s_unsignedInt11f11f10fRevFloatRef,	DE_NULL,						DE_NULL							},
1155	{ s_unsignedInt999E5RevIn,		DE_LENGTH_OF_ARRAY(s_unsignedInt999E5RevIn),		s_unsignedInt999E5RevFloatRef,		DE_NULL,						DE_NULL							},
1156	{ s_unsignedInt1688In,			DE_LENGTH_OF_ARRAY(s_unsignedInt1688In),			s_unsignedInt1688FloatRef,			DE_NULL,						s_unsignedInt1688UintRef		},
1157	{ s_unsignedInt248In,			DE_LENGTH_OF_ARRAY(s_unsignedInt248In),				s_unsignedInt248FloatRef,			DE_NULL,						s_unsignedInt248UintRef			},
1158	{ s_unsignedInt248RevIn,		DE_LENGTH_OF_ARRAY(s_unsignedInt248RevIn),			s_unsignedInt248RevFloatRef,		DE_NULL,						s_unsignedInt248RevUintRef		},
1159	{ s_signedInt8In,				DE_LENGTH_OF_ARRAY(s_signedInt8In),					s_signedInt8FloatRef,				s_signedInt8IntRef,				s_signedInt8UintRef				},
1160	{ s_signedInt16In,				DE_LENGTH_OF_ARRAY(s_signedInt16In),				s_signedInt16FloatRef,				s_signedInt16IntRef,			s_signedInt16UintRef			},
1161	{ s_signedInt32In,				DE_LENGTH_OF_ARRAY(s_signedInt32In),				s_signedInt32FloatRef,				s_signedInt32IntRef,			s_signedInt32UintRef			},
1162	{ s_unsignedInt8In,				DE_LENGTH_OF_ARRAY(s_unsignedInt8In),				s_unsignedInt8FloatRef,				s_unsignedInt8IntRef,			s_unsignedInt8UintRef			},
1163	{ s_unsignedInt16In,			DE_LENGTH_OF_ARRAY(s_unsignedInt16In),				s_unsignedInt16FloatRef,			s_unsignedInt16IntRef,			s_unsignedInt16UintRef			},
1164	{ s_unsignedInt24In,			DE_LENGTH_OF_ARRAY(s_unsignedInt24In),				s_unsignedInt24FloatRef,			s_unsignedInt24IntRef,			s_unsignedInt24UintRef			},
1165	{ s_unsignedInt32In,			DE_LENGTH_OF_ARRAY(s_unsignedInt32In),				s_unsignedInt32FloatRef,			s_unsignedInt32IntRef,			s_unsignedInt32UintRef			},
1166	{ s_halfFloatIn,				DE_LENGTH_OF_ARRAY(s_halfFloatIn),					s_halfFloatFloatRef,				s_halfFloatIntRef,				s_halfFloatUintRef				},
1167	{ s_floatIn,					DE_LENGTH_OF_ARRAY(s_floatIn),						s_floatFloatRef,					s_floatIntRef,					s_floatUintRef					},
1168	{ s_float64In,					DE_LENGTH_OF_ARRAY(s_float64In),					s_float64FloatRef,					s_float64IntRef,				s_float64IntRef					},
1169	{ s_floatUnsignedInt248RevIn,	DE_LENGTH_OF_ARRAY(s_floatUnsignedInt248RevIn),		s_floatUnsignedInt248RevFloatRef,	DE_NULL,						s_floatUnsignedInt248RevUintRef	},
1170
1171	{ s_unormShort10In,				DE_LENGTH_OF_ARRAY(s_unormShort10In),				s_unormShort10FloatRef,				s_unormShort10IntRef,			s_unormShort10UintRef			},
1172	{ s_unormShort12In,				DE_LENGTH_OF_ARRAY(s_unormShort12In),				s_unormShort12FloatRef,				s_unormShort12IntRef,			s_unormShort12UintRef			},
1173};
1174DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_formatData) == TextureFormat::CHANNELTYPE_LAST);
1175
1176TextureFormat getBaseFormat (TextureFormat format)
1177{
1178	const TextureFormat::ChannelOrder baseOrders[] = { TextureFormat::RGBA, TextureFormat::RGB, TextureFormat::DS };
1179
1180	for (int baseOrderNdx = 0; baseOrderNdx < DE_LENGTH_OF_ARRAY(baseOrders); baseOrderNdx++)
1181	{
1182		const TextureFormat	curBaseFmt	(baseOrders[baseOrderNdx], format.type);
1183		if (isValid(curBaseFmt))
1184			return curBaseFmt;
1185	}
1186
1187	return format;
1188}
1189
1190ConstPixelBufferAccess getInputAccess (TextureFormat format)
1191{
1192	const TextureFormat	inputFormat		= getBaseFormat(format);
1193	const int			inputPixelSize	= getPixelSize(inputFormat);
1194	const int			numPixels		= s_formatData[format.type].inputSize / inputPixelSize;
1195
1196	DE_ASSERT(numPixels == 4);
1197	DE_ASSERT(numPixels*inputPixelSize == s_formatData[format.type].inputSize);
1198
1199	return ConstPixelBufferAccess(format, IVec3(numPixels, 1, 1), IVec3(inputPixelSize, 0, 0), s_formatData[format.type].input);
1200}
1201
1202template<typename T>
1203const deUint32* getRawReference (TextureFormat format);
1204
1205template<>
1206const deUint32* getRawReference<float> (TextureFormat format)
1207{
1208	return s_formatData[format.type].floatRef;
1209}
1210
1211template<>
1212const deUint32* getRawReference<deInt32> (TextureFormat format)
1213{
1214	return s_formatData[format.type].intRef;
1215}
1216
1217template<>
1218const deUint32* getRawReference<deUint32> (TextureFormat format)
1219{
1220	return s_formatData[format.type].uintRef;
1221}
1222
1223template<typename T>
1224void getReferenceValues (TextureFormat storageFormat, TextureFormat viewFormat, vector<Vector<T, 4> >& dst)
1225{
1226	const int					numPixels	= getInputAccess(storageFormat).getWidth();
1227	const deUint32* const		rawValues	= getRawReference<T>(storageFormat);
1228	const tcu::TextureSwizzle&	swizzle		= tcu::getChannelReadSwizzle(viewFormat.order);
1229
1230	dst.resize(numPixels);
1231
1232	for (int pixelNdx = 0; pixelNdx < numPixels; pixelNdx++)
1233	{
1234		const deUint32*	srcPixPtr	= rawValues + pixelNdx*4;
1235		T*				dstPixPtr	= (T*)&dst[pixelNdx];
1236
1237		for (int c = 0; c < 4; c++)
1238		{
1239			switch (swizzle.components[c])
1240			{
1241				case tcu::TextureSwizzle::CHANNEL_0:
1242				case tcu::TextureSwizzle::CHANNEL_1:
1243				case tcu::TextureSwizzle::CHANNEL_2:
1244				case tcu::TextureSwizzle::CHANNEL_3:
1245					deMemcpy(dstPixPtr + c, srcPixPtr + (int)swizzle.components[c], sizeof(deUint32));
1246					break;
1247
1248				case tcu::TextureSwizzle::CHANNEL_ZERO:
1249					dstPixPtr[c] = T(0);
1250					break;
1251
1252				case tcu::TextureSwizzle::CHANNEL_ONE:
1253					dstPixPtr[c] = T(1);
1254					break;
1255
1256				default:
1257					DE_FATAL("Unknown swizzle");
1258			}
1259		}
1260	}
1261}
1262
1263template<typename T>
1264bool componentEqual (T a, T b)
1265{
1266	return a == b;
1267}
1268
1269template<>
1270bool componentEqual<float> (float a, float b)
1271{
1272	return (a == b) || (deFloatIsNaN(a) && deFloatIsNaN(b));
1273}
1274
1275template<typename T, int Size>
1276bool allComponentsEqual (const Vector<T, Size>& a, const Vector<T, Size>& b)
1277{
1278	for (int ndx = 0; ndx < Size; ndx++)
1279	{
1280		if (!componentEqual(a[ndx], b[ndx]))
1281			return false;
1282	}
1283
1284	return true;
1285}
1286
1287template<typename T>
1288void copyPixels (const ConstPixelBufferAccess& src, const PixelBufferAccess& dst)
1289{
1290	for (int ndx = 0; ndx < src.getWidth(); ndx++)
1291		dst.setPixel(src.getPixelT<T>(ndx, 0, 0), ndx, 0, 0);
1292}
1293
1294void copyGetSetDepth (const ConstPixelBufferAccess& src, const PixelBufferAccess& dst)
1295{
1296	for (int ndx = 0; ndx < src.getWidth(); ndx++)
1297		dst.setPixDepth(src.getPixDepth(ndx, 0, 0), ndx, 0, 0);
1298}
1299
1300void copyGetSetStencil (const ConstPixelBufferAccess& src, const PixelBufferAccess& dst)
1301{
1302	for (int ndx = 0; ndx < src.getWidth(); ndx++)
1303		dst.setPixStencil(src.getPixStencil(ndx, 0, 0), ndx, 0, 0);
1304}
1305
1306void copyPixels (const ConstPixelBufferAccess& src, const PixelBufferAccess& dst)
1307{
1308	switch (getTextureChannelClass(dst.getFormat().type))
1309	{
1310		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1311		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1312		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1313			copyPixels<float>(src, dst);
1314			break;
1315
1316		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1317			copyPixels<deInt32>(src, dst);
1318			break;
1319
1320		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1321			copyPixels<deUint32>(src, dst);
1322			break;
1323
1324		default:
1325			DE_FATAL("Unknown channel class");
1326	}
1327}
1328
1329const char* getTextureAccessTypeDescription (TextureAccessType type)
1330{
1331	static const char* s_desc[] =
1332	{
1333		"floating-point",
1334		"signed integer",
1335		"unsigned integer"
1336	};
1337	return de::getSizedArrayElement<tcu::TEXTUREACCESSTYPE_LAST>(s_desc, type);
1338}
1339
1340template<typename T>
1341TextureAccessType getTextureAccessType (void);
1342
1343template<>
1344TextureAccessType getTextureAccessType<float> (void)
1345{
1346	return tcu::TEXTUREACCESSTYPE_FLOAT;
1347}
1348
1349template<>
1350TextureAccessType getTextureAccessType<deInt32> (void)
1351{
1352	return tcu::TEXTUREACCESSTYPE_SIGNED_INT;
1353}
1354
1355template<>
1356TextureAccessType getTextureAccessType<deUint32> (void)
1357{
1358	return tcu::TEXTUREACCESSTYPE_UNSIGNED_INT;
1359}
1360
1361static std::string getCaseName (TextureFormat format)
1362{
1363	std::ostringstream str;
1364
1365	str << format.type << "_" << format.order;
1366
1367	return de::toLower(str.str());
1368}
1369
1370class TextureFormatCase : public tcu::TestCase
1371{
1372public:
1373	TextureFormatCase (tcu::TestContext& testCtx, TextureFormat format)
1374		: tcu::TestCase	(testCtx, getCaseName(format).c_str(), "")
1375		, m_format		(format)
1376	{
1377		DE_ASSERT(isValid(format));
1378	}
1379
1380protected:
1381	template<typename T>
1382	void verifyRead (const ConstPixelBufferAccess& src)
1383	{
1384		const int				numPixels	= src.getWidth();
1385		vector<Vector<T, 4> >	res			(numPixels);
1386		vector<Vector<T, 4> >	ref;
1387
1388		m_testCtx.getLog()
1389			<< TestLog::Message << "Verifying " << getTextureAccessTypeDescription(getTextureAccessType<T>()) << " access" << TestLog::EndMessage;
1390
1391		for (int ndx = 0; ndx < numPixels; ndx++)
1392			res[ndx] = src.getPixelT<T>(ndx, 0, 0);
1393
1394		// \note m_format != src.getFormat() for DS formats, and we specifically need to
1395		//		 use the combined format as storage format to get right reference values.
1396		getReferenceValues<T>(m_format, src.getFormat(), ref);
1397
1398		for (int pixelNdx = 0; pixelNdx < numPixels; pixelNdx++)
1399		{
1400			if (!allComponentsEqual(res[pixelNdx], ref[pixelNdx]))
1401			{
1402				m_testCtx.getLog()
1403					<< TestLog::Message << "ERROR: at pixel " << pixelNdx << ": expected " << ref[pixelNdx] << ", got " << res[pixelNdx] << TestLog::EndMessage;
1404
1405				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Comparison failed");
1406			}
1407		}
1408	}
1409
1410	void verifyRead (const ConstPixelBufferAccess& src)
1411	{
1412		// \todo [2016-08-04 pyry] Overflow in float->int conversion is not defined and
1413		//						   produces different results depending on arch.
1414		const bool	isFloat32Or64	= src.getFormat().type == tcu::TextureFormat::FLOAT ||
1415									  src.getFormat().type == tcu::TextureFormat::FLOAT64;
1416
1417		if (isAccessValid(src.getFormat(), tcu::TEXTUREACCESSTYPE_FLOAT))
1418			verifyRead<float>(src);
1419
1420		if (isAccessValid(src.getFormat(), tcu::TEXTUREACCESSTYPE_UNSIGNED_INT) && !isFloat32Or64)
1421			verifyRead<deUint32>(src);
1422
1423		if (isAccessValid(src.getFormat(), tcu::TEXTUREACCESSTYPE_SIGNED_INT) && !isFloat32Or64)
1424			verifyRead<deInt32>(src);
1425	}
1426
1427	void verifyGetPixDepth (const ConstPixelBufferAccess& refAccess, const ConstPixelBufferAccess& combinedAccess)
1428	{
1429		m_testCtx.getLog()
1430			<< TestLog::Message << "Verifying getPixDepth()" << TestLog::EndMessage;
1431
1432		for (int pixelNdx = 0; pixelNdx < refAccess.getWidth(); pixelNdx++)
1433		{
1434			const float		ref		= refAccess.getPixel(pixelNdx, 0, 0).x();
1435			const float		res		= combinedAccess.getPixDepth(pixelNdx, 0, 0);
1436
1437			if (!componentEqual(res, ref))
1438			{
1439				m_testCtx.getLog()
1440					<< TestLog::Message << "ERROR: at pixel " << pixelNdx << ": expected " << ref << ", got " << res << TestLog::EndMessage;
1441
1442				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Comparison failed");
1443			}
1444		}
1445	}
1446
1447	void verifyGetPixStencil (const ConstPixelBufferAccess& refAccess, const ConstPixelBufferAccess& combinedAccess)
1448	{
1449		m_testCtx.getLog()
1450			<< TestLog::Message << "Verifying getPixStencil()" << TestLog::EndMessage;
1451
1452		for (int pixelNdx = 0; pixelNdx < refAccess.getWidth(); pixelNdx++)
1453		{
1454			const int	ref		= refAccess.getPixelInt(pixelNdx, 0, 0).x();
1455			const int	res		= combinedAccess.getPixStencil(pixelNdx, 0, 0);
1456
1457			if (!componentEqual(res, ref))
1458			{
1459				m_testCtx.getLog()
1460					<< TestLog::Message << "ERROR: at pixel " << pixelNdx << ": expected " << ref << ", got " << res << TestLog::EndMessage;
1461
1462				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Comparison failed");
1463			}
1464		}
1465	}
1466
1467	void verifyInfoQueries (void)
1468	{
1469		const tcu::TextureChannelClass	chnClass	= tcu::getTextureChannelClass(m_format.type);
1470		const tcu::TextureFormatInfo	fmtInfo		= tcu::getTextureFormatInfo(m_format);
1471
1472		if (tcu::isCombinedDepthStencilType(m_format.type))
1473			TCU_CHECK(chnClass == tcu::TEXTURECHANNELCLASS_LAST);
1474		else
1475			TCU_CHECK(de::inBounds(chnClass, (tcu::TextureChannelClass)0, tcu::TEXTURECHANNELCLASS_LAST));
1476
1477		DE_UNREF(fmtInfo);
1478	}
1479
1480	const TextureFormat		m_format;
1481};
1482
1483class ColorFormatCase : public TextureFormatCase
1484{
1485public:
1486	ColorFormatCase (tcu::TestContext& testCtx, TextureFormat format)
1487		: TextureFormatCase(testCtx, format)
1488	{
1489		DE_ASSERT(format.order != TextureFormat::D &&
1490				  format.order != TextureFormat::S &&
1491				  format.order != TextureFormat::DS);
1492	}
1493
1494	IterateResult iterate (void)
1495	{
1496		const ConstPixelBufferAccess	inputAccess		= getInputAccess(m_format);
1497		vector<deUint8>					tmpMem			(getPixelSize(inputAccess.getFormat())*inputAccess.getWidth());
1498		const PixelBufferAccess			tmpAccess		(inputAccess.getFormat(), inputAccess.getWidth(), 1, 1, &tmpMem[0]);
1499
1500		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1501
1502		verifyInfoQueries();
1503
1504		verifyRead(inputAccess);
1505
1506		// \todo [2015-10-12 pyry] Handle lossy conversion with *NORM_INT32
1507		if (m_format.type != TextureFormat::UNORM_INT32 && m_format.type != TextureFormat::SNORM_INT32)
1508		{
1509			m_testCtx.getLog() << TestLog::Message << "Copying with getPixel() -> setPixel()" << TestLog::EndMessage;
1510			copyPixels(inputAccess, tmpAccess);
1511			verifyRead(tmpAccess);
1512		}
1513
1514		return STOP;
1515	}
1516};
1517
1518class DepthFormatCase : public TextureFormatCase
1519{
1520public:
1521	DepthFormatCase (tcu::TestContext& testCtx, TextureFormat format)
1522		: TextureFormatCase(testCtx, format)
1523	{
1524		DE_ASSERT(format.order == TextureFormat::D);
1525	}
1526
1527	IterateResult iterate (void)
1528	{
1529		const ConstPixelBufferAccess	inputAccess			= getInputAccess(m_format);
1530		vector<deUint8>					tmpMem				(getPixelSize(inputAccess.getFormat())*inputAccess.getWidth());
1531		const PixelBufferAccess			tmpAccess			(inputAccess.getFormat(), inputAccess.getWidth(), 1, 1, &tmpMem[0]);
1532		const ConstPixelBufferAccess	inputDepthAccess	= getEffectiveDepthStencilAccess(inputAccess, tcu::Sampler::MODE_DEPTH);
1533		const PixelBufferAccess			tmpDepthAccess		= getEffectiveDepthStencilAccess(tmpAccess, tcu::Sampler::MODE_DEPTH);
1534
1535		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1536
1537		verifyInfoQueries();
1538
1539		verifyRead(inputDepthAccess);
1540
1541		m_testCtx.getLog() << TestLog::Message << "Copying with getPixel() -> setPixel()" << TestLog::EndMessage;
1542		copyPixels(inputDepthAccess, tmpDepthAccess);
1543		verifyRead(tmpDepthAccess);
1544
1545		verifyGetPixDepth(inputDepthAccess, inputAccess);
1546
1547		m_testCtx.getLog() << TestLog::Message << "Copying both depth getPixDepth() -> setPixDepth()" << TestLog::EndMessage;
1548		tcu::clear(tmpDepthAccess, tcu::Vec4(0.0f));
1549		copyGetSetDepth(inputAccess, tmpAccess);
1550		verifyGetPixDepth(tmpDepthAccess, tmpAccess);
1551
1552		return STOP;
1553	}
1554};
1555
1556class StencilFormatCase : public TextureFormatCase
1557{
1558public:
1559	StencilFormatCase (tcu::TestContext& testCtx, TextureFormat format)
1560		: TextureFormatCase(testCtx, format)
1561	{
1562		DE_ASSERT(format.order == TextureFormat::S);
1563	}
1564
1565	IterateResult iterate (void)
1566	{
1567		const ConstPixelBufferAccess	inputAccess			= getInputAccess(m_format);
1568		vector<deUint8>					tmpMem				(getPixelSize(inputAccess.getFormat())*inputAccess.getWidth());
1569		const PixelBufferAccess			tmpAccess			(inputAccess.getFormat(), inputAccess.getWidth(), 1, 1, &tmpMem[0]);
1570		const ConstPixelBufferAccess	inputStencilAccess	= getEffectiveDepthStencilAccess(inputAccess, tcu::Sampler::MODE_STENCIL);
1571		const PixelBufferAccess			tmpStencilAccess	= getEffectiveDepthStencilAccess(tmpAccess, tcu::Sampler::MODE_STENCIL);
1572
1573		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1574
1575		verifyInfoQueries();
1576
1577		verifyRead(inputStencilAccess);
1578
1579		m_testCtx.getLog() << TestLog::Message << "Copying with getPixel() -> setPixel()" << TestLog::EndMessage;
1580		copyPixels(inputStencilAccess, tmpStencilAccess);
1581		verifyRead(tmpStencilAccess);
1582
1583		verifyGetPixStencil(inputStencilAccess, inputAccess);
1584
1585		m_testCtx.getLog() << TestLog::Message << "Copying both depth getPixStencil() -> setPixStencil()" << TestLog::EndMessage;
1586		tcu::clear(tmpStencilAccess, tcu::IVec4(0));
1587		copyGetSetStencil(inputAccess, tmpAccess);
1588		verifyGetPixStencil(tmpStencilAccess, tmpAccess);
1589
1590		return STOP;
1591	}
1592};
1593
1594class DepthStencilFormatCase : public TextureFormatCase
1595{
1596public:
1597	DepthStencilFormatCase (tcu::TestContext& testCtx, TextureFormat format)
1598		: TextureFormatCase(testCtx, format)
1599	{
1600		DE_ASSERT(format.order == TextureFormat::DS);
1601	}
1602
1603	IterateResult iterate (void)
1604	{
1605		const ConstPixelBufferAccess	inputAccess			= getInputAccess(m_format);
1606		vector<deUint8>					tmpMem				(getPixelSize(inputAccess.getFormat())*inputAccess.getWidth());
1607		const PixelBufferAccess			tmpAccess			(inputAccess.getFormat(), inputAccess.getWidth(), 1, 1, &tmpMem[0]);
1608		const ConstPixelBufferAccess	inputDepthAccess	= getEffectiveDepthStencilAccess(inputAccess, tcu::Sampler::MODE_DEPTH);
1609		const ConstPixelBufferAccess	inputStencilAccess	= getEffectiveDepthStencilAccess(inputAccess, tcu::Sampler::MODE_STENCIL);
1610		const PixelBufferAccess			tmpDepthAccess		= getEffectiveDepthStencilAccess(tmpAccess, tcu::Sampler::MODE_DEPTH);
1611		const PixelBufferAccess			tmpStencilAccess	= getEffectiveDepthStencilAccess(tmpAccess, tcu::Sampler::MODE_STENCIL);
1612
1613		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1614
1615		verifyInfoQueries();
1616
1617		verifyRead(inputDepthAccess);
1618		verifyRead(inputStencilAccess);
1619
1620		verifyGetPixDepth(inputDepthAccess, inputAccess);
1621		verifyGetPixStencil(inputStencilAccess, inputAccess);
1622
1623		m_testCtx.getLog() << TestLog::Message << "Copying both depth and stencil with getPixel() -> setPixel()" << TestLog::EndMessage;
1624		copyPixels(inputDepthAccess, tmpDepthAccess);
1625		copyPixels(inputStencilAccess, tmpStencilAccess);
1626		verifyRead(tmpDepthAccess);
1627		verifyRead(tmpStencilAccess);
1628
1629		m_testCtx.getLog() << TestLog::Message << "Copying both depth and stencil with getPix{Depth,Stencil}() -> setPix{Depth,Stencil}()" << TestLog::EndMessage;
1630		copyGetSetDepth(inputDepthAccess, tmpDepthAccess);
1631		copyGetSetStencil(inputStencilAccess, tmpStencilAccess);
1632		verifyRead(tmpDepthAccess);
1633		verifyRead(tmpStencilAccess);
1634
1635		m_testCtx.getLog() << TestLog::Message << "Verifying that clearing depth component with clearDepth() doesn't affect stencil" << TestLog::EndMessage;
1636		tcu::copy(tmpAccess, inputAccess);
1637		tcu::clearDepth(tmpAccess, 0.0f);
1638		verifyRead(tmpStencilAccess);
1639
1640		m_testCtx.getLog() << TestLog::Message << "Verifying that clearing stencil component with clearStencil() doesn't affect depth" << TestLog::EndMessage;
1641		tcu::copy(tmpAccess, inputAccess);
1642		tcu::clearStencil(tmpAccess, 0);
1643		verifyRead(tmpDepthAccess);
1644
1645		m_testCtx.getLog() << TestLog::Message << "Verifying that clearing depth component with setPixDepth() doesn't affect stencil" << TestLog::EndMessage;
1646		tcu::copy(tmpAccess, inputAccess);
1647
1648		for (int ndx = 0; ndx < tmpAccess.getWidth(); ndx++)
1649			tmpAccess.setPixDepth(0.0f, ndx, 0, 0);
1650
1651		verifyRead(tmpStencilAccess);
1652
1653		m_testCtx.getLog() << TestLog::Message << "Verifying that clearing stencil component with setPixStencil() doesn't affect depth" << TestLog::EndMessage;
1654		tcu::copy(tmpAccess, inputAccess);
1655
1656		for (int ndx = 0; ndx < tmpAccess.getWidth(); ndx++)
1657			tmpAccess.setPixStencil(0, ndx, 0, 0);
1658
1659		verifyRead(tmpDepthAccess);
1660
1661		return STOP;
1662	}
1663};
1664
1665} // anonymous
1666
1667tcu::TestCaseGroup* createTextureFormatTests (tcu::TestContext& testCtx)
1668{
1669	de::MovePtr<tcu::TestCaseGroup>	group	(new tcu::TestCaseGroup(testCtx, "texture_format", "Texture format tests"));
1670
1671	for (int channelType = 0; channelType < TextureFormat::CHANNELTYPE_LAST; channelType++)
1672	{
1673		for (int channelOrder = 0; channelOrder < TextureFormat::CHANNELORDER_LAST; channelOrder++)
1674		{
1675			const TextureFormat		format		((TextureFormat::ChannelOrder)channelOrder, (TextureFormat::ChannelType)channelType);
1676
1677			if (!isValid(format))
1678				continue;
1679
1680			if (tcu::isSRGB(format))
1681				continue; // \todo [2015-10-12 pyry] Tests for sRGB formats (need thresholds)
1682
1683			if (format.order == TextureFormat::DS)
1684				group->addChild(new DepthStencilFormatCase(testCtx, format));
1685			else if (format.order == TextureFormat::D)
1686				group->addChild(new DepthFormatCase(testCtx, format));
1687			else if (format.order == TextureFormat::S)
1688				group->addChild(new StencilFormatCase(testCtx, format));
1689			else
1690				group->addChild(new ColorFormatCase(testCtx, format));
1691		}
1692	}
1693
1694	return group.release();
1695}
1696
1697} // dit
1698