Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/deqp_support/es31cVertexAttribBindingTests_override.cpp
1693 views
1
/*-------------------------------------------------------------------------
2
* OpenGL Conformance Test Suite
3
* -----------------------------
4
*
5
* Copyright (c) 2014-2016 The Khronos Group Inc.
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
22
*/ /*-------------------------------------------------------------------*/
23
24
#include <cstdarg>
25
#include "es31cVertexAttribBindingTests.hpp"
26
#include "glwEnums.hpp"
27
#include "tcuMatrix.hpp"
28
#include "tcuRenderTarget.hpp"
29
30
#include <cmath>
31
32
namespace glcts
33
{
34
using namespace glw;
35
using tcu::IVec2;
36
using tcu::IVec3;
37
using tcu::IVec4;
38
using tcu::Mat4;
39
using tcu::UVec2;
40
using tcu::UVec3;
41
using tcu::UVec4;
42
using tcu::Vec2;
43
using tcu::Vec3;
44
using tcu::Vec4;
45
46
namespace
47
{
48
49
class VertexAttribBindingBase : public glcts::SubcaseBase
50
{
51
virtual std::string Title() { return NL ""; }
52
53
virtual std::string Purpose() { return NL ""; }
54
55
virtual std::string Method() { return NL ""; }
56
57
virtual std::string PassCriteria() { return NL ""; }
58
59
public:
60
bool IsSSBOInVSFSAvailable(int required)
61
{
62
GLint blocksVS, blocksFS;
63
glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &blocksVS);
64
glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &blocksFS);
65
if (blocksVS >= required && blocksFS >= required)
66
return true;
67
else
68
{
69
std::ostringstream reason;
70
reason << "Required " << required << " VS storage blocks but only " << blocksVS
71
<< " available." << std::endl
72
<< "Required " << required << " FS storage blocks but only " << blocksFS
73
<< " available." << std::endl;
74
OutputNotSupported(reason.str());
75
return false;
76
}
77
}
78
79
int getWindowWidth()
80
{
81
const tcu::RenderTarget &renderTarget = m_context.getRenderTarget();
82
return renderTarget.getWidth();
83
}
84
85
int getWindowHeight()
86
{
87
const tcu::RenderTarget &renderTarget = m_context.getRenderTarget();
88
return renderTarget.getHeight();
89
}
90
91
inline bool ColorEqual(const Vec4 &c0, const Vec4 &c1, const Vec4 &epsilon)
92
{
93
if (fabs(c0[0] - c1[0]) > epsilon[0])
94
return false;
95
if (fabs(c0[1] - c1[1]) > epsilon[1])
96
return false;
97
if (fabs(c0[2] - c1[2]) > epsilon[2])
98
return false;
99
if (fabs(c0[3] - c1[3]) > epsilon[3])
100
return false;
101
return true;
102
}
103
104
bool CheckProgram(GLuint program)
105
{
106
GLint status;
107
glGetProgramiv(program, GL_LINK_STATUS, &status);
108
109
if (status == GL_FALSE)
110
{
111
GLint attached_shaders;
112
glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
113
114
if (attached_shaders > 0)
115
{
116
std::vector<GLuint> shaders(attached_shaders);
117
glGetAttachedShaders(program, attached_shaders, NULL, &shaders[0]);
118
119
for (GLint i = 0; i < attached_shaders; ++i)
120
{
121
GLenum type;
122
glGetShaderiv(shaders[i], GL_SHADER_TYPE, reinterpret_cast<GLint *>(&type));
123
switch (type)
124
{
125
case GL_VERTEX_SHADER:
126
m_context.getTestContext().getLog()
127
<< tcu::TestLog::Message << "*** Vertex Shader ***"
128
<< tcu::TestLog::EndMessage;
129
break;
130
case GL_FRAGMENT_SHADER:
131
m_context.getTestContext().getLog()
132
<< tcu::TestLog::Message << "*** Fragment Shader ***"
133
<< tcu::TestLog::EndMessage;
134
break;
135
default:
136
m_context.getTestContext().getLog()
137
<< tcu::TestLog::Message << "*** Unknown Shader ***"
138
<< tcu::TestLog::EndMessage;
139
break;
140
}
141
GLint length;
142
glGetShaderiv(shaders[i], GL_SHADER_SOURCE_LENGTH, &length);
143
if (length > 0)
144
{
145
std::vector<GLchar> source(length);
146
glGetShaderSource(shaders[i], length, NULL, &source[0]);
147
m_context.getTestContext().getLog()
148
<< tcu::TestLog::Message << &source[0] << tcu::TestLog::EndMessage;
149
}
150
glGetShaderiv(shaders[i], GL_INFO_LOG_LENGTH, &length);
151
if (length > 0)
152
{
153
std::vector<GLchar> log(length);
154
glGetShaderInfoLog(shaders[i], length, NULL, &log[0]);
155
m_context.getTestContext().getLog()
156
<< tcu::TestLog::Message << &log[0] << tcu::TestLog::EndMessage;
157
}
158
}
159
}
160
GLint length;
161
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
162
if (length > 0)
163
{
164
std::vector<GLchar> log(length);
165
glGetProgramInfoLog(program, length, NULL, &log[0]);
166
m_context.getTestContext().getLog()
167
<< tcu::TestLog::Message << &log[0] << tcu::TestLog::EndMessage;
168
}
169
}
170
return status == GL_TRUE ? true : false;
171
}
172
173
bool IsEqual(IVec4 a, IVec4 b)
174
{
175
return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]) && (a[3] == b[3]);
176
}
177
178
bool IsEqual(UVec4 a, UVec4 b)
179
{
180
return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]) && (a[3] == b[3]);
181
}
182
183
bool IsEqual(Vec2 a, Vec2 b) { return (a[0] == b[0]) && (a[1] == b[1]); }
184
185
bool IsEqual(IVec2 a, IVec2 b) { return (a[0] == b[0]) && (a[1] == b[1]); }
186
187
bool IsEqual(UVec2 a, UVec2 b) { return (a[0] == b[0]) && (a[1] == b[1]); }
188
189
bool CheckFB(Vec3 expected)
190
{
191
const tcu::RenderTarget &renderTarget = m_context.getRenderContext().getRenderTarget();
192
const tcu::PixelFormat &pixelFormat = renderTarget.getPixelFormat();
193
Vec3 g_color_eps = Vec3(1.f / static_cast<float>(1 << pixelFormat.redBits),
194
1.f / static_cast<float>(1 << pixelFormat.greenBits),
195
1.f / static_cast<float>(1 << pixelFormat.blueBits));
196
Vec3 g_color_max = Vec3(255);
197
std::vector<GLubyte> fb(getWindowWidth() * getWindowHeight() * 4);
198
int fb_w = getWindowWidth();
199
int fb_h = getWindowHeight();
200
glReadPixels(0, 0, fb_w, fb_h, GL_RGBA, GL_UNSIGNED_BYTE, &fb[0]);
201
for (GLint i = 0, y = 0; y < fb_h; ++y)
202
for (GLint x = 0; x < fb_w; ++x, i += 4)
203
{
204
if (fabs(fb[i + 0] / g_color_max[0] - expected[0]) > g_color_eps[0] ||
205
fabs(fb[i + 1] / g_color_max[1] - expected[1]) > g_color_eps[1] ||
206
fabs(fb[i + 2] / g_color_max[2] - expected[2]) > g_color_eps[2])
207
{
208
m_context.getTestContext().getLog()
209
<< tcu::TestLog::Message << "Incorrect framebuffer color at pixel (" << x
210
<< " " << y << "). Color is (" << fb[i + 0] / g_color_max[0] << " "
211
<< fb[i + 1] / g_color_max[1] << " " << fb[i + 2] / g_color_max[2]
212
<< ". Color should be (" << expected[0] << " " << expected[1] << " "
213
<< expected[2] << ")." << tcu::TestLog::EndMessage;
214
return false;
215
}
216
}
217
return true;
218
}
219
220
GLhalf FloatToHalf(float f)
221
{
222
const unsigned int HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP = 0x38000000;
223
/* max exponent value in single precision that will be converted */
224
/* to Inf or Nan when stored as a half-float */
225
const unsigned int HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP = 0x47800000;
226
/* 255 is the max exponent biased value */
227
const unsigned int FLOAT_MAX_BIASED_EXP = (0xFF << 23);
228
const unsigned int HALF_FLOAT_MAX_BIASED_EXP = (0x1F << 10);
229
char *c = reinterpret_cast<char *>(&f);
230
unsigned int x = *reinterpret_cast<unsigned int *>(c);
231
unsigned int sign = (GLhalf)(x >> 31);
232
unsigned int mantissa;
233
unsigned int exp;
234
GLhalf hf;
235
236
/* get mantissa */
237
mantissa = x & ((1 << 23) - 1);
238
/* get exponent bits */
239
exp = x & FLOAT_MAX_BIASED_EXP;
240
if (exp >= HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP)
241
{
242
/* check if the original single precision float number is a NaN */
243
if (mantissa && (exp == FLOAT_MAX_BIASED_EXP))
244
{
245
/* we have a single precision NaN */
246
mantissa = (1 << 23) - 1;
247
}
248
else
249
{
250
/* 16-bit half-float representation stores number as Inf */
251
mantissa = 0;
252
}
253
hf = (GLhalf)((((GLhalf)sign) << 15) | (GLhalf)(HALF_FLOAT_MAX_BIASED_EXP) |
254
(GLhalf)(mantissa >> 13));
255
}
256
/* check if exponent is <= -15 */
257
else if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP)
258
{
259
/* store a denorm half-float value or zero */
260
exp = ((HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23) + 14;
261
// handle 0.0 specially to avoid a right-shift by too many bits
262
if (exp >= 32)
263
{
264
return 0;
265
}
266
mantissa |= (1 << 23);
267
mantissa >>= exp;
268
hf = (GLhalf)((((GLhalf)sign) << 15) | (GLhalf)(mantissa));
269
}
270
else
271
{
272
hf = (GLhalf)((((GLhalf)sign) << 15) |
273
(GLhalf)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) |
274
(GLhalf)(mantissa >> 13));
275
}
276
277
return hf;
278
}
279
};
280
//=============================================================================
281
// 1.1 BasicUsage
282
//-----------------------------------------------------------------------------
283
class BasicUsage : public VertexAttribBindingBase
284
{
285
bool pipeline;
286
287
GLuint m_vsp, m_fsp, m_ppo, m_vao, m_vbo;
288
289
virtual long Setup()
290
{
291
if (pipeline)
292
{
293
m_vsp = m_fsp = 0;
294
glGenProgramPipelines(1, &m_ppo);
295
}
296
else
297
{
298
m_ppo = 0;
299
}
300
glGenVertexArrays(1, &m_vao);
301
glGenBuffers(1, &m_vbo);
302
return NO_ERROR;
303
}
304
305
virtual long Cleanup()
306
{
307
if (pipeline)
308
{
309
glDeleteProgram(m_vsp);
310
glDeleteProgram(m_fsp);
311
glDeleteProgramPipelines(1, &m_ppo);
312
}
313
else
314
{
315
glUseProgram(0);
316
glDeleteProgram(m_ppo);
317
}
318
glDeleteVertexArrays(1, &m_vao);
319
glDeleteBuffers(1, &m_vbo);
320
return NO_ERROR;
321
}
322
323
virtual long Run()
324
{
325
const char *const glsl_vs =
326
"#version 310 es" NL "layout(location = 7) in vec4 vs_in_position;" NL
327
"layout(location = 1) in vec3 vs_in_color;" NL "out vec3 g_color;" NL "void main() {" NL
328
" gl_Position = vs_in_position;" NL " g_color = vs_in_color;" NL "}";
329
const char *const glsl_fs = "#version 310 es" NL "precision highp float;" NL
330
"in vec3 g_color;" NL "out vec4 fs_out_color;" NL
331
"void main() {" NL " fs_out_color = vec4(g_color, 1);" NL "}";
332
if (pipeline)
333
{
334
m_vsp = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
335
m_fsp = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &glsl_fs);
336
if (!CheckProgram(m_vsp) || !CheckProgram(m_fsp))
337
return ERROR;
338
glUseProgramStages(m_ppo, GL_VERTEX_SHADER_BIT, m_vsp);
339
glUseProgramStages(m_ppo, GL_FRAGMENT_SHADER_BIT, m_fsp);
340
}
341
else
342
{
343
m_ppo = glCreateProgram();
344
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
345
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
346
glShaderSource(sh, 1, &glsl_vs, NULL);
347
glShaderSource(fsh, 1, &glsl_fs, NULL);
348
glCompileShader(sh);
349
glCompileShader(fsh);
350
glAttachShader(m_ppo, sh);
351
glAttachShader(m_ppo, fsh);
352
glDeleteShader(sh);
353
glDeleteShader(fsh);
354
glLinkProgram(m_ppo);
355
if (!CheckProgram(m_ppo))
356
return ERROR;
357
}
358
/* vbo */
359
{
360
const float data[] = {
361
-1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
362
-1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
363
-1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f,
364
-1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
365
};
366
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
367
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
368
glBindBuffer(GL_ARRAY_BUFFER, 0);
369
}
370
glBindVertexArray(m_vao);
371
glVertexAttribFormat(7, 2, GL_FLOAT, GL_FALSE, 0);
372
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 8);
373
glVertexAttribBinding(7, 0);
374
glVertexAttribBinding(1, 0);
375
glBindVertexBuffer(0, m_vbo, 0, 20);
376
glEnableVertexAttribArray(7);
377
glEnableVertexAttribArray(1);
378
glBindVertexArray(0);
379
380
glClear(GL_COLOR_BUFFER_BIT);
381
glBindVertexArray(m_vao);
382
if (pipeline)
383
glBindProgramPipeline(m_ppo);
384
else
385
glUseProgram(m_ppo);
386
387
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
388
if (!CheckFB(Vec3(0, 1, 0)))
389
return ERROR;
390
391
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
392
if (!CheckFB(Vec3(1, 1, 0)))
393
return ERROR;
394
395
return NO_ERROR;
396
}
397
398
public:
399
BasicUsage() : pipeline(true) {}
400
};
401
//=============================================================================
402
// BasicInputBase
403
//-----------------------------------------------------------------------------
404
class BasicInputBase : public VertexAttribBindingBase
405
{
406
407
GLuint m_po, m_xfbo;
408
409
protected:
410
Vec4 expected_data[60];
411
GLsizei instance_count;
412
GLint base_instance;
413
414
virtual long Setup()
415
{
416
m_po = 0;
417
glGenBuffers(1, &m_xfbo);
418
for (int i = 0; i < 60; ++i)
419
expected_data[i] = Vec4(0.0f);
420
instance_count = 1;
421
base_instance = -1;
422
return NO_ERROR;
423
}
424
425
virtual long Cleanup()
426
{
427
glDisable(GL_RASTERIZER_DISCARD);
428
glUseProgram(0);
429
glDeleteProgram(m_po);
430
glDeleteBuffers(1, &m_xfbo);
431
return NO_ERROR;
432
}
433
434
virtual long Run()
435
{
436
const char *const glsl_vs =
437
"#version 310 es" NL "layout(location = 0) in vec4 vs_in_attrib0;" NL
438
"layout(location = 1) in vec4 vs_in_attrib1;" NL
439
"layout(location = 2) in vec4 vs_in_attrib2;" NL
440
"layout(location = 3) in vec4 vs_in_attrib3;" NL
441
"layout(location = 4) in vec4 vs_in_attrib4;" NL
442
"layout(location = 5) in vec4 vs_in_attrib5;" NL
443
"layout(location = 6) in vec4 vs_in_attrib6;" NL
444
"layout(location = 7) in vec4 vs_in_attrib7;" NL
445
"layout(location = 8) in vec4 vs_in_attrib8;" NL
446
"layout(location = 9) in vec4 vs_in_attrib9;" NL
447
"layout(location = 10) in vec4 vs_in_attrib10;" NL
448
"layout(location = 11) in vec4 vs_in_attrib11;" NL
449
"layout(location = 12) in vec4 vs_in_attrib12;" NL
450
"layout(location = 13) in vec4 vs_in_attrib13;" NL
451
"layout(location = 14) in vec4 vs_in_attrib14;" NL "out vec4 attrib[15];" NL
452
"void main() {" NL " attrib[0] = vs_in_attrib0;" NL " attrib[1] = vs_in_attrib1;" NL
453
" attrib[2] = vs_in_attrib2;" NL " attrib[3] = vs_in_attrib3;" NL
454
" attrib[4] = vs_in_attrib4;" NL " attrib[5] = vs_in_attrib5;" NL
455
" attrib[6] = vs_in_attrib6;" NL " attrib[7] = vs_in_attrib7;" NL
456
" attrib[8] = vs_in_attrib8;" NL " attrib[9] = vs_in_attrib9;" NL
457
" attrib[10] = vs_in_attrib10;" NL " attrib[11] = vs_in_attrib11;" NL
458
" attrib[12] = vs_in_attrib12;" NL " attrib[13] = vs_in_attrib13;" NL
459
" attrib[14] = vs_in_attrib14;" NL "}";
460
const char *const glsl_fs =
461
"#version 310 es" NL "precision mediump float;" NL "in vec4 attrib[15];" NL
462
"out vec4 fs_out_color;" NL "void main() {" NL " fs_out_color = attrib[8];" NL "}";
463
m_po = glCreateProgram();
464
/* attach shader */
465
{
466
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
467
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
468
glShaderSource(sh, 1, &glsl_vs, NULL);
469
glShaderSource(fsh, 1, &glsl_fs, NULL);
470
glCompileShader(sh);
471
glCompileShader(fsh);
472
glAttachShader(m_po, sh);
473
glAttachShader(m_po, fsh);
474
glDeleteShader(sh);
475
glDeleteShader(fsh);
476
}
477
/* setup XFB */
478
{
479
const GLchar *const v = "attrib";
480
glTransformFeedbackVaryings(m_po, 1, &v, GL_INTERLEAVED_ATTRIBS);
481
}
482
glLinkProgram(m_po);
483
if (!CheckProgram(m_po))
484
return ERROR;
485
486
/* buffer data */
487
{
488
std::vector<GLubyte> zero(sizeof(expected_data));
489
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_xfbo);
490
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sizeof(expected_data), &zero[0],
491
GL_DYNAMIC_DRAW);
492
}
493
494
// capture
495
glEnable(GL_RASTERIZER_DISCARD);
496
glUseProgram(m_po);
497
glBeginTransformFeedback(GL_POINTS);
498
if (base_instance != -1)
499
{
500
glDrawArraysInstancedBaseInstance(GL_POINTS, 0, 2, instance_count,
501
static_cast<GLuint>(base_instance));
502
}
503
else
504
{
505
glDrawArraysInstanced(GL_POINTS, 0, 2, instance_count);
506
}
507
glEndTransformFeedback();
508
509
Vec4 *data = static_cast<Vec4 *>(
510
glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(Vec4) * 60, GL_MAP_READ_BIT));
511
512
long status = NO_ERROR;
513
for (int i = 0; i < 60; ++i)
514
{
515
if (!ColorEqual(expected_data[i], data[i], Vec4(0.01f)))
516
{
517
m_context.getTestContext().getLog()
518
<< tcu::TestLog::Message << "Data is: " << data[i][0] << " " << data[i][1]
519
<< " " << data[i][2] << " " << data[i][3]
520
<< ", data should be: " << expected_data[i][0] << " " << expected_data[i][1]
521
<< " " << expected_data[i][2] << " " << expected_data[i][3]
522
<< ", index is: " << i << tcu::TestLog::EndMessage;
523
status = ERROR;
524
break;
525
}
526
}
527
return status;
528
}
529
};
530
531
//=============================================================================
532
// 1.2.1 BasicInputCase1
533
//-----------------------------------------------------------------------------
534
class BasicInputCase1 : public BasicInputBase
535
{
536
537
GLuint m_vao, m_vbo;
538
539
virtual long Setup()
540
{
541
BasicInputBase::Setup();
542
glGenVertexArrays(1, &m_vao);
543
glGenBuffers(1, &m_vbo);
544
return NO_ERROR;
545
}
546
547
virtual long Cleanup()
548
{
549
BasicInputBase::Cleanup();
550
glDeleteVertexArrays(1, &m_vao);
551
glDeleteBuffers(1, &m_vbo);
552
return NO_ERROR;
553
}
554
555
virtual long Run()
556
{
557
for (GLuint i = 0; i < 16; ++i)
558
{
559
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
560
}
561
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
562
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec3) * 2, NULL, GL_STATIC_DRAW);
563
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec3), &Vec3(1.0f, 2.0f, 3.0f)[0]);
564
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(Vec3), &Vec3(4.0f, 5.0f, 6.0f)[0]);
565
glBindBuffer(GL_ARRAY_BUFFER, 0);
566
567
glBindVertexArray(m_vao);
568
glBindVertexBuffer(0, m_vbo, 0, 12);
569
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 0);
570
glVertexAttribBinding(1, 0);
571
glEnableVertexAttribArray(1);
572
expected_data[1] = Vec4(1.0f, 2.0f, 3.0f, 1.0f);
573
expected_data[16] = Vec4(4.0f, 5.0f, 6.0f, 1.0f);
574
return BasicInputBase::Run();
575
}
576
};
577
//=============================================================================
578
// 1.2.2 BasicInputCase2
579
//-----------------------------------------------------------------------------
580
class BasicInputCase2 : public BasicInputBase
581
{
582
583
GLuint m_vao, m_vbo;
584
585
virtual long Setup()
586
{
587
BasicInputBase::Setup();
588
glGenVertexArrays(1, &m_vao);
589
glGenBuffers(1, &m_vbo);
590
return NO_ERROR;
591
}
592
593
virtual long Cleanup()
594
{
595
BasicInputBase::Cleanup();
596
glDeleteVertexArrays(1, &m_vao);
597
glDeleteBuffers(1, &m_vbo);
598
return NO_ERROR;
599
}
600
601
virtual long Run()
602
{
603
for (GLuint i = 0; i < 16; ++i)
604
{
605
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
606
}
607
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
608
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec3) * 2, NULL, GL_STATIC_DRAW);
609
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec3), &Vec3(1.0f, 2.0f, 3.0f)[0]);
610
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(Vec3), &Vec3(4.0f, 5.0f, 6.0f)[0]);
611
glBindBuffer(GL_ARRAY_BUFFER, 0);
612
613
glBindVertexArray(m_vao);
614
glVertexAttribBinding(1, 0);
615
glVertexAttribFormat(0, 2, GL_FLOAT, GL_FALSE, 0);
616
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 0);
617
glVertexAttribFormat(7, 1, GL_FLOAT, GL_FALSE, 8);
618
glVertexAttribFormat(14, 2, GL_FLOAT, GL_FALSE, 4);
619
glVertexAttribBinding(0, 0);
620
glVertexAttribBinding(7, 0);
621
glVertexAttribBinding(14, 0);
622
glBindVertexBuffer(0, m_vbo, 0, 12);
623
glEnableVertexAttribArray(0);
624
glEnableVertexAttribArray(1);
625
glEnableVertexAttribArray(7);
626
glEnableVertexAttribArray(14);
627
628
expected_data[0] = Vec4(1.0f, 2.0f, 0.0f, 1.0f);
629
expected_data[1] = Vec4(1.0f, 2.0f, 3.0f, 1.0f);
630
expected_data[7] = Vec4(3.0f, 0.0f, 0.0f, 1.0f);
631
expected_data[14] = Vec4(2.0f, 3.0f, 0.0f, 1.0f);
632
expected_data[15] = Vec4(4.0f, 5.0f, 0.0f, 1.0f);
633
expected_data[16] = Vec4(4.0f, 5.0f, 6.0f, 1.0f);
634
expected_data[22] = Vec4(6.0f, 0.0f, 0.0f, 1.0f);
635
expected_data[29] = Vec4(5.0f, 6.0f, 0.0f, 1.0f);
636
return BasicInputBase::Run();
637
}
638
};
639
//=============================================================================
640
// 1.2.3 BasicInputCase3
641
//-----------------------------------------------------------------------------
642
class BasicInputCase3 : public BasicInputBase
643
{
644
645
GLuint m_vao, m_vbo;
646
647
virtual long Setup()
648
{
649
BasicInputBase::Setup();
650
glGenVertexArrays(1, &m_vao);
651
glGenBuffers(1, &m_vbo);
652
return NO_ERROR;
653
}
654
655
virtual long Cleanup()
656
{
657
BasicInputBase::Cleanup();
658
glDeleteVertexArrays(1, &m_vao);
659
glDeleteBuffers(1, &m_vbo);
660
return NO_ERROR;
661
}
662
663
virtual long Run()
664
{
665
for (GLuint i = 0; i < 16; ++i)
666
{
667
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
668
}
669
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
670
glBufferData(GL_ARRAY_BUFFER, 36 * 2, NULL, GL_STATIC_DRAW);
671
/* */
672
{
673
GLubyte d[] = {1, 2, 3, 4};
674
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
675
}
676
glBufferSubData(GL_ARRAY_BUFFER, 16, sizeof(Vec3), &Vec3(5.0f, 6.0f, 7.0f)[0]);
677
glBufferSubData(GL_ARRAY_BUFFER, 28, sizeof(Vec2), &Vec2(8.0f, 9.0f)[0]);
678
/* */
679
{
680
GLubyte d[] = {10, 11, 12, 13};
681
glBufferSubData(GL_ARRAY_BUFFER, 0 + 36, sizeof(d), d);
682
}
683
glBufferSubData(GL_ARRAY_BUFFER, 16 + 36, sizeof(Vec3), &Vec3(14.0f, 15.0f, 16.0f)[0]);
684
glBufferSubData(GL_ARRAY_BUFFER, 28 + 36, sizeof(Vec2), &Vec2(17.0f, 18.0f)[0]);
685
glBindBuffer(GL_ARRAY_BUFFER, 0);
686
687
glBindVertexArray(m_vao);
688
glEnableVertexAttribArray(1);
689
glVertexAttribFormat(0, 4, GL_UNSIGNED_BYTE, GL_FALSE, 0);
690
glVertexAttribBinding(1, 3);
691
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 16);
692
glVertexAttribBinding(2, 3);
693
glVertexAttribFormat(2, 2, GL_FLOAT, GL_FALSE, 28);
694
glVertexAttribBinding(0, 3);
695
glBindVertexBuffer(3, m_vbo, 0, 36);
696
glEnableVertexAttribArray(0);
697
glEnableVertexAttribArray(2);
698
699
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
700
expected_data[1] = Vec4(5.0f, 6.0f, 7.0f, 1.0f);
701
expected_data[2] = Vec4(8.0f, 9.0f, 0.0f, 1.0f);
702
expected_data[0 + 15] = Vec4(10.0f, 11.0f, 12.0f, 13.0f);
703
expected_data[1 + 15] = Vec4(14.0f, 15.0f, 16.0f, 1.0f);
704
expected_data[2 + 15] = Vec4(17.0f, 18.0f, 0.0f, 1.0f);
705
return BasicInputBase::Run();
706
}
707
};
708
//=============================================================================
709
// 1.2.4 BasicInputCase4
710
//-----------------------------------------------------------------------------
711
class BasicInputCase4 : public BasicInputBase
712
{
713
714
GLuint m_vao, m_vbo[2];
715
716
virtual long Setup()
717
{
718
BasicInputBase::Setup();
719
glGenVertexArrays(1, &m_vao);
720
glGenBuffers(2, m_vbo);
721
return NO_ERROR;
722
}
723
724
virtual long Cleanup()
725
{
726
BasicInputBase::Cleanup();
727
glDeleteVertexArrays(1, &m_vao);
728
glDeleteBuffers(2, m_vbo);
729
return NO_ERROR;
730
}
731
732
virtual long Run()
733
{
734
for (GLuint i = 0; i < 16; ++i)
735
{
736
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
737
}
738
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
739
glBufferData(GL_ARRAY_BUFFER, 20 * 2, NULL, GL_STATIC_DRAW);
740
/* */
741
{
742
GLbyte d[] = {-127, 127, -127, 127};
743
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
744
}
745
/* */
746
{
747
GLushort d[] = {1, 2, 3, 4};
748
glBufferSubData(GL_ARRAY_BUFFER, 4, sizeof(d), d);
749
}
750
/* */
751
{
752
GLuint d[] = {5, 6};
753
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(d), d);
754
}
755
/* */
756
{
757
GLbyte d[] = {127, -127, 127, -127};
758
glBufferSubData(GL_ARRAY_BUFFER, 0 + 20, sizeof(d), d);
759
}
760
/* */
761
{
762
GLushort d[] = {7, 8, 9, 10};
763
glBufferSubData(GL_ARRAY_BUFFER, 4 + 20, sizeof(d), d);
764
}
765
/* */
766
{
767
GLuint d[] = {11, 12};
768
glBufferSubData(GL_ARRAY_BUFFER, 12 + 20, sizeof(d), d);
769
}
770
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
771
glBufferData(GL_ARRAY_BUFFER, 24 * 2 + 8, NULL, GL_STATIC_DRAW);
772
/* */
773
{
774
GLhalf d[] = {FloatToHalf(0.0), FloatToHalf(100.0), FloatToHalf(200.0)};
775
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
776
}
777
/* */
778
{
779
GLhalf d[] = {FloatToHalf(300.0), FloatToHalf(400.0)};
780
glBufferSubData(GL_ARRAY_BUFFER, 26, sizeof(d), d);
781
}
782
glBindBuffer(GL_ARRAY_BUFFER, 0);
783
784
glBindVertexArray(m_vao);
785
glVertexAttribFormat(0, 4, GL_BYTE, GL_TRUE, 0);
786
glVertexAttribFormat(1, 4, GL_UNSIGNED_SHORT, GL_FALSE, 4);
787
glVertexAttribFormat(2, 2, GL_UNSIGNED_INT, GL_FALSE, 12);
788
glVertexAttribFormat(5, 2, GL_HALF_FLOAT, GL_FALSE, 0);
789
glVertexAttribBinding(0, 0);
790
glVertexAttribBinding(1, 0);
791
glVertexAttribBinding(2, 0);
792
glVertexAttribBinding(5, 6);
793
glBindVertexBuffer(0, m_vbo[0], 0, 20);
794
glBindVertexBuffer(6, m_vbo[1], 2, 24);
795
glEnableVertexAttribArray(0);
796
glEnableVertexAttribArray(1);
797
glEnableVertexAttribArray(2);
798
glEnableVertexAttribArray(5);
799
800
expected_data[0] = Vec4(-1.0f, 1.0f, -1.0f, 1.0f);
801
expected_data[1] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
802
expected_data[2] = Vec4(5.0f, 6.0f, 0.0f, 1.0f);
803
expected_data[5] = Vec4(100.0f, 200.0f, 0.0f, 1.0f);
804
expected_data[0 + 15] = Vec4(1.0f, -1.0f, 1.0f, -1.0f);
805
expected_data[1 + 15] = Vec4(7.0f, 8.0f, 9.0f, 10.0f);
806
expected_data[2 + 15] = Vec4(11.0f, 12.0f, 0.0f, 1.0f);
807
expected_data[5 + 15] = Vec4(300.0f, 400.0f, 0.0f, 1.0f);
808
return BasicInputBase::Run();
809
}
810
};
811
//=============================================================================
812
// 1.2.5 BasicInputCase5
813
//-----------------------------------------------------------------------------
814
class BasicInputCase5 : public BasicInputBase
815
{
816
817
GLuint m_vao, m_vbo;
818
819
virtual long Setup()
820
{
821
BasicInputBase::Setup();
822
glGenVertexArrays(1, &m_vao);
823
glGenBuffers(1, &m_vbo);
824
return NO_ERROR;
825
}
826
827
virtual long Cleanup()
828
{
829
BasicInputBase::Cleanup();
830
glDeleteVertexArrays(1, &m_vao);
831
glDeleteBuffers(1, &m_vbo);
832
return NO_ERROR;
833
}
834
835
virtual long Run()
836
{
837
for (GLuint i = 0; i < 16; ++i)
838
{
839
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
840
}
841
const int kStride = 116;
842
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
843
glBufferData(GL_ARRAY_BUFFER, kStride * 2, NULL, GL_STATIC_DRAW);
844
/* */
845
{
846
GLubyte d[] = {0, 0xff, 0xff / 2, 0};
847
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
848
}
849
/* */
850
{
851
GLushort d[] = {0, 0xffff, 0xffff / 2, 0};
852
glBufferSubData(GL_ARRAY_BUFFER, 4, sizeof(d), d);
853
}
854
/* */
855
{
856
GLuint d[] = {0, 0xffffffff, 0xffffffff / 2, 0};
857
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(d), d);
858
}
859
/* */
860
{
861
GLbyte d[] = {0, -127, 127, 0};
862
glBufferSubData(GL_ARRAY_BUFFER, 28, sizeof(d), d);
863
}
864
/* */
865
{
866
GLshort d[] = {0, -32767, 32767, 0};
867
glBufferSubData(GL_ARRAY_BUFFER, 32, sizeof(d), d);
868
}
869
/* */
870
{
871
GLint d[] = {0, -2147483647, 2147483647, 0};
872
glBufferSubData(GL_ARRAY_BUFFER, 40, sizeof(d), d);
873
}
874
/* */
875
{
876
GLfloat d[] = {0, 1.0f, 2.0f, 0};
877
glBufferSubData(GL_ARRAY_BUFFER, 56, sizeof(d), d);
878
}
879
/* */
880
{
881
GLhalf d[] = {FloatToHalf(0.0), FloatToHalf(10.0), FloatToHalf(20.0), FloatToHalf(0.0)};
882
glBufferSubData(GL_ARRAY_BUFFER, 72, sizeof(d), d);
883
}
884
/* */
885
{
886
GLubyte d[] = {0, 0xff / 4, 0xff / 2, 0xff};
887
glBufferSubData(GL_ARRAY_BUFFER, 104, sizeof(d), d);
888
}
889
/* */
890
{
891
GLuint d = 0 | (1023 << 10) | (511 << 20) | (1 << 30);
892
glBufferSubData(GL_ARRAY_BUFFER, 108, sizeof(d), &d);
893
}
894
/* */
895
{
896
GLint d = 0 | (511 << 10) | (255 << 20) | (0 << 30);
897
glBufferSubData(GL_ARRAY_BUFFER, 112, sizeof(d), &d);
898
}
899
900
/* */
901
{
902
GLubyte d[] = {0xff, 0xff, 0xff / 2, 0};
903
glBufferSubData(GL_ARRAY_BUFFER, 0 + kStride, sizeof(d), d);
904
}
905
/* */
906
{
907
GLushort d[] = {0xffff, 0xffff, 0xffff / 2, 0};
908
glBufferSubData(GL_ARRAY_BUFFER, 4 + kStride, sizeof(d), d);
909
}
910
/* */
911
{
912
GLuint d[] = {0xffffffff, 0xffffffff, 0xffffffff / 2, 0};
913
glBufferSubData(GL_ARRAY_BUFFER, 12 + kStride, sizeof(d), d);
914
}
915
/* */
916
{
917
GLbyte d[] = {127, -127, 127, 0};
918
glBufferSubData(GL_ARRAY_BUFFER, 28 + kStride, sizeof(d), d);
919
}
920
/* */
921
{
922
GLshort d[] = {32767, -32767, 32767, 0};
923
glBufferSubData(GL_ARRAY_BUFFER, 32 + kStride, sizeof(d), d);
924
}
925
/* */
926
{
927
GLint d[] = {2147483647, -2147483647, 2147483647, 0};
928
glBufferSubData(GL_ARRAY_BUFFER, 40 + kStride, sizeof(d), d);
929
}
930
/* */
931
{
932
GLfloat d[] = {0, 3.0f, 4.0f, 0};
933
glBufferSubData(GL_ARRAY_BUFFER, 56 + kStride, sizeof(d), d);
934
}
935
/* */
936
{
937
GLhalf d[] = {FloatToHalf(0.0), FloatToHalf(30.0), FloatToHalf(40.0), FloatToHalf(0.0)};
938
glBufferSubData(GL_ARRAY_BUFFER, 72 + kStride, sizeof(d), d);
939
}
940
/* */
941
{
942
GLubyte d[] = {0xff, 0xff / 2, 0xff / 4, 0};
943
glBufferSubData(GL_ARRAY_BUFFER, 104 + kStride, sizeof(d), d);
944
}
945
/* */
946
{
947
GLuint d = 0 | (1023 << 10) | (511 << 20) | (2u << 30);
948
glBufferSubData(GL_ARRAY_BUFFER, 108 + kStride, sizeof(d), &d);
949
}
950
/* */
951
{
952
GLint d = (-511 & 0x3ff) | (511 << 10) | (255 << 20) | 3 << 30;
953
glBufferSubData(GL_ARRAY_BUFFER, 112 + kStride, sizeof(d), &d);
954
}
955
glBindBuffer(GL_ARRAY_BUFFER, 0);
956
957
glBindVertexArray(m_vao);
958
glVertexAttribFormat(0, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0);
959
glVertexAttribFormat(1, 4, GL_UNSIGNED_SHORT, GL_TRUE, 4);
960
glVertexAttribFormat(2, 4, GL_UNSIGNED_INT, GL_TRUE, 12);
961
glVertexAttribFormat(3, 4, GL_BYTE, GL_TRUE, 28);
962
glVertexAttribFormat(4, 4, GL_SHORT, GL_TRUE, 32);
963
glVertexAttribFormat(5, 4, GL_INT, GL_TRUE, 40);
964
glVertexAttribFormat(6, 4, GL_FLOAT, GL_TRUE, 56);
965
glVertexAttribFormat(7, 4, GL_HALF_FLOAT, GL_TRUE, 72);
966
glVertexAttribFormat(8, 4, GL_UNSIGNED_BYTE, GL_TRUE, 104);
967
glVertexAttribFormat(9, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 108);
968
glVertexAttribFormat(10, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 108);
969
glVertexAttribFormat(11, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 112);
970
glVertexAttribFormat(12, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 112);
971
for (GLuint i = 0; i < 13; ++i)
972
{
973
glVertexAttribBinding(i, 0);
974
glEnableVertexAttribArray(i);
975
}
976
glBindVertexBuffer(0, m_vbo, 0, kStride);
977
978
expected_data[0] = Vec4(0.0f, 1.0f, 0.5f, 0.0f);
979
expected_data[1] = Vec4(0.0f, 1.0f, 0.5f, 0.0f);
980
expected_data[2] = Vec4(0.0f, 1.0f, 0.5f, 0.0f);
981
expected_data[3] = Vec4(0.0f, -1.0f, 1.0f, 0.0f);
982
expected_data[4] = Vec4(0.0f, -1.0f, 1.0f, 0.0f);
983
expected_data[5] = Vec4(0.0f, -1.0f, 1.0f, 0.0f);
984
expected_data[6] = Vec4(0.0f, 1.0f, 2.0f, 0.0f);
985
expected_data[7] = Vec4(0.0f, 10.0f, 20.0f, 0.0f);
986
expected_data[8] = Vec4(0.0f, 0.25f, 0.5f, 1.0f);
987
expected_data[9] = Vec4(0.0f, 1.0f, 0.5f, 0.33f);
988
expected_data[10] = Vec4(0.0f, 1.0f, 0.5f, 0.33f);
989
expected_data[11] = Vec4(0.0f, 1.0f, 0.5f, 0.0f);
990
expected_data[12] = Vec4(0.0f, 1.0f, 0.5f, 0.0f);
991
expected_data[0 + 15] = Vec4(1.0f, 1.0f, 0.5f, 0.0f);
992
expected_data[1 + 15] = Vec4(1.0f, 1.0f, 0.5f, 0.0f);
993
expected_data[2 + 15] = Vec4(1.0f, 1.0f, 0.5f, 0.0f);
994
expected_data[3 + 15] = Vec4(1.0f, -1.0f, 1.0f, 0.0f);
995
expected_data[4 + 15] = Vec4(1.0f, -1.0f, 1.0f, 0.0f);
996
expected_data[5 + 15] = Vec4(1.0f, -1.0f, 1.0f, 0.0f);
997
expected_data[6 + 15] = Vec4(0.0f, 3.0f, 4.0f, 0.0f);
998
expected_data[7 + 15] = Vec4(0.0f, 30.0f, 40.0f, 0.0f);
999
expected_data[8 + 15] = Vec4(1.0f, 0.5f, 0.25f, 0.0f);
1000
expected_data[9 + 15] = Vec4(0.0f, 1.0f, 0.5f, 0.66f);
1001
expected_data[10 + 15] = Vec4(0.0f, 1.0f, 0.5f, 0.66f);
1002
expected_data[11 + 15] = Vec4(-1.0f, 1.0f, 0.5f, -1.0f);
1003
expected_data[12 + 15] = Vec4(-1.0f, 1.0f, 0.5f, -1.0f);
1004
return BasicInputBase::Run();
1005
}
1006
};
1007
//=============================================================================
1008
// 1.2.6 BasicInputCase6
1009
//-----------------------------------------------------------------------------
1010
class BasicInputCase6 : public BasicInputBase
1011
{
1012
1013
GLuint m_vao, m_vbo;
1014
1015
virtual long Setup()
1016
{
1017
BasicInputBase::Setup();
1018
glGenVertexArrays(1, &m_vao);
1019
glGenBuffers(1, &m_vbo);
1020
return NO_ERROR;
1021
}
1022
1023
virtual long Cleanup()
1024
{
1025
BasicInputBase::Cleanup();
1026
glDeleteVertexArrays(1, &m_vao);
1027
glDeleteBuffers(1, &m_vbo);
1028
return NO_ERROR;
1029
}
1030
1031
virtual long Run()
1032
{
1033
for (GLuint i = 0; i < 16; ++i)
1034
{
1035
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
1036
}
1037
const int kStride = 112;
1038
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1039
glBufferData(GL_ARRAY_BUFFER, kStride * 2, NULL, GL_STATIC_DRAW);
1040
/* */
1041
{
1042
GLubyte d[] = {1, 2, 3, 4};
1043
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
1044
}
1045
/* */
1046
{
1047
GLushort d[] = {5, 6, 7, 8};
1048
glBufferSubData(GL_ARRAY_BUFFER, 4, sizeof(d), d);
1049
}
1050
/* */
1051
{
1052
GLuint d[] = {9, 10, 11, 12};
1053
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(d), d);
1054
}
1055
/* */
1056
{
1057
GLbyte d[] = {-1, 2, -3, 4};
1058
glBufferSubData(GL_ARRAY_BUFFER, 28, sizeof(d), d);
1059
}
1060
/* */
1061
{
1062
GLshort d[] = {-5, 6, -7, 8};
1063
glBufferSubData(GL_ARRAY_BUFFER, 32, sizeof(d), d);
1064
}
1065
/* */
1066
{
1067
GLint d[] = {-9, 10, -11, 12};
1068
glBufferSubData(GL_ARRAY_BUFFER, 40, sizeof(d), d);
1069
}
1070
/* */
1071
{
1072
GLfloat d[] = {-13.0f, 14.0f, -15.0f, 16.0f};
1073
glBufferSubData(GL_ARRAY_BUFFER, 56, sizeof(d), d);
1074
}
1075
/* */
1076
{
1077
GLhalf d[] = {FloatToHalf(-18.0), FloatToHalf(19.0), FloatToHalf(-20.0),
1078
FloatToHalf(21.0)};
1079
glBufferSubData(GL_ARRAY_BUFFER, 72, sizeof(d), d);
1080
}
1081
/* */
1082
{
1083
GLuint d = 0 | (11 << 10) | (12 << 20) | (2u << 30);
1084
glBufferSubData(GL_ARRAY_BUFFER, 104, sizeof(d), &d);
1085
}
1086
/* */
1087
{
1088
GLint d = 0 | ((0xFFFFFFF5 << 10) & (0x3ff << 10)) | (12 << 20) | (1 << 30);
1089
glBufferSubData(GL_ARRAY_BUFFER, 108, sizeof(d), &d);
1090
}
1091
1092
/* */
1093
{
1094
GLubyte d[] = {22, 23, 24, 25};
1095
glBufferSubData(GL_ARRAY_BUFFER, 0 + kStride, sizeof(d), d);
1096
}
1097
/* */
1098
{
1099
GLushort d[] = {26, 27, 28, 29};
1100
glBufferSubData(GL_ARRAY_BUFFER, 4 + kStride, sizeof(d), d);
1101
}
1102
/* */
1103
{
1104
GLuint d[] = {30, 31, 32, 33};
1105
glBufferSubData(GL_ARRAY_BUFFER, 12 + kStride, sizeof(d), d);
1106
}
1107
/* */
1108
{
1109
GLbyte d[] = {-34, 35, -36, 37};
1110
glBufferSubData(GL_ARRAY_BUFFER, 28 + kStride, sizeof(d), d);
1111
}
1112
/* */
1113
{
1114
GLshort d[] = {-38, 39, -40, 41};
1115
glBufferSubData(GL_ARRAY_BUFFER, 32 + kStride, sizeof(d), d);
1116
}
1117
/* */
1118
{
1119
GLint d[] = {-42, 43, -44, 45};
1120
glBufferSubData(GL_ARRAY_BUFFER, 40 + kStride, sizeof(d), d);
1121
}
1122
/* */
1123
{
1124
GLfloat d[] = {-46.0f, 47.0f, -48.0f, 49.0f};
1125
glBufferSubData(GL_ARRAY_BUFFER, 56 + kStride, sizeof(d), d);
1126
}
1127
/* */
1128
{
1129
GLhalf d[] = {FloatToHalf(-50.0), FloatToHalf(51.0), FloatToHalf(-52.0),
1130
FloatToHalf(53.0)};
1131
glBufferSubData(GL_ARRAY_BUFFER, 72 + kStride, sizeof(d), d);
1132
}
1133
/* */
1134
{
1135
GLuint d = 0 | (11 << 10) | (12 << 20) | (1 << 30);
1136
glBufferSubData(GL_ARRAY_BUFFER, 104 + kStride, sizeof(d), &d);
1137
}
1138
/* */
1139
{
1140
GLint d = 123 | ((0xFFFFFFFD << 10) & (0x3ff << 10)) |
1141
((0xFFFFFE0C << 20) & (0x3ff << 20)) | ((0xFFFFFFFF << 30) & (0x3 << 30));
1142
glBufferSubData(GL_ARRAY_BUFFER, 108 + kStride, sizeof(d), &d);
1143
}
1144
glBindBuffer(GL_ARRAY_BUFFER, 0);
1145
1146
glBindVertexArray(m_vao);
1147
glVertexAttribFormat(0, 4, GL_UNSIGNED_BYTE, GL_FALSE, 0);
1148
glVertexAttribFormat(1, 4, GL_UNSIGNED_SHORT, GL_FALSE, 4);
1149
glVertexAttribFormat(2, 4, GL_UNSIGNED_INT, GL_FALSE, 12);
1150
glVertexAttribFormat(3, 4, GL_BYTE, GL_FALSE, 28);
1151
glVertexAttribFormat(4, 4, GL_SHORT, GL_FALSE, 32);
1152
glVertexAttribFormat(5, 4, GL_INT, GL_FALSE, 40);
1153
glVertexAttribFormat(6, 4, GL_FLOAT, GL_FALSE, 56);
1154
glVertexAttribFormat(7, 4, GL_HALF_FLOAT, GL_FALSE, 72);
1155
glVertexAttribFormat(8, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 104);
1156
glVertexAttribFormat(9, 4, GL_INT_2_10_10_10_REV, GL_FALSE, 108);
1157
for (GLuint i = 0; i < 10; ++i)
1158
{
1159
glVertexAttribBinding(i, 0);
1160
glEnableVertexAttribArray(i);
1161
}
1162
glBindVertexBuffer(0, m_vbo, 0, kStride);
1163
1164
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1165
expected_data[1] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1166
expected_data[2] = Vec4(9.0f, 10.0f, 11.0f, 12.0f);
1167
expected_data[3] = Vec4(-1.0f, 2.0f, -3.0f, 4.0f);
1168
expected_data[4] = Vec4(-5.0f, 6.0f, -7.0f, 8.0f);
1169
expected_data[5] = Vec4(-9.0f, 10.0f, -11.0f, 12.0f);
1170
expected_data[6] = Vec4(-13.0f, 14.0f, -15.0f, 16.0f);
1171
expected_data[7] = Vec4(-18.0f, 19.0f, -20.0f, 21.0f);
1172
expected_data[8] = Vec4(0.0f, 11.0f, 12.0f, 2.0f);
1173
expected_data[9] = Vec4(0.0f, -11.0f, 12.0f, 1.0f);
1174
expected_data[0 + 15] = Vec4(22.0f, 23.0f, 24.0f, 25.0f);
1175
expected_data[1 + 15] = Vec4(26.0f, 27.0f, 28.0f, 29.0f);
1176
expected_data[2 + 15] = Vec4(30.0f, 31.0f, 32.0f, 33.0f);
1177
expected_data[3 + 15] = Vec4(-34.0f, 35.0f, -36.0f, 37.0f);
1178
expected_data[4 + 15] = Vec4(-38.0f, 39.0f, -40.0f, 41.0f);
1179
expected_data[5 + 15] = Vec4(-42.0f, 43.0f, -44.0f, 45.0f);
1180
expected_data[6 + 15] = Vec4(-46.0f, 47.0f, -48.0f, 49.0f);
1181
expected_data[7 + 15] = Vec4(-50.0f, 51.0f, -52.0f, 53.0f);
1182
expected_data[8 + 15] = Vec4(0.0f, 11.0f, 12.0f, 1.0f);
1183
expected_data[9 + 15] = Vec4(123.0f, -3.0f, -500.0f, -1.0f);
1184
return BasicInputBase::Run();
1185
}
1186
};
1187
//=============================================================================
1188
// 1.2.8 BasicInputCase8
1189
//-----------------------------------------------------------------------------
1190
class BasicInputCase8 : public BasicInputBase
1191
{
1192
1193
GLuint m_vao, m_vbo[2];
1194
1195
virtual long Setup()
1196
{
1197
BasicInputBase::Setup();
1198
glGenVertexArrays(1, &m_vao);
1199
glGenBuffers(2, m_vbo);
1200
return NO_ERROR;
1201
}
1202
1203
virtual long Cleanup()
1204
{
1205
BasicInputBase::Cleanup();
1206
glDeleteVertexArrays(1, &m_vao);
1207
glDeleteBuffers(2, m_vbo);
1208
return NO_ERROR;
1209
}
1210
1211
virtual long Run()
1212
{
1213
for (GLuint i = 0; i < 16; ++i)
1214
{
1215
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
1216
}
1217
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
1218
glBufferData(GL_ARRAY_BUFFER, 6 * 4, NULL, GL_STATIC_DRAW);
1219
/* */
1220
{
1221
GLfloat d[] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
1222
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
1223
}
1224
1225
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
1226
glBufferData(GL_ARRAY_BUFFER, 10 * 4, NULL, GL_STATIC_DRAW);
1227
/* */
1228
{
1229
GLfloat d[] = {-1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f, -9.0f, -10.0f};
1230
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
1231
}
1232
glBindBuffer(GL_ARRAY_BUFFER, 0);
1233
1234
glBindVertexArray(m_vao);
1235
glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, 0);
1236
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 0);
1237
glVertexAttribFormat(2, 1, GL_FLOAT, GL_FALSE, 4);
1238
glVertexAttribFormat(5, 4, GL_FLOAT, GL_FALSE, 12);
1239
glVertexAttribFormat(14, 2, GL_FLOAT, GL_FALSE, 8);
1240
glVertexAttribBinding(0, 0);
1241
glVertexAttribBinding(1, 1);
1242
glVertexAttribBinding(2, 1);
1243
glVertexAttribBinding(5, 15);
1244
glVertexAttribBinding(14, 7);
1245
glBindVertexBuffer(0, m_vbo[0], 0, 12);
1246
glBindVertexBuffer(1, m_vbo[0], 4, 4);
1247
glBindVertexBuffer(7, m_vbo[1], 8, 16);
1248
glBindVertexBuffer(15, m_vbo[1], 12, 0);
1249
glEnableVertexAttribArray(0);
1250
glEnableVertexAttribArray(1);
1251
glEnableVertexAttribArray(2);
1252
glEnableVertexAttribArray(5);
1253
glEnableVertexAttribArray(14);
1254
1255
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 1.0f);
1256
expected_data[1] = Vec4(2.0f, 3.0f, 4.0f, 1.0f);
1257
expected_data[2] = Vec4(3.0f, 0.0f, 0.0f, 1.0f);
1258
expected_data[5] = Vec4(-7.0f, -8.0f, -9.0f, -10.0f);
1259
expected_data[14] = Vec4(-5.0f, -6.0f, 0.0f, 1.0f);
1260
expected_data[0 + 15] = Vec4(4.0f, 5.0f, 6.0f, 1.0f);
1261
expected_data[1 + 15] = Vec4(3.0f, 4.0f, 5.0f, 1.0f);
1262
expected_data[2 + 15] = Vec4(4.0f, 0.0f, 0.0f, 1.0f);
1263
expected_data[5 + 15] = Vec4(-7.0f, -8.0f, -9.0f, -10.0f);
1264
expected_data[14 + 15] = Vec4(-9.0f, -10.0f, 0.0f, 1.0f);
1265
return BasicInputBase::Run();
1266
}
1267
};
1268
//=============================================================================
1269
// 1.2.9 BasicInputCase9
1270
//-----------------------------------------------------------------------------
1271
class BasicInputCase9 : public BasicInputBase
1272
{
1273
1274
GLuint m_vao, m_vbo[2];
1275
1276
virtual long Setup()
1277
{
1278
BasicInputBase::Setup();
1279
glGenVertexArrays(1, &m_vao);
1280
glGenBuffers(2, m_vbo);
1281
return NO_ERROR;
1282
}
1283
1284
virtual long Cleanup()
1285
{
1286
BasicInputBase::Cleanup();
1287
glDeleteVertexArrays(1, &m_vao);
1288
glDeleteBuffers(2, m_vbo);
1289
return NO_ERROR;
1290
}
1291
1292
virtual long Run()
1293
{
1294
for (GLuint i = 0; i < 16; ++i)
1295
{
1296
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
1297
}
1298
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
1299
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec4) * 3, NULL, GL_STATIC_DRAW);
1300
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec4), &Vec4(1.0f, 2.0f, 3.0f, 4.0f)[0]);
1301
glBufferSubData(GL_ARRAY_BUFFER, 16, sizeof(Vec4), &Vec4(5.0f, 6.0f, 7.0f, 8.0f)[0]);
1302
glBufferSubData(GL_ARRAY_BUFFER, 32, sizeof(Vec4), &Vec4(9.0f, 10.0f, 11.0f, 12.0f)[0]);
1303
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
1304
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec4) * 3, NULL, GL_STATIC_DRAW);
1305
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec4), &Vec4(10.0f, 20.0f, 30.0f, 40.0f)[0]);
1306
glBufferSubData(GL_ARRAY_BUFFER, 16, sizeof(Vec4), &Vec4(50.0f, 60.0f, 70.0f, 80.0f)[0]);
1307
glBindBuffer(GL_ARRAY_BUFFER, 0);
1308
1309
glBindVertexArray(m_vao);
1310
glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, 0);
1311
glVertexAttribFormat(2, 4, GL_FLOAT, GL_FALSE, 0);
1312
glVertexAttribFormat(4, 2, GL_FLOAT, GL_FALSE, 4);
1313
glVertexAttribBinding(0, 0);
1314
glVertexAttribBinding(2, 1);
1315
glVertexAttribBinding(4, 3);
1316
glEnableVertexAttribArray(0);
1317
glEnableVertexAttribArray(2);
1318
glEnableVertexAttribArray(4);
1319
glBindVertexBuffer(0, m_vbo[0], 0, 16);
1320
glBindVertexBuffer(1, m_vbo[0], 0, 16);
1321
glBindVertexBuffer(3, m_vbo[1], 4, 8);
1322
glVertexBindingDivisor(1, 1);
1323
1324
instance_count = 2;
1325
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1326
expected_data[2] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1327
expected_data[4] = Vec4(30.0f, 40.0f, 0.0f, 1.0f);
1328
expected_data[0 + 15] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1329
expected_data[2 + 15] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1330
expected_data[4 + 15] = Vec4(50.0f, 60.0f, 0.0f, 1.0f);
1331
1332
expected_data[0 + 30] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1333
expected_data[2 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1334
expected_data[4 + 30] = Vec4(30.0f, 40.0f, 0.0f, 1.0f);
1335
expected_data[0 + 15 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1336
expected_data[2 + 15 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1337
expected_data[4 + 15 + 30] = Vec4(50.0f, 60.0f, 0.0f, 1.0f);
1338
return BasicInputBase::Run();
1339
}
1340
};
1341
//=============================================================================
1342
// 1.2.11 BasicInputCase11
1343
//-----------------------------------------------------------------------------
1344
class BasicInputCase11 : public BasicInputBase
1345
{
1346
1347
GLuint m_vao, m_vbo[2];
1348
1349
virtual long Setup()
1350
{
1351
BasicInputBase::Setup();
1352
glGenVertexArrays(1, &m_vao);
1353
glGenBuffers(2, m_vbo);
1354
return NO_ERROR;
1355
}
1356
1357
virtual long Cleanup()
1358
{
1359
BasicInputBase::Cleanup();
1360
glDeleteVertexArrays(1, &m_vao);
1361
glDeleteBuffers(2, m_vbo);
1362
return NO_ERROR;
1363
}
1364
1365
virtual long Run()
1366
{
1367
for (GLuint i = 0; i < 16; ++i)
1368
{
1369
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
1370
}
1371
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
1372
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec4) * 3, NULL, GL_STATIC_DRAW);
1373
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec4), &Vec4(1.0f, 2.0f, 3.0f, 4.0f)[0]);
1374
glBufferSubData(GL_ARRAY_BUFFER, 16, sizeof(Vec4), &Vec4(5.0f, 6.0f, 7.0f, 8.0f)[0]);
1375
glBufferSubData(GL_ARRAY_BUFFER, 32, sizeof(Vec4), &Vec4(9.0f, 10.0f, 11.0f, 12.0f)[0]);
1376
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
1377
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec4) * 3, NULL, GL_STATIC_DRAW);
1378
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec4), &Vec4(10.0f, 20.0f, 30.0f, 40.0f)[0]);
1379
glBufferSubData(GL_ARRAY_BUFFER, 16, sizeof(Vec4), &Vec4(50.0f, 60.0f, 70.0f, 80.0f)[0]);
1380
glBindBuffer(GL_ARRAY_BUFFER, 0);
1381
1382
glBindVertexArray(m_vao);
1383
glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, 0);
1384
glVertexAttribFormat(2, 4, GL_FLOAT, GL_FALSE, 0);
1385
glVertexAttribFormat(4, 2, GL_FLOAT, GL_FALSE, 4);
1386
glVertexAttribBinding(0, 0);
1387
glVertexAttribBinding(2, 1);
1388
glVertexAttribBinding(4, 2);
1389
glEnableVertexAttribArray(0);
1390
glEnableVertexAttribArray(2);
1391
glEnableVertexAttribArray(4);
1392
glBindVertexBuffer(0, m_vbo[0], 0, 16);
1393
glBindVertexBuffer(1, m_vbo[0], 0, 16);
1394
glBindVertexBuffer(2, m_vbo[1], 4, 8);
1395
glVertexBindingDivisor(1, 1);
1396
1397
instance_count = 2;
1398
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1399
expected_data[2] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1400
expected_data[4] = Vec4(30.0f, 40.0f, 0.0f, 1.0f);
1401
expected_data[0 + 15] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1402
expected_data[2 + 15] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1403
expected_data[4 + 15] = Vec4(50.0f, 60.0f, 0.0f, 1.0f);
1404
1405
expected_data[0 + 30] = Vec4(1.0f, 2.0f, 3.0f, 4.0f);
1406
expected_data[2 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1407
expected_data[4 + 30] = Vec4(30.0f, 40.0f, 0.0f, 1.0f);
1408
expected_data[0 + 15 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1409
expected_data[2 + 15 + 30] = Vec4(5.0f, 6.0f, 7.0f, 8.0f);
1410
expected_data[4 + 15 + 30] = Vec4(50.0f, 60.0f, 0.0f, 1.0f);
1411
return BasicInputBase::Run();
1412
}
1413
};
1414
//=============================================================================
1415
// 1.2.12 BasicInputCase12
1416
//-----------------------------------------------------------------------------
1417
class BasicInputCase12 : public BasicInputBase
1418
{
1419
1420
GLuint m_vao, m_vbo;
1421
1422
virtual long Setup()
1423
{
1424
BasicInputBase::Setup();
1425
glGenVertexArrays(1, &m_vao);
1426
glGenBuffers(1, &m_vbo);
1427
return NO_ERROR;
1428
}
1429
1430
virtual long Cleanup()
1431
{
1432
BasicInputBase::Cleanup();
1433
glDeleteVertexArrays(1, &m_vao);
1434
glDeleteBuffers(1, &m_vbo);
1435
return NO_ERROR;
1436
}
1437
1438
virtual long Run()
1439
{
1440
for (GLuint i = 0; i < 16; ++i)
1441
{
1442
glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f);
1443
}
1444
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1445
glBufferData(GL_ARRAY_BUFFER, sizeof(Vec3) * 2, NULL, GL_STATIC_DRAW);
1446
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vec3), &Vec3(1.0f, 2.0f, 3.0f)[0]);
1447
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(Vec3), &Vec3(4.0f, 5.0f, 6.0f)[0]);
1448
glBindBuffer(GL_ARRAY_BUFFER, 0);
1449
1450
glBindVertexArray(m_vao);
1451
1452
// glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 0);
1453
// glVertexAttribBinding(1, 1);
1454
// glBindVertexBuffer(1, m_vbo, 0, 12);
1455
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1456
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 12, 0);
1457
glBindBuffer(GL_ARRAY_BUFFER, 0);
1458
1459
glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, 0);
1460
glVertexAttribBinding(0, 1);
1461
1462
glEnableVertexAttribArray(0);
1463
glEnableVertexAttribArray(1);
1464
1465
expected_data[0] = Vec4(1.0f, 2.0f, 3.0f, 1.0f);
1466
expected_data[1] = Vec4(1.0f, 2.0f, 3.0f, 1.0f);
1467
expected_data[0 + 15] = Vec4(4.0f, 5.0f, 6.0f, 1.0f);
1468
expected_data[1 + 15] = Vec4(4.0f, 5.0f, 6.0f, 1.0f);
1469
return BasicInputBase::Run();
1470
}
1471
};
1472
//=============================================================================
1473
// BasicInputIBase
1474
//-----------------------------------------------------------------------------
1475
class BasicInputIBase : public VertexAttribBindingBase
1476
{
1477
1478
GLuint m_po, m_xfbo;
1479
1480
protected:
1481
IVec4 expected_datai[32];
1482
UVec4 expected_dataui[32];
1483
GLsizei instance_count;
1484
GLuint base_instance;
1485
1486
virtual long Setup()
1487
{
1488
m_po = 0;
1489
glGenBuffers(1, &m_xfbo);
1490
for (int i = 0; i < 32; ++i)
1491
{
1492
expected_datai[i] = IVec4(0);
1493
expected_dataui[i] = UVec4(0);
1494
}
1495
instance_count = 1;
1496
return NO_ERROR;
1497
}
1498
1499
virtual long Cleanup()
1500
{
1501
glDisable(GL_RASTERIZER_DISCARD);
1502
glUseProgram(0);
1503
glDeleteProgram(m_po);
1504
glDeleteBuffers(1, &m_xfbo);
1505
return NO_ERROR;
1506
}
1507
1508
virtual long Run()
1509
{
1510
const char *const glsl_vs =
1511
"#version 310 es" NL "layout(location = 0) in ivec4 vs_in_attribi0;" NL
1512
"layout(location = 1) in ivec4 vs_in_attribi1;" NL
1513
"layout(location = 2) in ivec4 vs_in_attribi2;" NL
1514
"layout(location = 3) in ivec4 vs_in_attribi3;" NL
1515
"layout(location = 4) in ivec4 vs_in_attribi4;" NL
1516
"layout(location = 5) in ivec4 vs_in_attribi5;" NL
1517
"layout(location = 6) in ivec4 vs_in_attribi6;" NL
1518
"layout(location = 7) in ivec4 vs_in_attribi7;" NL
1519
"layout(location = 8) in uvec4 vs_in_attribui8;" NL
1520
"layout(location = 9) in uvec4 vs_in_attribui9;" NL
1521
"layout(location = 10) in uvec4 vs_in_attribui10;" NL
1522
"layout(location = 11) in uvec4 vs_in_attribui11;" NL
1523
"layout(location = 12) in uvec4 vs_in_attribui12;" NL
1524
"layout(location = 13) in uvec4 vs_in_attribui13;" NL
1525
"layout(location = 14) in uvec4 vs_in_attribui14;" NL
1526
"layout(location = 15) in uvec4 vs_in_attribui15;" NL "flat out ivec4 attribi[8];" NL
1527
"flat out uvec4 attribui[7];" NL "void main() {" NL " attribi[0] = vs_in_attribi0;" NL
1528
" attribi[1] = vs_in_attribi1;" NL " attribi[2] = vs_in_attribi2;" NL
1529
" attribi[3] = vs_in_attribi3;" NL " attribi[4] = vs_in_attribi4;" NL
1530
" attribi[5] = vs_in_attribi5;" NL " attribi[6] = vs_in_attribi6;" NL
1531
" attribi[7] = vs_in_attribi7;" NL " attribui[0] = vs_in_attribui8;" NL
1532
" attribui[1] = vs_in_attribui9;" NL " attribui[2] = vs_in_attribui10;" NL
1533
" attribui[3] = vs_in_attribui11;" NL " attribui[4] = vs_in_attribui12;" NL
1534
" attribui[5] = vs_in_attribui13;" NL " attribui[6] = vs_in_attribui14;" NL "}";
1535
const char *const glsl_fs =
1536
"#version 310 es" NL "precision mediump float;" NL "flat in ivec4 attribi[8];" NL
1537
"flat in uvec4 attribui[7];" NL "out vec4 fs_out_color;" NL "void main() {" NL
1538
" fs_out_color = vec4(attribui[1]);" NL "}";
1539
m_po = glCreateProgram();
1540
/* attach shader */
1541
{
1542
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
1543
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
1544
glShaderSource(sh, 1, &glsl_vs, NULL);
1545
glShaderSource(fsh, 1, &glsl_fs, NULL);
1546
glCompileShader(sh);
1547
glCompileShader(fsh);
1548
glAttachShader(m_po, sh);
1549
glAttachShader(m_po, fsh);
1550
glDeleteShader(sh);
1551
glDeleteShader(fsh);
1552
}
1553
/* setup XFB */
1554
{
1555
const GLchar *const v[2] = {"attribi", "attribui"};
1556
glTransformFeedbackVaryings(m_po, 2, v, GL_INTERLEAVED_ATTRIBS);
1557
}
1558
glLinkProgram(m_po);
1559
if (!CheckProgram(m_po))
1560
return ERROR;
1561
1562
/* buffer data */
1563
{
1564
std::vector<GLubyte> zero(64 * 16);
1565
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_xfbo);
1566
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, (GLsizeiptr)zero.size(), &zero[0],
1567
GL_DYNAMIC_COPY);
1568
}
1569
1570
glEnable(GL_RASTERIZER_DISCARD);
1571
glUseProgram(m_po);
1572
glBeginTransformFeedback(GL_POINTS);
1573
glDrawArraysInstanced(GL_POINTS, 0, 2, instance_count);
1574
glEndTransformFeedback();
1575
1576
void *data =
1577
glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(UVec4) * 64, GL_MAP_READ_BIT);
1578
IVec4 *datai = static_cast<IVec4 *>(data);
1579
UVec4 *dataui = (static_cast<UVec4 *>(data)) + 8;
1580
1581
for (int i = 0; i < 4; ++i)
1582
for (int j = 0; j < 8; ++j)
1583
{
1584
if (!IsEqual(expected_datai[i * 8 + j], datai[i * 15 + j]))
1585
{
1586
m_context.getTestContext().getLog()
1587
<< tcu::TestLog::Message << "Datai is: " << datai[i * 15 + j][0] << " "
1588
<< datai[i * 15 + j][1] << " " << datai[i * 15 + j][2] << " "
1589
<< datai[i * 15 + j][3]
1590
<< ", data should be: " << expected_datai[i * 8 + j][0] << " "
1591
<< expected_datai[i * 8 + j][1] << " " << expected_datai[i * 8 + j][2]
1592
<< " " << expected_datai[i * 8 + j][3] << ", index is: " << i * 8 + j
1593
<< tcu::TestLog::EndMessage;
1594
return ERROR;
1595
}
1596
if (j != 7 && !IsEqual(expected_dataui[i * 8 + j], dataui[i * 15 + j]))
1597
{
1598
m_context.getTestContext().getLog()
1599
<< tcu::TestLog::Message << "Dataui is: " << dataui[i * 15 + j][0] << " "
1600
<< dataui[i * 15 + j][1] << " " << dataui[i * 15 + j][2] << " "
1601
<< dataui[i * 15 + j][3]
1602
<< ", data should be: " << expected_datai[i * 8 + j][0] << " "
1603
<< expected_datai[i * 8 + j][1] << " " << expected_datai[i * 8 + j][2]
1604
<< " " << expected_datai[i * 8 + j][3] << ", index is: " << i * 8 + j
1605
<< tcu::TestLog::EndMessage;
1606
return ERROR;
1607
}
1608
}
1609
return NO_ERROR;
1610
}
1611
};
1612
//=============================================================================
1613
// 1.3.1 BasicInputICase1
1614
//-----------------------------------------------------------------------------
1615
class BasicInputICase1 : public BasicInputIBase
1616
{
1617
1618
GLuint m_vao, m_vbo;
1619
1620
virtual long Setup()
1621
{
1622
BasicInputIBase::Setup();
1623
glGenVertexArrays(1, &m_vao);
1624
glGenBuffers(1, &m_vbo);
1625
return NO_ERROR;
1626
}
1627
1628
virtual long Cleanup()
1629
{
1630
BasicInputIBase::Cleanup();
1631
glDeleteVertexArrays(1, &m_vao);
1632
glDeleteBuffers(1, &m_vbo);
1633
return NO_ERROR;
1634
}
1635
1636
virtual long Run()
1637
{
1638
for (GLuint i = 0; i < 8; ++i)
1639
{
1640
glVertexAttribI4i(i, 0, 0, 0, 0);
1641
glVertexAttribI4ui(i + 8, 0, 0, 0, 0);
1642
}
1643
const int kStride = 88;
1644
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1645
glBufferData(GL_ARRAY_BUFFER, kStride * 2, NULL, GL_STATIC_DRAW);
1646
/* */
1647
{
1648
GLbyte d[] = {1, -2, 3, -4};
1649
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(d), d);
1650
}
1651
/* */
1652
{
1653
GLshort d[] = {5, -6, 7, -8};
1654
glBufferSubData(GL_ARRAY_BUFFER, 4, sizeof(d), d);
1655
}
1656
/* */
1657
{
1658
GLint d[] = {9, -10, 11, -12};
1659
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(d), d);
1660
}
1661
/* */
1662
{
1663
GLubyte d[] = {13, 14, 15, 16};
1664
glBufferSubData(GL_ARRAY_BUFFER, 28, sizeof(d), d);
1665
}
1666
/* */
1667
{
1668
GLushort d[] = {17, 18, 19, 20};
1669
glBufferSubData(GL_ARRAY_BUFFER, 32, sizeof(d), d);
1670
}
1671
/* */
1672
{
1673
GLuint d[] = {21, 22, 23, 24};
1674
glBufferSubData(GL_ARRAY_BUFFER, 40, sizeof(d), d);
1675
}
1676
/* */
1677
{
1678
GLint d[] = {90, -91, 92, -93};
1679
glBufferSubData(GL_ARRAY_BUFFER, 56, sizeof(d), d);
1680
}
1681
/* */
1682
{
1683
GLuint d[] = {94, 95, 96, 97};
1684
glBufferSubData(GL_ARRAY_BUFFER, 72, sizeof(d), d);
1685
}
1686
1687
/* */
1688
{
1689
GLbyte d[] = {25, -26, 27, -28};
1690
glBufferSubData(GL_ARRAY_BUFFER, 0 + kStride, sizeof(d), d);
1691
}
1692
/* */
1693
{
1694
GLshort d[] = {29, -30, 31, -32};
1695
glBufferSubData(GL_ARRAY_BUFFER, 4 + kStride, sizeof(d), d);
1696
}
1697
/* */
1698
{
1699
GLint d[] = {33, -34, 35, -36};
1700
glBufferSubData(GL_ARRAY_BUFFER, 12 + kStride, sizeof(d), d);
1701
}
1702
/* */
1703
{
1704
GLubyte d[] = {37, 38, 39, 40};
1705
glBufferSubData(GL_ARRAY_BUFFER, 28 + kStride, sizeof(d), d);
1706
}
1707
/* */
1708
{
1709
GLushort d[] = {41, 42, 43, 44};
1710
glBufferSubData(GL_ARRAY_BUFFER, 32 + kStride, sizeof(d), d);
1711
}
1712
/* */
1713
{
1714
GLuint d[] = {45, 46, 47, 48};
1715
glBufferSubData(GL_ARRAY_BUFFER, 40 + kStride, sizeof(d), d);
1716
}
1717
/* */
1718
{
1719
GLint d[] = {98, -99, 100, -101};
1720
glBufferSubData(GL_ARRAY_BUFFER, 56 + kStride, sizeof(d), d);
1721
}
1722
/* */
1723
{
1724
GLuint d[] = {102, 103, 104, 105};
1725
glBufferSubData(GL_ARRAY_BUFFER, 72 + kStride, sizeof(d), d);
1726
}
1727
glBindBuffer(GL_ARRAY_BUFFER, 0);
1728
1729
glBindVertexArray(m_vao);
1730
glVertexAttribIFormat(0, 1, GL_BYTE, 0);
1731
glVertexAttribIFormat(1, 2, GL_SHORT, 4);
1732
glVertexAttribIFormat(2, 3, GL_INT, 12);
1733
glVertexAttribIFormat(3, 4, GL_INT, 56);
1734
glVertexAttribIFormat(8, 3, GL_UNSIGNED_BYTE, 28);
1735
glVertexAttribIFormat(9, 2, GL_UNSIGNED_SHORT, 32);
1736
glVertexAttribIFormat(10, 1, GL_UNSIGNED_INT, 40);
1737
glVertexAttribIFormat(11, 4, GL_UNSIGNED_INT, 72);
1738
glVertexAttribBinding(0, 0);
1739
glVertexAttribBinding(1, 0);
1740
glVertexAttribBinding(2, 0);
1741
glVertexAttribBinding(3, 0);
1742
glVertexAttribBinding(8, 0);
1743
glVertexAttribBinding(9, 0);
1744
glVertexAttribBinding(10, 0);
1745
glVertexAttribBinding(11, 0);
1746
glBindVertexBuffer(0, m_vbo, 0, kStride);
1747
glEnableVertexAttribArray(0);
1748
glEnableVertexAttribArray(1);
1749
glEnableVertexAttribArray(2);
1750
glEnableVertexAttribArray(3);
1751
glEnableVertexAttribArray(8);
1752
glEnableVertexAttribArray(9);
1753
glEnableVertexAttribArray(10);
1754
glEnableVertexAttribArray(11);
1755
1756
expected_datai[0] = IVec4(1, 0, 0, 1);
1757
expected_datai[1] = IVec4(5, -6, 0, 1);
1758
expected_datai[2] = IVec4(9, -10, 11, 1);
1759
expected_datai[3] = IVec4(90, -91, 92, -93);
1760
expected_dataui[0] = UVec4(13, 14, 15, 1);
1761
expected_dataui[1] = UVec4(17, 18, 0, 1);
1762
expected_dataui[2] = UVec4(21, 0, 0, 1);
1763
expected_dataui[3] = UVec4(94, 95, 96, 97);
1764
expected_datai[8] = IVec4(25, 0, 0, 1);
1765
expected_datai[9] = IVec4(29, -30, 0, 1);
1766
expected_datai[10] = IVec4(33, -34, 35, 1);
1767
expected_datai[11] = IVec4(98, -99, 100, -101);
1768
expected_dataui[8] = UVec4(37, 38, 39, 1);
1769
expected_dataui[9] = UVec4(41, 42, 0, 1);
1770
expected_dataui[10] = UVec4(45, 0, 0, 1);
1771
expected_dataui[11] = UVec4(102, 103, 104, 105);
1772
return BasicInputIBase::Run();
1773
}
1774
};
1775
//=============================================================================
1776
// 1.3.2 BasicInputICase2
1777
//-----------------------------------------------------------------------------
1778
class BasicInputICase2 : public BasicInputIBase
1779
{
1780
1781
GLuint m_vao, m_vbo[2];
1782
1783
virtual long Setup()
1784
{
1785
BasicInputIBase::Setup();
1786
glGenVertexArrays(1, &m_vao);
1787
glGenBuffers(2, m_vbo);
1788
return NO_ERROR;
1789
}
1790
1791
virtual long Cleanup()
1792
{
1793
BasicInputIBase::Cleanup();
1794
glDeleteVertexArrays(1, &m_vao);
1795
glDeleteBuffers(2, m_vbo);
1796
return NO_ERROR;
1797
}
1798
1799
virtual long Run()
1800
{
1801
for (GLuint i = 0; i < 8; ++i)
1802
{
1803
glVertexAttribI4i(i, 0, 0, 0, 0);
1804
glVertexAttribI4ui(i + 8, 0, 0, 0, 0);
1805
}
1806
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
1807
glBufferData(GL_ARRAY_BUFFER, sizeof(IVec3) * 2, NULL, GL_STATIC_DRAW);
1808
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(IVec3), &IVec3(1, 2, 3)[0]);
1809
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(IVec3), &IVec3(4, 5, 6)[0]);
1810
1811
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
1812
glBufferData(GL_ARRAY_BUFFER, sizeof(UVec4), NULL, GL_STATIC_DRAW);
1813
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(UVec4), &UVec4(10, 20, 30, 40)[0]);
1814
glBindBuffer(GL_ARRAY_BUFFER, 0);
1815
1816
glBindVertexArray(m_vao);
1817
glVertexAttribIFormat(0, 3, GL_INT, 0);
1818
glVertexAttribIFormat(2, 2, GL_INT, 4);
1819
glVertexAttribIFormat(14, 1, GL_UNSIGNED_INT, 0);
1820
glVertexAttribBinding(0, 2);
1821
glVertexAttribBinding(2, 0);
1822
glVertexAttribBinding(14, 7);
1823
glEnableVertexAttribArray(0);
1824
glEnableVertexAttribArray(2);
1825
glEnableVertexAttribArray(14);
1826
glBindVertexBuffer(0, m_vbo[0], 0, 8);
1827
glBindVertexBuffer(2, m_vbo[0], 0, 12);
1828
glBindVertexBuffer(7, m_vbo[1], 4, 16);
1829
glVertexBindingDivisor(0, 1);
1830
glVertexBindingDivisor(2, 0);
1831
glVertexBindingDivisor(7, 2);
1832
1833
instance_count = 2;
1834
expected_datai[0] = IVec4(1, 2, 3, 1);
1835
expected_datai[2] = IVec4(2, 3, 0, 1);
1836
expected_dataui[6] = UVec4(20, 0, 0, 1);
1837
expected_datai[8] = IVec4(4, 5, 6, 1);
1838
expected_datai[10] = IVec4(2, 3, 0, 1);
1839
expected_dataui[14] = UVec4(20, 0, 0, 1);
1840
1841
expected_datai[16] = IVec4(1, 2, 3, 1);
1842
expected_datai[18] = IVec4(4, 5, 0, 1);
1843
expected_dataui[22] = UVec4(20, 0, 0, 1);
1844
expected_datai[24] = IVec4(4, 5, 6, 1);
1845
expected_datai[26] = IVec4(4, 5, 0, 1);
1846
expected_dataui[30] = UVec4(20, 0, 0, 1);
1847
return BasicInputIBase::Run();
1848
}
1849
};
1850
//=============================================================================
1851
// 1.3.3 BasicInputICase3
1852
//-----------------------------------------------------------------------------
1853
class BasicInputICase3 : public BasicInputIBase
1854
{
1855
1856
GLuint m_vao, m_vbo;
1857
1858
virtual long Setup()
1859
{
1860
BasicInputIBase::Setup();
1861
glGenVertexArrays(1, &m_vao);
1862
glGenBuffers(1, &m_vbo);
1863
return NO_ERROR;
1864
}
1865
1866
virtual long Cleanup()
1867
{
1868
BasicInputIBase::Cleanup();
1869
glDeleteVertexArrays(1, &m_vao);
1870
glDeleteBuffers(1, &m_vbo);
1871
return NO_ERROR;
1872
}
1873
1874
virtual long Run()
1875
{
1876
for (GLuint i = 0; i < 8; ++i)
1877
{
1878
glVertexAttribI4i(i, 0, 0, 0, 0);
1879
glVertexAttribI4ui(i + 8, 0, 0, 0, 0);
1880
}
1881
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1882
glBufferData(GL_ARRAY_BUFFER, sizeof(IVec3) * 2, NULL, GL_STATIC_DRAW);
1883
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(IVec3), &IVec3(1, 2, 3)[0]);
1884
glBufferSubData(GL_ARRAY_BUFFER, 12, sizeof(IVec3), &IVec3(4, 5, 6)[0]);
1885
glBindBuffer(GL_ARRAY_BUFFER, 0);
1886
1887
glBindVertexArray(m_vao);
1888
1889
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
1890
glVertexAttribIPointer(7, 3, GL_INT, 12, 0);
1891
glBindBuffer(GL_ARRAY_BUFFER, 0);
1892
1893
glVertexAttribIFormat(0, 2, GL_INT, 4);
1894
glVertexAttribBinding(0, 7);
1895
1896
glEnableVertexAttribArray(0);
1897
glEnableVertexAttribArray(7);
1898
1899
expected_datai[0] = IVec4(2, 3, 0, 1);
1900
expected_datai[7] = IVec4(1, 2, 3, 1);
1901
expected_datai[0 + 8] = IVec4(5, 6, 0, 1);
1902
expected_datai[7 + 8] = IVec4(4, 5, 6, 1);
1903
return BasicInputIBase::Run();
1904
}
1905
};
1906
1907
class VertexAttribState : public glcts::GLWrapper
1908
{
1909
public:
1910
int array_enabled;
1911
int array_size;
1912
int array_stride;
1913
int array_type;
1914
int array_normalized;
1915
int array_integer;
1916
int array_divisor;
1917
deUintptr array_pointer;
1918
int array_buffer_binding;
1919
int binding;
1920
int relative_offset;
1921
int index;
1922
1923
VertexAttribState(int attribindex)
1924
: array_enabled(0),
1925
array_size(4),
1926
array_stride(0),
1927
array_type(GL_FLOAT),
1928
array_normalized(0),
1929
array_integer(0),
1930
array_divisor(0),
1931
array_pointer(0),
1932
array_buffer_binding(0),
1933
binding(attribindex),
1934
relative_offset(0),
1935
index(attribindex)
1936
{}
1937
1938
bool stateVerify()
1939
{
1940
GLint p;
1941
bool status = true;
1942
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &p);
1943
if (p != array_enabled)
1944
{
1945
m_context.getTestContext().getLog()
1946
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_ENABLED(" << index << ") is "
1947
<< p << " should be " << array_enabled << tcu::TestLog::EndMessage;
1948
status = false;
1949
}
1950
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_SIZE, &p);
1951
if (p != array_size)
1952
{
1953
m_context.getTestContext().getLog()
1954
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_SIZE(" << index << ") is " << p
1955
<< " should be " << array_size << tcu::TestLog::EndMessage;
1956
status = false;
1957
}
1958
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &p);
1959
if (p != array_stride)
1960
{
1961
m_context.getTestContext().getLog()
1962
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_STRIDE(" << index << ") is "
1963
<< p << " should be " << array_stride << tcu::TestLog::EndMessage;
1964
status = false;
1965
}
1966
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_TYPE, &p);
1967
if (p != array_type)
1968
{
1969
m_context.getTestContext().getLog()
1970
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_TYPE(" << index << ") is "
1971
<< tcu::toHex(p) << " should be " << tcu::toHex(array_type)
1972
<< tcu::TestLog::EndMessage;
1973
status = false;
1974
}
1975
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &p);
1976
if (p != array_normalized)
1977
{
1978
m_context.getTestContext().getLog()
1979
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED(" << index << ") is "
1980
<< p << " should be " << array_normalized << tcu::TestLog::EndMessage;
1981
status = false;
1982
}
1983
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_INTEGER, &p);
1984
if (p != array_integer)
1985
{
1986
m_context.getTestContext().getLog()
1987
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_INTEGER(" << index << ") is "
1988
<< p << " should be " << array_integer << tcu::TestLog::EndMessage;
1989
status = false;
1990
}
1991
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &p);
1992
if (p != array_divisor)
1993
{
1994
m_context.getTestContext().getLog()
1995
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_DIVISOR(" << index << ") is "
1996
<< p << " should be " << array_divisor << tcu::TestLog::EndMessage;
1997
status = false;
1998
}
1999
void *pp;
2000
glGetVertexAttribPointerv(index, GL_VERTEX_ATTRIB_ARRAY_POINTER, &pp);
2001
if (reinterpret_cast<deUintptr>(pp) != array_pointer)
2002
{
2003
m_context.getTestContext().getLog()
2004
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_POINTER(" << index << ") is "
2005
<< pp << " should be " << reinterpret_cast<void *>(array_pointer)
2006
<< tcu::TestLog::EndMessage;
2007
status = false;
2008
}
2009
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &p);
2010
if (p != array_buffer_binding)
2011
{
2012
m_context.getTestContext().getLog()
2013
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING(" << index
2014
<< ") is " << p << " should be " << array_buffer_binding
2015
<< tcu::TestLog::EndMessage;
2016
status = false;
2017
}
2018
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_BINDING, &p);
2019
if (static_cast<GLint>(binding) != p)
2020
{
2021
m_context.getTestContext().getLog()
2022
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_BINDING(" << index << ") is " << p
2023
<< " should be " << binding << tcu::TestLog::EndMessage;
2024
status = false;
2025
}
2026
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_RELATIVE_OFFSET, &p);
2027
if (p != relative_offset)
2028
{
2029
m_context.getTestContext().getLog()
2030
<< tcu::TestLog::Message << "GL_VERTEX_ATTRIB_RELATIVE_OFFSET(" << index << ") is "
2031
<< p << " should be " << relative_offset << tcu::TestLog::EndMessage;
2032
status = false;
2033
}
2034
return status;
2035
}
2036
};
2037
class VertexBindingState : public glcts::GLWrapper
2038
{
2039
public:
2040
int buffer;
2041
long int offset;
2042
int stride;
2043
int divisor;
2044
int index;
2045
2046
VertexBindingState(int bindingindex)
2047
: buffer(0), offset(0), stride(16), divisor(0), index(bindingindex)
2048
{}
2049
bool stateVerify()
2050
{
2051
bool status = true;
2052
GLint p;
2053
glGetIntegeri_v(GL_VERTEX_BINDING_BUFFER, index, &p);
2054
if (p != buffer)
2055
{
2056
m_context.getTestContext().getLog()
2057
<< tcu::TestLog::Message << "GL_VERTEX_BINDING_BUFFER(" << index << ") is " << p
2058
<< " should be " << buffer << tcu::TestLog::EndMessage;
2059
status = false;
2060
}
2061
GLint64 p64;
2062
glGetInteger64i_v(GL_VERTEX_BINDING_OFFSET, index, &p64);
2063
if (p64 != offset)
2064
{
2065
m_context.getTestContext().getLog()
2066
<< tcu::TestLog::Message << "GL_VERTEX_BINDING_OFFSET(" << index << ") is " << p64
2067
<< " should be " << offset << tcu::TestLog::EndMessage;
2068
status = false;
2069
}
2070
glGetIntegeri_v(GL_VERTEX_BINDING_STRIDE, index, &p);
2071
if (p != stride)
2072
{
2073
m_context.getTestContext().getLog()
2074
<< tcu::TestLog::Message << "GL_VERTEX_BINDING_STRIDE(" << index << ") is " << p
2075
<< " should be " << stride << tcu::TestLog::EndMessage;
2076
status = false;
2077
}
2078
glGetIntegeri_v(GL_VERTEX_BINDING_DIVISOR, index, &p);
2079
if (p != divisor)
2080
{
2081
m_context.getTestContext().getLog()
2082
<< tcu::TestLog::Message << "GL_VERTEX_BINDING_DIVISOR(" << index << ") is " << p
2083
<< " should be " << divisor << tcu::TestLog::EndMessage;
2084
status = false;
2085
}
2086
return status;
2087
}
2088
};
2089
//=============================================================================
2090
// 1.5 BasicState1
2091
//-----------------------------------------------------------------------------
2092
class BasicState1 : public VertexAttribBindingBase
2093
{
2094
2095
GLuint m_vao, m_vbo[3];
2096
2097
virtual long Setup()
2098
{
2099
glGenVertexArrays(1, &m_vao);
2100
glGenBuffers(3, m_vbo);
2101
return NO_ERROR;
2102
}
2103
2104
virtual long Cleanup()
2105
{
2106
glDeleteVertexArrays(1, &m_vao);
2107
glDeleteBuffers(3, m_vbo);
2108
return NO_ERROR;
2109
}
2110
2111
virtual long Run()
2112
{
2113
bool status = true;
2114
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
2115
glBufferData(GL_ARRAY_BUFFER, 10000, NULL, GL_DYNAMIC_COPY);
2116
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
2117
glBufferData(GL_ARRAY_BUFFER, 10000, NULL, GL_DYNAMIC_COPY);
2118
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[2]);
2119
glBufferData(GL_ARRAY_BUFFER, 10000, NULL, GL_DYNAMIC_COPY);
2120
glBindBuffer(GL_ARRAY_BUFFER, 0);
2121
2122
GLint p;
2123
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &p);
2124
if (p < 16)
2125
{
2126
m_context.getTestContext().getLog()
2127
<< tcu::TestLog::Message << "GL_MAX_VERTEX_ATTRIB_BINDINGS is" << p
2128
<< "but must be at least 16." << tcu::TestLog::EndMessage;
2129
status = false;
2130
}
2131
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, &p);
2132
if (p < 2047)
2133
{
2134
m_context.getTestContext().getLog()
2135
<< tcu::TestLog::Message << "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET is" << p
2136
<< "but must be at least 2047." << tcu::TestLog::EndMessage;
2137
status = false;
2138
}
2139
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &p);
2140
if (p < 2048)
2141
{
2142
m_context.getTestContext().getLog()
2143
<< tcu::TestLog::Message << "GL_MAX_VERTEX_ATTRIB_STRIDE is" << p
2144
<< "but must be at least 2048." << tcu::TestLog::EndMessage;
2145
status = false;
2146
}
2147
2148
glBindVertexArray(m_vao);
2149
// check default state
2150
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &p);
2151
if (0 != p)
2152
{
2153
m_context.getTestContext().getLog()
2154
<< tcu::TestLog::Message << "GL_ELEMENT_ARRAY_BUFFER_BINDING is" << p
2155
<< "should be 0." << tcu::TestLog::EndMessage;
2156
status = false;
2157
}
2158
for (GLuint i = 0; i < 16; ++i)
2159
{
2160
VertexAttribState va(i);
2161
if (!va.stateVerify())
2162
status = false;
2163
}
2164
for (GLuint i = 0; i < 16; ++i)
2165
{
2166
VertexBindingState vb(i);
2167
if (!vb.stateVerify())
2168
status = false;
2169
}
2170
if (!status)
2171
{
2172
m_context.getTestContext().getLog()
2173
<< tcu::TestLog::Message << "Default state check failed."
2174
<< tcu::TestLog::EndMessage;
2175
status = false;
2176
}
2177
2178
VertexAttribState va0(0);
2179
va0.array_size = 2;
2180
va0.array_type = GL_BYTE;
2181
va0.array_normalized = 1;
2182
va0.relative_offset = 16;
2183
VertexBindingState vb0(0);
2184
glVertexAttribFormat(0, 2, GL_BYTE, GL_TRUE, 16);
2185
if (!va0.stateVerify() || !vb0.stateVerify())
2186
{
2187
m_context.getTestContext().getLog()
2188
<< tcu::TestLog::Message << "glVertexAttribFormat state change check failed."
2189
<< tcu::TestLog::EndMessage;
2190
status = false;
2191
}
2192
2193
VertexAttribState va2(2);
2194
va2.array_size = 3;
2195
va2.array_type = GL_INT;
2196
va2.array_integer = 1;
2197
va2.relative_offset = 512;
2198
VertexBindingState vb2(2);
2199
glVertexAttribIFormat(2, 3, GL_INT, 512);
2200
if (!va2.stateVerify() || !vb2.stateVerify())
2201
{
2202
m_context.getTestContext().getLog()
2203
<< tcu::TestLog::Message << "glVertexAttribIFormat state change check failed."
2204
<< tcu::TestLog::EndMessage;
2205
status = false;
2206
}
2207
2208
va0.array_buffer_binding = m_vbo[0];
2209
vb0.buffer = m_vbo[0];
2210
vb0.offset = 2048;
2211
vb0.stride = 128;
2212
glBindVertexBuffer(0, m_vbo[0], 2048, 128);
2213
if (!va0.stateVerify() || !vb0.stateVerify())
2214
{
2215
m_context.getTestContext().getLog()
2216
<< tcu::TestLog::Message << "glBindVertexBuffer state change check failed."
2217
<< tcu::TestLog::EndMessage;
2218
status = false;
2219
}
2220
2221
va2.array_buffer_binding = m_vbo[2];
2222
vb2.buffer = m_vbo[2];
2223
vb2.offset = 64;
2224
vb2.stride = 256;
2225
glBindVertexBuffer(2, m_vbo[2], 64, 256);
2226
if (!va2.stateVerify() || !vb2.stateVerify())
2227
{
2228
m_context.getTestContext().getLog()
2229
<< tcu::TestLog::Message << "glBindVertexBuffer state change check failed."
2230
<< tcu::TestLog::EndMessage;
2231
status = false;
2232
}
2233
2234
glVertexAttribBinding(2, 0);
2235
va2.binding = 0;
2236
va2.array_buffer_binding = m_vbo[0];
2237
if (!va0.stateVerify() || !vb0.stateVerify() || !va2.stateVerify() || !vb2.stateVerify())
2238
{
2239
m_context.getTestContext().getLog()
2240
<< tcu::TestLog::Message << "glVertexAttribBinding state change check failed."
2241
<< tcu::TestLog::EndMessage;
2242
status = false;
2243
}
2244
2245
VertexAttribState va15(15);
2246
VertexBindingState vb15(15);
2247
glVertexAttribBinding(0, 15);
2248
va0.binding = 15;
2249
va0.array_buffer_binding = 0;
2250
if (!va0.stateVerify() || !vb0.stateVerify() || !va15.stateVerify() || !vb15.stateVerify())
2251
{
2252
m_context.getTestContext().getLog()
2253
<< tcu::TestLog::Message << "glVertexAttribBinding state change check failed."
2254
<< tcu::TestLog::EndMessage;
2255
status = false;
2256
}
2257
2258
glBindVertexBuffer(15, m_vbo[1], 16, 32);
2259
va0.array_buffer_binding = m_vbo[1];
2260
va15.array_buffer_binding = m_vbo[1];
2261
vb15.buffer = m_vbo[1];
2262
vb15.offset = 16;
2263
vb15.stride = 32;
2264
if (!va0.stateVerify() || !vb0.stateVerify() || !va15.stateVerify() || !vb15.stateVerify())
2265
{
2266
m_context.getTestContext().getLog()
2267
<< tcu::TestLog::Message << "glBindVertexBuffer state change check failed."
2268
<< tcu::TestLog::EndMessage;
2269
status = false;
2270
}
2271
2272
glVertexAttribFormat(15, 1, GL_HALF_FLOAT, GL_FALSE, 1024);
2273
va15.array_size = 1;
2274
va15.array_type = GL_HALF_FLOAT;
2275
va15.relative_offset = 1024;
2276
if (!va0.stateVerify() || !vb0.stateVerify() || !va2.stateVerify() || !vb2.stateVerify() ||
2277
!va15.stateVerify() || !vb15.stateVerify())
2278
{
2279
m_context.getTestContext().getLog()
2280
<< tcu::TestLog::Message << "glVertexAttribFormat state change check failed."
2281
<< tcu::TestLog::EndMessage;
2282
status = false;
2283
}
2284
2285
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[2]);
2286
glVertexAttribPointer(0, 4, GL_UNSIGNED_BYTE, GL_FALSE, 8, (void *)640);
2287
glBindBuffer(GL_ARRAY_BUFFER, 0);
2288
va0.array_size = 4;
2289
va0.array_type = GL_UNSIGNED_BYTE;
2290
va0.array_stride = 8;
2291
va0.array_pointer = 640;
2292
va0.relative_offset = 0;
2293
va0.array_normalized = 0;
2294
va0.binding = 0;
2295
va0.array_buffer_binding = m_vbo[2];
2296
vb0.buffer = m_vbo[2];
2297
vb0.offset = 640;
2298
vb0.stride = 8;
2299
va2.array_buffer_binding = m_vbo[2];
2300
if (!va0.stateVerify() || !vb0.stateVerify() || !va2.stateVerify() || !vb2.stateVerify() ||
2301
!va15.stateVerify() || !vb15.stateVerify())
2302
{
2303
m_context.getTestContext().getLog()
2304
<< tcu::TestLog::Message << "glVertexAttribPointer state change check failed."
2305
<< tcu::TestLog::EndMessage;
2306
status = false;
2307
}
2308
2309
glBindVertexBuffer(0, m_vbo[1], 80, 24);
2310
vb0.buffer = m_vbo[1];
2311
vb0.offset = 80;
2312
vb0.stride = 24;
2313
va2.array_buffer_binding = m_vbo[1];
2314
va0.array_buffer_binding = m_vbo[1];
2315
if (!va0.stateVerify() || !vb0.stateVerify() || !va2.stateVerify() || !vb2.stateVerify() ||
2316
!va15.stateVerify() || !vb15.stateVerify())
2317
{
2318
m_context.getTestContext().getLog()
2319
<< tcu::TestLog::Message << "glBindVertexBuffer state change check failed."
2320
<< tcu::TestLog::EndMessage;
2321
status = false;
2322
}
2323
2324
if (status)
2325
return NO_ERROR;
2326
else
2327
return ERROR;
2328
}
2329
};
2330
//=============================================================================
2331
// 1.6 BasicState2
2332
//-----------------------------------------------------------------------------
2333
class BasicState2 : public VertexAttribBindingBase
2334
{
2335
2336
GLuint m_vao;
2337
2338
virtual long Setup()
2339
{
2340
glGenVertexArrays(1, &m_vao);
2341
return NO_ERROR;
2342
}
2343
2344
virtual long Cleanup()
2345
{
2346
glDeleteVertexArrays(1, &m_vao);
2347
return NO_ERROR;
2348
}
2349
2350
virtual long Run()
2351
{
2352
bool status = true;
2353
glBindVertexArray(m_vao);
2354
2355
for (GLuint i = 0; i < 16; ++i)
2356
{
2357
VertexAttribState va(i);
2358
VertexBindingState vb(i);
2359
glVertexAttribDivisor(i, i + 7);
2360
va.array_divisor = i + 7;
2361
vb.divisor = i + 7;
2362
if (!va.stateVerify() || !vb.stateVerify())
2363
{
2364
m_context.getTestContext().getLog()
2365
<< tcu::TestLog::Message << "glVertexAttribDivisor state change check failed."
2366
<< tcu::TestLog::EndMessage;
2367
status = false;
2368
}
2369
}
2370
for (GLuint i = 0; i < 16; ++i)
2371
{
2372
VertexAttribState va(i);
2373
VertexBindingState vb(i);
2374
glVertexBindingDivisor(i, i);
2375
va.array_divisor = i;
2376
vb.divisor = i;
2377
if (!va.stateVerify() || !vb.stateVerify())
2378
{
2379
m_context.getTestContext().getLog()
2380
<< tcu::TestLog::Message << "glVertexBindingDivisor state change check failed."
2381
<< tcu::TestLog::EndMessage;
2382
status = false;
2383
}
2384
}
2385
2386
glVertexAttribBinding(2, 5);
2387
VertexAttribState va5(5);
2388
va5.array_divisor = 5;
2389
VertexBindingState vb5(5);
2390
vb5.divisor = 5;
2391
VertexAttribState va2(2);
2392
va2.array_divisor = 5; // binding state seen thru mapping
2393
VertexBindingState vb2(2);
2394
vb2.divisor = 2;
2395
va2.binding = 5;
2396
if (!va5.stateVerify() || !vb5.stateVerify() || !va2.stateVerify() || !vb2.stateVerify())
2397
{
2398
m_context.getTestContext().getLog()
2399
<< tcu::TestLog::Message << "glVertexAttribBinding state change check failed."
2400
<< tcu::TestLog::EndMessage;
2401
status = false;
2402
}
2403
2404
glVertexAttribDivisor(2, 23);
2405
va2.binding = 2; // glVAD defaults mapping
2406
va2.array_divisor = 23;
2407
vb2.divisor = 23;
2408
if (!va5.stateVerify() || !vb5.stateVerify() || !va2.stateVerify() || !vb2.stateVerify())
2409
{
2410
m_context.getTestContext().getLog()
2411
<< tcu::TestLog::Message << "glVertexAttribDivisor state change check failed."
2412
<< tcu::TestLog::EndMessage;
2413
status = false;
2414
}
2415
2416
if (status)
2417
return NO_ERROR;
2418
else
2419
return ERROR;
2420
}
2421
};
2422
//=============================================================================
2423
// 2.1 AdvancedBindingUpdate
2424
//-----------------------------------------------------------------------------
2425
class AdvancedBindingUpdate : public VertexAttribBindingBase
2426
{
2427
bool pipeline;
2428
GLuint m_vao[2], m_vbo[2], m_ebo[2], m_vsp, m_fsp, m_ppo;
2429
2430
virtual long Setup()
2431
{
2432
glGenVertexArrays(2, m_vao);
2433
glGenBuffers(2, m_vbo);
2434
glGenBuffers(2, m_ebo);
2435
if (pipeline)
2436
{
2437
m_vsp = m_fsp = 0;
2438
glGenProgramPipelines(1, &m_ppo);
2439
}
2440
else
2441
{
2442
m_ppo = 0;
2443
}
2444
return NO_ERROR;
2445
}
2446
2447
virtual long Cleanup()
2448
{
2449
glDeleteVertexArrays(2, m_vao);
2450
glDeleteBuffers(2, m_vbo);
2451
glDeleteBuffers(2, m_ebo);
2452
if (pipeline)
2453
{
2454
glDeleteProgram(m_vsp);
2455
glDeleteProgram(m_fsp);
2456
glDeleteProgramPipelines(1, &m_ppo);
2457
}
2458
else
2459
{
2460
glUseProgram(0);
2461
glDeleteProgram(m_ppo);
2462
}
2463
return NO_ERROR;
2464
}
2465
2466
virtual long Run()
2467
{
2468
const char *const glsl_vs =
2469
"#version 310 es" NL "layout(location = 0) in vec4 vs_in_position;" NL
2470
"layout(location = 1) in vec2 vs_in_color_rg;" NL
2471
"layout(location = 2) in float vs_in_color_b;" NL
2472
"layout(location = 3) in uvec3 vs_in_data0;" NL
2473
"layout(location = 4) in ivec2 vs_in_data1;" NL "out vec2 color_rg;" NL
2474
"out float color_b;" NL "flat out uvec3 data0;" NL "flat out ivec2 data1;" NL
2475
"void main() {" NL " data0 = vs_in_data0;" NL " data1 = vs_in_data1;" NL
2476
" color_b = vs_in_color_b;" NL " color_rg = vs_in_color_rg;" NL
2477
" gl_Position = vs_in_position;" NL "}";
2478
const char *const glsl_fs =
2479
"#version 310 es" NL "precision highp float;" NL "precision highp int;" NL
2480
"in vec2 color_rg;" NL "in float color_b;" NL "flat in uvec3 data0;" NL
2481
"flat in ivec2 data1;" NL "out vec4 fs_out_color;" NL
2482
"uniform uvec3 g_expected_data0;" NL "uniform ivec2 g_expected_data1;" NL
2483
"void main() {" NL " fs_out_color = vec4(color_rg, color_b, 1);" NL
2484
" if (data0 != g_expected_data0) fs_out_color = vec4(1);" NL
2485
" if (data1 != g_expected_data1) fs_out_color = vec4(1);" NL "}";
2486
if (pipeline)
2487
{
2488
m_vsp = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
2489
m_fsp = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &glsl_fs);
2490
if (!CheckProgram(m_vsp) || !CheckProgram(m_fsp))
2491
return ERROR;
2492
glUseProgramStages(m_ppo, GL_VERTEX_SHADER_BIT, m_vsp);
2493
glUseProgramStages(m_ppo, GL_FRAGMENT_SHADER_BIT, m_fsp);
2494
}
2495
else
2496
{
2497
m_ppo = glCreateProgram();
2498
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
2499
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
2500
glShaderSource(sh, 1, &glsl_vs, NULL);
2501
glShaderSource(fsh, 1, &glsl_fs, NULL);
2502
glCompileShader(sh);
2503
glCompileShader(fsh);
2504
glAttachShader(m_ppo, sh);
2505
glAttachShader(m_ppo, fsh);
2506
glDeleteShader(sh);
2507
glDeleteShader(fsh);
2508
glLinkProgram(m_ppo);
2509
if (!CheckProgram(m_ppo))
2510
return ERROR;
2511
}
2512
2513
const GLsizei kStride[2] = {52, 64};
2514
const GLintptr kOffset[2] = {0, 8};
2515
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[0]);
2516
/* first VBO */
2517
{
2518
glBufferData(GL_ARRAY_BUFFER, kOffset[0] + 4 * kStride[0], NULL, GL_STATIC_DRAW);
2519
GLubyte *ptr = static_cast<GLubyte *>(glMapBufferRange(
2520
GL_ARRAY_BUFFER, 0, kOffset[0] + 4 * kStride[0], GL_MAP_WRITE_BIT));
2521
*reinterpret_cast<Vec2 *>(&ptr[kOffset[0] + 0 * kStride[0]]) = Vec2(-1.0f, -1.0f);
2522
*reinterpret_cast<Vec2 *>(&ptr[kOffset[0] + 1 * kStride[0]]) = Vec2(1.0f, -1.0f);
2523
*reinterpret_cast<Vec2 *>(&ptr[kOffset[0] + 2 * kStride[0]]) = Vec2(1.0f, 1.0f);
2524
*reinterpret_cast<Vec2 *>(&ptr[kOffset[0] + 3 * kStride[0]]) = Vec2(-1.0f, 1.0f);
2525
for (int i = 0; i < 4; ++i)
2526
{
2527
*reinterpret_cast<Vec2 *>(&ptr[kOffset[0] + 8 + i * kStride[0]]) = Vec2(0.0f, 1.0f);
2528
*reinterpret_cast<float *>(&ptr[kOffset[0] + 16 + i * kStride[0]]) = 0.0f;
2529
*reinterpret_cast<UVec3 *>(&ptr[kOffset[0] + 20 + i * kStride[0]]) = UVec3(1, 2, 3);
2530
*reinterpret_cast<IVec2 *>(&ptr[kOffset[0] + 44 + i * kStride[0]]) = IVec2(1, 2);
2531
}
2532
glUnmapBuffer(GL_ARRAY_BUFFER);
2533
}
2534
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[1]);
2535
/* second VBO */
2536
{
2537
glBufferData(GL_ARRAY_BUFFER, kOffset[1] + 4 * kStride[1], NULL, GL_STATIC_DRAW);
2538
GLubyte *ptr = static_cast<GLubyte *>(glMapBufferRange(
2539
GL_ARRAY_BUFFER, 0, kOffset[1] + 4 * kStride[1], GL_MAP_WRITE_BIT));
2540
*reinterpret_cast<Vec2 *>(&ptr[kOffset[1] + 0 * kStride[1]]) = Vec2(-1.0f, 1.0f);
2541
*reinterpret_cast<Vec2 *>(&ptr[kOffset[1] + 1 * kStride[1]]) = Vec2(1.0f, 1.0f);
2542
*reinterpret_cast<Vec2 *>(&ptr[kOffset[1] + 2 * kStride[1]]) = Vec2(1.0f, -1.0f);
2543
*reinterpret_cast<Vec2 *>(&ptr[kOffset[1] + 3 * kStride[1]]) = Vec2(-1.0f, -1.0f);
2544
for (int i = 0; i < 4; ++i)
2545
{
2546
*reinterpret_cast<Vec2 *>(&ptr[kOffset[1] + 8 + i * kStride[1]]) = Vec2(0.0f, 0.0f);
2547
*reinterpret_cast<float *>(&ptr[kOffset[1] + 16 + i * kStride[1]]) = 1.0f;
2548
*reinterpret_cast<UVec3 *>(&ptr[kOffset[1] + 20 + i * kStride[1]]) = UVec3(4, 5, 6);
2549
*reinterpret_cast<IVec2 *>(&ptr[kOffset[1] + 44 + i * kStride[1]]) = IVec2(3, 4);
2550
}
2551
glUnmapBuffer(GL_ARRAY_BUFFER);
2552
}
2553
glBindBuffer(GL_ARRAY_BUFFER, 0);
2554
2555
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[0]);
2556
/* first EBO */
2557
{
2558
GLushort data[4] = {0, 1, 3, 2};
2559
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
2560
}
2561
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[1]);
2562
/* second EBO */
2563
{
2564
GLuint data[4] = {3, 2, 0, 1};
2565
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
2566
}
2567
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2568
2569
glBindVertexArray(m_vao[0]);
2570
glVertexAttribFormat(0, 2, GL_FLOAT, GL_FALSE, 0);
2571
glVertexAttribFormat(1, 2, GL_FLOAT, GL_FALSE, 8);
2572
glVertexAttribFormat(2, 1, GL_FLOAT, GL_FALSE, 16);
2573
glVertexAttribIFormat(3, 3, GL_UNSIGNED_INT, 20);
2574
glVertexAttribIFormat(4, 2, GL_INT, 44);
2575
for (GLuint i = 0; i < 5; ++i)
2576
{
2577
glVertexAttribBinding(i, 0);
2578
glEnableVertexAttribArray(i);
2579
}
2580
glBindVertexArray(m_vao[1]);
2581
glVertexAttribFormat(0, 2, GL_FLOAT, GL_FALSE, 0);
2582
glVertexAttribFormat(1, 2, GL_FLOAT, GL_FALSE, 8);
2583
glVertexAttribFormat(2, 1, GL_FLOAT, GL_FALSE, 16);
2584
glVertexAttribIFormat(3, 3, GL_UNSIGNED_INT, 20);
2585
glVertexAttribIFormat(4, 2, GL_INT, 44);
2586
glVertexAttribBinding(0, 1);
2587
glVertexAttribBinding(1, 8);
2588
glVertexAttribBinding(2, 1);
2589
glVertexAttribBinding(3, 1);
2590
glVertexAttribBinding(4, 8);
2591
glEnableVertexAttribArray(0);
2592
glEnableVertexAttribArray(1);
2593
glEnableVertexAttribArray(2);
2594
glEnableVertexAttribArray(3);
2595
glEnableVertexAttribArray(4);
2596
glBindVertexBuffer(1, m_vbo[1], kOffset[1], kStride[1]);
2597
glBindVertexBuffer(8, m_vbo[0], kOffset[0], kStride[0]);
2598
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[1]);
2599
glBindVertexArray(0);
2600
2601
glClear(GL_COLOR_BUFFER_BIT);
2602
GLuint ppo;
2603
if (pipeline)
2604
{
2605
glBindProgramPipeline(m_ppo);
2606
ppo = m_fsp;
2607
}
2608
else
2609
{
2610
glUseProgram(m_ppo);
2611
ppo = m_ppo;
2612
}
2613
glBindVertexArray(m_vao[0]);
2614
2615
// Bind first VBO
2616
glProgramUniform3ui(ppo, glGetUniformLocation(ppo, "g_expected_data0"), 1, 2, 3);
2617
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 1, 2);
2618
glBindVertexBuffer(0, m_vbo[0], kOffset[0], kStride[0]);
2619
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[0]);
2620
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, 0, 1);
2621
2622
bool status = true;
2623
if (!CheckFB(Vec3(0, 1, 0)))
2624
status = false;
2625
if (!status)
2626
return ERROR;
2627
2628
// Bind second VBO (change all vertex attribs with one call)
2629
glProgramUniform3ui(ppo, glGetUniformLocation(ppo, "g_expected_data0"), 4, 5, 6);
2630
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 3, 4);
2631
2632
glBindVertexBuffer(0, m_vbo[1], kOffset[1], kStride[1]);
2633
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[1]);
2634
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0, 1);
2635
2636
if (!CheckFB(Vec3(0, 0, 1)))
2637
status = false;
2638
if (!status)
2639
return ERROR;
2640
2641
// Change attrib bindings (all attribs from one buffer)
2642
glBindVertexBuffer(0, 0, 0, 0); // "unbind" buffer
2643
2644
glProgramUniform3ui(ppo, glGetUniformLocation(ppo, "g_expected_data0"), 1, 2, 3);
2645
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 1, 2);
2646
2647
for (GLuint i = 0; i < 5; ++i)
2648
glVertexAttribBinding(i, 15);
2649
glBindVertexBuffer(15, m_vbo[0], kOffset[0], kStride[0]);
2650
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[0]);
2651
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, 0, 1);
2652
2653
if (!CheckFB(Vec3(0, 1, 0)))
2654
status = false;
2655
if (!status)
2656
return ERROR;
2657
2658
// Change attrib bindings (attribs from two buffers)
2659
glBindVertexBuffer(15, 0, 0, 0); // "unbind" buffer
2660
2661
glProgramUniform3ui(ppo, glGetUniformLocation(ppo, "g_expected_data0"), 1, 2, 3);
2662
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 3, 4);
2663
2664
glBindVertexBuffer(7, m_vbo[0], kOffset[0], kStride[0]);
2665
glBindVertexBuffer(12, m_vbo[1], kOffset[1], kStride[1]);
2666
glVertexAttribBinding(0, 7);
2667
glVertexAttribBinding(1, 12);
2668
glVertexAttribBinding(2, 12);
2669
glVertexAttribBinding(3, 7);
2670
glVertexAttribBinding(4, 12);
2671
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo[0]);
2672
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, 0, 1);
2673
2674
if (!CheckFB(Vec3(0, 0, 1)))
2675
status = false;
2676
if (!status)
2677
return ERROR;
2678
2679
// Disable one of the attribs
2680
glClear(GL_COLOR_BUFFER_BIT);
2681
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 0, 0);
2682
glDisableVertexAttribArray(4);
2683
glVertexAttribI4i(4, 0, 0, 0, 0);
2684
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, 0, 1);
2685
2686
if (!CheckFB(Vec3(0, 0, 1)))
2687
status = false;
2688
if (!status)
2689
return ERROR;
2690
2691
// Change VAO
2692
glProgramUniform3ui(ppo, glGetUniformLocation(ppo, "g_expected_data0"), 4, 5, 6);
2693
glProgramUniform2i(ppo, glGetUniformLocation(ppo, "g_expected_data1"), 1, 2);
2694
2695
glBindVertexArray(m_vao[1]);
2696
glDrawElementsInstanced(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0, 1);
2697
2698
if (!CheckFB(Vec3(0, 1, 1)))
2699
status = false;
2700
if (!status)
2701
return ERROR;
2702
2703
return NO_ERROR;
2704
}
2705
2706
public:
2707
AdvancedBindingUpdate() : pipeline(true) {}
2708
};
2709
//=============================================================================
2710
// 2.3 AdvancedIterations
2711
//-----------------------------------------------------------------------------
2712
class AdvancedIterations : public VertexAttribBindingBase
2713
{
2714
2715
GLuint m_po, m_vao[2], m_buffer[2];
2716
2717
virtual long Setup()
2718
{
2719
m_po = 0;
2720
glGenVertexArrays(2, m_vao);
2721
glGenBuffers(2, m_buffer);
2722
return NO_ERROR;
2723
}
2724
2725
virtual long Cleanup()
2726
{
2727
glDisable(GL_RASTERIZER_DISCARD);
2728
glUseProgram(0);
2729
glDeleteProgram(m_po);
2730
glDeleteVertexArrays(2, m_vao);
2731
glDeleteBuffers(2, m_buffer);
2732
return NO_ERROR;
2733
}
2734
2735
virtual long Run()
2736
{
2737
const char *const glsl_vs =
2738
"#version 310 es" NL "in ivec4 vs_in_data;" NL "flat out ivec4 data;" NL
2739
"void main() {" NL " data = vs_in_data + 1;" NL "}";
2740
const char *const glsl_fs =
2741
"#version 310 es" NL "precision mediump float;" NL "flat in ivec4 data;" NL
2742
"out vec4 fs_out_color;" NL "void main() {" NL " fs_out_color = vec4(data);" NL "}";
2743
m_po = glCreateProgram();
2744
/* attach shader */
2745
{
2746
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
2747
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
2748
glShaderSource(sh, 1, &glsl_vs, NULL);
2749
glShaderSource(fsh, 1, &glsl_fs, NULL);
2750
glCompileShader(sh);
2751
glCompileShader(fsh);
2752
glAttachShader(m_po, sh);
2753
glAttachShader(m_po, fsh);
2754
glDeleteShader(sh);
2755
glDeleteShader(fsh);
2756
}
2757
if (!RelinkProgram(1))
2758
return ERROR;
2759
2760
glBindBuffer(GL_ARRAY_BUFFER, m_buffer[0]);
2761
IVec4 zero(0);
2762
glBufferData(GL_ARRAY_BUFFER, 16, &zero, GL_STATIC_DRAW);
2763
glBindBuffer(GL_ARRAY_BUFFER, 0);
2764
2765
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, m_buffer[1]);
2766
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, &zero, GL_DYNAMIC_READ);
2767
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
2768
2769
glBindVertexArray(m_vao[0]);
2770
glVertexAttribIFormat(1, 4, GL_INT, 0);
2771
glEnableVertexAttribArray(1);
2772
glBindVertexBuffer(1, m_buffer[0], 0, 16);
2773
glBindVertexArray(m_vao[1]);
2774
glVertexAttribIFormat(1, 4, GL_INT, 0);
2775
glEnableVertexAttribArray(1);
2776
glBindVertexBuffer(1, m_buffer[1], 0, 16);
2777
glBindVertexArray(0);
2778
glEnable(GL_RASTERIZER_DISCARD);
2779
glUseProgram(m_po);
2780
2781
for (int i = 0; i < 10; ++i)
2782
{
2783
glBindVertexArray(m_vao[i % 2]);
2784
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_buffer[(i + 1) % 2]);
2785
glBeginTransformFeedback(GL_POINTS);
2786
glDrawArrays(GL_POINTS, 0, 1);
2787
glEndTransformFeedback();
2788
}
2789
/* */
2790
{
2791
IVec4 *data = static_cast<IVec4 *>(
2792
glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(IVec4), GL_MAP_READ_BIT));
2793
if (!IsEqual(*data, IVec4(10)))
2794
{
2795
m_context.getTestContext().getLog()
2796
<< tcu::TestLog::Message << "Data is: " << (*data)[0] << " " << (*data)[1]
2797
<< " " << (*data)[2] << " " << (*data)[3] << ", data should be: 10 10 10 10."
2798
<< tcu::TestLog::EndMessage;
2799
return ERROR;
2800
}
2801
glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
2802
}
2803
2804
if (!RelinkProgram(5))
2805
return ERROR;
2806
glBindVertexArray(m_vao[0]);
2807
glDisableVertexAttribArray(1);
2808
glBindVertexBuffer(1, 0, 0, 0);
2809
glVertexAttribIFormat(5, 4, GL_INT, 0);
2810
glEnableVertexAttribArray(5);
2811
glBindVertexBuffer(5, m_buffer[0], 0, 16);
2812
glBindVertexArray(m_vao[1]);
2813
glDisableVertexAttribArray(1);
2814
glBindVertexBuffer(1, 0, 0, 0);
2815
glVertexAttribIFormat(5, 4, GL_INT, 0);
2816
glEnableVertexAttribArray(5);
2817
glBindVertexBuffer(7, m_buffer[1], 0, 16);
2818
glVertexAttribBinding(5, 7);
2819
glBindVertexArray(0);
2820
2821
for (int i = 0; i < 10; ++i)
2822
{
2823
glBindVertexArray(m_vao[i % 2]);
2824
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_buffer[(i + 1) % 2]);
2825
glBeginTransformFeedback(GL_POINTS);
2826
glDrawArrays(GL_POINTS, 0, 1);
2827
glEndTransformFeedback();
2828
}
2829
/* */
2830
{
2831
IVec4 *data = static_cast<IVec4 *>(
2832
glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(IVec4), GL_MAP_READ_BIT));
2833
if (!IsEqual(*data, IVec4(20)))
2834
{
2835
m_context.getTestContext().getLog()
2836
<< tcu::TestLog::Message << "Data is: " << (*data)[0] << " " << (*data)[1]
2837
<< " " << (*data)[2] << " " << (*data)[3] << ", data should be: 20 20 20 20."
2838
<< tcu::TestLog::EndMessage;
2839
return ERROR;
2840
}
2841
glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
2842
}
2843
2844
if (!RelinkProgram(11))
2845
return ERROR;
2846
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
2847
glBindVertexArray(m_vao[0]);
2848
glDisableVertexAttribArray(5);
2849
glBindVertexBuffer(5, 0, 0, 0);
2850
glVertexAttribIFormat(11, 4, GL_INT, 0);
2851
glEnableVertexAttribArray(11);
2852
for (int i = 0; i < 10; ++i)
2853
{
2854
glBindVertexBuffer(11, m_buffer[i % 2], 0, 16);
2855
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_buffer[(i + 1) % 2]);
2856
glBeginTransformFeedback(GL_POINTS);
2857
glDrawArrays(GL_POINTS, 0, 1);
2858
glEndTransformFeedback();
2859
}
2860
/* */
2861
{
2862
IVec4 *data = static_cast<IVec4 *>(
2863
glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(IVec4), GL_MAP_READ_BIT));
2864
if (!IsEqual(*data, IVec4(30)))
2865
{
2866
m_context.getTestContext().getLog()
2867
<< tcu::TestLog::Message << "Data is: " << (*data)[0] << " " << (*data)[1]
2868
<< " " << (*data)[2] << " " << (*data)[3] << ", data should be: 30 30 30 30."
2869
<< tcu::TestLog::EndMessage;
2870
return ERROR;
2871
}
2872
}
2873
2874
return NO_ERROR;
2875
}
2876
2877
bool RelinkProgram(GLuint index)
2878
{
2879
glBindAttribLocation(m_po, index, "vs_in_data");
2880
/* setup XFB */
2881
{
2882
const GLchar *const v[1] = {"data"};
2883
glTransformFeedbackVaryings(m_po, 1, v, GL_INTERLEAVED_ATTRIBS);
2884
}
2885
glLinkProgram(m_po);
2886
if (!CheckProgram(m_po))
2887
return false;
2888
return true;
2889
}
2890
};
2891
//=============================================================================
2892
// 2.4 AdvancedLargeStrideAndOffsetsNewAndLegacyAPI
2893
//-----------------------------------------------------------------------------
2894
class AdvancedLargeStrideAndOffsetsNewAndLegacyAPI : public VertexAttribBindingBase
2895
{
2896
bool pipeline;
2897
GLuint m_vsp, m_fsp, m_ppo, m_ssbo, m_vao, m_vbo;
2898
2899
virtual long Setup()
2900
{
2901
m_vsp = 0;
2902
if (pipeline)
2903
{
2904
m_vsp = m_fsp = 0;
2905
glGenProgramPipelines(1, &m_ppo);
2906
}
2907
else
2908
{
2909
m_ppo = 0;
2910
}
2911
glGenBuffers(1, &m_ssbo);
2912
glGenVertexArrays(1, &m_vao);
2913
glGenBuffers(1, &m_vbo);
2914
return NO_ERROR;
2915
}
2916
2917
virtual long Cleanup()
2918
{
2919
glDisable(GL_RASTERIZER_DISCARD);
2920
if (pipeline)
2921
{
2922
glDeleteProgram(m_vsp);
2923
glDeleteProgram(m_fsp);
2924
glDeleteProgramPipelines(1, &m_ppo);
2925
}
2926
else
2927
{
2928
glUseProgram(0);
2929
glDeleteProgram(m_ppo);
2930
}
2931
glDeleteBuffers(1, &m_ssbo);
2932
glDeleteVertexArrays(1, &m_vao);
2933
glDeleteBuffers(1, &m_vbo);
2934
return NO_ERROR;
2935
}
2936
2937
virtual long Run()
2938
{
2939
if (!IsSSBOInVSFSAvailable(2))
2940
return NOT_SUPPORTED;
2941
const char *const glsl_vs =
2942
"#version 310 es" NL "layout(location = 0) in vec2 vs_in_attrib0;" NL
2943
"layout(location = 4) in ivec2 vs_in_attrib1;" NL
2944
"layout(location = 8) in uvec2 vs_in_attrib2;" NL
2945
"layout(location = 15) in float vs_in_attrib3;" NL
2946
"layout(std430, binding = 1) buffer Output {" NL " vec2 attrib0[4];" NL
2947
" ivec2 attrib1[4];" NL " uvec2 attrib2[4];" NL " float attrib3[4];" NL
2948
"} g_output;" NL "void main() {" NL
2949
" g_output.attrib0[2 * gl_InstanceID + gl_VertexID] = vs_in_attrib0;" NL
2950
" g_output.attrib1[2 * gl_InstanceID + gl_VertexID] = vs_in_attrib1;" NL
2951
" g_output.attrib2[2 * gl_InstanceID + gl_VertexID] = vs_in_attrib2;" NL
2952
" g_output.attrib3[2 * gl_InstanceID + gl_VertexID] = vs_in_attrib3;" NL "}";
2953
const char *const glsl_fs =
2954
"#version 310 es" NL "precision mediump float;" NL "out vec4 fs_out_color;" NL
2955
"void main() {" NL " fs_out_color = vec4(0.5,0.5,0.5,1.0);" NL "}";
2956
if (pipeline)
2957
{
2958
m_vsp = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
2959
m_fsp = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &glsl_fs);
2960
if (!CheckProgram(m_vsp) || !CheckProgram(m_fsp))
2961
return ERROR;
2962
glUseProgramStages(m_ppo, GL_VERTEX_SHADER_BIT, m_vsp);
2963
glUseProgramStages(m_ppo, GL_FRAGMENT_SHADER_BIT, m_fsp);
2964
}
2965
else
2966
{
2967
m_ppo = glCreateProgram();
2968
const GLuint sh = glCreateShader(GL_VERTEX_SHADER);
2969
const GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);
2970
glShaderSource(sh, 1, &glsl_vs, NULL);
2971
glShaderSource(fsh, 1, &glsl_fs, NULL);
2972
glCompileShader(sh);
2973
glCompileShader(fsh);
2974
glAttachShader(m_ppo, sh);
2975
glAttachShader(m_ppo, fsh);
2976
glDeleteShader(sh);
2977
glDeleteShader(fsh);
2978
glLinkProgram(m_ppo);
2979
if (!CheckProgram(m_ppo))
2980
return ERROR;
2981
}
2982
2983
/* vbo */
2984
{
2985
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
2986
glBufferData(GL_ARRAY_BUFFER, 100000, NULL, GL_STATIC_DRAW);
2987
GLubyte *ptr = static_cast<GLubyte *>(
2988
glMapBufferRange(GL_ARRAY_BUFFER, 0, 100000, GL_MAP_WRITE_BIT));
2989
// attrib0
2990
*reinterpret_cast<Vec2 *>(&ptr[16 + 0 * 2048]) = Vec2(1.0f, 2.0f);
2991
*reinterpret_cast<Vec2 *>(&ptr[16 + 1 * 2048]) = Vec2(3.0f, 4.0f);
2992
// attrib1
2993
*reinterpret_cast<IVec2 *>(&ptr[128 + 0 * 2048]) = IVec2(5, 6);
2994
*reinterpret_cast<IVec2 *>(&ptr[128 + 1 * 2048]) = IVec2(7, 8);
2995
// attrib2
2996
*reinterpret_cast<UVec2 *>(&ptr[1024 + 0 * 2048]) = UVec2(9, 10);
2997
*reinterpret_cast<UVec2 *>(&ptr[1024 + 1 * 2048]) = UVec2(11, 12);
2998
// attrib3
2999
*reinterpret_cast<float *>(&ptr[2032 + 0 * 2048]) = 13.0f;
3000
*reinterpret_cast<float *>(&ptr[2032 + 1 * 2048]) = 14.0f;
3001
glUnmapBuffer(GL_ARRAY_BUFFER);
3002
glBindBuffer(GL_ARRAY_BUFFER, 0);
3003
}
3004
// vao
3005
glBindVertexArray(m_vao);
3006
glVertexAttribFormat(0, 2, GL_FLOAT, GL_FALSE, 16);
3007
glVertexAttribIFormat(8, 2, GL_UNSIGNED_INT, 1024);
3008
glVertexAttribFormat(15, 1, GL_FLOAT, GL_FALSE, 2032);
3009
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
3010
glVertexAttribIPointer(4, 2, GL_INT, 2048, reinterpret_cast<void *>(128));
3011
glBindBuffer(GL_ARRAY_BUFFER, 0);
3012
glVertexAttribBinding(8, 3);
3013
glVertexAttribBinding(15, 3);
3014
glBindVertexBuffer(0, m_vbo, 0, 2048);
3015
glBindVertexBuffer(3, m_vbo, 0, 2048);
3016
glEnableVertexAttribArray(0);
3017
glEnableVertexAttribArray(4);
3018
glEnableVertexAttribArray(8);
3019
glEnableVertexAttribArray(15);
3020
glBindVertexArray(0);
3021
3022
// ssbo
3023
std::vector<GLubyte> data(
3024
(sizeof(Vec2) + sizeof(IVec2) + sizeof(UVec2) + sizeof(float)) * 4, 0xff);
3025
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_ssbo);
3026
glBufferData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)data.size(), &data[0], GL_DYNAMIC_DRAW);
3027
3028
glEnable(GL_RASTERIZER_DISCARD);
3029
if (pipeline)
3030
glBindProgramPipeline(m_ppo);
3031
else
3032
glUseProgram(m_ppo);
3033
glBindVertexArray(m_vao);
3034
glDrawArraysInstanced(GL_POINTS, 0, 2, 2);
3035
3036
/* */
3037
{
3038
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_ssbo);
3039
GLubyte *ptr = static_cast<GLubyte *>(glMapBufferRange(
3040
GL_SHADER_STORAGE_BUFFER, 0, (GLsizeiptr)data.size(), GL_MAP_READ_BIT));
3041
// attrib0
3042
Vec2 i0_v0_a0 = *reinterpret_cast<Vec2 *>(&ptr[0]);
3043
Vec2 i0_v1_a0 = *reinterpret_cast<Vec2 *>(&ptr[8]);
3044
Vec2 i1_v0_a0 = *reinterpret_cast<Vec2 *>(&ptr[16]);
3045
Vec2 i1_v1_a0 = *reinterpret_cast<Vec2 *>(&ptr[24]);
3046
if (!IsEqual(i0_v0_a0, Vec2(1.0f, 2.0f)))
3047
return ERROR;
3048
if (!IsEqual(i0_v1_a0, Vec2(3.0f, 4.0f)))
3049
return ERROR;
3050
if (!IsEqual(i1_v0_a0, Vec2(1.0f, 2.0f)))
3051
return ERROR;
3052
if (!IsEqual(i1_v1_a0, Vec2(3.0f, 4.0f)))
3053
return ERROR;
3054
// attrib1
3055
IVec2 i0_v0_a1 = *reinterpret_cast<IVec2 *>(&ptr[32]);
3056
IVec2 i0_v1_a1 = *reinterpret_cast<IVec2 *>(&ptr[40]);
3057
IVec2 i1_v0_a1 = *reinterpret_cast<IVec2 *>(&ptr[48]);
3058
IVec2 i1_v1_a1 = *reinterpret_cast<IVec2 *>(&ptr[56]);
3059
if (!IsEqual(i0_v0_a1, IVec2(5, 6)))
3060
return ERROR;
3061
if (!IsEqual(i0_v1_a1, IVec2(7, 8)))
3062
return ERROR;
3063
if (!IsEqual(i1_v0_a1, IVec2(5, 6)))
3064
return ERROR;
3065
if (!IsEqual(i1_v1_a1, IVec2(7, 8)))
3066
return ERROR;
3067
// attrib2
3068
UVec2 i0_v0_a2 = *reinterpret_cast<UVec2 *>(&ptr[64]);
3069
UVec2 i0_v1_a2 = *reinterpret_cast<UVec2 *>(&ptr[72]);
3070
UVec2 i1_v0_a2 = *reinterpret_cast<UVec2 *>(&ptr[80]);
3071
UVec2 i1_v1_a2 = *reinterpret_cast<UVec2 *>(&ptr[88]);
3072
if (!IsEqual(i0_v0_a2, UVec2(9, 10)))
3073
return ERROR;
3074
if (!IsEqual(i0_v1_a2, UVec2(11, 12)))
3075
return ERROR;
3076
if (!IsEqual(i1_v0_a2, UVec2(9, 10)))
3077
return ERROR;
3078
if (!IsEqual(i1_v1_a2, UVec2(11, 12)))
3079
return ERROR;
3080
// attrib3
3081
float i0_v0_a3 = *reinterpret_cast<float *>(&ptr[96]);
3082
float i0_v1_a3 = *reinterpret_cast<float *>(&ptr[100]);
3083
float i1_v0_a3 = *reinterpret_cast<float *>(&ptr[104]);
3084
float i1_v1_a3 = *reinterpret_cast<float *>(&ptr[108]);
3085
if (i0_v0_a3 != 13.0f)
3086
return ERROR;
3087
if (i0_v1_a3 != 14.0f)
3088
return ERROR;
3089
if (i1_v0_a3 != 13.0f)
3090
return ERROR;
3091
if (i1_v1_a3 != 14.0f)
3092
return ERROR;
3093
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
3094
}
3095
return NO_ERROR;
3096
}
3097
3098
public:
3099
AdvancedLargeStrideAndOffsetsNewAndLegacyAPI() : pipeline(true) {}
3100
};
3101
//=============================================================================
3102
// 4.1 NegativeBindVertexBuffer
3103
//-----------------------------------------------------------------------------
3104
class NegativeBindVertexBuffer : public VertexAttribBindingBase
3105
{
3106
3107
GLuint m_vao, m_vbo;
3108
3109
virtual long Setup()
3110
{
3111
glGenVertexArrays(1, &m_vao);
3112
glGenBuffers(1, &m_vbo);
3113
return NO_ERROR;
3114
}
3115
3116
virtual long Cleanup()
3117
{
3118
glDeleteVertexArrays(1, &m_vao);
3119
glDeleteBuffers(1, &m_vbo);
3120
return NO_ERROR;
3121
}
3122
3123
virtual long Run()
3124
{
3125
/*
3126
Errors
3127
An INVALID_OPERATION error is generated if buffer is not zero or a name
3128
returned from a previous call to GenBuffers, or if such a name has since been
3129
deleted with DeleteBuffers.
3130
An INVALID_VALUE error is generated if bindingindex is greater than or
3131
equal to the value of MAX_VERTEX_ATTRIB_BINDINGS.
3132
OpenGL 4.4 (Core Profile) - July 21, 2013
3133
10.3. VERTEX ARRAYS 315
3134
An INVALID_VALUE error is generated if stride or offset is negative, or if
3135
stride is greater than the value of MAX_VERTEX_ATTRIB_STRIDE.
3136
An INVALID_OPERATION error is generated if no vertex array object is
3137
bound.
3138
*/
3139
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
3140
glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
3141
glBindBuffer(GL_ARRAY_BUFFER, 0);
3142
3143
glBindVertexArray(m_vao);
3144
3145
glBindVertexBuffer(0, 1234, 0, 12);
3146
if (glGetError() != GL_INVALID_OPERATION)
3147
{
3148
m_context.getTestContext().getLog()
3149
<< tcu::TestLog::Message
3150
<< "INVALID_OPERATION should be generated (buffer name not genned)."
3151
<< tcu::TestLog::EndMessage;
3152
return ERROR;
3153
}
3154
3155
GLint p;
3156
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &p);
3157
glBindVertexBuffer(p + 1, m_vbo, 0, 12);
3158
if (glGetError() != GL_INVALID_VALUE)
3159
{
3160
m_context.getTestContext().getLog()
3161
<< tcu::TestLog::Message
3162
<< "INVALID_VALUE should be generated (bindingIndex greater than "
3163
"GL_MAX_VERTEX_ATTRIB_BINDINGS)."
3164
<< tcu::TestLog::EndMessage;
3165
return ERROR;
3166
}
3167
3168
glBindVertexBuffer(0, m_vbo, -10, 12);
3169
if (glGetError() != GL_INVALID_VALUE)
3170
{
3171
m_context.getTestContext().getLog()
3172
<< tcu::TestLog::Message << "INVALID_VALUE should be generated (negative offset)."
3173
<< tcu::TestLog::EndMessage;
3174
return ERROR;
3175
}
3176
glBindVertexBuffer(0, m_vbo, 0, -12);
3177
if (glGetError() != GL_INVALID_VALUE)
3178
{
3179
m_context.getTestContext().getLog()
3180
<< tcu::TestLog::Message << "INVALID_VALUE should be generated (negative stride)."
3181
<< tcu::TestLog::EndMessage;
3182
return ERROR;
3183
}
3184
3185
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &p);
3186
glBindVertexBuffer(0, m_vbo, 0, p + 4);
3187
if (glGetError() != GL_INVALID_VALUE)
3188
{
3189
m_context.getTestContext().getLog() << tcu::TestLog::Message
3190
<< "INVALID_VALUE should be generated (stride "
3191
"greater than GL_MAX_VERTEX_ATTRIB_STRIDE)."
3192
<< tcu::TestLog::EndMessage;
3193
return ERROR;
3194
}
3195
3196
glBindVertexArray(0);
3197
glBindVertexBuffer(0, m_vbo, 0, 12);
3198
if (glGetError() != GL_INVALID_OPERATION)
3199
{
3200
m_context.getTestContext().getLog()
3201
<< tcu::TestLog::Message << "INVALID_OPERATION should be generated (default VAO)."
3202
<< tcu::TestLog::EndMessage;
3203
return ERROR;
3204
}
3205
3206
return NO_ERROR;
3207
}
3208
};
3209
//=============================================================================
3210
// 4.2 NegativeVertexAttribFormat
3211
//-----------------------------------------------------------------------------
3212
class NegativeVertexAttribFormat : public VertexAttribBindingBase
3213
{
3214
3215
GLuint m_vao, m_vbo;
3216
3217
virtual long Setup()
3218
{
3219
glGenVertexArrays(1, &m_vao);
3220
glGenBuffers(1, &m_vbo);
3221
return NO_ERROR;
3222
}
3223
3224
virtual long Cleanup()
3225
{
3226
glDeleteVertexArrays(1, &m_vao);
3227
glDeleteBuffers(1, &m_vbo);
3228
return NO_ERROR;
3229
}
3230
3231
virtual long Run()
3232
{
3233
/*
3234
Errors
3235
An INVALID_VALUE error is generated if attribindex is greater than or
3236
equal to the value of MAX_VERTEX_ATTRIBS.
3237
An INVALID_VALUE error is generated if size is not one of the values
3238
shown in table 10.2 for the corresponding command.
3239
An INVALID_ENUM error is generated if type is not one of the parameter
3240
token names from table 8.2 corresponding to one of the allowed GL data types
3241
for that command as shown in table 10.2.
3242
An INVALID_OPERATION error is generated under any of the following
3243
conditions:
3244
- if no vertex array object is currently bound (see section 10.4);
3245
- type is INT_2_10_10_10_REV or UNSIGNED_INT_2_10_10_10_-
3246
REV, and size is not 4;
3247
An INVALID_VALUE error is generated if relativeoffset is larger than the
3248
value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.
3249
*/
3250
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
3251
glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
3252
glBindBuffer(GL_ARRAY_BUFFER, 0);
3253
3254
glBindVertexArray(m_vao);
3255
3256
GLint p;
3257
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &p);
3258
glVertexAttribFormat(p + 1, 4, GL_FLOAT, GL_FALSE, 0);
3259
if (glGetError() != GL_INVALID_VALUE)
3260
{
3261
m_context.getTestContext().getLog() << tcu::TestLog::Message
3262
<< "INVALID_VALUE should be generated (attribindex "
3263
"greater than GL_MAX_VERTEX_ATTRIBS)."
3264
<< tcu::TestLog::EndMessage;
3265
return ERROR;
3266
}
3267
glVertexAttribIFormat(p + 2, 4, GL_INT, 0);
3268
if (glGetError() != GL_INVALID_VALUE)
3269
{
3270
m_context.getTestContext().getLog() << tcu::TestLog::Message
3271
<< "INVALID_VALUE should be generated (attribindex "
3272
"greater than GL_MAX_VERTEX_ATTRIBS)."
3273
<< tcu::TestLog::EndMessage;
3274
return ERROR;
3275
}
3276
glVertexAttribFormat(0, 0, GL_FLOAT, GL_FALSE, 0);
3277
if (glGetError() != GL_INVALID_VALUE)
3278
{
3279
m_context.getTestContext().getLog()
3280
<< tcu::TestLog::Message
3281
<< "INVALID_VALUE should be generated (invalid number of components)."
3282
<< tcu::TestLog::EndMessage;
3283
return ERROR;
3284
}
3285
glVertexAttribFormat(0, 5, GL_FLOAT, GL_FALSE, 0);
3286
if (glGetError() != GL_INVALID_VALUE)
3287
{
3288
m_context.getTestContext().getLog()
3289
<< tcu::TestLog::Message
3290
<< "INVALID_VALUE should be generated (invalid number of components)."
3291
<< tcu::TestLog::EndMessage;
3292
return ERROR;
3293
}
3294
glVertexAttribIFormat(0, 5, GL_INT, 0);
3295
if (glGetError() != GL_INVALID_VALUE)
3296
{
3297
m_context.getTestContext().getLog()
3298
<< tcu::TestLog::Message
3299
<< "INVALID_VALUE should be generated (invalid number of components)."
3300
<< tcu::TestLog::EndMessage;
3301
return ERROR;
3302
}
3303
glVertexAttribFormat(0, 4, GL_R32F, GL_FALSE, 0);
3304
if (glGetError() != GL_INVALID_ENUM)
3305
{
3306
m_context.getTestContext().getLog()
3307
<< tcu::TestLog::Message << "INVALID_ENUM should be generated (invalid type)."
3308
<< tcu::TestLog::EndMessage;
3309
return ERROR;
3310
}
3311
glVertexAttribIFormat(0, 4, GL_FLOAT, 0);
3312
if (glGetError() != GL_INVALID_ENUM)
3313
{
3314
m_context.getTestContext().getLog()
3315
<< tcu::TestLog::Message << "INVALID_ENUM should be generated (invalid type)."
3316
<< tcu::TestLog::EndMessage;
3317
return ERROR;
3318
}
3319
glVertexAttribFormat(0, 3, GL_INT_2_10_10_10_REV, GL_FALSE, 0);
3320
if (glGetError() != GL_INVALID_OPERATION)
3321
{
3322
m_context.getTestContext().getLog() << tcu::TestLog::Message
3323
<< "INVALID_OPERATION should be generated (invalid "
3324
"number of components for packed type)."
3325
<< tcu::TestLog::EndMessage;
3326
return ERROR;
3327
}
3328
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, &p);
3329
glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, p + 10);
3330
if (glGetError() != GL_INVALID_VALUE)
3331
{
3332
m_context.getTestContext().getLog()
3333
<< tcu::TestLog::Message
3334
<< "INVALID_VALUE should be generated (relativeoffset greater than "
3335
"GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)."
3336
<< tcu::TestLog::EndMessage;
3337
return ERROR;
3338
}
3339
glVertexAttribIFormat(0, 4, GL_INT, p + 10);
3340
if (glGetError() != GL_INVALID_VALUE)
3341
{
3342
m_context.getTestContext().getLog()
3343
<< tcu::TestLog::Message
3344
<< "INVALID_VALUE should be generated (relativeoffset greater than "
3345
"GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)."
3346
<< tcu::TestLog::EndMessage;
3347
return ERROR;
3348
}
3349
glBindVertexArray(0);
3350
glVertexAttribFormat(0, 4, GL_FLOAT, GL_FALSE, 0);
3351
if (glGetError() != GL_INVALID_OPERATION)
3352
{
3353
m_context.getTestContext().getLog()
3354
<< tcu::TestLog::Message << "INVALID_OPERATION should be generated (default VAO)."
3355
<< tcu::TestLog::EndMessage;
3356
return ERROR;
3357
}
3358
glVertexAttribIFormat(0, 4, GL_INT, 0);
3359
if (glGetError() != GL_INVALID_OPERATION)
3360
{
3361
m_context.getTestContext().getLog()
3362
<< tcu::TestLog::Message << "INVALID_OPERATION should be generated (default VAO)."
3363
<< tcu::TestLog::EndMessage;
3364
return ERROR;
3365
}
3366
return NO_ERROR;
3367
}
3368
};
3369
3370
//=============================================================================
3371
// 4.3 NegativeVertexAttribBinding
3372
//-----------------------------------------------------------------------------
3373
class NegativeVertexAttribBinding : public VertexAttribBindingBase
3374
{
3375
GLuint m_vao;
3376
3377
virtual long Setup()
3378
{
3379
glGenVertexArrays(1, &m_vao);
3380
return NO_ERROR;
3381
}
3382
3383
virtual long Cleanup()
3384
{
3385
glDeleteVertexArrays(1, &m_vao);
3386
return NO_ERROR;
3387
}
3388
3389
virtual long Run()
3390
{
3391
/*
3392
Errors
3393
An INVALID_VALUE error is generated if attribindex is greater than or
3394
equal to the value of MAX_VERTEX_ATTRIBS.
3395
An INVALID_VALUE error is generated if bindingindex is greater than or
3396
equal to the value of MAX_VERTEX_ATTRIB_BINDINGS.
3397
An INVALID_OPERATION error is generated if no vertex array object is
3398
bound.
3399
*/
3400
glBindVertexArray(m_vao);
3401
GLint p;
3402
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &p);
3403
glVertexAttribBinding(p + 1, 0);
3404
if (glGetError() != GL_INVALID_VALUE)
3405
{
3406
m_context.getTestContext().getLog() << tcu::TestLog::Message
3407
<< "INVALID_VALUE should be generated (attribindex "
3408
"greater than GL_MAX_VERTEX_ATTRIBS)."
3409
<< tcu::TestLog::EndMessage;
3410
return ERROR;
3411
}
3412
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &p);
3413
glVertexAttribBinding(0, p + 1);
3414
if (glGetError() != GL_INVALID_VALUE)
3415
{
3416
m_context.getTestContext().getLog()
3417
<< tcu::TestLog::Message
3418
<< "INVALID_VALUE should be generated (bindingIndex greater than "
3419
"GL_MAX_VERTEX_ATTRIB_BINDINGS)."
3420
<< tcu::TestLog::EndMessage;
3421
return ERROR;
3422
}
3423
glBindVertexArray(0);
3424
glVertexAttribBinding(0, 0);
3425
if (glGetError() != GL_INVALID_OPERATION)
3426
{
3427
m_context.getTestContext().getLog()
3428
<< tcu::TestLog::Message << "INVALID_OPERATION should be generated (default VAO)."
3429
<< tcu::TestLog::EndMessage;
3430
return ERROR;
3431
}
3432
return NO_ERROR;
3433
}
3434
};
3435
//=============================================================================
3436
// 4.4 NegativeVertexAttribDivisor
3437
//-----------------------------------------------------------------------------
3438
class NegativeVertexAttribDivisor : public VertexAttribBindingBase
3439
{
3440
3441
GLuint m_vao;
3442
3443
virtual long Setup()
3444
{
3445
glGenVertexArrays(1, &m_vao);
3446
return NO_ERROR;
3447
}
3448
3449
virtual long Cleanup()
3450
{
3451
glDeleteVertexArrays(1, &m_vao);
3452
return NO_ERROR;
3453
}
3454
3455
virtual long Run()
3456
{
3457
/*
3458
Errors
3459
An INVALID_VALUE error is generated if index is greater than or equal to
3460
the value of MAX_VERTEX_ATTRIBS.
3461
An INVALID_OPERATION error is generated if no vertex array object is
3462
bound.
3463
*/
3464
glBindVertexArray(m_vao);
3465
GLint p;
3466
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &p);
3467
glVertexBindingDivisor(p + 1, 1);
3468
if (glGetError() != GL_INVALID_VALUE)
3469
{
3470
m_context.getTestContext().getLog()
3471
<< tcu::TestLog::Message
3472
<< "INVALID_VALUE should be generated (bindingIndex greater than "
3473
"GL_MAX_VERTEX_ATTRIBS)."
3474
<< tcu::TestLog::EndMessage;
3475
return ERROR;
3476
}
3477
glBindVertexArray(0);
3478
glVertexBindingDivisor(0, 1);
3479
if (glGetError() != GL_INVALID_OPERATION)
3480
{
3481
m_context.getTestContext().getLog()
3482
<< tcu::TestLog::Message << "INVALID_OPERATION should be generated (default VAO)."
3483
<< tcu::TestLog::EndMessage;
3484
return ERROR;
3485
}
3486
return NO_ERROR;
3487
}
3488
};
3489
//=============================================================================
3490
3491
} // namespace
3492
VertexAttribBindingTests::VertexAttribBindingTests(glcts::Context &context)
3493
: TestCaseGroup(context, "vertex_attrib_binding", "")
3494
{}
3495
3496
VertexAttribBindingTests::~VertexAttribBindingTests(void) {}
3497
3498
void VertexAttribBindingTests::init()
3499
{
3500
using namespace glcts;
3501
addChild(new TestSubcase(m_context, "basic-usage", TestSubcase::Create<BasicUsage>));
3502
addChild(new TestSubcase(m_context, "basic-input-case1", TestSubcase::Create<BasicInputCase1>));
3503
addChild(new TestSubcase(m_context, "basic-input-case2", TestSubcase::Create<BasicInputCase2>));
3504
addChild(new TestSubcase(m_context, "basic-input-case3", TestSubcase::Create<BasicInputCase3>));
3505
addChild(new TestSubcase(m_context, "basic-input-case4", TestSubcase::Create<BasicInputCase4>));
3506
addChild(new TestSubcase(m_context, "basic-input-case5", TestSubcase::Create<BasicInputCase5>));
3507
addChild(new TestSubcase(m_context, "basic-input-case6", TestSubcase::Create<BasicInputCase6>));
3508
addChild(new TestSubcase(m_context, "basic-input-case8", TestSubcase::Create<BasicInputCase8>));
3509
addChild(new TestSubcase(m_context, "basic-input-case9", TestSubcase::Create<BasicInputCase9>));
3510
addChild(
3511
new TestSubcase(m_context, "basic-input-case11", TestSubcase::Create<BasicInputCase11>));
3512
addChild(
3513
new TestSubcase(m_context, "basic-input-case12", TestSubcase::Create<BasicInputCase12>));
3514
addChild(
3515
new TestSubcase(m_context, "basic-inputI-case1", TestSubcase::Create<BasicInputICase1>));
3516
addChild(
3517
new TestSubcase(m_context, "basic-inputI-case2", TestSubcase::Create<BasicInputICase2>));
3518
addChild(
3519
new TestSubcase(m_context, "basic-inputI-case3", TestSubcase::Create<BasicInputICase3>));
3520
addChild(new TestSubcase(m_context, "basic-state1", TestSubcase::Create<BasicState1>));
3521
addChild(new TestSubcase(m_context, "basic-state2", TestSubcase::Create<BasicState2>));
3522
addChild(new TestSubcase(m_context, "advanced-bindingUpdate",
3523
TestSubcase::Create<AdvancedBindingUpdate>));
3524
addChild(
3525
new TestSubcase(m_context, "advanced-iterations", TestSubcase::Create<AdvancedIterations>));
3526
addChild(new TestSubcase(m_context, "advanced-largeStrideAndOffsetsNewAndLegacyAPI",
3527
TestSubcase::Create<AdvancedLargeStrideAndOffsetsNewAndLegacyAPI>));
3528
addChild(new TestSubcase(m_context, "negative-bindVertexBuffer",
3529
TestSubcase::Create<NegativeBindVertexBuffer>));
3530
addChild(new TestSubcase(m_context, "negative-vertexAttribFormat",
3531
TestSubcase::Create<NegativeVertexAttribFormat>));
3532
addChild(new TestSubcase(m_context, "negative-vertexAttribBinding",
3533
TestSubcase::Create<NegativeVertexAttribBinding>));
3534
addChild(new TestSubcase(m_context, "negative-vertexAttribDivisor",
3535
TestSubcase::Create<NegativeVertexAttribDivisor>));
3536
}
3537
} // namespace glcts
3538
3539