[Piglit] [PATCH 6/7] arb_vertex_attrib_binding: Test instance-divisor
Eric Anholt
eric at anholt.net
Wed Oct 30 19:13:53 CET 2013
Fredrik Höglund <fredrik at kde.org> writes:
> diff --git a/tests/spec/arb_vertex_attrib_binding/instance-divisor.c b/tests/spec/arb_vertex_attrib_binding/instance-divisor.c
> new file mode 100644
> index 0000000..88ae454
> --- /dev/null
> +++ b/tests/spec/arb_vertex_attrib_binding/instance-divisor.c
> +const char *vs_source =
> + "attribute vec4 pos;\n"
> + "attribute vec2 offset;\n"
> + "attribute vec4 color;\n"
> + "uniform vec2 global_offset;\n"
> + "varying vec4 col;\n"
> + "void main() {\n"
> + " col = color;\n"
> + " gl_Position = pos + vec4(global_offset + offset, vec2(0, 0));\n"
> + "}";
> +enum piglit_result
> +piglit_display(void)
> +{
> + const struct vec2 quad[] = {
> + { -0.125, 0.125 }, { 0.125, 0.125 },
> + { -0.125, -0.125 }, { 0.125, -0.125 }
> + };
> +
> + const struct vec2 offsets[] = {
> + { -.75, 0 }, { -.25, 0 }, { .25, 0 }, { .75, 0 }
> + };
> +
> + const struct vec4 colors[] = {
> + { 1.0, 0.0, 0.0, 1.0 },
> + { 0.0, 1.0, 0.0, 1.0 },
> + { 0.0, 0.0, 1.0, 1.0 },
> + { 1.0, 1.0, 1.0, 1.0 }
> + };
> +
> + GLuint vbo1, vbo2, vbo3, vao;
> + bool pass = true;
> +
> + glGenVertexArrays(1, &vao);
> + glBindVertexArray(vao);
> +
> + glGenBuffers(1, &vbo1);
> + glGenBuffers(1, &vbo2);
> + glGenBuffers(1, &vbo3);
> +
> + glBindBuffer(GL_ARRAY_BUFFER, vbo1);
> + glBufferData(GL_ARRAY_BUFFER, sizeof(quad), (const GLvoid *) quad, GL_STATIC_DRAW);
> +
> + glBindBuffer(GL_ARRAY_BUFFER, vbo2);
> + glBufferData(GL_ARRAY_BUFFER, sizeof(offsets), (const GLvoid *) offsets, GL_STATIC_DRAW);
I'm confused why there's both pos/quad (with two names) and offset.
Could you just have a single pre-baked pos vec2?
> + pass = piglit_probe_pixel_rgba(piglit_width * .125, piglit_height * .75, (const float *) &colors[0]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .375, piglit_height * .75, (const float *) &colors[1]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .625, piglit_height * .75, (const float *) &colors[2]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .875, piglit_height * .75, (const float *) &colors[3]);
> +
> + pass = piglit_probe_pixel_rgba(piglit_width * .125, piglit_height * .25, (const float *) &colors[0]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .375, piglit_height * .25, (const float *) &colors[0]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .625, piglit_height * .25, (const float *) &colors[1]);
> + pass = piglit_probe_pixel_rgba(piglit_width * .875, piglit_height * .25, (const float *) &colors[1]);
Again, not required, but I like probe_rect (when the HW craps out and
only draws some of the pixels, you get fewer false positives).
> +void
> +piglit_init(int argc, char **argv)
> +{
> + GLuint vs, fs;
> +
> + piglit_require_extension("GL_ARB_vertex_attrib_binding");
Since I think we're enabling this extension on all Mesa drivers
regardless of HW support for instancing, I think this should also depend
on GL_ARB_instanced_arrays. (It's not called out in the spec because
they wrote it against 4.2).
> + vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
> + fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
> + program = piglit_link_simple_program(vs, fs);
piglit_build_simple_program().
> + pos = glGetAttribLocation(program, "pos");
> + offset = glGetAttribLocation(program, "offset");
> + color = glGetAttribLocation(program, "color");
> + global_offset = glGetUniformLocation(program, "global_offset");
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20131030/5fcb4e11/attachment-0001.pgp>
More information about the Piglit
mailing list