[Piglit] [PATCH 2/2] Test glMultiDrawElementsIndirect with non-VBO attribs
Marek Olšák
maraeo at gmail.com
Tue Jul 24 04:11:23 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
tests/opengl.py | 3 +-
.../multidrawelements.c | 69 +++++++++++++------
2 files changed, 50 insertions(+), 22 deletions(-)
diff --git a/tests/opengl.py b/tests/opengl.py
index ce67d485b..3ca4ee74b 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -1750,21 +1750,22 @@ with profile.test_list.group_manager(
g(['arb_draw_indirect-transform-feedback'])
g(['arb_draw_indirect-vertexid'],
'gl_VertexID used with glDrawArraysIndirect')
g(['arb_draw_indirect-vertexid', 'elements'],
'gl_VertexID used with glDrawElementsIndirect')
# Group ARB_draw_indirect
with profile.test_list.group_manager(
PiglitGLTest,
grouptools.join('spec', 'ARB_multi_draw_indirect')) as g:
- g(['gl-3.0-multidrawarrays-vertexid', '-indirect'],
+ g(['gl-3.0-multidrawarrays-vertexid', '-indirect'])
+ g(['arb_draw_elements_base_vertex-multidrawelements', '-indirect'])
# Group ARB_fragment_program
with profile.test_list.group_manager(
PiglitGLTest,
grouptools.join('spec', 'ARB_fragment_program')) as g:
g(['arb_fragment_program-minmax'], 'minmax')
g(['fp-abs-01'])
g(['fp-fog'])
g(['fp-formats'])
g(['fp-fragment-position'])
diff --git a/tests/spec/arb_draw_elements_base_vertex/multidrawelements.c b/tests/spec/arb_draw_elements_base_vertex/multidrawelements.c
index a18d77d37..1038631d3 100644
--- a/tests/spec/arb_draw_elements_base_vertex/multidrawelements.c
+++ b/tests/spec/arb_draw_elements_base_vertex/multidrawelements.c
@@ -48,21 +48,20 @@
* DrawElementsBaseVertex(mode, count[i], type,
* indices[i], basevertex[i]);
*
*/
#include "piglit-util-gl.h"
PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 10;
- config.supports_gl_core_version = 31;
config.window_width = 200;
config.window_height = 200;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
config.khr_no_error_support = PIGLIT_NO_ERRORS;
PIGLIT_GL_TEST_CONFIG_END
const char *vs_source = {
"#version 130\n"
@@ -99,89 +98,117 @@ static GLfloat vertices[] = {
1.0,-1.0
};
static GLsizei vertices_size = sizeof(vertices);
static GLuint indices[] = {
0, 1, 2, 1, 2, 3, /* top square */
4, 5, 6, 5, 6, 7, /* bot square */
};
static GLsizei indices_size = sizeof(indices);
-static const GLvoid * const indices_offset[] = {
- (GLvoid*) 0, (GLvoid*)(6 * sizeof(GLuint))
+static const uintptr_t indices_offset[] = {
+ 0, 6 * sizeof(GLuint)
};
static GLsizei indices_count[] = {
6, 6
};
static GLint basevertex[] = { 2, 2 };
+static bool indirect;
void
piglit_init(int argc, char **argv)
{
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-indirect") == 0) {
+ piglit_require_extension("GL_ARB_multi_draw_indirect");
+ puts("Testing GL_ARB_multi_draw_indirect");
+ indirect = true;
+ }
+ }
+
GLuint program;
GLuint vertex_index;
piglit_require_GLSL_version(130);
if (piglit_get_gl_version() < 32) {
piglit_require_extension("GL_ARB_draw_elements_base_vertex");
}
/* Create program */
program = piglit_build_simple_program(vs_source, fs_source);
glUseProgram(program);
+ /* Retrieve index from vs */
+ vertex_index = glGetAttribLocation(program, "vertex");
+ glEnableVertexAttribArray(vertex_index);
/* Gen vertex array buffer */
- glGenBuffers(1, &vertexBuffer);
- glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
- glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, GL_STATIC_DRAW);
+ if (indirect) {
+ /* Use non-VBO attributes to test this codepath. */
+ glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+ } else {
+ glGenBuffers(1, &vertexBuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
+ glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, GL_STATIC_DRAW);
+
+ glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ }
/* Gen indices array buffer */
glGenBuffers(1, &indexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_size,
indices, GL_STATIC_DRAW);
- /* Gen VAO */
- glGenVertexArrays(1, &vao);
- glBindVertexArray(vao);
-
- /* Retrieve index from vs */
- vertex_index = glGetAttribLocation(program, "vertex");
-
- /* Enabel vertexAttribPointer */
- glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
- glEnableVertexAttribArray(vertex_index);
- glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0);
-
if(!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
enum piglit_result
piglit_display(void)
{
bool pass = true;
float green[] = {0, 1, 0};
float blue[] = {0, 0, 1};
glClearColor(blue[0], blue[1], blue[2], 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
- glMultiDrawElementsBaseVertex(GL_TRIANGLES, indices_count,
- GL_UNSIGNED_INT, (GLvoid*)indices_offset,
- 2, basevertex);
+ if (indirect) {
+ unsigned data[2 * 5];
+
+ for (unsigned i = 0; i < 2; i++) {
+ data[i*5+0] = indices_count[i];
+ data[i*5+1] = 1;
+ data[i*5+2] = indices_offset[i] / sizeof(GLuint);
+ data[i*5+3] = basevertex[i];
+ data[i*5+4] = 0;
+ }
+ GLuint ib;
+
+ glGenBuffers(1, &ib);
+ glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ib);
+ glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(data), data,
+ GL_STATIC_DRAW);
+
+ glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, NULL, 2, 0);
+ glDeleteBuffers(1, &ib);
+ } else {
+ glMultiDrawElementsBaseVertex(GL_TRIANGLES, indices_count,
+ GL_UNSIGNED_INT, (GLvoid*)indices_offset,
+ 2, basevertex);
+ }
/* Check for test pass */
pass = piglit_probe_pixel_rgb(100, 175, blue) && pass;
pass = piglit_probe_pixel_rgb(100, 125, green) && pass;
pass = piglit_probe_pixel_rgb(100, 75, blue) && pass;
pass = piglit_probe_pixel_rgb(100, 25, green) && pass;
if(!piglit_check_gl_error(GL_NO_ERROR))
pass = false;
--
2.17.1
More information about the Piglit
mailing list