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

Kenneth Graunke kenneth at whitecape.org
Sat Nov 19 00:25:32 PST 2011


On 11/18/2011 04:15 PM, Ian Romanick wrote:
> On 11/17/2011 10:48 PM, Kenneth Graunke wrote:
>> This exhaustively tests 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>
>> ---
>>   tests/all.tests                                  |    5 +
>>   tests/spec/glsl-1.30/execution/CMakeLists.gl.txt |    1 +
>>   tests/spec/glsl-1.30/execution/textureSize.c     |  327
>> ++++++++++++++++++++++
> 
> I think the test code should live somewhere else.  In later GL versions,
> cubemap arrays are added, new shader stages are added, etc.  We can use
> this same test for those features as well.  Putting the code somewhere
> "common" and listing the tests (in all.tests) under glsl-1.30 or gl-3.0
> seems like the right answer.

Yeah, I was thinking the same thing, but wasn't sure where to put it.
Do you have a suggestion?  tests/texturing?  tests/shaders?  A new
subdirectory of one of those?

[snip]
>> +    for (i = sampler->size; i<  3; i++)
>> +        tex_size[i] = 0;
> 
> Why not memset the whole thing at the top?

Because it'd overwrite my initial values:
int tex_size[3] = { 65, 32, 0 };

But, maybe I really should just initialize it with {0, 0, 0} and set the
dimensions I want in each case.  That's probably more sensible.

[snip]
>> +             "out vec%d size;\n"
> 
>                           flat out ivec%d size;
> 
> Right?

Yeah.  I'll also have to add #define ivec1 int.

[snip]
>> +             "void main()\n"
>> +             "{\n"
>> +             "    size = textureSize(tex, lod);\n"
> 
> Doesn't this give an int-to-float implicit conversion error?

No, because int-to-float implicit conversions are legal in 1.30.
But it doesn't matter since I'm using flat out ivec%d now.

[snip]
>> +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 },
>                    samplerRectARB
> 
>> +        { "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 },
> 
>                    samplerRectShadowARB

I assume you mean sampler2DRect.  We obviously want to test these, but
I'm confused where they come from.  GLSL 1.40 defines these signatures:

ivec2 textureSize(gsampler2DRect sampler, int lod)
ivec2 textureSize(sampler2DRectShadow sampler, int lod)

Also, GL_EXT_gpu_shader4 defines one of them:
ivec2 textureSize2DRect(sampler2DRect sampler, int lod)

But I don't think GLSL 1.30 + GL_ARB_texture_rectangle defines any...

>> +        { "sampler1DArray",       2, GL_TEXTURE_1D_ARRAY, false },
>> +        { "sampler2DArray",       3, GL_TEXTURE_2D_ARRAY, false },
>> +        { "sampler1DArrayShadow", 2, GL_TEXTURE_1D_ARRAY, true},
>> +        { "sampler2DArrayShadow", 3, GL_TEXTURE_2D_ARRAY, true}
>> +    };
>> +
>> +    for (i = 0; i<  ARRAY_SIZE(samplers); i++) {
>> +        if (strcmp(samplers[i].name, name) == 0) {
>> +            sampler =&samplers[i];
>> +            return;
>> +        }
>> +    }
>> +}
>> +
>> +void
>> +fail_and_show_usage()
>> +{
>> +    printf("Usage: textureSize<vs|fs>  <sampler type>  [piglit
>> args...]\n");
>> +    piglit_report_result(PIGLIT_SKIP);
>> +}
>> +
>> +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);
>> +
>> +    for (i = 1; i<  argc; i++) {
>> +        /* Ignore piglit arguments like -auto and -fbo */
>> +        if (argv[i][0] == '-')
>> +            continue;
> 
> Don't these get consumed before piglit_init is called?  I've never seen
> another test do this.

You're right, of course.  I could've sworn I ran into some tests that
did shenanigans to avoid -auto, and thought it was silly that piglit
made you do that.  But it doesn't, so...I've removed this hunk.


More information about the Piglit mailing list