[2/2] arb_robustness: add test for empty vbo

Submitted by Erik Faye-Lund on Dec. 5, 2018, 11:31 a.m.

Details

Message ID 20181205113110.20672-2-erik.faye-lund@collabora.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Erik Faye-Lund Dec. 5, 2018, 11:31 a.m.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
---
 tests/spec/arb_robustness/draw-vbo-bounds.c | 77 ++++++++++++++++++++-
 1 file changed, 75 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_robustness/draw-vbo-bounds.c b/tests/spec/arb_robustness/draw-vbo-bounds.c
index 4d031ff6f..76e2df7d3 100644
--- a/tests/spec/arb_robustness/draw-vbo-bounds.c
+++ b/tests/spec/arb_robustness/draw-vbo-bounds.c
@@ -47,6 +47,21 @@ 
 
 #include "piglit-util-gl.h"
 
+static enum piglit_result
+do_random(void *);
+
+static enum piglit_result
+empty_vbo(void *);
+
+static struct piglit_subtest
+subtests[] = {
+	{ .name = "random", .option = "random", .subtest_func = do_random },
+	{ .name = "empty-vbo", .option = "empty-vbo", .subtest_func = empty_vbo },
+	{ 0 },
+};
+
+static const struct piglit_gl_test_config *piglit_config;
+
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 10;
@@ -56,6 +71,9 @@  PIGLIT_GL_TEST_CONFIG_BEGIN
 	config.window_visual = PIGLIT_GL_VISUAL_RGB;
 	config.khr_no_error_support = PIGLIT_NO_ERRORS;
 
+	config.subtests = subtests;
+	piglit_config = &config;
+
 PIGLIT_GL_TEST_CONFIG_END
 
 void piglit_init(int argc, char **argv)
@@ -191,12 +209,13 @@  test_random(void)
     return pass;
 }
 
-enum piglit_result
-piglit_display(void)
+static enum piglit_result
+do_random(void * data)
 {
     bool pass = true;
     unsigned i;
 
+    glClearColor(0.2, 0.2, 0.2, 1.0);
     glClear(GL_COLOR_BUFFER_BIT);
     glEnableClientState(GL_VERTEX_ARRAY);
 
@@ -205,5 +224,59 @@  piglit_display(void)
         pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
     }
 
+    glDisableClientState(GL_VERTEX_ARRAY);
     return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
+
+static enum piglit_result
+empty_vbo(void * data)
+{
+    bool pass = true;
+    GLuint color_buffer;
+    float black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+
+    if (!piglit_is_extension_supported("GL_ARB_robustness"))
+        return PIGLIT_SKIP;
+
+    glClearColor(1.0, 0.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    float positions[] = {
+         0.0f,  0.0f, 0.0f,
+         piglit_width, 0.0f, 0.0f,
+         0.0f,  piglit_height, 0.0f
+    };
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glVertexPointer(3, GL_FLOAT, 0, positions);
+    glEnableClientState(GL_VERTEX_ARRAY);
+
+    /* use empty buffer object */
+    glGenBuffers(1, &color_buffer);
+    glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
+    glColorPointer(4, GL_FLOAT, 0, NULL);
+    glEnableClientState(GL_COLOR_ARRAY);
+
+    glDrawArrays(GL_TRIANGLES, 0, 3);
+
+    glDisableClientState(GL_VERTEX_ARRAY);
+    glDisableClientState(GL_COLOR_ARRAY);
+
+    pass &= piglit_probe_rect_rgba(1, 1,
+                                   piglit_width / 2 - 1, piglit_height / 2 -1,
+                                   black);
+
+    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+    enum piglit_result result = PIGLIT_PASS;
+    result = piglit_run_selected_subtests(piglit_config->subtests,
+                                          piglit_config->selected_subtests,
+                                          piglit_config->num_selected_subtests,
+                                          result);
+    piglit_present_results();
+    return result;
+}

Comments

On Wed, 2018-12-05 at 12:31 +0100, Erik Faye-Lund wrote:
> Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
> ---

Just a tiny bit of background:
- ARB_robustness defines what happens with zero-sized buffers (should
return all-zero values).
- This test currently pass on i965.
- ...but fail on all gallium drivers. I'm working on patches for the
latter.