1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RobustClientMemoryTest.cpp : Tests of the GL_ANGLE_robust_client_memory extension.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
namespace angle
{
class RobustClientMemoryTest : public ANGLETest
{
protected:
RobustClientMemoryTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
void SetUp() override
{
ANGLETest::SetUp();
glGetBooleanvRobustANGLE = reinterpret_cast<PFNGLGETBOOLEANVROBUSTANGLE>(
eglGetProcAddress("glGetBooleanvRobustANGLE"));
glGetBufferParameterivRobustANGLE = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetBufferParameterivRobustANGLE"));
glGetFloatvRobustANGLE = reinterpret_cast<PFNGLGETFLOATVROBUSTANGLE>(
eglGetProcAddress("glGetFloatvRobustANGLE"));
glGetFramebufferAttachmentParameterivRobustANGLE =
reinterpret_cast<PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetFramebufferAttachmentParameterivRobustANGLE"));
glGetIntegervRobustANGLE = reinterpret_cast<PFNGLGETINTEGERVROBUSTANGLE>(
eglGetProcAddress("glGetIntegervRobustANGLE"));
glGetProgramivRobustANGLE = reinterpret_cast<PFNGLGETPROGRAMIVROBUSTANGLE>(
eglGetProcAddress("glGetProgramivRobustANGLE"));
glGetRenderbufferParameterivRobustANGLE =
reinterpret_cast<PFNGLGETRENDERBUFFERPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetRenderbufferParameterivRobustANGLE"));
glGetShaderivRobustANGLE = reinterpret_cast<PFNGLGETSHADERIVROBUSTANGLE>(
eglGetProcAddress("glGetShaderivRobustANGLE"));
glGetTexParameterfvRobustANGLE = reinterpret_cast<PFNGLGETTEXPARAMETERFVROBUSTANGLE>(
eglGetProcAddress("glGetTexParameterfvRobustANGLE"));
glGetTexParameterivRobustANGLE = reinterpret_cast<PFNGLGETTEXPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetTexParameterivRobustANGLE"));
glGetUniformfvRobustANGLE = reinterpret_cast<PFNGLGETUNIFORMFVROBUSTANGLE>(
eglGetProcAddress("glGetUniformfvRobustANGLE"));
glGetUniformivRobustANGLE = reinterpret_cast<PFNGLGETUNIFORMIVROBUSTANGLE>(
eglGetProcAddress("glGetUniformivRobustANGLE"));
glGetVertexAttribfvRobustANGLE = reinterpret_cast<PFNGLGETVERTEXATTRIBFVROBUSTANGLE>(
eglGetProcAddress("glGetVertexAttribfvRobustANGLE"));
glGetVertexAttribivRobustANGLE = reinterpret_cast<PFNGLGETVERTEXATTRIBIVROBUSTANGLE>(
eglGetProcAddress("glGetVertexAttribivRobustANGLE"));
glGetVertexAttribPointervRobustANGLE =
reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVROBUSTANGLE>(
eglGetProcAddress("glGetVertexAttribPointervRobustANGLE"));
glReadPixelsRobustANGLE = reinterpret_cast<PFNGLREADPIXELSROBUSTANGLE>(
eglGetProcAddress("glReadPixelsRobustANGLE"));
glTexImage2DRobustANGLE = reinterpret_cast<PFNGLTEXIMAGE2DROBUSTANGLE>(
eglGetProcAddress("glTexImage2DRobustANGLE"));
glTexParameterfvRobustANGLE = reinterpret_cast<PFNGLTEXPARAMETERFVROBUSTANGLE>(
eglGetProcAddress("glTexParameterfvRobustANGLE"));
glTexParameterivRobustANGLE = reinterpret_cast<PFNGLTEXPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glTexParameterivRobustANGLE"));
glTexSubImage2DRobustANGLE = reinterpret_cast<PFNGLTEXSUBIMAGE2DROBUSTANGLE>(
eglGetProcAddress("glTexSubImage2DRobustANGLE"));
glTexImage3DRobustANGLE = reinterpret_cast<PFNGLTEXIMAGE3DROBUSTANGLE>(
eglGetProcAddress("glTexImage3DRobustANGLE"));
glTexSubImage3DRobustANGLE = reinterpret_cast<PFNGLTEXSUBIMAGE3DROBUSTANGLE>(
eglGetProcAddress("glTexSubImage3DRobustANGLE"));
glGetQueryivRobustANGLE = reinterpret_cast<PFNGLGETQUERYIVROBUSTANGLE>(
eglGetProcAddress("glGetQueryivRobustANGLE"));
glGetQueryObjectuivRobustANGLE = reinterpret_cast<PFNGLGETQUERYOBJECTUIVROBUSTANGLE>(
eglGetProcAddress("glGetQueryObjectuivRobustANGLE"));
glGetBufferPointervRobustANGLE = reinterpret_cast<PFNGLGETBUFFERPOINTERVROBUSTANGLE>(
eglGetProcAddress("glGetBufferPointervRobustANGLE"));
glGetIntegeri_vRobustANGLE = reinterpret_cast<PFNGLGETINTEGERI_VROBUSTANGLE>(
eglGetProcAddress("glGetIntegeri_vRobustANGLE"));
glGetInternalformativRobustANGLE = reinterpret_cast<PFNGETINTERNALFORMATIVROBUSTANGLE>(
eglGetProcAddress("glGetInternalformativRobustANGLE"));
glGetVertexAttribIivRobustANGLE = reinterpret_cast<PFNGLGETVERTEXATTRIBIIVROBUSTANGLE>(
eglGetProcAddress("glGetVertexAttribIivRobustANGLE"));
glGetVertexAttribIuivRobustANGLE = reinterpret_cast<PFNGLGETVERTEXATTRIBIUIVROBUSTANGLE>(
eglGetProcAddress("glGetVertexAttribIuivRobustANGLE"));
glGetUniformuivRobustANGLE = reinterpret_cast<PFNGLGETUNIFORMUIVROBUSTANGLE>(
eglGetProcAddress("glGetUniformuivRobustANGLE"));
glGetActiveUniformBlockivRobustANGLE =
reinterpret_cast<PFNGLGETACTIVEUNIFORMBLOCKIVROBUSTANGLE>(
eglGetProcAddress("glGetActiveUniformBlockivRobustANGLE"));
glGetInteger64vRobustANGLE = reinterpret_cast<PFNGLGETINTEGER64VROBUSTANGLE>(
eglGetProcAddress("glGetInteger64vRobustANGLE"));
glGetInteger64i_vRobustANGLE = reinterpret_cast<PFNGLGETINTEGER64I_VROBUSTANGLE>(
eglGetProcAddress("glGetInteger64i_vRobustANGLE"));
glGetBufferParameteri64vRobustANGLE =
reinterpret_cast<PFNGLGETBUFFERPARAMETERI64VROBUSTANGLE>(
eglGetProcAddress("glGetBufferParameteri64vRobustANGLE"));
glSamplerParameterivRobustANGLE = reinterpret_cast<PFNGLSAMPLERPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glSamplerParameterivRobustANGLE"));
glSamplerParameterfvRobustANGLE = reinterpret_cast<PFNGLSAMPLERPARAMETERFVROBUSTANGLE>(
eglGetProcAddress("glSamplerParameterfvRobustANGLE"));
glGetSamplerParameterivRobustANGLE =
reinterpret_cast<PFNGLGETSAMPLERPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetSamplerParameterivRobustANGLE"));
glGetSamplerParameterfvRobustANGLE =
reinterpret_cast<PFNGLGETSAMPLERPARAMETERFVROBUSTANGLE>(
eglGetProcAddress("glGetSamplerParameterfvRobustANGLE"));
glGetFramebufferParameterivRobustANGLE =
reinterpret_cast<PFNGLGETFRAMEBUFFERPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetFramebufferParameterivRobustANGLE"));
glGetProgramInterfaceivRobustANGLE =
reinterpret_cast<PFNGLGETPROGRAMINTERFACEIVROBUSTANGLE>(
eglGetProcAddress("glGetProgramInterfaceivRobustANGLE"));
glGetBooleani_vRobustANGLE = reinterpret_cast<PFNGLGETBOOLEANI_VROBUSTANGLE>(
eglGetProcAddress("glGetBooleani_vRobustANGLE"));
glGetMultisamplefvRobustANGLE = reinterpret_cast<PFNGLGETMULTISAMPLEFVROBUSTANGLE>(
eglGetProcAddress("glGetMultisamplefvRobustANGLE"));
glGetTexLevelParameterivRobustANGLE =
reinterpret_cast<PFNGLGETTEXLEVELPARAMETERIVROBUSTANGLE>(
eglGetProcAddress("glGetTexLevelParameterivRobustANGLE"));
glGetTexLevelParameterfvRobustANGLE =
reinterpret_cast<PFNGLGETTEXLEVELPARAMETERFVROBUSTANGLE>(
eglGetProcAddress("glGetTexLevelParameterfvRobustANGLE"));
glGetPointervRobustANGLERobustANGLE =
reinterpret_cast<PFNGLGETPOINTERVROBUSTANGLEROBUSTANGLE>(
eglGetProcAddress("glGetPointervRobustANGLERobustANGLE"));
glReadnPixelsRobustANGLE = reinterpret_cast<PFNGLREADNPIXELSROBUSTANGLE>(
eglGetProcAddress("glReadnPixelsRobustANGLE"));
glGetnUniformfvRobustANGLE = reinterpret_cast<PFNGLGETNUNIFORMFVROBUSTANGLE>(
eglGetProcAddress("glGetnUniformfvRobustANGLE"));
glGetnUniformivRobustANGLE = reinterpret_cast<PFNGLGETNUNIFORMIVROBUSTANGLE>(
eglGetProcAddress("glGetnUniformivRobustANGLE"));
glGetnUniformuivRobustANGLE = reinterpret_cast<PFNGLGETNUNIFORMUIVROBUSTANGLE>(
eglGetProcAddress("glGetnUniformuivRobustANGLE"));
glTexParameterIivRobustANGLE = reinterpret_cast<PFNGLTEXPARAMETERIIVROBUSTANGLE>(
eglGetProcAddress("glTexParameterIivRobustANGLE"));
glTexParameterIuivRobustANGLE = reinterpret_cast<PFNGLTEXPARAMETERIUIVROBUSTANGLE>(
eglGetProcAddress("glTexParameterIuivRobustANGLE"));
glGetTexParameterIivRobustANGLE = reinterpret_cast<PFNGLGETTEXPARAMETERIIVROBUSTANGLE>(
eglGetProcAddress("glGetTexParameterIivRobustANGLE"));
glGetTexParameterIuivRobustANGLE = reinterpret_cast<PFNGLGETTEXPARAMETERIUIVROBUSTANGLE>(
eglGetProcAddress("glGetTexParameterIuivRobustANGLE"));
glSamplerParameterIivRobustANGLE = reinterpret_cast<PFNGLSAMPLERPARAMETERIIVROBUSTANGLE>(
eglGetProcAddress("glSamplerParameterIivRobustANGLE"));
glSamplerParameterIuivRobustANGLE = reinterpret_cast<PFNGLSAMPLERPARAMETERIUIVROBUSTANGLE>(
eglGetProcAddress("glSamplerParameterIuivRobustANGLE"));
glGetSamplerParameterIivRobustANGLE =
reinterpret_cast<PFNGLGETSAMPLERPARAMETERIIVROBUSTANGLE>(
eglGetProcAddress("glGetSamplerParameterIivRobustANGLE"));
glGetSamplerParameterIuivRobustANGLE =
reinterpret_cast<PFNGLGETSAMPLERPARAMETERIUIVROBUSTANGLE>(
eglGetProcAddress("glGetSamplerParameterIuivRobustANGLE"));
glGetQueryObjectivRobustANGLE = reinterpret_cast<PFNGLGETQUERYOBJECTIVROBUSTANGLE>(
eglGetProcAddress("glGetQueryObjectivRobustANGLE"));
glGetQueryObjecti64vRobustANGLE = reinterpret_cast<PFNGLGETQUERYOBJECTI64VROBUSTANGLE>(
eglGetProcAddress("glGetQueryObjecti64vRobustANGLE"));
glGetQueryObjectui64vRobustANGLE = reinterpret_cast<PFNGLGETQUERYOBJECTUI64VROBUSTANGLE>(
eglGetProcAddress("glGetQueryObjectui64vRobustANGLE"));
}
void TearDown() override { ANGLETest::TearDown(); }
bool extensionsPresent() const
{
if (!extensionEnabled("GL_ANGLE_robust_client_memory"))
{
std::cout << "Test skipped because GL_ANGLE_robust_client_memory is not available.";
return false;
}
return true;
}
PFNGLGETBOOLEANVROBUSTANGLE glGetBooleanvRobustANGLE = nullptr;
PFNGLGETBUFFERPARAMETERIVROBUSTANGLE glGetBufferParameterivRobustANGLE = nullptr;
PFNGLGETFLOATVROBUSTANGLE glGetFloatvRobustANGLE = nullptr;
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVROBUSTANGLE
glGetFramebufferAttachmentParameterivRobustANGLE = nullptr;
PFNGLGETINTEGERVROBUSTANGLE glGetIntegervRobustANGLE = nullptr;
PFNGLGETPROGRAMIVROBUSTANGLE glGetProgramivRobustANGLE = nullptr;
PFNGLGETRENDERBUFFERPARAMETERIVROBUSTANGLE glGetRenderbufferParameterivRobustANGLE = nullptr;
PFNGLGETSHADERIVROBUSTANGLE glGetShaderivRobustANGLE = nullptr;
PFNGLGETTEXPARAMETERFVROBUSTANGLE glGetTexParameterfvRobustANGLE = nullptr;
PFNGLGETTEXPARAMETERIVROBUSTANGLE glGetTexParameterivRobustANGLE = nullptr;
PFNGLGETUNIFORMFVROBUSTANGLE glGetUniformfvRobustANGLE = nullptr;
PFNGLGETUNIFORMIVROBUSTANGLE glGetUniformivRobustANGLE = nullptr;
PFNGLGETVERTEXATTRIBFVROBUSTANGLE glGetVertexAttribfvRobustANGLE = nullptr;
PFNGLGETVERTEXATTRIBIVROBUSTANGLE glGetVertexAttribivRobustANGLE = nullptr;
PFNGLGETVERTEXATTRIBPOINTERVROBUSTANGLE glGetVertexAttribPointervRobustANGLE = nullptr;
PFNGLREADPIXELSROBUSTANGLE glReadPixelsRobustANGLE = nullptr;
PFNGLTEXIMAGE2DROBUSTANGLE glTexImage2DRobustANGLE = nullptr;
PFNGLTEXPARAMETERFVROBUSTANGLE glTexParameterfvRobustANGLE = nullptr;
PFNGLTEXPARAMETERIVROBUSTANGLE glTexParameterivRobustANGLE = nullptr;
PFNGLTEXSUBIMAGE2DROBUSTANGLE glTexSubImage2DRobustANGLE = nullptr;
PFNGLTEXIMAGE3DROBUSTANGLE glTexImage3DRobustANGLE = nullptr;
PFNGLTEXSUBIMAGE3DROBUSTANGLE glTexSubImage3DRobustANGLE = nullptr;
PFNGLGETQUERYIVROBUSTANGLE glGetQueryivRobustANGLE = nullptr;
PFNGLGETQUERYOBJECTUIVROBUSTANGLE glGetQueryObjectuivRobustANGLE = nullptr;
PFNGLGETBUFFERPOINTERVROBUSTANGLE glGetBufferPointervRobustANGLE = nullptr;
PFNGLGETINTEGERI_VROBUSTANGLE glGetIntegeri_vRobustANGLE = nullptr;
PFNGETINTERNALFORMATIVROBUSTANGLE glGetInternalformativRobustANGLE = nullptr;
PFNGLGETVERTEXATTRIBIIVROBUSTANGLE glGetVertexAttribIivRobustANGLE = nullptr;
PFNGLGETVERTEXATTRIBIUIVROBUSTANGLE glGetVertexAttribIuivRobustANGLE = nullptr;
PFNGLGETUNIFORMUIVROBUSTANGLE glGetUniformuivRobustANGLE = nullptr;
PFNGLGETACTIVEUNIFORMBLOCKIVROBUSTANGLE glGetActiveUniformBlockivRobustANGLE = nullptr;
PFNGLGETINTEGER64VROBUSTANGLE glGetInteger64vRobustANGLE = nullptr;
PFNGLGETINTEGER64I_VROBUSTANGLE glGetInteger64i_vRobustANGLE = nullptr;
PFNGLGETBUFFERPARAMETERI64VROBUSTANGLE glGetBufferParameteri64vRobustANGLE = nullptr;
PFNGLSAMPLERPARAMETERIVROBUSTANGLE glSamplerParameterivRobustANGLE = nullptr;
PFNGLSAMPLERPARAMETERFVROBUSTANGLE glSamplerParameterfvRobustANGLE = nullptr;
PFNGLGETSAMPLERPARAMETERIVROBUSTANGLE glGetSamplerParameterivRobustANGLE = nullptr;
PFNGLGETSAMPLERPARAMETERFVROBUSTANGLE glGetSamplerParameterfvRobustANGLE = nullptr;
PFNGLGETFRAMEBUFFERPARAMETERIVROBUSTANGLE glGetFramebufferParameterivRobustANGLE = nullptr;
PFNGLGETPROGRAMINTERFACEIVROBUSTANGLE glGetProgramInterfaceivRobustANGLE = nullptr;
PFNGLGETBOOLEANI_VROBUSTANGLE glGetBooleani_vRobustANGLE = nullptr;
PFNGLGETMULTISAMPLEFVROBUSTANGLE glGetMultisamplefvRobustANGLE = nullptr;
PFNGLGETTEXLEVELPARAMETERIVROBUSTANGLE glGetTexLevelParameterivRobustANGLE = nullptr;
PFNGLGETTEXLEVELPARAMETERFVROBUSTANGLE glGetTexLevelParameterfvRobustANGLE = nullptr;
PFNGLGETPOINTERVROBUSTANGLEROBUSTANGLE glGetPointervRobustANGLERobustANGLE = nullptr;
PFNGLREADNPIXELSROBUSTANGLE glReadnPixelsRobustANGLE = nullptr;
PFNGLGETNUNIFORMFVROBUSTANGLE glGetnUniformfvRobustANGLE = nullptr;
PFNGLGETNUNIFORMIVROBUSTANGLE glGetnUniformivRobustANGLE = nullptr;
PFNGLGETNUNIFORMUIVROBUSTANGLE glGetnUniformuivRobustANGLE = nullptr;
PFNGLTEXPARAMETERIIVROBUSTANGLE glTexParameterIivRobustANGLE = nullptr;
PFNGLTEXPARAMETERIUIVROBUSTANGLE glTexParameterIuivRobustANGLE = nullptr;
PFNGLGETTEXPARAMETERIIVROBUSTANGLE glGetTexParameterIivRobustANGLE = nullptr;
PFNGLGETTEXPARAMETERIUIVROBUSTANGLE glGetTexParameterIuivRobustANGLE = nullptr;
PFNGLSAMPLERPARAMETERIIVROBUSTANGLE glSamplerParameterIivRobustANGLE = nullptr;
PFNGLSAMPLERPARAMETERIUIVROBUSTANGLE glSamplerParameterIuivRobustANGLE = nullptr;
PFNGLGETSAMPLERPARAMETERIIVROBUSTANGLE glGetSamplerParameterIivRobustANGLE = nullptr;
PFNGLGETSAMPLERPARAMETERIUIVROBUSTANGLE glGetSamplerParameterIuivRobustANGLE = nullptr;
PFNGLGETQUERYOBJECTIVROBUSTANGLE glGetQueryObjectivRobustANGLE = nullptr;
PFNGLGETQUERYOBJECTI64VROBUSTANGLE glGetQueryObjecti64vRobustANGLE = nullptr;
PFNGLGETQUERYOBJECTUI64VROBUSTANGLE glGetQueryObjectui64vRobustANGLE = nullptr;
};
// Test basic usage and validation of glGetIntegervRobustANGLE
TEST_P(RobustClientMemoryTest, GetInteger)
{
if (!extensionsPresent())
{
return;
}
// Verify that the robust and regular entry points return the same values
GLint resultRobust;
GLsizei length;
glGetIntegervRobustANGLE(GL_MAX_VERTEX_ATTRIBS, 1, &length, &resultRobust);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(1, length);
GLint resultRegular;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &resultRegular);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(resultRegular, resultRobust);
// Query a dynamic value
GLint numCompressedFormats;
glGetIntegervRobustANGLE(GL_NUM_COMPRESSED_TEXTURE_FORMATS, 1, &length, &numCompressedFormats);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(1, length);
if (numCompressedFormats > 0)
{
std::vector<GLint> resultBuf(numCompressedFormats * 2, 0);
// Test when the bufSize is too low
glGetIntegervRobustANGLE(GL_COMPRESSED_TEXTURE_FORMATS, numCompressedFormats - 1, &length,
resultBuf.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
EXPECT_TRUE(std::all_of(resultBuf.begin(), resultBuf.end(),
[](GLint value) { return value == 0; }));
// Make sure the GL doesn't touch the end of the buffer
glGetIntegervRobustANGLE(GL_COMPRESSED_TEXTURE_FORMATS,
static_cast<GLsizei>(resultBuf.size()), &length, resultBuf.data());
EXPECT_GL_NO_ERROR();
EXPECT_EQ(numCompressedFormats, length);
EXPECT_TRUE(std::none_of(resultBuf.begin(), resultBuf.begin() + length,
[](GLint value) { return value == 0; }));
EXPECT_TRUE(std::all_of(resultBuf.begin() + length, resultBuf.end(),
[](GLint value) { return value == 0; }));
}
// Test with null length
glGetIntegervRobustANGLE(GL_MAX_VARYING_VECTORS, 1, nullptr, &resultRobust);
EXPECT_GL_NO_ERROR();
glGetIntegervRobustANGLE(GL_MAX_VIEWPORT_DIMS, 1, nullptr, &resultRobust);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
GLint maxViewportDims[2];
glGetIntegervRobustANGLE(GL_MAX_VIEWPORT_DIMS, 2, nullptr, maxViewportDims);
EXPECT_GL_NO_ERROR();
}
// Test basic usage and validation of glTexImage2DRobustANGLE
TEST_P(RobustClientMemoryTest, TexImage2D)
{
if (!extensionsPresent())
{
return;
}
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex.get());
GLsizei dataDimension = 1024;
std::vector<GLubyte> rgbaData(dataDimension * dataDimension * 4);
// Test the regular case
glTexImage2DRobustANGLE(GL_TEXTURE_2D, 0, GL_RGBA, dataDimension, dataDimension, 0, GL_RGBA,
GL_UNSIGNED_BYTE, static_cast<GLsizei>(rgbaData.size()),
rgbaData.data());
EXPECT_GL_NO_ERROR();
// Test with a data size that is too small
glTexImage2DRobustANGLE(GL_TEXTURE_2D, 0, GL_RGBA, dataDimension, dataDimension, 0, GL_RGBA,
GL_UNSIGNED_BYTE, static_cast<GLsizei>(rgbaData.size()) / 2,
rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
if (getClientMajorVersion() >= 3)
{
// Set an unpack parameter that would cause the driver to read past the end of the buffer
glPixelStorei(GL_UNPACK_ROW_LENGTH, dataDimension + 1);
glTexImage2DRobustANGLE(GL_TEXTURE_2D, 0, GL_RGBA, dataDimension, dataDimension, 0, GL_RGBA,
GL_UNSIGNED_BYTE, static_cast<GLsizei>(rgbaData.size()),
rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
}
// Test basic usage and validation of glReadPixelsRobustANGLE
TEST_P(RobustClientMemoryTest, ReadPixels)
{
if (!extensionsPresent())
{
return;
}
GLsizei dataDimension = 16;
std::vector<GLubyte> rgbaData(dataDimension * dataDimension * 4);
// Test the regular case
GLsizei length = 0;
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()), &length, rgbaData.data());
EXPECT_GL_NO_ERROR();
EXPECT_EQ(static_cast<GLsizei>(rgbaData.size()), length);
// Test with a data size that is too small
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()) - 1, &length, rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
if (getClientMajorVersion() >= 3)
{
// Set a pack parameter that would cause the driver to write past the end of the buffer
glPixelStorei(GL_PACK_ROW_LENGTH, dataDimension + 1);
glReadPixelsRobustANGLE(0, 0, dataDimension, dataDimension, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(rgbaData.size()), &length, rgbaData.data());
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(RobustClientMemoryTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_D3D11_FL9_3(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES());
} // namespace
|