summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <nroberts@igalia.com>2017-11-10 18:28:10 +0100
committerNeil Roberts <nroberts@igalia.com>2018-02-07 17:49:58 +0100
commit3943e72582a08620dbde122c66ed35417bc197f8 (patch)
tree1b27cd34bd530ca97e255b102662b368b5ceb425
parent891f1ee52c86ec03fa2523e48e9a23c122e4fac0 (diff)
shader_draw_parameters: Also test using an indirect draw
The test can now take an extra argument ‘indirect’ which will cause it to emit the draw calls via an indirect buffer. This is useful to test at least on i965 because emitting the gl_BaseVertex takes a different path in that case. Reviewed-by: Antia Puentes <apuentes@igalia.com>
-rw-r--r--tests/all.py10
-rw-r--r--tests/spec/arb_shader_draw_parameters/basevertex.c122
2 files changed, 104 insertions, 28 deletions
diff --git a/tests/all.py b/tests/all.py
index a681cd26e..310161a57 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4882,15 +4882,17 @@ with profile.test_list.group_manager(
grouptools.join('spec', 'ARB_shader_draw_parameters')) as g:
g(['arb_shader_draw_parameters-drawid', 'drawid'], 'drawid')
g(['arb_shader_draw_parameters-drawid', 'vertexid'], 'drawid-vertexid')
- g(['arb_shader_draw_parameters-basevertex', 'basevertex'], 'basevertex')
- g(['arb_shader_draw_parameters-basevertex', 'baseinstance'], 'baseinstance')
- g(['arb_shader_draw_parameters-basevertex', 'basevertex-baseinstance'], 'basevertex-baseinstance')
- g(['arb_shader_draw_parameters-basevertex', 'vertexid-zerobased'], 'vertexid-zerobased')
g(['arb_shader_draw_parameters-drawid-indirect', 'drawid'], 'drawid-indirect')
g(['arb_shader_draw_parameters-drawid-indirect', 'basevertex'], 'drawid-indirect-basevertex')
g(['arb_shader_draw_parameters-drawid-indirect', 'baseinstance'], 'drawid-indirect-baseinstance')
g(['arb_shader_draw_parameters-drawid-indirect', 'vertexid'], 'drawid-indirect-vertexid')
+ variables = ('basevertex', 'baseinstance', 'basevertex-baseinstance', 'vertexid-zerobased')
+ for v in variables:
+ g(['arb_shader_draw_parameters-basevertex', v], v)
+ for v in variables:
+ g(['arb_shader_draw_parameters-basevertex', v, 'indirect'], v + '-indirect')
+
# Group ARB_indirect_parameters
with profile.test_list.group_manager(
PiglitGLTest,
diff --git a/tests/spec/arb_shader_draw_parameters/basevertex.c b/tests/spec/arb_shader_draw_parameters/basevertex.c
index 333d4e2e9..4db6cd17b 100644
--- a/tests/spec/arb_shader_draw_parameters/basevertex.c
+++ b/tests/spec/arb_shader_draw_parameters/basevertex.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2015 Intel Corporation
+ * Copyright © 2015, 2017 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -82,6 +82,8 @@ static const char fs_text[] =
" gl_FragColor = color;\n"
"}\n";
+static bool opt_draw_indirect = false;
+
void
piglit_init(int argc, char **argv)
{
@@ -105,16 +107,102 @@ piglit_init(int argc, char **argv)
piglit_report_result(PIGLIT_FAIL);
}
+ if (argc > 2) {
+ if (strcmp(argv[2], "indirect") == 0) {
+ opt_draw_indirect = true;
+ } else {
+ printf("Unknown second argument: %s\n", argv[2]);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ }
+
piglit_require_GLSL_version(330);
piglit_require_extension("GL_ARB_shader_draw_parameters");
piglit_require_extension("GL_ARB_base_instance");
+ if (opt_draw_indirect)
+ piglit_require_extension("GL_ARB_draw_indirect");
prog = piglit_build_simple_program(vs_text, fs_text);
glUseProgram(prog);
}
+static void
+draw_direct(void)
+{
+ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, NULL);
+
+ /* We use this monster to draw the right half of the
+ * window. Base vertex so that we can reuse the indices to
+ * draw with vertices and colors 4-7, base instance so that we
+ * can verify that the value presented in the shader is
+ * correct. We only draw one instance so the only effect of
+ * instancing is that gl_BaseInstanceARB is 7.
+ */
+ glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, 6,
+ GL_UNSIGNED_INT,
+ NULL, 1,
+ 4, /* basevertex */
+ 7 /* baseinstance */);
+
+ /* Test using glDrawArrays with a non-zero ‘first’ parameter.
+ * This value should be included in gl_VertexID but not in
+ * gl_BaseVertex.
+ */
+ glDrawArrays(GL_TRIANGLE_STRIP,
+ 8, /* first */
+ 4 /* count */);
+}
+
+static void
+draw_indirect(void)
+{
+ GLuint params_bo;
+
+ static const GLuint draw_params[] = {
+ 6, /* count */
+ 1, /* prim count */
+ 0, /* firstIndex */
+ 0, /* baseVertex */
+ 0, /* baseInstance */
+
+ 6, /* count */
+ 1, /* prim count */
+ 0, /* firstIndex */
+ 4, /* baseVertex */
+ 7, /* baseInstance */
+
+ 4, /* count */
+ 1, /* prim count */
+ 8, /* first */
+ 0, /* baseInstance */
+ };
+
+ glGenBuffers(1, &params_bo);
+ glBindBuffer(GL_DRAW_INDIRECT_BUFFER, params_bo);
+ glBufferData(GL_DRAW_INDIRECT_BUFFER,
+ sizeof draw_params,
+ draw_params,
+ GL_STATIC_DRAW);
+
+ /* The draw commands are all equivalent to those in draw_direct. */
+
+ glDrawElementsIndirect(GL_TRIANGLES,
+ GL_UNSIGNED_INT,
+ (void *) 0);
+
+ glDrawElementsIndirect(GL_TRIANGLES,
+ GL_UNSIGNED_INT,
+ (void *) (5 * sizeof draw_params[0]));
+
+ glDrawArraysIndirect(GL_TRIANGLE_STRIP,
+ (void *) (10 * sizeof draw_params[0]));
+
+ glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
+ glDeleteBuffers(1, &params_bo);
+}
+
enum piglit_result
piglit_display()
{
@@ -162,7 +250,7 @@ piglit_display()
float green[] = { 0, 1, 0, 1 };
- GLuint vao, vbo;
+ GLuint vao, vbo, ibo;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
@@ -170,6 +258,10 @@ piglit_display()
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, 2048, NULL, GL_STATIC_DRAW);
+ glGenBuffers(1, &ibo);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof indices, indices, GL_STATIC_DRAW);
+
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 0);
glVertexAttribIPointer(1, 4, GL_UNSIGNED_INT, 4 * sizeof(int), (void *) 1024);
@@ -180,28 +272,10 @@ piglit_display()
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertex_array), vertex_array);
glBufferSubData(GL_ARRAY_BUFFER, 1024, sizeof(reference_array), reference_array);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, indices);
-
- /* We use this monster to draw the right half of the
- * window. Base vertex so that we can reuse the indices to
- * draw with vertices and colors 4-7, base instance so that we
- * can verify that the value presented in the shader is
- * correct. We only draw one instance so the only effect of
- * instancing is that gl_BaseInstanceARB is 7.
- */
- glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, 6,
- GL_UNSIGNED_INT,
- indices, 1,
- 4, /* basevertex */
- 7 /* baseinstance */);
-
- /* Test using glDrawArrays with a non-zero ‘first’ parameter.
- * This value should be included in gl_VertexID but not in
- * gl_BaseVertex.
- */
- glDrawArrays(GL_TRIANGLE_STRIP,
- 8, /* first */
- 4 /* count */);
+ if (opt_draw_indirect)
+ draw_indirect();
+ else
+ draw_direct();
pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
green);