[Piglit] [PATCH 2/4] textureSize: Add testing of GLSL 1.40's texture buffers.

Eric Anholt eric at anholt.net
Fri Apr 13 16:35:32 PDT 2012


---
 tests/texturing/shaders/common.c      |   19 ++++++++++++++++++-
 tests/texturing/shaders/textureSize.c |   21 ++++++++++++++++-----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index 848b415..0e2c4be 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -45,6 +45,7 @@ upload_miplevel_data(GLenum target, int level, void *level_image)
 	const GLenum format          = sampler.format;
 	const GLenum internal_format = sampler.internal_format;
 	const GLenum data_type       = sampler.data_type;
+	GLuint bo;
 
 	switch (target) {
 	case GL_TEXTURE_1D:
@@ -77,6 +78,15 @@ upload_miplevel_data(GLenum target, int level, void *level_image)
 			     level_size[level][0], level_size[level][2],
 			     0, format, data_type, level_image);
 		break;
+
+	case GL_TEXTURE_BUFFER:
+		glGenBuffers(1, &bo);
+		glBindBuffer(GL_TEXTURE_BUFFER, bo);
+		glBufferData(GL_TEXTURE_BUFFER, 16 * level_size[level][0],
+			     level_image, GL_STATIC_DRAW);
+		glTexBuffer(GL_TEXTURE_BUFFER, internal_format, bo);
+		break;
+
 	default:
 		assert(!"Not implemented yet.");
 		break;
@@ -122,7 +132,8 @@ compute_miplevel_info()
 
 	miplevels = (int) log2f(max_dimension) + 1;
 
-	if (sampler.target == GL_TEXTURE_RECTANGLE)
+	if (sampler.target == GL_TEXTURE_RECTANGLE ||
+	    sampler.target == GL_TEXTURE_BUFFER)
 		miplevels = 1;
 
 	/* Compute the size of each miplevel */
@@ -194,6 +205,7 @@ select_sampler(const char *name)
 		{ "sampler1DArray",         GL_SAMPLER_1D_ARRAY,                    GL_TEXTURE_1D_ARRAY       },
 		{ "sampler2DArray",         GL_SAMPLER_2D_ARRAY,                    GL_TEXTURE_2D_ARRAY       },
 		{ "samplerCubeArray",       GL_SAMPLER_CUBE_MAP_ARRAY,              GL_TEXTURE_CUBE_MAP_ARRAY },
+		{ "samplerBuffer",          GL_SAMPLER_BUFFER,                      GL_TEXTURE_BUFFER },
 
 		{ "sampler1DShadow",        GL_SAMPLER_1D_SHADOW,                   GL_TEXTURE_1D             },
 		{ "sampler2DShadow",        GL_SAMPLER_2D_SHADOW,                   GL_TEXTURE_2D             },
@@ -211,6 +223,7 @@ select_sampler(const char *name)
 		{ "isampler1DArray",        GL_INT_SAMPLER_1D_ARRAY,                GL_TEXTURE_1D_ARRAY       },
 		{ "isampler2DArray",        GL_INT_SAMPLER_2D_ARRAY,                GL_TEXTURE_2D_ARRAY       },
 		{ "isamplerCubeArray",      GL_INT_SAMPLER_CUBE_MAP_ARRAY,          GL_TEXTURE_CUBE_MAP_ARRAY },
+		{ "isamplerBuffer",         GL_INT_SAMPLER_BUFFER,                  GL_TEXTURE_BUFFER },
 
 		{ "usampler1D",             GL_UNSIGNED_INT_SAMPLER_1D,             GL_TEXTURE_1D             },
 		{ "usampler2D",             GL_UNSIGNED_INT_SAMPLER_2D,             GL_TEXTURE_2D             },
@@ -220,6 +233,7 @@ select_sampler(const char *name)
 		{ "usampler1DArray",        GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,       GL_TEXTURE_1D_ARRAY       },
 		{ "usampler2DArray",        GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,       GL_TEXTURE_2D_ARRAY       },
 		{ "usamplerCubeArray",      GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY },
+		{ "usamplerBuffer",         GL_UNSIGNED_INT_SAMPLER_BUFFER,         GL_TEXTURE_BUFFER },
 	};
 
 	for (i = 0; i < ARRAY_SIZE(samplers); i++) {
@@ -303,6 +317,9 @@ require_GL_features(enum shader_target test_stage)
 	case GL_TEXTURE_RECTANGLE:
 		piglit_require_extension("GL_ARB_texture_rectangle");
 		break;
+	case GL_TEXTURE_BUFFER:
+		piglit_require_extension("GL_ARB_texture_buffer_object");
+		break;
 	}
 
 	/* If testing in the VS, check for VS texture units */
diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c
index ec91878..c194aa6 100644
--- a/tests/texturing/shaders/textureSize.c
+++ b/tests/texturing/shaders/textureSize.c
@@ -60,6 +60,7 @@ sampler_size()
 {
 	switch (sampler.target) {
 	case GL_TEXTURE_1D:
+	case GL_TEXTURE_BUFFER:
 		return 1;
 	case GL_TEXTURE_2D:
 	case GL_TEXTURE_1D_ARRAY:
@@ -151,7 +152,12 @@ generate_texture()
 
 	glGenTextures(1, &tex);
 	glBindTexture(target, tex);
-	if (target == GL_TEXTURE_RECTANGLE) {
+	if (target == GL_TEXTURE_BUFFER) {
+		/* Texture buffers only use texelFetch() and
+		 * textureSize(), so setting the filter parameters on
+		 * them is invalid.
+		 */
+	} else if (target == GL_TEXTURE_RECTANGLE) {
 		glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 		glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	} else {
@@ -160,8 +166,10 @@ generate_texture()
 		glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	}
 
-	glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	if (target != GL_TEXTURE_BUFFER) {
+		glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+		glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	}
 
 	for (l = 0; l < miplevels; l++) {
 		if (target == GL_TEXTURE_CUBE_MAP) {
@@ -188,8 +196,11 @@ generate_GLSL(enum shader_target test_stage)
 
 	const int size = sampler_size();
 
-	/* The GLSL 1.40 sampler2DRect samplers don't take a lod argument. */
-	if (sampler.target == GL_TEXTURE_RECTANGLE)
+	/* The GLSL 1.40 sampler2DRect/samplerBuffer samplers don't
+	 * take a lod argument.
+	 */
+	if (sampler.target == GL_TEXTURE_RECTANGLE ||
+	    sampler.target == GL_TEXTURE_BUFFER)
 		lod_arg = "";
 	else
 		lod_arg = ", lod";
-- 
1.7.10



More information about the Piglit mailing list