[Piglit] [PATCH] draw-elements: test glMultiDrawElements(GL_UNSIGNED_BYTE)

2017-02-17 Thread Marek Olšák
From: Marek Olšák 

this was broken in radeonsi
---
 tests/general/draw-elements.c | 34 +++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/tests/general/draw-elements.c b/tests/general/draw-elements.c
index 29436cf..d20e85a 100644
--- a/tests/general/draw-elements.c
+++ b/tests/general/draw-elements.c
@@ -55,22 +55,24 @@ void piglit_init(int argc, char **argv)
}
 
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
piglit_require_gl_version(15);
 
glShadeModel(GL_FLAT);
glClearColor(0.2, 0.2, 0.2, 1.0);
 }
 
-static void test_ubyte_indices(float x1, float y1, float x2, float y2, int 
index)
+static void test_ubyte_indices(float x1, float y1, float x2, float y2, int 
test)
 {
+   bool use_multi = test / 4;
+   int index = test % 4;
float v[] = {
x1, y1,
x1, y2,
x2, y1,
 
x1, y1,
x1, y2,
x2, y1,
 
x1, y1,
@@ -93,25 +95,46 @@ static void test_ubyte_indices(float x1, float y1, float 
x2, float y2, int index
11, 11, 11, 11
};
GLuint buf;
 
glVertexPointer(2, GL_FLOAT, 0, v);
 
if (!user) {
glGenBuffers(1, );
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indx), indx, 
GL_STATIC_DRAW);
-   glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, 
(void*)(intptr_t)(index*9));
+   if (use_multi) {
+   GLsizei count[] = {3, 3};
+   /* We need 2 draws in order to get non-zero in
+* pipe_draw_info::start, so make the second draw
+* a zero-area triangle. */
+   const void *offset[] = {(void*)(intptr_t)(index*9),
+   (void*)(intptr_t)1};
+   glMultiDrawElements(GL_TRIANGLES, count,
+   GL_UNSIGNED_BYTE, offset, 2);
+   } else {
+   glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE,
+  (void*)(intptr_t)(index*9));
+   }
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDeleteBuffers(1, );
} else {
-   glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, indx + 
index*9);
+   if (use_multi) {
+   GLsizei count[] = {3, 3};
+   /* The second draw is a zero-area triangle. */
+   const void *indices[] = {indx + index*9, indx + 1};
+   glMultiDrawElements(GL_TRIANGLES, count,
+   GL_UNSIGNED_BYTE, indices, 2);
+   } else {
+   glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE,
+  indx + index*9);
+   }
}
 }
 
 static void test_ushort_indices(float x1, float y1, float x2, float y2, int 
index)
 {
float v[] = {
x1, y1,
x1, y2,
x2, y1,
 
@@ -208,20 +231,25 @@ struct test {
int flag;
const char *name;
 };
 
 struct test tests[] = {
{test_ubyte_indices, 0, {1, 1, 1}, BOTH, "Ubyte indices - offset: 0"},
{test_ubyte_indices, 1, {1, 1, 1}, BOTH, "Ubyte indices - offset: 1"},
{test_ubyte_indices, 2, {1, 1, 1}, BOTH, "Ubyte indices - offset: 2"},
{test_ubyte_indices, 3, {1, 1, 1}, BOTH, "Ubyte indices - offset: 3"},
 
+   {test_ubyte_indices, 4, {1, 1, 1}, BOTH, "Ubyte indices - offset: 0 
(glMultiDraw)"},
+   {test_ubyte_indices, 5, {1, 1, 1}, BOTH, "Ubyte indices - offset: 1 
(glMultiDraw)"},
+   {test_ubyte_indices, 6, {1, 1, 1}, BOTH, "Ubyte indices - offset: 2 
(glMultiDraw)"},
+   {test_ubyte_indices, 7, {1, 1, 1}, BOTH, "Ubyte indices - offset: 3 
(glMultiDraw)"},
+
{test_ushort_indices, 0, {1, 1, 1}, BOTH, "Ushort indices - offset: 0"},
{test_ushort_indices, 1, {1, 1, 1}, BOTH, "Ushort indices - offset: 2"},
 
{test_large_index_count, 1, {1, 1, 1}, USER, "Large index count"},
{test_large_indexbuf_offset, 0, {1, 1, 1}, VBO, "Large index offset"},
 
{0}
 };
 
 enum piglit_result
-- 
2.7.4

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


Re: [Piglit] [PATCH] gles-es-3.10: unsized-array-not-in-last-position

2017-02-17 Thread Andres Gomez
Reviewed-by: Andres Gomez 

On Fri, 2017-02-10 at 14:15 +0100, Jose Maria Casanova Crespo wrote:
> From GLSL ES 3.10 spec, section 4.1.9 "Arrays":
> 
> "If an array is declared as the last member of a shader storage block
> and the size is not specified at compile-time, it is sized at run-time.
> In all other cases, arrays are sized only at compile-time."
> 
> Signed-off-by: Jose Maria Casanova Crespo 
> ---
>  .../unsized-array-not-in-last-position.comp | 21 
> +
>  1 file changed, 21 insertions(+)
>  create mode 100644 
> tests/spec/glsl-es-3.10/compiler/unsized-array-not-in-last-position.comp
> 
> diff --git 
> a/tests/spec/glsl-es-3.10/compiler/unsized-array-not-in-last-position.comp 
> b/tests/spec/glsl-es-3.10/compiler/unsized-array-not-in-last-position.comp
> new file mode 100644
> index 000..fc9219d
> --- /dev/null
> +++ b/tests/spec/glsl-es-3.10/compiler/unsized-array-not-in-last-position.comp
> @@ -0,0 +1,21 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 3.10 es
> +// [end config]
> +
> +#version 310 es
> +
> +/* From GLSL ES 3.10 spec, section 4.1.9 "Arrays":
> + *
> + * "If an array is declared as the last member of a shader storage block
> + *  and the size is not specified at compile-time, it is sized at run-time.
> + *  In all other cases, arrays are sized only at compile-time."
> + */
> +
> +buffer ssbo {
> + int c[];
> + vec4 d;
> +};
> +
> +void main(void) {
> +}
-- 
Br,

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