Use glReadnPixels only if KHR_robustness is supported

glReadnPixels is introduced in KHR_robustness/GLES 3.2.
Use of this function in GLES 3.1 tests will result in segfault
on implementations that don't support KHR_robustness.

Components: AOSP, Framework

Affects: dEQP-GLES31.functional.debug.negative_coverage.callbacks.buffer.read_pixels_format_mismatch

VK-GL-CTS issue: 166

Change-Id: Idbe8734f7d82882ea99c75a8b74d693ac6dd831f
diff --git a/framework/opengl/wrapper/glwEnums.inl b/framework/opengl/wrapper/glwEnums.inl
index 0f08910..22aa3b5 100644
--- a/framework/opengl/wrapper/glwEnums.inl
+++ b/framework/opengl/wrapper/glwEnums.inl
@@ -453,14 +453,19 @@
 #define GL_DEBUG_TYPE_OTHER												0x8251
 #define GL_DEBUG_TYPE_OTHER_KHR											0x8251
 #define GL_LOSE_CONTEXT_ON_RESET										0x8252
+#define GL_LOSE_CONTEXT_ON_RESET_EXT									0x8252
 #define GL_LOSE_CONTEXT_ON_RESET_KHR									0x8252
 #define GL_GUILTY_CONTEXT_RESET											0x8253
+#define GL_GUILTY_CONTEXT_RESET_EXT										0x8253
 #define GL_GUILTY_CONTEXT_RESET_KHR										0x8253
 #define GL_INNOCENT_CONTEXT_RESET										0x8254
+#define GL_INNOCENT_CONTEXT_RESET_EXT									0x8254
 #define GL_INNOCENT_CONTEXT_RESET_KHR									0x8254
 #define GL_UNKNOWN_CONTEXT_RESET										0x8255
+#define GL_UNKNOWN_CONTEXT_RESET_EXT									0x8255
 #define GL_UNKNOWN_CONTEXT_RESET_KHR									0x8255
 #define GL_RESET_NOTIFICATION_STRATEGY									0x8256
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT								0x8256
 #define GL_RESET_NOTIFICATION_STRATEGY_KHR								0x8256
 #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT								0x8257
 #define GL_PROGRAM_SEPARABLE											0x8258
@@ -479,6 +484,7 @@
 #define GL_UNDEFINED_VERTEX												0x8260
 #define GL_UNDEFINED_VERTEX_EXT											0x8260
 #define GL_NO_RESET_NOTIFICATION										0x8261
+#define GL_NO_RESET_NOTIFICATION_EXT									0x8261
 #define GL_NO_RESET_NOTIFICATION_KHR									0x8261
 #define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE								0x8262
 #define GL_MAX_COMPUTE_UNIFORM_COMPONENTS								0x8263
@@ -1426,6 +1432,7 @@
 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER			0x90ED
 #define GL_DISPATCH_INDIRECT_BUFFER										0x90EE
 #define GL_DISPATCH_INDIRECT_BUFFER_BINDING								0x90EF
+#define GL_CONTEXT_ROBUST_ACCESS_EXT									0x90F3
 #define GL_CONTEXT_ROBUST_ACCESS_KHR									0x90F3
 #define GL_TEXTURE_2D_MULTISAMPLE										0x9100
 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE									0x9101
diff --git a/framework/opengl/wrapper/glwInitExtES.inl b/framework/opengl/wrapper/glwInitExtES.inl
index 93d04ad..7272074 100644
--- a/framework/opengl/wrapper/glwInitExtES.inl
+++ b/framework/opengl/wrapper/glwInitExtES.inl
@@ -43,6 +43,14 @@
 	gl->framebufferTexture	= (glFramebufferTextureFunc)	loader->get("glFramebufferTextureEXT");
 }
 
+if (de::contains(extSet, "GL_EXT_robustness"))
+{
+	gl->getGraphicsResetStatus	= (glGetGraphicsResetStatusFunc)	loader->get("glGetGraphicsResetStatusEXT");
+	gl->getnUniformfv			= (glGetnUniformfvFunc)				loader->get("glGetnUniformfvEXT");
+	gl->getnUniformiv			= (glGetnUniformivFunc)				loader->get("glGetnUniformivEXT");
+	gl->readnPixels				= (glReadnPixelsFunc)				loader->get("glReadnPixelsEXT");
+}
+
 if (de::contains(extSet, "GL_EXT_texture_buffer"))
 {
 	gl->texBuffer		= (glTexBufferFunc)			loader->get("glTexBufferEXT");
diff --git a/modules/gles31/functional/es31fNegativeBufferApiTests.cpp b/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
index 309a507..39474ee 100644
--- a/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
+++ b/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
@@ -196,6 +196,7 @@
 
 void readn_pixels (NegativeTestContext& ctx)
 {
+	std::vector<GLfloat>	floatData	(4);
 	std::vector<GLubyte>	ubyteData	(4);
 	GLuint					fbo			= 0x1234;
 
@@ -223,6 +224,8 @@
 	ctx.beginSection("GL_INVALID_OPERATION is generated by ReadnPixels if the buffer size required to store the requested data is larger than bufSize.");
 	ctx.glReadnPixels(0, 0, 0x1234, 0x1234, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
 	ctx.expectError(GL_INVALID_OPERATION);
+	ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
+	ctx.expectError(GL_INVALID_OPERATION);
 	ctx.endSection();
 
 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
@@ -240,7 +243,6 @@
 {
 	std::vector<GLubyte>	ubyteData	(4);
 	std::vector<GLushort>	ushortData	(4);
-	std::vector<GLfloat>	floatData	(4);
 	GLint					readFormat	= 0x1234;
 	GLint					readType	= 0x1234;
 
@@ -257,8 +259,6 @@
 	ctx.expectError(GL_INVALID_OPERATION);
 	ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
 	ctx.expectError(GL_INVALID_OPERATION);
-	ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
-	ctx.expectError(GL_INVALID_OPERATION);
 	ctx.endSection();
 
 	ctx.beginSection("GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
diff --git a/scripts/opengl/src_util.py b/scripts/opengl/src_util.py
index 03f0314..0b13e29 100644
--- a/scripts/opengl/src_util.py
+++ b/scripts/opengl/src_util.py
@@ -51,6 +51,7 @@
 	'GL_EXT_geometry_point_size',
 	'GL_EXT_tessellation_shader',
 	'GL_EXT_geometry_shader',
+	'GL_EXT_robustness',
 	'GL_EXT_texture_buffer',
 	'GL_EXT_texture_cube_map_array',
 	'GL_EXT_texture_snorm',