Use NEAREST filtering for integer formats in sparse access tests

Component: OpenGL

Affects: KHR-GL46.sparse_texture2_tests.SparseTexture2Lookup

VK-GL-CTS issue: 5018

Change-Id: I37f5f22acb8c73a81294dec052d8e944cd3fd96e
diff --git a/external/openglcts/modules/gl/gl4cSparseTexture2Tests.cpp b/external/openglcts/modules/gl/gl4cSparseTexture2Tests.cpp
index b755eda..7f9a23d 100644
--- a/external/openglcts/modules/gl/gl4cSparseTexture2Tests.cpp
+++ b/external/openglcts/modules/gl/gl4cSparseTexture2Tests.cpp
@@ -2446,6 +2446,11 @@
 				if (format == GL_DEPTH_COMPONENT16)
 					setupDepthMode(gl, target, texture);
 
+				if ((getTextureChannelClass(mState.format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
+						getTextureChannelClass(mState.format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER) &&
+					target != GL_TEXTURE_2D_MULTISAMPLE && target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
+					setupNearestFilter(gl, target, texture);
+
 				for (int l = 0; l < mState.levels; ++l)
 				{
 					if (commitTexturePage(gl, target, format, texture, l))
@@ -2843,6 +2848,21 @@
 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
 }
 
+/** Setup nearest filtering for a texture
+ *
+ * @param gl           GL API functions
+ * @param target       Target for which texture is binded
+ * @param texture      Texture object
+ */
+void SparseTexture2LookupTestCase::setupNearestFilter(const Functions& gl, GLint target, GLuint& texture)
+{
+	Texture::Bind(gl, texture, target);
+    gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
+    gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
+}
+
 /** Verify if data stored in texture is as expected
  *
  * @param gl           GL API functions
diff --git a/external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp b/external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp
index 56e3feb..0c3bac6 100644
--- a/external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp
+++ b/external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp
@@ -259,6 +259,7 @@
 	virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
 
 	virtual void setupDepthMode(const Functions& gl, GLint target, GLuint& texture);
+	virtual void setupNearestFilter(const Functions& gl, GLint target, GLuint& texture);
 	virtual bool verifyLookupTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
 										 FunctionToken& funcToken);
 };