[Piglit] [PATCH 2/2] texture_integer: add ARB_texture_rgb10_a2ui support.

Brian Paul brianp at vmware.com
Mon Dec 5 06:59:06 PST 2011


On 12/04/2011 01:04 PM, Dave Airlie wrote:
> From: Dave Airlie<airlied at redhat.com>
>
> This adds support for the GL_RGB10_A2UI format to the integer texture
> format test.
>
> Signed-off-by: Dave Airlie<airlied at redhat.com>
> ---
>   .../ext_texture_integer/texture-integer-glsl130.c  |   54 +++++++++++++++++++-
>   1 files changed, 52 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/ext_texture_integer/texture-integer-glsl130.c b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
> index eaaa525..6d1920f 100644
> --- a/tests/spec/ext_texture_integer/texture-integer-glsl130.c
> +++ b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
> @@ -116,6 +116,13 @@ static const struct format_info rg_formats[] = {
>   	{ "GL_R32UI", GL_R32UI, GL_RED_INTEGER, 32, GL_FALSE },
>   };
>
> +static const struct format_info rgb10_formats[] = {
> +	{ "GL_RGB10_A2UI", GL_RGB10_A2UI, GL_RGBA_INTEGER_EXT, 10, GL_FALSE },
> +	{ "GL_RGB10_A2UI (bgra)", GL_RGB10_A2UI, GL_BGRA_INTEGER_EXT, 10, GL_FALSE },
> +	{ "GL_RGB10_A2UI (rev)", GL_RGB10_A2UI, GL_RGBA_INTEGER_EXT, 10, GL_TRUE },
> +	{ "GL_RGB10_A2UI (rev bgra)", GL_RGB10_A2UI, GL_BGRA_INTEGER_EXT, 10, GL_TRUE },

It looks like you're overloading the Signed field to test the REV vs. 
non-REV formats.  Is that right?  Maybe you should have a comment 
explaining what you're doing then.


> +};
> +
>   static const char *FragShaderText =
>   	"#version 130\n"
>   	"uniform vec4 bias; \n"
> @@ -141,6 +148,9 @@ get_max_val(const struct format_info *info)
>   		else
>   			max = 255;
>   		break;
> +	case 10:
> +		max = 1023;
> +		break;
>   	case 16:
>   		if (info->Signed)
>   			max = 32767;
> @@ -230,6 +240,29 @@ fill_array(int comps, int texels, void *buf, int bpp, const int val[4])
>   	}
>   }
>
> +static void
> +fill_array_rgb10(int comps, int texels, void *buf, int type,
> +	   const int val[4])
> +{
> +	int i;
> +	GLuint *b = (GLuint *)buf;
> +
> +	if (type == GL_UNSIGNED_INT_2_10_10_10_REV) {
> +		for (i = 0; i<  texels; i++) {
> +			b[i] = (val[0]&  0x3ff)<<  0 |
> +				(val[1]&  0x3ff)<<  10 |
> +				(val[2]&  0x3ff)<<  20 |
> +				(val[3]&  0x3)<<  30;
> +		}
> +	} else if (type == GL_UNSIGNED_INT_10_10_10_2) {
> +		for (i = 0; i<  texels; i++) {
> +			b[i] = (val[3]&  0x3)<<  0 |
> +			       (val[2]&  0x3ff)<<  2 |
> +			       (val[1]&  0x3ff)<<  12 |
> +			       (val[0]&  0x3ff)<<  22;
> +		}
> +	}
> +}
>
>   static GLenum
>   get_datatype(const struct format_info *info)
> @@ -237,6 +270,8 @@ get_datatype(const struct format_info *info)
>   	switch (info->BitsPerChannel) {
>   	case 8:
>   		return info->Signed ? GL_BYTE : GL_UNSIGNED_BYTE;
> +	case 10:
> +		return info->Signed ? GL_UNSIGNED_INT_10_10_10_2 : GL_UNSIGNED_INT_2_10_10_10_REV;
>   	case 16:
>   		return info->Signed ? GL_SHORT : GL_UNSIGNED_SHORT;
>   	case 32:
> @@ -286,8 +321,14 @@ test_format(const struct format_info *info)
>   	value[3] = rand() % max;
>
>   	/* alloc, fill texture image */
> -	buf = malloc(comps * texels * info->BitsPerChannel / 8);
> -	fill_array(comps, texels, buf, info->BitsPerChannel, value);
> +	if (info->BitsPerChannel == 10) {
> +		value[3] = rand() % 3;
> +		buf = malloc(texels * 4);
> +		fill_array_rgb10(comps, texels, buf, type, value);
> +	} else {
> +		buf = malloc(comps * texels * info->BitsPerChannel / 8);
> +		fill_array(comps, texels, buf, info->BitsPerChannel, value);
> +	}
>
>   	glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0,
>   		     info->BaseFormat, type, buf);
> @@ -429,6 +470,15 @@ test_general_formats(void)
>   			}
>   		}
>   	}
> +
> +	if (piglit_is_extension_supported("GL_ARB_texture_rgb10_a2ui")) {
> +		for (f = 0; f<  ARRAY_SIZE(rgb10_formats); f++) {
> +			for (i = 0; i<  5; i++) {
> +				if (!test_format(&rgb10_formats[f]))
> +					return GL_FALSE;
> +			}
> +		}
> +	}
>   	return GL_TRUE;
>   }
>

Looks OK otherwise.

-Brian


More information about the Piglit mailing list