[Piglit] [PATCH 2/2 v2] getteximage-targets: Add read texture image into PBO case for each target

Chia-I Wu olvaffe at gmail.com
Sat Mar 22 00:27:38 PDT 2014


On Sat, Mar 22, 2014 at 5:03 AM, Jon Ashburn <jon at lunarg.com> wrote:

> ---
>  tests/texturing/getteximage-targets.c | 38
> ++++++++++++++++++++++++++++-------
>  1 file changed, 31 insertions(+), 7 deletions(-)
>
> diff --git a/tests/texturing/getteximage-targets.c
> b/tests/texturing/getteximage-targets.c
> index 1b626db..9b471c2 100644
> --- a/tests/texturing/getteximage-targets.c
> +++ b/tests/texturing/getteximage-targets.c
> @@ -97,16 +97,24 @@ compare_layer(int layer, int num_elements, int
> tolerance,
>  }
>
>  static bool
> -getTexImage(GLenum target, GLubyte data[][IMAGE_SIZE],
> +getTexImage(bool doPBO, GLenum target, GLubyte data[][IMAGE_SIZE],
>             GLenum internalformat, int tolerance)
>  {
>         int i, j;
>         int num_layers=1, num_faces=1, layer_size;
>         GLubyte data2[18][IMAGE_SIZE];
> +       GLuint packPBO;
>         bool pass = true;
>
> -
> -       memset(data2, 123, sizeof(data2));
> +       /* Setup the PBO or data array to read into from glGetTexImage */
> +       if (doPBO) {
> +               glGenBuffers(1, &packPBO);
> +               glBindBuffer(GL_PIXEL_PACK_BUFFER, packPBO);
> +       } else {
> +               glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
> +               memset(data2, 123, sizeof(data2));
> +       }
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
>
>         switch (target) {
>         case GL_TEXTURE_1D:
> @@ -176,8 +184,20 @@ getTexImage(GLenum target, GLubyte data[][IMAGE_SIZE],
>         }
>         for (i = 0; i < num_faces; i++) {
>                 GLubyte *dataGet=NULL;
> -               glGetTexImage(target + i, 0, GL_RGBA, GL_UNSIGNED_BYTE,
> data2[i]);
> -               dataGet = data2[i];
> +               if (doPBO) {
> +                       glBufferData(GL_PIXEL_PACK_BUFFER, layer_size *
> num_layers,
> +                                               NULL, GL_STREAM_READ);
> +                       glGetTexImage(target + i, 0, GL_RGBA,
> +                                     GL_UNSIGNED_BYTE, NULL);
> +                       dataGet = (GLubyte *) glMapBufferRange(
> +
>  GL_PIXEL_PACK_BUFFER, 0,
> +                                                      layer_size *
> num_layers,
> +                                                      GL_MAP_READ_BIT);
>
No matching glUnmapBuffer?


> +               } else {
> +                       glGetTexImage(target + i, 0, GL_RGBA,
> GL_UNSIGNED_BYTE,
> +                                     data2[i]);
> +                       dataGet = data2[i];
> +               }
>                 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
>
>                 for (j = 0; j < num_layers; j++) {
> @@ -238,8 +258,12 @@ piglit_init(int argc, char **argv)
>
>         init_layer_data(data[0], 18);
>
> -       printf("Testing %s\n", piglit_get_gl_enum_name(target));
> -       pass = getTexImage(target, data, internalformat, tolerance) &&
> +       printf("Testing %s into PBO\n", piglit_get_gl_enum_name(target));
> +       pass = getTexImage(true, target, data, internalformat, tolerance)
> &&
> +                               pass;
> +
> +       printf("Testing %s into client array\n",
> piglit_get_gl_enum_name(target));
> +       pass = getTexImage(false, target, data, internalformat, tolerance)
> &&
>                                 pass;
>
>         pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> --
> 1.8.1.2
>
>


-- 
olv at LunarG.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140322/005e5661/attachment.html>


More information about the Piglit mailing list