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