[Piglit] [PATCH] gpu_shader5: Add a test that uses an absurd number of texture arguments

2015-01-09 Thread Jason Ekstrand
This adds a test that uses an indirect offset into an array of 2D shadow
samplers with a textureProjGradOffset.  The primary purpse of this is to
use a lot of arguments with an indirect offset.  This hits a bug in the
current NIR code where we originally assumed a max of 4 texture arguments.
---
 .../compiler/indirect-projGradOffset-shadow.frag   | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 
tests/spec/arb_gpu_shader5/compiler/indirect-projGradOffset-shadow.frag

diff --git 
a/tests/spec/arb_gpu_shader5/compiler/indirect-projGradOffset-shadow.frag 
b/tests/spec/arb_gpu_shader5/compiler/indirect-projGradOffset-shadow.frag
new file mode 100644
index 000..43bbe0b
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/indirect-projGradOffset-shadow.frag
@@ -0,0 +1,18 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.30
+// [end config]
+#version 130
+#extension GL_ARB_gpu_shader5: require
+
+uniform int i;
+uniform vec4 coord;
+uniform ivec2 offset;
+uniform sampler2DShadow s[5];
+
+void main()
+{
+  float f = textureProjGradOffset(s[i], coord, coord.xy, coord.zw,
+ ivec2(43, 7));
+  gl_FragColor = vec4(0, f, 0, 1);
+}
-- 
2.2.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] piglit-print-commands.py: PEP8 fixes.

2015-01-09 Thread Vinson Lee
piglit-print-commands.py:41:32: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:41:34: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:42:31: E221 multiple spaces before operator
piglit-print-commands.py:42:31: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:42:34: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:43:32: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:43:34: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:44:29: E221 multiple spaces before operator
piglit-print-commands.py:44:29: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:44:34: E251 unexpected spaces around keyword / 
parameter equals
piglit-print-commands.py:44:80: E501 line too long (89 > 79 characters)
piglit-print-commands.py:57:24: E128 continuation line under-indented for 
visual indent

Signed-off-by: Vinson Lee 
---
 piglit-print-commands.py | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/piglit-print-commands.py b/piglit-print-commands.py
index af24902..be7e0ec 100755
--- a/piglit-print-commands.py
+++ b/piglit-print-commands.py
@@ -38,10 +38,11 @@ def main():
 core.get_config()
 parser = argparse.ArgumentParser(sys.argv)
 parser.add_argument("-t", "--include-tests",
-default = [],
-action  = "append",
-metavar = "",
-help= "Run only matching tests (can be used more 
than once)")
+default=[],
+action="append",
+metavar="",
+help="Run only matching tests (can be used more than "
+ "once)")
 parser.add_argument("-x", "--exclude-tests",
 default=[],
 action="append",
@@ -54,7 +55,7 @@ def main():
 args = parser.parse_args()
 
 opts = core.Options(exclude_filter=args.exclude_tests,
-   include_filter=args.include_tests)
+include_filter=args.include_tests)
 
 # Change to the piglit's path
 piglit_dir = path.dirname(path.realpath(sys.argv[0]))
-- 
2.1.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] glx-query-drawable: Initialize variable.

2015-01-09 Thread Vinson Lee
Fix uninitialized scalar variable defect reported by Coverity.

Signed-off-by: Vinson Lee 
---
 tests/glx/glx-query-drawable.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/glx/glx-query-drawable.c b/tests/glx/glx-query-drawable.c
index 588b4f5..cd58ae6 100644
--- a/tests/glx/glx-query-drawable.c
+++ b/tests/glx/glx-query-drawable.c
@@ -315,6 +315,9 @@ int main(int argc, char **argv) {
case WINDOW:
draw = piglit_get_glx_window(display, visual);
break;
+   default:
+   assert(0);
+   draw = 0;
}
 
glXMakeCurrent(display, draw, ctx);
-- 
2.1.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] ext_framebuffer_multisample_blit_scaled: Use const reference.

2015-01-09 Thread Vinson Lee
Fix big parameter passed by value defect reported by Coverity.

Signed-off-by: Vinson Lee 
---
 tests/spec/ext_framebuffer_multisample_blit_scaled/blit-scaled.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/spec/ext_framebuffer_multisample_blit_scaled/blit-scaled.cpp 
b/tests/spec/ext_framebuffer_multisample_blit_scaled/blit-scaled.cpp
index 0996d31..7e14d59 100644
--- a/tests/spec/ext_framebuffer_multisample_blit_scaled/blit-scaled.cpp
+++ b/tests/spec/ext_framebuffer_multisample_blit_scaled/blit-scaled.cpp
@@ -309,7 +309,7 @@ piglit_init(int argc, char **argv)
}
 }
 
-bool test_ms_blit_scaled(Fbo ms_fbo)
+bool test_ms_blit_scaled(const Fbo& ms_fbo)
 {
GLfloat scale;
bool pass = true, result = true;
-- 
2.1.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2] arb_direct_state_access: Fix memory leak.

2015-01-09 Thread Vinson Lee
Fix resource leak defect reported by Coverity.

Also move piglit_rgbw_image_ubyte call outside of loop as suggested by
Brian Paul.

Signed-off-by: Vinson Lee 
---
 tests/spec/arb_direct_state_access/getcompressedtextureimage.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c 
b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
index 734ef72..9546af5 100644
--- a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
+++ b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
@@ -96,13 +96,15 @@ make_layer_data(int num_layers)
int z;
GLubyte *layer_data =
malloc(num_layers * IMAGE_SIZE * sizeof(GLubyte));
+   GLubyte *data = piglit_rgbw_image_ubyte(IMAGE_WIDTH,
+   IMAGE_HEIGHT, true);
 
for (z = 0; z < num_layers; z++) {
-   GLubyte *data = piglit_rgbw_image_ubyte(IMAGE_WIDTH,
-   IMAGE_HEIGHT, true);
memcpy(layer_data + IMAGE_SIZE * z, data, IMAGE_SIZE);
}
 
+   free(data);
+
/* Show the first layer of the completed layer data. */
show_image(layer_data, num_layers, "Test Data");
 
-- 
2.1.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


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

2015-01-09 Thread Dylan Baker
On Friday, January 09, 2015 03:13:05 PM Jason Ekstrand wrote:
> On Fri, Jan 9, 2015 at 2:58 PM, Dylan Baker  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?

well, it seems really silly to loop over the same iterator multiple
times.

> 
> 
> >
> > >  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,
> > > 

Re: [Piglit] [PATCH] tests/all.py: fix typo in recent list conversion

2015-01-09 Thread Mark Janes
Dylan Baker  writes:

> In one case the comma was put on the inside of the quote, resulting in
> two strings being combined into a single string rather than being two
> elements in a list.
>
> Signed-off-by: Dylan Baker 
> ---
>  tests/all.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/all.py b/tests/all.py
> index 87ff8e9..696ba45 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -1513,7 +1513,7 @@ for stage in ['vs', 'gs', 'fs']:
>  spec[grouptools.join(
>  'glsl-{}'.format(version), 'execution', 'texelFetchOffset',
>  '{}-{}'.format(stage, sampler))] = PiglitGLTest(
> -['texelFetch', 'offset,' '140', stage, sampler],
> +['texelFetch', 'offset', '140', stage, sampler],
>  run_concurrent=True)
>  
>  spec['glsl-1.50'] = {}
> -- 
> 2.2.1

Reviewed-by: Mark Janes 
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


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

2015-01-09 Thread Jason Ekstrand
On Fri, Jan 9, 2015 at 2:58 PM, Dylan Baker  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

[Piglit] [PATCH] tests/all.py: fix typo in recent list conversion

2015-01-09 Thread Dylan Baker
In one case the comma was put on the inside of the quote, resulting in
two strings being combined into a single string rather than being two
elements in a list.

Signed-off-by: Dylan Baker 
---
 tests/all.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/all.py b/tests/all.py
index 87ff8e9..696ba45 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1513,7 +1513,7 @@ for stage in ['vs', 'gs', 'fs']:
 spec[grouptools.join(
 'glsl-{}'.format(version), 'execution', 'texelFetchOffset',
 '{}-{}'.format(stage, sampler))] = PiglitGLTest(
-['texelFetch', 'offset,' '140', stage, sampler],
+['texelFetch', 'offset', '140', stage, sampler],
 run_concurrent=True)
 
 spec['glsl-1.50'] = {}
-- 
2.2.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


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

2015-01-09 Thread Dylan Baker
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?

>  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, da

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

2015-01-09 Thread Jason Ekstrand
---
 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])
+
 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 {
   

[Piglit] [PATCH 2/2] teximage-colors: Improve --benchmark option

2015-01-09 Thread Jason Ekstrand
This commit does a couple of things.  First, we increase the size of the
texture uploaded while benchmarking to 1024 square to reduce the affect of
set-up overhead.  Second, we do a render and then call glFinish at the end
of the upload loop to ensure that things actually get flushed through the
GPU and GPU time is included in the test.
---
 tests/texturing/teximage-colors.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/tests/texturing/teximage-colors.c 
b/tests/texturing/teximage-colors.c
index 5944137..ff2b174 100644
--- a/tests/texturing/teximage-colors.c
+++ b/tests/texturing/teximage-colors.c
@@ -29,6 +29,9 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
config.supports_gl_compat_version = 13;
 
+   config.window_width = 1024;
+   config.window_height = 1024;
+
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -475,7 +478,7 @@ piglit_init(int argc, char **argv)
srand(seed);
} else if (strcmp(argv[i], "--benchmark") == 0) {
benchmark = true;
-   texture_size = 128;
+   texture_size = 1024;
} else if (strcmp(argv[i], "--pbo") == 0) {
use_pbo = true;
} else if (i == argc - 1) {
@@ -754,33 +757,41 @@ run_test(GLenum test_format, GLenum test_type, float 
*time_out)
to_expected(test_format, test_type, (GLubyte *)data + (i * Bpp),
expected + 4 * i);
 
+   if (is_format_signed(format->internal_format)) {
+   glUseProgram(signed_prog);
+
+   for (i = 0; i < texture_size * texture_size * 4; ++i)
+   expected[i] = 0.5 + 0.5 * expected[i];
+   } else {
+   glUseProgram(unsigned_prog);
+   }
+
if (benchmark) {
time = piglit_time_get_nano();
+
for (i = 0; i < BENCHMARK_ITERATIONS; ++i)
glTexImage2D(GL_TEXTURE_2D, 0, format->internal_format,
 texture_size, texture_size, 0,
 test_format, test_type, teximage_ptr);
+
+   piglit_draw_rect_tex(0, 0, texture_size, texture_size,
+0, 0, 1, 1);
+   glFinish();
+
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, 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);
+   pass &= piglit_check_gl_error(GL_NO_ERROR);
 
-   for (i = 0; i < texture_size * texture_size * 4; ++i)
-   expected[i] = 0.5 + 0.5 * expected[i];
-   } else {
-   glUseProgram(unsigned_prog);
+   piglit_draw_rect_tex(0, 0, texture_size, texture_size,
+0, 0, 1, 1);
}
 
-   piglit_draw_rect_tex(0, 0, texture_size, texture_size, 0, 0, 1, 1);
+   glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
observed = malloc(texture_size * texture_size * 4 * sizeof(float));
glReadPixels(0, 0, texture_size, texture_size,
-- 
2.2.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [Bug 88222] [Bisected]Piglit spec_ARB_texture_rectangle_arb_texrect-texture-base-level-error fails

2015-01-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88222

Laura Ekstrand  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [Bug 88221] [SNB+ Bisected]Piglit spec_ARB_texture_storage_multisample_tex-param fails

2015-01-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88221

Laura Ekstrand  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Laura Ekstrand  ---
This bug is fixed by the series I pushed to Mesa yesterday:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4dce7a6a69de30ab7aad7612f93302c69421fea

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [Bug 88222] [Bisected]Piglit spec_ARB_texture_rectangle_arb_texrect-texture-base-level-error fails

2015-01-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88222

--- Comment #1 from Laura Ekstrand  ---
This bug is fixed by the series I pushed to Mesa yesterday:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4dce7a6a69de30ab7aad7612f93302c69421fea

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [Bug 88222] New: [Bisected]Piglit spec_ARB_texture_rectangle_arb_texrect-texture-base-level-error fails

2015-01-09 Thread Laura Ekstrand
This bug is fixed by the series I pushed to Mesa yesterday:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4dce7a6a69de30ab7aad7612f93302c69421fea

Laura
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH piglit v2] texsubimage: Test GL_ARB_texture_cube_map_array

2015-01-09 Thread Anuj Phogat
On Fri, Jan 9, 2015 at 10:40 AM, Neil Roberts  wrote:
>
> Anuj Phogat  writes:
>
> > Looking at the output image I assumed 6 rectangles drawn in a row show
> > 6 faces of the cubemap and 8 rows represent 8 layers. But draw coordinates
> > don't follow this pattern. It's not incorrect but confusing. I think what 
> > you
> > need here is:
> > piglit_draw_rect_tex3d(i % 6 * w, i / 6 * h, /* x/y */
>
> This is a bit awkward to change. I originally made it so that it would
> draw the 6 faces vertically like that because the function is also used
> to draw the 3D texture slices and I didn't want to mess with the
> appearance of that. If I make the change as you suggest then the 3D case
> will render six layers in one row with two layers in the second row
> which I think is weirder than having the cube faces not take up a single
> row. I would also have to increase the window size to 768 because the
> width of the 3D slices are 128. I was hoping to make the minimal changes
> and didn't think that lining up the cube faces would matter all that
> much.
>
> Regards,
> - Neil

Makes sense. Patch is:
Reviewed-by: Anuj Phogat 
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH piglit v2] texsubimage: Test GL_ARB_texture_cube_map_array

2015-01-09 Thread Neil Roberts
Anuj Phogat  writes:

> Looking at the output image I assumed 6 rectangles drawn in a row show
> 6 faces of the cubemap and 8 rows represent 8 layers. But draw coordinates
> don't follow this pattern. It's not incorrect but confusing. I think what you
> need here is:
> piglit_draw_rect_tex3d(i % 6 * w, i / 6 * h, /* x/y */

This is a bit awkward to change. I originally made it so that it would
draw the 6 faces vertically like that because the function is also used
to draw the 3D texture slices and I didn't want to mess with the
appearance of that. If I make the change as you suggest then the 3D case
will render six layers in one row with two layers in the second row
which I think is weirder than having the cube faces not take up a single
row. I would also have to increase the window size to 768 because the
width of the 3D slices are 128. I was hoping to make the minimal changes
and didn't think that lining up the cube faces would matter all that
much.

Regards,
- Neil
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] deqp: Add option to run subset of external dEQP-GLES3

2015-01-09 Thread Dylan Baker
I have CC'd Chad (who added dEQP support)

I have a couple of questions before I get into it:

First, your link doesn't seem to work, but I found this link
(https://android.googlesource.com/platform/external/deqp/+/lollipop-dev/android/cts/),
and I'm a little confused, it might just be terminology, but I see a
es30-mustpass-2013.2.9-2014-10-13.txt which on cursory examination seems
to contain all of the same tests as com.drawelements.deqp.gles3.xml,
already in txt form, am I incorrect?

If this text file is usable you should just remove the hardcoded use of
dEQP-GLES3-cases.txt and allow different text lists to be plugged.

Second, the approach of using re's to parse xml is not good, we make
extensive use of xml.etree.cElementTree to parse xml in piglit, and if
we can't just rely on the text list in the source tree I would rather
see a solution that uses that.

Finally, I've pointed out a few things below for your information,
mostly about piglit style.

On Friday, January 09, 2015 09:26:53 PM Wang Shuo wrote:
> Google have already added a subset of dEQP into Android CTS test,
> and we believe this part of dEQP have higher priority than the rest
> of dEQP test cases.
> the case list is stored at some xml files. Such as:
> com.drawelements.deqp.gles3.xml.
> It's git repo lives in the Android tree at
> [https://android.googlesource.com/platform/external/deqp/android \
>  /cts/com.drawelements.deqp.gles3.xml]
> 
> This patch is based on Chad's patch(Add test profile for external
> dEQP-GLES3 tests), and add an option to run the subset of dEQP-GLES3.
> The only differnce for the running method is: you need to set the
> environment variable PIGLIT_DEQP_MUSTPASS or the piglit.conf
> option deqp-gles3.mustpasslist,then it will run the subset of dEQP
> follow the test case list. If not set, it will still run the whole
> dEQP.
> 
> Tested on Intel HSW. There are 45866 test cases for the whole dEQP
> and 37354 test cases for the subset of dEQP using Android CTS test
> case list.
> 
> Signed-off-by: Wang Shuo 
> ---
>  piglit.conf.example |  6 ++
>  tests/deqp_gles3.py | 51 +++
>  2 files changed, 57 insertions(+)
> 
> diff --git a/piglit.conf.example b/piglit.conf.example
> index b3869c2..c30eef4 100644
> --- a/piglit.conf.example
> +++ b/piglit.conf.example
> @@ -44,6 +44,12 @@ testB
>  ; option is not required. The environment variable 
> PIGLIT_DEQP_GLES3_EXTRA_ARGS
>  ; overrides the value set here.
>  ;extra_args=--deqp-visibility hidden
> +;
> +; Path to the test case list of CTS for deqp-gles3. You can also set this 
> with
> +; the environment variable PIGLIT_DEQP_MUSTPASS. Piglit will run the subset 
> of
> +; dEQP-GLES3 tests if and only if this option is set.
> +;mustpasslist= \
> +; /android/platform/external/deqp/android/cts/com.drawelements.deqp.gles3.xml
>  
>  ; Section for specific oclconform test.  One of these sections is required 
> for
>  ; each test list in the oclconform section and must be called:
> diff --git a/tests/deqp_gles3.py b/tests/deqp_gles3.py
> index b1bb33b..f587d06 100644
> --- a/tests/deqp_gles3.py
> +++ b/tests/deqp_gles3.py
> @@ -21,6 +21,7 @@
>  import ConfigParser
>  import os
>  import subprocess
> +import re
>  
>  # Piglit modules
>  import framework
> @@ -28,6 +29,50 @@ from framework.profile import Test, TestProfile
>  
>  __all__ = ['profile']

Piglit uses PEP8 (https://www.python.org/dev/peps/pep-0008/) naming
conventions for python, functions should be all lowercase with
underscores separating words. There should also be two blank lines above
a function declaration and two blank lines after.

>  
> +def loadTestHierarchy (input, output):
> +   """Google have added a subset of dEQP to CTS test, the case list is
> +   stored at some xml files. Such as: com.drawelements.deqp.gles3.xml
> +   This function is used to parser the file, and generate 
> +   a new dEQP-GLES3-cases.txt which only contain the subset of dEQP.
> +   """
> +   inputfile = open(input,'r')
> +   outputfile = open(output,'w')

When opening files use "with open(file, ) as open_file:", this
ensures that the file is closed, which these are not

> +   line = inputfile.readline()
> +   rootGroup = range(0, 10)
> +   i = 0
> +
> +   for line in inputfile:
> +   line = line.strip()
> +   pat_TestSuite = re.compile(r' +   Name_TestSuite = re.findall(pat_TestSuite, line)

There are two things you could do here that would be better.
1) Don't put re.compile in the loop, the way it is now the re will be
recompiled on each iteration of the loop, losing all of the benefit of
using re.compile.
2) Generally when using re.compile you would use pat_TestSuite.findall()
rather than re.findall

> +   if Name_TestSuite:
> +   rootGroup[i] = Name_TestSuite[0]
> +   i += 1
> +
> +   pat_TestCase = re.compile(r' +   Name_TestCase = re.findall(pat_TestCase, line)
> +   if Name_TestCase

[Piglit] [PATCH] gles2: add a test for GL_EXT_draw_buffers

2015-01-09 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 tests/all.py |   1 +
 tests/spec/gles-2.0/CMakeLists.gles2.txt |   1 +
 tests/spec/gles-2.0/draw-buffers.c   | 221 +++
 3 files changed, 223 insertions(+)
 create mode 100644 tests/spec/gles-2.0/draw-buffers.c

diff --git a/tests/all.py b/tests/all.py
index a92ce8a..53315a1 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4257,6 +4257,7 @@ gles20['link-no-vsfs'] = 
PiglitGLTest('link-no-vsfs_gles2', run_concurrent=True)
 add_concurrent_test(gles20, 'minmax_gles2')
 add_concurrent_test(gles20, 'multiple-shader-objects_gles2')
 add_concurrent_test(gles20, 'fbo_discard_gles2')
+add_concurrent_test(gles20, 'draw_buffers_gles2')
 
 gles30 = {}
 spec['!OpenGL ES 3.0'] = gles30
diff --git a/tests/spec/gles-2.0/CMakeLists.gles2.txt 
b/tests/spec/gles-2.0/CMakeLists.gles2.txt
index e2e5433..a29ad82 100644
--- a/tests/spec/gles-2.0/CMakeLists.gles2.txt
+++ b/tests/spec/gles-2.0/CMakeLists.gles2.txt
@@ -8,5 +8,6 @@ piglit_add_executable(link-no-vsfs_gles2 link-no-vsfs.c)
 piglit_add_executable(minmax_gles2 minmax.c)
 piglit_add_executable(multiple-shader-objects_gles2 multiple-shader-objects.c)
 piglit_add_executable(fbo_discard_gles2 fbo-discard.c)
+piglit_add_executable(draw_buffers_gles2 draw-buffers.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/gles-2.0/draw-buffers.c 
b/tests/spec/gles-2.0/draw-buffers.c
new file mode 100644
index 000..8ed75cb
--- /dev/null
+++ b/tests/spec/gles-2.0/draw-buffers.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Tapani Pälli 
+ */
+
+/** @file draw-buffers.c
+ *
+ * Tests GL_EXT_draw_buffers implementation
+ *
+ * Test iterates over valid and invalid arguments and checks that the
+ * implementation returns correct error codes.
+ *
+ * GL_EXT_draw_buffers specification "Errors" section states:
+ *
+ *  "The INVALID_OPERATION error is generated if DrawBuffersEXT is called
+ *   when the default framebuffer is bound and any of the following conditions
+ *   hold:
+ *-  is zero,
+ *-  is greater than 1 and less than MAX_DRAW_BUFFERS_EXT,
+ *-  contains a value other than BACK or NONE.
+ *
+ *   The INVALID_OPERATION error is generated if DrawBuffersEXT is called
+ *   when bound to a draw framebuffer object and any of the following
+ *   conditions hold:
+ *   - the th value in  is not COLOR_ATTACHMENT_EXT or NONE.
+ *
+ *   The INVALID_VALUE error is generated if DrawBuffersEXT is called
+ *   with a value of  which is greater than MAX_DRAW_BUFFERS_EXT.
+ *
+ *   The INVALID_ENUM error is generated by FramebufferRenderbuffer if
+ *   the  parameter is not one of the values listed in Table 4.x.
+ *
+ *   The INVALID_ENUM error is generated by FramebufferTexture2D if
+ *   the  parameter is not one of the values listed in Table 4.x.
+ *
+ *   The INVALID_ENUM error is generated by GetFramebufferAttachmentParameteriv
+ *   if the  parameter is not one of the values listed in Table 
4.x."
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_es_version = 20;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define TEXTURE_AMOUNT 3
+
+static const GLenum valid_buffer_list[] = {
+   GL_COLOR_ATTACHMENT0,
+   GL_COLOR_ATTACHMENT1,
+   GL_COLOR_ATTACHMENT2,
+};
+
+static const GLenum invalid_buffer_list[] = {
+   GL_COLOR_ATTACHMENT0,
+   GL_BACK,
+   GL_COLOR_ATTACHMENT1,
+};
+
+static GLuint
+create_fbo()
+{
+   GLuint fbo;
+   GLuint depth;
+   GLuint textures[TEXTURE_AMOUNT];
+   GLint param;
+   unsigned i;
+
+   /* Generate fbo with TEXTURE_AMOUNT color attachments. */
+   glGenFramebuffers(1, &fbo);
+   glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+   glGenTextures(TEXTURE_AMOUNT, textures);
+
+   for (i = 0; i < TEXTURE_AMOUNT; i++) {
+