inp005.c
8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#include <bstring.h>
#include <math.h>
#include <stdio.h>
#include "inp.h"
static void varyKeyValues(void);
static void passThrough(void);
static void boundaryValues(void);
static void checkCompareClamp(void);
static void monteCarlo(void);
static void initKeyMode(cc_t *);
int
main(int argc, char *argv[])
{
printHeader();
passThrough();
varyKeyValues();
boundaryValues();
checkCompareClamp();
monteCarlo();
printTrailingCycles();
}
static void
passThrough(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i;
printf("# Verify X (SUBA) inputs are passed through to pixel outputs\n");
initKeyMode(ccp);
printf("# tf = (0x%x,0x%x,0x%x)\n", ccp->tf_r, ccp->tf_g, ccp->tf_b);
printVector(ccp, 1);
for (i = 0; i < 9; i++) {
ccp->tf_b = 1 << i;
printf("# tf = (0x%x,0x%x,0x%x)\n",
ccp->tf_r, ccp->tf_g, ccp->tf_b);
printVector(ccp, 1);
}
ccp->tf_b = 0;
for (i = 0; i < 9; i++) {
ccp->tf_g = 1 << i;
printf("# tf = (0x%x,0x%x,0x%x)\n",
ccp->tf_r, ccp->tf_g, ccp->tf_b);
printVector(ccp, 1);
}
ccp->tf_g = 0;
for (i = 0; i < 9; i++) {
ccp->tf_r = 1 << i;
printf("# tf = (0x%x,0x%x,0x%x)\n",
ccp->tf_r, ccp->tf_g, ccp->tf_b);
printVector(ccp, 1);
}
ccp->tf_r = 0;
}
static void
varyKeyValues(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i;
initKeyMode(ccp);
ccp->tf_r = ccp->tf_g = ccp->tf_b = 0x0;
ccp->center_r = ccp->center_g = ccp->center_b = 0x1;
ccp->scale_r = ccp->scale_g = ccp->scale_b = 0x80;
for (i = 0; i < 16; i++) {
ccp->width_r = ccp->width_g = ccp->width_b = i;
printVector(ccp, 1);
}
}
static void
checkCompareClamp(void)
{
cc_t cc;
cc_t *ccp = &cc;
initKeyMode(ccp);
printf("# 0 on red, 1 on green, 1 on blue\n");
ccp->tf_r = ccp->tf_g = ccp->tf_b = 0x0;
ccp->width_r = ccp->width_g = ccp->width_b = 0x8;
ccp->scale_r = 0x0;
ccp->center_r = 0x0;
ccp->scale_g = ccp->scale_b = 0xff;
ccp->center_g = ccp->center_b = 0x01;
printVector(ccp, 1);
printf("# 1 on red, 0 on green, 1 on blue\n");
ccp->scale_g = 0x0;
ccp->center_g = 0x0;
ccp->scale_r = ccp->scale_b = 0xff;
ccp->center_r = ccp->center_b = 0x01;
printVector(ccp, 1);
printf("# 1 on red, 1 on green, 0 on blue\n");
ccp->scale_b = 0x0;
ccp->center_b = 0x0;
ccp->scale_r = ccp->scale_g = 0xff;
ccp->center_r = ccp->center_g = 0x01;
printVector(ccp, 1);
printf("# 1 on red, -1 on green, -1 on blue\n");
ccp->tf_r = 0x0;
ccp->scale_r = 0xff;
ccp->center_r = 0x01;
ccp->width_r = 0x8;
ccp->tf_g = ccp->tf_b = 0xf;
ccp->scale_g = ccp->scale_b = 0xff;
ccp->center_g = ccp->center_b = 0x0;
ccp->width_g = ccp->width_b = 0x1e7;
printVector(ccp, 1);
printf("# -1 on red, 1 on green, -1 on blue\n");
ccp->tf_g = 0x0;
ccp->scale_g = 0xff;
ccp->center_g = 0x01;
ccp->width_g = 0x8;
ccp->tf_r = ccp->tf_b = 0xf;
ccp->scale_r = ccp->scale_b = 0xff;
ccp->center_r = ccp->center_b = 0x0;
ccp->width_r = ccp->width_b = 0x1e7;
printVector(ccp, 1);
printf("# -1 on red, -1 on green, 1 on blue\n");
ccp->tf_b = 0x0;
ccp->scale_b = 0xff;
ccp->center_b = 0x01;
ccp->width_b = 0x8;
ccp->tf_r = ccp->tf_g = 0xf;
ccp->scale_r = ccp->scale_g = 0xff;
ccp->center_r = ccp->center_g = 0x0;
ccp->width_r = ccp->width_g = 0x1e7;
printf("# 0xff on red, 0x100 on green, 0x100 on blue\n");
ccp->tf_r = ccp->tf_g = ccp->tf_b = 0x0;
ccp->center_r = ccp->center_g = ccp->center_b = 0x1;
ccp->width_r = ccp->width_g = ccp->width_b = 0x10;
ccp->scale_r = 0x7f;
ccp->scale_g = 0x80;
ccp->scale_b = 0x80;
printVector(ccp, 1);
printf("# 0x100 on red, 0xff on green, 0x100 on blue\n");
ccp->scale_r = 0x80;
ccp->scale_g = 0x7f;
ccp->scale_b = 0x80;
printVector(ccp, 1);
printf("# 0x100 on red, 0x100 on green, 0xff on blue\n");
ccp->scale_r = 0x80;
ccp->scale_g = 0x80;
ccp->scale_b = 0x7f;
printVector(ccp, 1);
printf("# 0x100 on red, 0x7ff0 on green, 0x7ff0 on blue\n");
ccp->tf_r = ccp->tf_g = ccp->tf_b = 0x0;
ccp->center_r = ccp->center_g = ccp->center_b = 0x1;
ccp->scale_r = ccp->scale_g = ccp->scale_b = 0x80;
ccp->width_r = 0x10;
ccp->width_g = 0x7ff;
ccp->width_b = 0x7ff;
printVector(ccp, 1);
printf("# 0x7ff0 on red, 0x100 on green, 0x7ff0 on blue\n");
ccp->width_r = 0x7ff;
ccp->width_g = 0x10;
ccp->width_b = 0x7ff;
printVector(ccp, 1);
printf("# 0x7ff0 on red, 0x7ff0 on green, 0x100 on blue\n");
ccp->width_r = 0x7ff;
ccp->width_g = 0x7ff;
ccp->width_b = 0x10;
printVector(ccp, 1);
printf("# 0x7ff0 on red, 0x7ff0 on green, 0x7ff0 on blue\n");
ccp->width_r = 0x7ff;
ccp->width_g = 0x7ff;
ccp->width_b = 0x7ff;
printVector(ccp, 1);
}
static void
boundaryValues(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i, j, k, l;
static int tf_values[] = {0x000, 0x001, 0x100, 0x101 };
static int scale_values[] = {0x00, 0x01, 0x80, 0x81 };
static int center_values[] = {0x00, 0x01, 0x80, 0x81 };
static int width_values[] = {0x00, 0x01, 0x800, 0x801 };
printf("# Boundary values\n");
initKeyMode(ccp);
for (i = 0; i < sizeof(tf_values)/sizeof(int); i++) {
ccp->tf_r = ccp->tf_g = ccp->tf_b = tf_values[i];
for (j = 0; j < sizeof(scale_values)/sizeof(int); j++) {
ccp->scale_r = ccp->scale_g = ccp->scale_b = scale_values[j];
for (k = 0; k < sizeof(center_values)/sizeof(int); k++) {
ccp->center_r = ccp->center_g = ccp->center_b =
center_values[k];
for (l = 0; l < sizeof(width_values)/sizeof(int); l++) {
ccp->width_r = ccp->width_g = ccp->width_b =
width_values[l];
printf("# tf 0x%x scale 0x%x center 0x%x width 0x%x\n",
ccp->tf_r, ccp->scale_r,
ccp->center_r, ccp->width_r);
printVector(ccp, 1);
}
}
}
}
}
static void
monteCarlo(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i;
printf("# Monte Carlo\n");
srandom(1);
initKeyMode(ccp);
printf("# Vary r,g,b components separately\n");
for (i = 0; i < 30; i++) {
ccp->tf_r = random() & 0x1ff;
ccp->tf_g = random() & 0x1ff;
ccp->tf_b = random() & 0x1ff;
ccp->scale_r = random() & 0xff;
ccp->scale_g = random() & 0xff;
ccp->scale_b = random() & 0xff;
ccp->center_r = random() & 0xff;
ccp->center_g = random() & 0xff;
ccp->center_b = random() & 0xff;
ccp->width_r = random() & 0xfff;
ccp->width_g = random() & 0xfff;
ccp->width_b = random() & 0xfff;
printVector(ccp, 1);
}
printf("# Vary (r,g) and b components separately\n");
for (i = 0; i < 30; i++) {
ccp->tf_r = ccp->tf_g = random() & 0x1ff;
ccp->tf_b = random() & 0x1ff;
ccp->scale_r = ccp->scale_g = random() & 0xff;
ccp->scale_b = random() & 0xff;
ccp->center_r = ccp->center_g = random() & 0xff;
ccp->center_b = random() & 0xff;
ccp->width_r = ccp->width_g = random() & 0xfff;
ccp->width_b = random() & 0xfff;
printVector(ccp, 1);
}
printf("# Vary (r,b) and g components separately\n");
for (i = 0; i < 30; i++) {
ccp->tf_r = ccp->tf_b = random() & 0x1ff;
ccp->tf_g = random() & 0x1ff;
ccp->scale_r = ccp->scale_b = random() & 0xff;
ccp->scale_g = random() & 0xff;
ccp->center_r = ccp->center_b = random() & 0xff;
ccp->center_g = random() & 0xff;
ccp->width_r = ccp->width_b = random() & 0xfff;
ccp->width_g = random() & 0xfff;
printVector(ccp, 1);
}
printf("# Vary (g,b) and r components separately\n");
for (i = 0; i < 30; i++) {
ccp->tf_g = ccp->tf_b = random() & 0x1ff;
ccp->tf_r = random() & 0x1ff;
ccp->scale_g = ccp->scale_b = random() & 0xff;
ccp->scale_r = random() & 0xff;
ccp->center_g = ccp->center_b = random() & 0xff;
ccp->center_r = random() & 0xff;
ccp->width_g = ccp->width_b = random() & 0xfff;
ccp->width_r = random() & 0xfff;
printVector(ccp, 1);
}
printf("# Vary r,g,b components together\n");
for (i = 0; i < 30; i++) {
ccp->tf_r = ccp->tf_g = ccp->tf_b = random() & 0x1ff;
ccp->scale_r = ccp->scale_g = ccp->scale_b = random() & 0xff;
ccp->center_r = ccp->center_g = ccp->center_b = random() & 0xff;
ccp->width_r = ccp->width_g = ccp->width_b = random() & 0xfff;
printVector(ccp, 1);
}
}
static void
initKeyMode(cc_t *ccp)
{
bzero(ccp, sizeof(*ccp));
ccp->ncyc = 0; /* single cycle mode */
ccp->key_en = 1; /* enable keying */
/* Initialize color selects to (texel 1, center, scale, texel 1) */
ccp->cc_x_sel_1_r = CC_SUBA_TEX_1;
ccp->cc_y_sel_1_r = CC_SUBB_CENTER;
ccp->cc_a_sel_1_r = CC_MULT_SCALE;
ccp->cc_c_sel_1_r = CC_ADD_TEX_1;
/* Initialize alpha selects to (0,0,0,0) */
ccp->cc_x_sel_1_a = CC_SUBA_ZERO_ALPHA;
ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
ccp->cc_a_sel_1_a = CC_MULT_ZERO_ALPHA;
ccp->cc_c_sel_1_a = CC_ADD_ZERO_ALPHA;
}