Re: [Piglit] [PATCH] arb_texture_compression: test set/get of GL_TEXTURE_COMPRESSION_HINT

2018-02-01 Thread Ian Romanick
On 02/01/2018 11:17 AM, Brian Paul wrote:
> Seems overkill to write a brand new test just for this so add it to
> the existing invalid-formats.c test.
> 
> See Bugzilla https://bugs.freedesktop.org/show_bug.cgi?id=104908

I think there are some tools that look for the format:

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104908

Looking at the bug report, it looks like this should reproduce the error.

Reviewed-by: Ian Romanick 

> ---
>  .../spec/arb_texture_compression/invalid-formats.c | 26 
> ++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tests/spec/arb_texture_compression/invalid-formats.c 
> b/tests/spec/arb_texture_compression/invalid-formats.c
> index a201f8f..cca35cc 100644
> --- a/tests/spec/arb_texture_compression/invalid-formats.c
> +++ b/tests/spec/arb_texture_compression/invalid-formats.c
> @@ -412,6 +412,30 @@ try_formats(const struct format_list *t, GLenum 
> *compressed_formats,
>   return pass;
>  }
>  
> +
> +static bool
> +test_hint(void)
> +{
> + GLint hint = 0;
> + glGetIntegerv(GL_TEXTURE_COMPRESSION_HINT, );
> + if (hint != GL_DONT_CARE) {
> + printf("Unexpected default GL_TEXTURE_COMPRESSION_HINT"
> +" value: %s\n", piglit_get_gl_enum_name(hint));
> + return false;
> + }
> +
> + glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
> + glGetIntegerv(GL_TEXTURE_COMPRESSION_HINT, );
> + if (hint != GL_NICEST) {
> + printf("Unexpected GL_TEXTURE_COMPRESSION_HINT"
> +" value: %s\n", piglit_get_gl_enum_name(hint));
> + return false;
> + }
> +
> + return true;
> +}
> +
> +
>  void
>  piglit_init(int argc, char **argv)
>  {
> @@ -593,5 +617,7 @@ piglit_init(int argc, char **argv)
>   }
>   }
>  
> + pass = test_hint() && pass;
> +
>   piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>  }
> 

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


[Piglit] [PATCH] arb_texture_compression: test set/get of GL_TEXTURE_COMPRESSION_HINT

2018-02-01 Thread Brian Paul
Seems overkill to write a brand new test just for this so add it to
the existing invalid-formats.c test.

See Bugzilla https://bugs.freedesktop.org/show_bug.cgi?id=104908
---
 .../spec/arb_texture_compression/invalid-formats.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/tests/spec/arb_texture_compression/invalid-formats.c 
b/tests/spec/arb_texture_compression/invalid-formats.c
index a201f8f..cca35cc 100644
--- a/tests/spec/arb_texture_compression/invalid-formats.c
+++ b/tests/spec/arb_texture_compression/invalid-formats.c
@@ -412,6 +412,30 @@ try_formats(const struct format_list *t, GLenum 
*compressed_formats,
return pass;
 }
 
+
+static bool
+test_hint(void)
+{
+   GLint hint = 0;
+   glGetIntegerv(GL_TEXTURE_COMPRESSION_HINT, );
+   if (hint != GL_DONT_CARE) {
+   printf("Unexpected default GL_TEXTURE_COMPRESSION_HINT"
+  " value: %s\n", piglit_get_gl_enum_name(hint));
+   return false;
+   }
+
+   glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
+   glGetIntegerv(GL_TEXTURE_COMPRESSION_HINT, );
+   if (hint != GL_NICEST) {
+   printf("Unexpected GL_TEXTURE_COMPRESSION_HINT"
+  " value: %s\n", piglit_get_gl_enum_name(hint));
+   return false;
+   }
+
+   return true;
+}
+
+
 void
 piglit_init(int argc, char **argv)
 {
@@ -593,5 +617,7 @@ piglit_init(int argc, char **argv)
}
}
 
+   pass = test_hint() && pass;
+
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
-- 
2.7.4

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


[Piglit] [PATCH] Fix probing for tests based on arb_uniform_buffer_object/rendering

2018-02-01 Thread Neil Roberts
These tests set up either UBOs or SSBOs containing different values in
order to render squares with different colors, sizes and rotations.
However the test was only probing the center pixel of the square so it
wouldn’t actually matter if the rotation or size was wrong. The
rotation is the only thing that isn’t in the first UBO for a shader
stage so it is important to test it to ensure that the driver can cope
with multiple UBOs.
---
 .../explicit-offset-bufferstorage.c| 66 --
 .../arb_shader_storage_buffer_object/rendering.c   | 66 --
 .../spec/arb_uniform_buffer_object/bufferstorage.c | 66 --
 .../spec/arb_uniform_buffer_object/rendering-dsa.c | 66 --
 tests/spec/arb_uniform_buffer_object/rendering.c   | 66 --
 5 files changed, 250 insertions(+), 80 deletions(-)

diff --git a/tests/spec/arb_enhanced_layouts/explicit-offset-bufferstorage.c 
b/tests/spec/arb_enhanced_layouts/explicit-offset-bufferstorage.c
index 438ba32f2..401c189a8 100644
--- a/tests/spec/arb_enhanced_layouts/explicit-offset-bufferstorage.c
+++ b/tests/spec/arb_enhanced_layouts/explicit-offset-bufferstorage.c
@@ -100,6 +100,10 @@ static const float color[NUM_SQUARES][8] = {
{ 0.2, 0.2, 0.2, 0.2, 0.0, 5.00, 0.0, 0.0 }
 };
 
+static const float clear_color[] = {
+   0.2, 0.2, 0.2, 0.2
+};
+
 /* Square rotations */
 static const float rotation[NUM_SQUARES] = {
0.0,
@@ -183,22 +187,58 @@ piglit_init(int argc, char **argv)
 
setup_ubos();
 
-   glClearColor(0.2, 0.2, 0.2, 0.2);
+   glClearColor(clear_color[0], clear_color[1],
+clear_color[2], clear_color[3]);
 }
 
 
 static bool
-probe(int x, int y, int color_index)
+probe(int square_index)
 {
-   float expected[4];
+   float square_color[4];
+   const float *expected;
+
+   assert(piglit_width == piglit_height);
+
+   float cx = (pos_size[square_index][2] / 2.0f + 0.5f) * piglit_width;
+   float cy = (pos_size[square_index][3] / 2.0f + 0.5f) * piglit_height;
+   int size = pos_size[square_index][6] * piglit_width - 2;
+   float rot = rotation[square_index];
+   float rot_cos = cosf(rot);
+   float rot_sin = sinf(rot);
 
/* mul color by color_scale */
-   expected[0] = color[color_index][0] * color[color_index][5];
-   expected[1] = color[color_index][1] * color[color_index][5];
-   expected[2] = color[color_index][2] * color[color_index][5];
-   expected[3] = color[color_index][3] * color[color_index][5];
+   for (int i = 0; i < 4; i++) {
+   square_color[i] = (color[square_index][i] *
+  color[square_index][5]);
+   }
+
+   for (int y = -(size / 2) - 4; y <= size / 2 + 4; y++) {
+   for (int x = -(size / 2) - 4 ; x <= size / 2 + 4; x++) {
+   int px = cx + x * rot_cos - y * rot_sin;
+   int py = cy + x * rot_sin + y * rot_cos;
+   /* Skip pixels that are outside of the screen
+* or too close to the edge of the square
+*/
+   if (px < 0 || px >= piglit_width ||
+   py < 0 || py >= piglit_height ||
+   abs(abs(x) - size / 2) <= 2 ||
+   abs(abs(y) - size / 2) <= 2) {
+   continue;
+   }
+
+   if (abs(x) >= size / 2 ||
+   abs(y) >= size / 2)
+   expected = clear_color;
+   else
+   expected = square_color;
+
+   if (!piglit_probe_pixel_rgba(px, py, expected))
+   return false;
+   }
+   }
 
-   return piglit_probe_pixel_rgba(x, y, expected);
+   return true;
 }
 
 
@@ -207,10 +247,6 @@ piglit_display(void)
 {
GLsync fence;
bool pass = true;
-   int x0 = piglit_width / 4;
-   int x1 = piglit_width * 3 / 4;
-   int y0 = piglit_height / 4;
-   int y1 = piglit_height * 3 / 4;
int i;
 
glViewport(0, 0, piglit_width, piglit_height);
@@ -233,10 +269,8 @@ piglit_display(void)
piglit_draw_rect(-1, -1, 2, 2);
}
 
-   pass = probe(x0, y0, 0) && pass;
-   pass = probe(x1, y0, 1) && pass;
-   pass = probe(x0, y1, 2) && pass;
-   pass = probe(x1, y1, 3) && pass;
+   for (i = 0; i < NUM_SQUARES; i++)
+   pass = probe(i) && pass;
 
piglit_present_results();
 
diff --git a/tests/spec/arb_shader_storage_buffer_object/rendering.c 
b/tests/spec/arb_shader_storage_buffer_object/rendering.c
index e68acbfaf..c5afcde1c 100644
--- a/tests/spec/arb_shader_storage_buffer_object/rendering.c
+++ b/tests/spec/arb_shader_storage_buffer_object/rendering.c
@@ -107,6 +107,10 @@ static