[Piglit] [PATCH 1/2] teximage-colors: Add support for testing PBO uploads

Jason Ekstrand jason at jlekstrand.net
Fri Jan 9 15:13:05 PST 2015


On Fri, Jan 9, 2015 at 2:58 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:

> On Friday, January 09, 2015 02:53:25 PM Jason Ekstrand wrote:
> > ---
> >  tests/all.py                      |  3 +++
> >  tests/texturing/teximage-colors.c | 54
> ++++++++++++++++++++++++++++-----------
> >  2 files changed, 42 insertions(+), 15 deletions(-)
> >
> > diff --git a/tests/all.py b/tests/all.py
> > index 87ff8e9..50d4b39 100644
> > --- a/tests/all.py
> > +++ b/tests/all.py
> > @@ -853,6 +853,9 @@ color_formats = [
> >  for format in color_formats:
> >      add_concurrent_test(gl11, ['teximage-colors', format])
> >
> > +for format in color_formats:
> > +    add_concurrent_test(gl11, ['teximage-colors', '--pbo', format])
> > +
>
> Is there a reason this cannot be part of the previous loop?
>

No.  Would you rather it be?


>
> >  gl10 = {}
> >  spec['!OpenGL 1.0'] = gl10
> >  add_concurrent_test(gl10, ['gl-1.0-beginend-coverage'])
> > diff --git a/tests/texturing/teximage-colors.c
> b/tests/texturing/teximage-colors.c
> > index 31136a9..5944137 100644
> > --- a/tests/texturing/teximage-colors.c
> > +++ b/tests/texturing/teximage-colors.c
> > @@ -459,8 +459,11 @@ int texture_size = 31;
> >  struct texture_format *format = NULL;
> >  GLuint unsigned_prog, signed_prog;
> >  void *rand_data;
> > +float *rand_float;
> > +GLuint pbo, float_pbo;
> >  float tolerance[4];
> >  bool benchmark = false;
> > +bool use_pbo = false;
> >
> >  void
> >  piglit_init(int argc, char **argv)
> > @@ -473,6 +476,8 @@ piglit_init(int argc, char **argv)
> >               } else if (strcmp(argv[i], "--benchmark") == 0) {
> >                       benchmark = true;
> >                       texture_size = 128;
> > +             } else if (strcmp(argv[i], "--pbo") == 0) {
> > +                     use_pbo = true;
> >               } else if (i == argc - 1) {
> >                       format = find_format(argv[i]);
> >                       break;
> > @@ -492,10 +497,31 @@ piglit_init(int argc, char **argv)
> >       unsigned_prog = piglit_build_simple_program(NULL,
> frag_shader_unsigned_src);
> >
> >       srand(seed);
> > +
> >       rand_data = malloc(texture_size * texture_size * 128);
> >       for (i = 0; i < texture_size * texture_size * 128; ++i)
> >               ((GLubyte *)rand_data)[i] = rand();
> >
> > +     rand_float = malloc(texture_size * texture_size * 128);
> > +     for (i = 0; i < texture_size * texture_size * 32; ++i)
> > +             rand_float[i] = sn_to_float(32, ((GLint *)rand_data)[i]);
> > +
> > +     if (use_pbo) {
> > +             glGenBuffers(1, &pbo);
> > +             glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
> > +             glBufferData(GL_PIXEL_UNPACK_BUFFER,
> > +                          texture_size * texture_size * 128, rand_data,
> > +                          GL_STATIC_DRAW);
> > +
> > +             glGenBuffers(1, &float_pbo);
> > +             glBindBuffer(GL_PIXEL_UNPACK_BUFFER, float_pbo);
> > +             glBufferData(GL_PIXEL_UNPACK_BUFFER,
> > +                          texture_size * texture_size * 128, rand_float,
> > +                          GL_STATIC_DRAW);
> > +
> > +             glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
> > +     }
> > +
> >       if (is_format_srgb(format->internal_format)) {
> >               /* We loose a little precision in the high numbers */
> >               tolerance[0] = 0.02;
> > @@ -701,9 +727,9 @@ run_test(GLenum test_format, GLenum test_type, float
> *time_out)
> >       bool pass = true;
> >       int64_t time;
> >       GLuint tex;
> > -     int i, Bpp, channels;
> > -     float *tmp, *expected, *observed;
> > -     void *data;
> > +     int i, Bpp;
> > +     float *expected, *observed;
> > +     void *data, *teximage_ptr;
> >
> >       glGenTextures(1, &tex);
> >       glBindTexture(GL_TEXTURE_2D, tex);
> > @@ -712,18 +738,15 @@ run_test(GLenum test_format, GLenum test_type,
> float *time_out)
> >
> >       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
> >
> > -     channels = num_channels(test_format);
> >       Bpp = bytes_per_pixel(test_format, test_type);
> >
> > -     if (test_type == GL_FLOAT) {
> > -             /* Sanatize so we don't get invalid floating point values
> */
> > -             tmp = malloc(texture_size * texture_size * channels *
> sizeof(float));
> > -             for (i = 0; i < texture_size * texture_size * channels;
> ++i)
> > -                     tmp[i] = sn_to_float(32, ((GLint *)rand_data)[i]);
> > -             data = tmp;
> > +     data = (test_type == GL_FLOAT) ? rand_float : rand_data;
> > +     if (use_pbo) {
> > +             glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
> > +                          (test_type == GL_FLOAT) ? float_pbo : pbo);
> > +             teximage_ptr = NULL;
> >       } else {
> > -             tmp = NULL;
> > -             data = rand_data;
> > +             teximage_ptr = data;
> >       }
> >
> >       expected = malloc(texture_size * texture_size * 4 * sizeof(float));
> > @@ -736,16 +759,18 @@ run_test(GLenum test_format, GLenum test_type,
> float *time_out)
> >               for (i = 0; i < BENCHMARK_ITERATIONS; ++i)
> >                       glTexImage2D(GL_TEXTURE_2D, 0,
> format->internal_format,
> >                                    texture_size, texture_size, 0,
> > -                                  test_format, test_type, data);
> > +                                  test_format, test_type, teximage_ptr);
> >               time = piglit_time_get_nano() - time;
> >               *time_out = (double)time /
> (double)(BENCHMARK_ITERATIONS*1000);
> >       } else {
> >               glTexImage2D(GL_TEXTURE_2D, 0, format->internal_format,
> >                            texture_size, texture_size, 0,
> > -                          test_format, test_type, data);
> > +                          test_format, test_type, teximage_ptr);
> >       }
> >       pass &= piglit_check_gl_error(GL_NO_ERROR);
> >
> > +     glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
> > +
> >       if (is_format_signed(format->internal_format)) {
> >               glUseProgram(signed_prog);
> >
> > @@ -767,7 +792,6 @@ run_test(GLenum test_format, GLenum test_type, float
> *time_out)
> >
> >       free(observed);
> >       free(expected);
> > -     free(tmp);
> >
> >       piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
> >                                    "%s texture with %s and %s",
> > --
> > 2.2.0
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150109/74a4f736/attachment-0001.html>


More information about the Piglit mailing list