[Piglit] [PATCH] texture-float-formats: a simple GL_ARB_texture_float test
Brian Paul
brianp at vmware.com
Tue Apr 26 11:11:21 PDT 2011
On 04/26/2011 10:06 AM, Eric Anholt wrote:
> On Mon, 25 Apr 2011 18:53:58 -0600, brianp at vmware.com wrote:
>> +static const struct format_info Formats[] = {
>> + { "GL_RGBA32F_ARB", GL_RGBA32F_ARB, GL_RGBA, 32 },
>> + { "GL_RGB32F_ARB", GL_RGB32F_ARB, GL_RGB, 32 },
>> + { "GL_ALPHA32F_ARB", GL_ALPHA32F_ARB, GL_ALPHA, 32 },
>> + { "GL_INTENSITY32F_ARB", GL_INTENSITY32F_ARB, GL_INTENSITY, 32 },
>> + { "GL_LUMINANCE32F_ARB", GL_LUMINANCE32F_ARB, GL_LUMINANCE, 32 },
>> + { "GL_LUMINANCE_ALPHA32F_ARB", GL_LUMINANCE_ALPHA32F_ARB, GL_LUMINANCE, 32 },
>> +
>> + { "GL_RGBA16F_ARB", GL_RGBA16F_ARB, GL_RGBA, 16 },
>> + { "GL_RGB16F_ARB", GL_RGB16F_ARB, GL_RGB, 16 },
>> + { "GL_ALPHA16F_ARB", GL_ALPHA16F_ARB, GL_ALPHA, 16 },
>> + { "GL_INTENSITY16F_ARB", GL_INTENSITY16F_ARB, GL_INTENSITY, 16 },
>> + { "GL_LUMINANCE16F_ARB", GL_LUMINANCE16F_ARB, GL_LUMINANCE, 16 },
>> + { "GL_LUMINANCE_ALPHA16F_ARB", GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE, 16 },
>> +
>> + /* XXX could also add tests for RED, RG formats */
>> +};
>
> Looks like the rest of the test is ready for RED, RG. Could they just
> get added now? I think they'd go under ARB_texture_rg, since other RG
> float tests have been there too.
I was going to add them in a follow-on patch someday.
>> +
>> + /*printf("Testing %s\n", info->Name);*/
>> +
>> + /* pick random texture color, comps in [-1000, 1000] */
>> + value[0] = rand() % 2001 - 1000;
>> + value[1] = rand() % 2001 - 1000;
>> + value[2] = rand() % 2001 - 1000;
>> + value[3] = rand() % 2001 - 1000;
>
> I don't like using rand() in testing. I think avoiding random test
> behavior has been one of piglit's strengths. Just pick some numbers, if
> you're only going to have 4 different ones.
will do.
>> + /* read color */
>> + glReadPixels(w/2, h/2, 1, 1, GL_RGBA, GL_FLOAT, result);
>> +
>> + glutSwapBuffers();
>> +
>> + if (check_error(__FILE__, __LINE__))
>> + return GL_FALSE;
>> +
>> + /* test */
>> + if (fabsf(result[0] - expected[0])> error ||
>> + fabsf(result[1] - expected[1])> error ||
>> + fabsf(result[2] - expected[2])> error ||
>> + fabsf(result[3] - expected[3])> error) {
>> + /* unexpected result */
>> + int i;
>> +
>> + fprintf(stderr, "%s: failure with format %s:\n", TestName, info->Name);
>> + fprintf(stderr, " texture color = ");
>> + for (i = 0; i< comps; i++) {
>> + fprintf(stderr, "%f", value[i]);
>> + if (i + 1< comps)
>> + fprintf(stderr, ", ");
>> + }
>> + fprintf(stderr, "\n");
>> + fprintf(stderr, " expected color = %g, %g, %g, %g\n",
>> + expected[0], expected[1], expected[2], expected[3]);
>> + fprintf(stderr, " rendered color = %g, %g, %g, %g\n",
>> + result[0], result[1], result[2], result[3]);
>> + return GL_FALSE;
>> + }
>
> You seem to have replicated piglit_probe_pixel_rgba() with an extra line
> of informatino about the texture format/color. Perhaps just print those
> out afterwards?
Will do.
-Brian
More information about the Piglit
mailing list