[Piglit] [PATCH 1/4] Add a new comprehensive test for textureSize().

Eric Anholt eric at anholt.net
Wed Nov 30 05:24:27 PST 2011


On Tue, 29 Nov 2011 23:32:27 -0800, Kenneth Graunke <kenneth at whitecape.org> wrote:
> This exhaustively tests all of GLSL 1.30's textureSize variants, both in
> the vertex and fragment shaders.  It covers:
> - Sampler data type (floating point, signed integer, unsigned integer)
> - Dimensionality (1D, 2D, 3D, Cube, 1DArray, 2DArray)
> - Color and shadow samplers
> - Mipmapped textures
> - Non-power-of-two textures
> 
> It doesn't cover texture format variations.  In fact, the test never
> actually provides any content for the textures, because it should be
> irrelevant for textureSize(), is easier to program, and also extra mean.
> 
> The new "textureSize" binary takes two arguments: shader stage and
> sampler type.  For example:
> 
> ./bin/textureSize fs sampler1DArrayShadow
> ./bin/textureSize vs usamplerCube
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---

> +#define BS 500

Heh.  Workaround for Windows developers always replacing nice asprintfs
with snprintf instead of just defining asprintf on their platform
produces #define BS :)

> +	int is_array = sampler->gl_target == GL_TEXTURE_1D_ARRAY ||
> +		       sampler->gl_target == GL_TEXTURE_2D_ARRAY;

is_array should probably imply a check for GL_EXT_texture_array.

> +	/* Draw consecutive squares for each mipmap level */
> +	for (l = 0; l < miplevels; l++) {
> +		const int x = 10 + l * 20;
> +		float expected_color[4] = { 0.0, 0.0, 0.0, 1.0 };
> +		for (i = 0; i < sampler->size; i++)
> +			expected_color[i] = 0.01 * level_size[i];
> +
> +		piglit_Uniform1i(lod_location, l);
> +		glViewport(x, 10, 10, 10);
> +		piglit_draw_rect(-1, -1, 2, 2);
> +
> +		pass &= piglit_probe_rect_rgba(x, 10, 10, 10, expected_color);
> +
> +		/* For arrays, the # of slices never changes; don't divide */
> +		for (i = 0; i < sampler->size - is_array; i++)
> +			level_size[i] = max2(level_size[i] / 2, 1);
> +	}

I'd be curious what the result is supposed to be for lod > maxlevel and
seeing that tested (also for single-level textures).

> +void
> +select_sampler(char *name)
> +{
> +	int i;
> +	static const struct sampler_info samplers[] =
> +	{
> +		{ "sampler1D",            1, GL_TEXTURE_1D,       false },
> +		{ "sampler2D",            2, GL_TEXTURE_2D,       false },
> +		{ "sampler3D",            3, GL_TEXTURE_3D,       false },
> +		{ "samplerCube",          2, GL_TEXTURE_CUBE_MAP, false },
> +		{ "sampler1DShadow",      1, GL_TEXTURE_1D,       true },
> +		{ "sampler2DShadow",      2, GL_TEXTURE_2D,       true },
> +		{ "samplerCubeShadow",    2, GL_TEXTURE_CUBE_MAP, true },

samplerCubeShadow's glTexImage setup should require GL 3.0 as opposed to
just GLSL 1.30.

> +void
> +piglit_init(int argc, char **argv)
> +{
> +	int prog;
> +	int tex_location;
> +	int i;
> +	enum shader_target test_stage = UNKNOWN;
> +	bool integer_format = false;
> +	piglit_require_GLSL_version(130);

> +		if (sampler == NULL) {
> +			/* Maybe it's the sampler type? */
> +			if (argv[i][0] == 'i' || argv[i][0] == 'u') {
> +				integer_format = true;
> +				select_sampler(argv[i] + 1);

This should probably test for EXT_texture_integer presence.

I note that we don't specify an integer internalformat for teximage when
using integer samplers.  It seems like it would be hard to break
textureSize from having mismatched texture format versus sampler type,
though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20111130/a4858e2d/attachment.pgp>


More information about the Piglit mailing list