File: vao.c

package info (click to toggle)
piglit 0~git20200212-f4710c51b-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 106,972 kB
  • sloc: ansic: 263,763; xml: 48,941; python: 29,918; lisp: 19,789; cpp: 12,142; sh: 22; makefile: 20; pascal: 5
file content (793 lines) | stat: -rw-r--r-- 25,033 bytes parent folder | download
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
/*
 * Copyright © 2019 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

/* This test verifies that the VAO functions added by EXT_direct_state_access
 * modifies the specified VAO object instead of the bound one.
 * Validation of the correct interpretation of the parameters is left to the
 * other VAO specific tests.
 */

#include "piglit-util-gl.h"

PIGLIT_GL_TEST_CONFIG_BEGIN

	config.supports_gl_compat_version = 30;

	config.window_visual = PIGLIT_GL_VISUAL_RGBA |
		PIGLIT_GL_VISUAL_DOUBLE;
	config.khr_no_error_support = PIGLIT_HAS_ERRORS;

PIGLIT_GL_TEST_CONFIG_END

static GLuint vao[2];
static GLuint buffers[11];

static bool
verify(const char* func, GLenum pname, GLintptr expected_value, bool is_pointer, int attrib_index)
{
	GLintptr v;
	char* get_fn;
	if (is_pointer) {
		void* ptr;
		if (attrib_index >= 0) {
			glGetVertexAttribPointerv(attrib_index, pname, &ptr);
			get_fn = "glGetVertexAttribPointerv";
		} else {
			glGetPointerv(pname, &ptr);
			get_fn = "glGetPointerv";
		}
		v = (GLintptr) ptr;
	} else {
		int d;
		if (attrib_index >= 0) {
			glGetVertexAttribiv(attrib_index, pname, &d);
			get_fn = "glGetVertexAttribiv";
		} else {
			glGetIntegerv(pname, &d);
			get_fn = "glGetIntegerv";
		}
		v = d;
	}

	if (v == expected_value)
		return true;

	if (is_pointer)
		printf("gl%s error: expected value is %p but %s(%s) read %p\n",
			func + 5, (void*) expected_value, get_fn, piglit_get_gl_enum_name(pname), (void*) v);
	else
		printf("gl%s error: expected value is %d but %s(%s) read %d\n",
			func + 5, (int) expected_value, get_fn, piglit_get_gl_enum_name(pname), (int) v);
	return false;
}

static enum piglit_result
test_VertexArrayVertexOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayVertexOffsetEXT(vao[1], buffer, 3, GL_DOUBLE, 24, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_VERTEX_ARRAY_SIZE, 3, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ARRAY_TYPE, GL_DOUBLE, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ARRAY_STRIDE, 24, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayColorOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayColorOffsetEXT(vao[1], buffer, 3, GL_FLOAT, 13, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_COLOR_ARRAY_SIZE, 3, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_COLOR_ARRAY_TYPE, GL_FLOAT, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_COLOR_ARRAY_STRIDE, 13, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_COLOR_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_COLOR_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayEdgeFlagOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayEdgeFlagOffsetEXT(vao[1], buffer, 56, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_EDGE_FLAG_ARRAY_STRIDE, 56, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_EDGE_FLAG_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_EDGE_FLAG_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayIndexOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayIndexOffsetEXT(vao[1], buffer, GL_UNSIGNED_BYTE, 12, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_INDEX_ARRAY_TYPE, GL_UNSIGNED_BYTE, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_INDEX_ARRAY_STRIDE, 12, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_INDEX_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_INDEX_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayNormalOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayNormalOffsetEXT(vao[1], buffer, GL_DOUBLE, 4, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_NORMAL_ARRAY_TYPE, GL_DOUBLE, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_NORMAL_ARRAY_STRIDE, 4, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_NORMAL_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_NORMAL_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayTexCoordOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayTexCoordOffsetEXT(vao[1], buffer, 2, GL_INT, 24, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_SIZE, 2, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_TYPE, GL_INT, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_STRIDE, 24, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayMultiTexCoordOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayMultiTexCoordOffsetEXT(vao[1], buffer, GL_TEXTURE3,
						    3, GL_SHORT, 10, offset);

		glBindVertexArray(vao[1]);
		glClientActiveTexture(GL_TEXTURE3);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_SIZE, 3, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_TYPE, GL_SHORT, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_STRIDE, 10, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);
		glClientActiveTexture(GL_TEXTURE0);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayFogCoordOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArrayFogCoordOffsetEXT(vao[1], buffer, GL_DOUBLE, 36, offset);

		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_FOG_COORD_ARRAY_TYPE, GL_DOUBLE, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_FOG_COORD_ARRAY_STRIDE, 36, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_FOG_COORD_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_FOG_COORD_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArraySecondaryColorOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;

		glVertexArraySecondaryColorOffsetEXT(vao[1], buffer, 3, GL_DOUBLE, 12, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_SECONDARY_COLOR_ARRAY_SIZE, 3, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_SECONDARY_COLOR_ARRAY_TYPE, GL_DOUBLE, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_SECONDARY_COLOR_ARRAY_STRIDE, 12, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING, buffer, false, -1) && pass;
		pass = verify(__FUNCTION__, GL_SECONDARY_COLOR_ARRAY_POINTER, offset, true, -1) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayVertexAttribOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;
		GLuint index = 5;

		glVertexArrayVertexAttribOffsetEXT(vao[1], buffer, index, 3, GL_DOUBLE, true, 8, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_SIZE, 3, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_DOUBLE, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, 1, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 8, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, buffer, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_POINTER, offset, true, index) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_VertexArrayVertexAttribIOffsetEXT(void* d)
{
	bool pass = true;
	for (int i = 0; i < 2; i++) {
		GLuint buffer = i ? buffers[rand() % ARRAY_SIZE(buffers)] : 0;
		GLintptr offset = buffer ? abs(rand()) : 0;
		GLuint index = 3;

		glVertexArrayVertexAttribIOffsetEXT(vao[1], buffer, index, 2, GL_UNSIGNED_INT, 10, offset);
		glBindVertexArray(vao[1]);

		/* Read back the values */
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_SIZE, 2, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_UNSIGNED_INT, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 10, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, buffer, false, index) && pass;
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_POINTER, offset, true, index) && pass;

		glBindVertexArray(vao[0]);

		if (buffer)
			pass = glIsBuffer(buffer) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

static enum piglit_result
test_EnableVertexArrayEXT(void* d)
{
	bool pass = true;
	GLenum caps[] = {
		GL_COLOR_ARRAY,
		GL_EDGE_FLAG_ARRAY,
		GL_FOG_COORD_ARRAY,
		GL_INDEX_ARRAY,
		GL_NORMAL_ARRAY,
		GL_SECONDARY_COLOR_ARRAY,
		GL_TEXTURE_COORD_ARRAY,
		GL_VERTEX_ARRAY,
	/* The EXT_direct_state_access spec says:
	 *
	 *    "Additionally EnableVertexArrayEXT and DisableVertexArrayEXT accept
	 *    the tokens TEXTURE0 through TEXTUREn where n is less than the
	 *    implementation-dependent limit of MAX_TEXTURE_COORDS.  For these
	 *    GL_TEXTUREi tokens, EnableVertexArrayEXT and DisableVertexArrayEXT
	 *    act identically to EnableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY)
	 *    or DisableVertexArrayEXT(vaobj, TEXTURE_COORD_ARRAY) respectively
	 *    as if the active client texture is set to texture coordinate set i
	 *    based on the token TEXTUREi indicated by array."
	 */
		GL_TEXTURE3,
	};
	for (int i = 0; i < ARRAY_SIZE(caps); i++) {
		int enabled;

		glEnableVertexArrayEXT(vao[1], caps[i]);

		glBindVertexArray(vao[1]);
		if (caps[i] == GL_TEXTURE3) {
			glClientActiveTexture(GL_TEXTURE3);
			glGetIntegerv(GL_TEXTURE_COORD_ARRAY, &enabled);
		} else
			glGetIntegerv(caps[i], &enabled);
		pass = enabled && pass;
		glBindVertexArray(vao[0]);
		glClientActiveTexture(GL_TEXTURE0);

		glDisableVertexArrayEXT(vao[1], caps[i]);

		glBindVertexArray(vao[1]);
		if (caps[i] == GL_TEXTURE3) {
			glClientActiveTexture(GL_TEXTURE3);
			glGetIntegerv(GL_TEXTURE_COORD_ARRAY, &enabled);
		} else
			glGetIntegerv(caps[i], &enabled);
		pass = !enabled && pass;
		glBindVertexArray(vao[0]);
		glClientActiveTexture(GL_TEXTURE0);
	}

	/* The EXT_direct_state_access spec says:
	 *
	 *    "[EnableVertexArrayAttribEXT and DisableVertexArrayAttribEXT] operate
	 *    identically to [...] EnableVertexAttribArray, and DisableVertexAttribArray
	 *    respectively except rather than updating the current vertex array client-state
	 *    these "VertexArray" commands update the vertex array enables
	 *    within the vertex array object named by the initial vaobj parameter.
	 *    [...].  The index parameter matches the index parameter for the corresponding
	 *    EnableVertexAttribArray and DisableVertexAttribArray commands.
	 */
	int max_attribs;
	glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs);
	for (int i = 0; i < max_attribs; i++) {
		int enabled;
		glEnableVertexArrayAttribEXT(vao[1], i);
		glBindVertexArray(vao[1]);
		glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
		pass = enabled && pass;
		glBindVertexArray(vao[0]);

		glDisableVertexArrayAttribEXT(vao[1], i);
		glBindVertexArray(vao[1]);
		glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
		pass = !enabled && pass;
		glBindVertexArray(vao[0]);
	}

	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}


static enum piglit_result
test_GetVertexArrayIntegervEXT(void* d)
{
	bool pass = true;
	/* The EXT_direct_state_access spec says:
	 *
	 *    "For GetVertexArrayIntegervEXT, pname must be one of the "Get value" tokens
	 *    in tables 6.6, 6.7, 6.8, and 6.9 that use GetIntegerv, IsEnabled, or
	 *    GetPointerv for their "Get command" (so excluding the VERTEX_ATTRIB_*
	 *    tokens)."
	 */
	static const GLenum pnames_GetIntegerv[] = {
		GL_CLIENT_ACTIVE_TEXTURE,
		GL_VERTEX_ARRAY_SIZE,
		GL_VERTEX_ARRAY_TYPE,
		GL_VERTEX_ARRAY_STRIDE,
		GL_VERTEX_ARRAY_BUFFER_BINDING,
		GL_COLOR_ARRAY_SIZE,
		GL_COLOR_ARRAY_TYPE,
		GL_COLOR_ARRAY_STRIDE,
		GL_COLOR_ARRAY_BUFFER_BINDING,
		GL_EDGE_FLAG_ARRAY_STRIDE,
		GL_EDGE_FLAG_ARRAY_BUFFER_BINDING,
		GL_INDEX_ARRAY_TYPE,
		GL_INDEX_ARRAY_STRIDE,
		GL_INDEX_ARRAY_BUFFER_BINDING,
		GL_NORMAL_ARRAY_TYPE,
		GL_NORMAL_ARRAY_STRIDE,
		GL_NORMAL_ARRAY_BUFFER_BINDING,
		GL_TEXTURE_COORD_ARRAY_SIZE,
		GL_TEXTURE_COORD_ARRAY_TYPE,
		GL_TEXTURE_COORD_ARRAY_STRIDE,
		GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING,
		GL_FOG_COORD_ARRAY_TYPE,
		GL_FOG_COORD_ARRAY_STRIDE,
		GL_FOG_COORD_ARRAY_BUFFER_BINDING,
		GL_SECONDARY_COLOR_ARRAY_SIZE,
		GL_SECONDARY_COLOR_ARRAY_TYPE,
		GL_SECONDARY_COLOR_ARRAY_STRIDE,
		GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING
	};

	for (int i = 0; i < ARRAY_SIZE(pnames_GetIntegerv); i++) {
		int value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayIntegervEXT(vao[1], pnames_GetIntegerv[i], &value);

		glBindVertexArray(vao[1]);
		pass = verify(__FUNCTION__, pnames_GetIntegerv[i], value, false, -1) && pass;
      	}

	static const GLenum pnames_IsEnabled[] = {
		GL_VERTEX_ARRAY,
		GL_COLOR_ARRAY,
		GL_EDGE_FLAG_ARRAY,
		GL_INDEX_ARRAY,
		GL_NORMAL_ARRAY,
		GL_TEXTURE_COORD_ARRAY,
		GL_FOG_COORD_ARRAY,
		GL_SECONDARY_COLOR_ARRAY
	};

	for (int i = 0; i < ARRAY_SIZE(pnames_IsEnabled); i++) {
		int value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayIntegervEXT(vao[1], pnames_IsEnabled[i], &value);

		glBindVertexArray(vao[1]);
		pass = verify(__FUNCTION__, pnames_IsEnabled[i], value, false, -1) && pass;
	}

	static const GLenum pnames_GetPointerv[] = {
		GL_VERTEX_ARRAY_POINTER,
		GL_COLOR_ARRAY_POINTER,
		GL_EDGE_FLAG_ARRAY_POINTER,
		GL_INDEX_ARRAY_POINTER,
		GL_NORMAL_ARRAY_POINTER,
		GL_TEXTURE_COORD_ARRAY_POINTER,
		GL_FOG_COORD_ARRAY_POINTER,
		GL_SECONDARY_COLOR_ARRAY_POINTER
	};

	for (int i = 0; i < ARRAY_SIZE(pnames_GetPointerv); i++) {
		int value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayIntegervEXT(vao[1], pnames_GetPointerv[i], &value);

		glBindVertexArray(vao[1]);
		pass = verify(__FUNCTION__, pnames_GetPointerv[i], value, true, -1) && pass;
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}


static enum piglit_result
test_GetVertexArrayIntegeri_vEXT(void* d)
{
	bool pass = true;
	/* The EXT_direct_state_access spec says:
	 *
	 *    "For GetVertexArrayIntegeri_vEXT, pname must be one of the
	 *    "Get value" tokens in tables 6.8 and 6.9 that use GetVertexAttribiv
	 *    or GetVertexAttribPointerv (so allowing only the VERTEX_ATTRIB_*
	 *    tokens) or a token of the form TEXTURE_COORD_ARRAY (the enable) or
	 *    TEXTURE_COORD_ARRAY_*"
	 */
	static const GLenum pnames_VertexAttribArray[] = {
		GL_VERTEX_ATTRIB_ARRAY_ENABLED,
		GL_VERTEX_ATTRIB_ARRAY_SIZE,
		GL_VERTEX_ATTRIB_ARRAY_STRIDE,
		GL_VERTEX_ATTRIB_ARRAY_TYPE,
		GL_VERTEX_ATTRIB_ARRAY_NORMALIZED,
		GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
	};

	int max_attribs;
	glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs);
	for (int i = 0; i < ARRAY_SIZE(pnames_VertexAttribArray); i++) {
		for (int j = 0; j < max_attribs; j++) {
			int value;
			glBindVertexArray(vao[0]);
			glGetVertexArrayIntegeri_vEXT(vao[1], j, pnames_VertexAttribArray[i], &value);

			glBindVertexArray(vao[1]);
			pass = verify(__FUNCTION__, pnames_VertexAttribArray[i], value, false, j) && pass;
		}
      	}

	static const GLenum pnames_TextureCoord[] = {
		GL_TEXTURE_COORD_ARRAY,
		GL_TEXTURE_COORD_ARRAY_SIZE,
		GL_TEXTURE_COORD_ARRAY_TYPE,
		GL_TEXTURE_COORD_ARRAY_STRIDE,
		GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING,
	};
	int max_texture_units;
	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_units);
	for (int i = 0; i < ARRAY_SIZE(pnames_TextureCoord); i++) {
		for (int j = 0; j < max_texture_units; j++) {
			int value;
			glBindVertexArray(vao[0]);
			glGetVertexArrayIntegeri_vEXT(vao[1], j, pnames_TextureCoord[i], &value);

			glBindVertexArray(vao[1]);
			glClientActiveTexture(GL_TEXTURE0 + j);
			pass = verify(__FUNCTION__, pnames_TextureCoord[i], value, false, -1) && pass;
			glClientActiveTexture(GL_TEXTURE0);
		}
	}

	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}


static enum piglit_result
test_GetVertexArrayPointervEXT(void* d)
{
	bool pass = true;
	/* The EXT_direct_state_access spec says:
	 *
	 *    "For GetVertexArrayPointervEXT, pname must be a *_ARRAY_POINTER token
	 *    from tables 6.6, 6.7, and 6.8 excluding VERTEX_ATTRIB_ARRAY_POINTER"
	 */
	static const GLenum pnames[] = {
		GL_VERTEX_ARRAY_POINTER,
		GL_COLOR_ARRAY_POINTER,
		GL_EDGE_FLAG_ARRAY_POINTER,
		GL_INDEX_ARRAY_POINTER,
		GL_NORMAL_ARRAY_POINTER,
		GL_TEXTURE_COORD_ARRAY_POINTER,
		GL_FOG_COORD_ARRAY_POINTER,
		GL_SECONDARY_COLOR_ARRAY_POINTER,
	};

	for (int i = 0; i < ARRAY_SIZE(pnames); i++) {
		void* value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayPointervEXT(vao[1], pnames[i], &value);

		glBindVertexArray(vao[1]);
		pass = verify(__FUNCTION__, pnames[i], (GLintptr) value, true, -1) && pass;
      	}

	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}


static enum piglit_result
test_GetVertexArrayPointeri_vEXT(void* d)
{
	bool pass = true;
	/* The EXT_direct_state_access spec says:
	 *
	 *    "For GetVertexArrayPointeri_vEXT, pname must be VERTEX_ATTRIB_ARRAY_POINTER
    	 *    or TEXTURE_COORD_ARRAY_POINTE"
	 */
	int max_attribs;
	glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs);
	for (int i = 0; i < max_attribs; i++) {
		void* value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayPointeri_vEXT(vao[1], i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &value);

		glBindVertexArray(vao[1]);
		pass = verify(__FUNCTION__, GL_VERTEX_ATTRIB_ARRAY_POINTER, (GLintptr) value, true, i) && pass;
	}

	int max_texture_units;
	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_units);
	for (int i = 0; i < max_texture_units; i++) {
		void* value;
		glBindVertexArray(vao[0]);
		glGetVertexArrayPointeri_vEXT(vao[1], i, GL_TEXTURE_COORD_ARRAY_POINTER, &value);

		glBindVertexArray(vao[1]);
		glClientActiveTexture(GL_TEXTURE0 + i);
		pass = verify(__FUNCTION__, GL_TEXTURE_COORD_ARRAY_POINTER, (GLintptr) value, true, -1) && pass;
		glClientActiveTexture(GL_TEXTURE0);
	}
	return (piglit_check_gl_error(GL_NO_ERROR) && pass) ? PIGLIT_PASS : PIGLIT_FAIL;
}

void
piglit_init(int argc, char **argv)
{
	piglit_require_extension("GL_EXT_direct_state_access");

	glGenVertexArrays(ARRAY_SIZE(vao), vao);
	glBindVertexArray(vao[0]);
	glGenBuffers(ARRAY_SIZE(buffers), buffers);

	static const struct piglit_subtest tests[] = {
		{
			"VertexArrayVertexOffsetEXT",
			NULL,
			test_VertexArrayVertexOffsetEXT,
		},
		{
			"VertexArrayVertexOffsetEXT",
			NULL,
			test_VertexArrayVertexOffsetEXT
		},
		{
			"VertexArrayColorOffsetEXT",
			NULL,
			test_VertexArrayColorOffsetEXT
		},
		{
			"VertexArrayEdgeFlagOffsetEXT",
			NULL,
			test_VertexArrayEdgeFlagOffsetEXT
		},
		{
			"VertexArrayIndexOffsetEXT",
			NULL,
			test_VertexArrayIndexOffsetEXT
		},
		{
			"VertexArrayNormalOffsetEXT",
			NULL,
			test_VertexArrayNormalOffsetEXT
		},
		{
			"VertexArrayTexCoordOffsetEXT",
			NULL,
			test_VertexArrayTexCoordOffsetEXT
		},
		{
			"VertexArrayMultiTexCoordOffsetEXT",
			NULL,
			test_VertexArrayMultiTexCoordOffsetEXT
		},
		{
			"VertexArrayFogCoordOffsetEXT",
			NULL,
			test_VertexArrayFogCoordOffsetEXT
		},
		{
			"VertexArraySecondaryColorOffsetEXT",
			NULL,
			test_VertexArraySecondaryColorOffsetEXT
		},
		{
			"VertexArrayVertexAttribOffsetEXT",
			NULL,
			test_VertexArrayVertexAttribOffsetEXT
		},
		{
			"VertexArrayVertexAttribIOffsetEXT",
			NULL,
			test_VertexArrayVertexAttribIOffsetEXT
		},
		{
			"EnableVertexArrayEXT/DisableVertexArrayEXT",
			NULL,
			test_EnableVertexArrayEXT
		},
		{
			"GetVertexArrayIntegervEXT",
			NULL,
			test_GetVertexArrayIntegervEXT
		},
		{
			"GetVertexArrayIntegeri_vEXT",
			NULL,
			test_GetVertexArrayIntegeri_vEXT
		},
		{
			"GetVertexArrayPointervEXT",
			NULL,
			test_GetVertexArrayPointervEXT
		},
		{
			"GetVertexArrayPointeri_vEXT",
			NULL,
			test_GetVertexArrayPointeri_vEXT
		},
		{
			NULL
		}
	};

	enum piglit_result r = piglit_run_selected_subtests(tests, NULL, 0, PIGLIT_PASS);

	glDeleteVertexArrays(ARRAY_SIZE(vao), vao);
	glDeleteBuffers(ARRAY_SIZE(buffers), buffers);

	piglit_report_result(r);
}

enum piglit_result
piglit_display(void)
{
	/* Unreachable */
	return PIGLIT_FAIL;
}