[01/14] dsa/utils: Add check_indexed_vao_param()

Submitted by Fredrik Höglund on March 31, 2015, 5:26 p.m.

Details

Message ID 1427822806-18528-2-git-send-email-fredrik@kde.org
State New
Headers show

Not browsing as part of any series.

Commit Message

Fredrik Höglund March 31, 2015, 5:26 p.m.
This function returns true if the given parameter matches the expected
value, and false otherwise.

An error message is printed if the parameter value doesn't match the
expected value.
---
 tests/spec/arb_direct_state_access/dsa-utils.c | 17 +++++++++++++++++
 tests/spec/arb_direct_state_access/dsa-utils.h |  7 +++++++
 2 files changed, 24 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_direct_state_access/dsa-utils.c b/tests/spec/arb_direct_state_access/dsa-utils.c
index ec7bb24..f065dbc 100644
--- a/tests/spec/arb_direct_state_access/dsa-utils.c
+++ b/tests/spec/arb_direct_state_access/dsa-utils.c
@@ -77,3 +77,20 @@  dsa_texture_with_unit(GLuint unit)
 {
 	glUniform1i(dsa_uniform, unit);
 }
+
+bool
+check_indexed_vao_param_(GLuint vao, GLuint index, GLuint param,
+                         GLuint expected, const char *file, int line)
+{
+	GLuint value;
+	glGetVertexArrayIndexediv(vao, index, param, (GLint *) &value);
+
+	if (value != expected) {
+		fprintf(stderr, "%s[%u] was %u, expected %u (%s:%d)\n",
+		        piglit_get_gl_enum_name(param),
+		        index, value, expected, file, line);
+		return false;
+	}
+
+	return true;
+}
diff --git a/tests/spec/arb_direct_state_access/dsa-utils.h b/tests/spec/arb_direct_state_access/dsa-utils.h
index 7bcf004..707a967 100644
--- a/tests/spec/arb_direct_state_access/dsa-utils.h
+++ b/tests/spec/arb_direct_state_access/dsa-utils.h
@@ -59,6 +59,13 @@  void dsa_init_program(void);
 
 void dsa_texture_with_unit(GLuint);
 
+bool check_indexed_vao_param_(GLuint vao, GLuint index, GLuint param,
+                              GLuint expected, const char *file, int line);
+
+#define check_indexed_vao_param(vao, index, param, expected) \
+	check_indexed_vao_param_(vao, index, param, expected, \
+	                         __FILE__, __LINE__)
+
 #ifdef __cplusplus
 } /* end extern "C" */
 #endif

Comments

LGTM, FWIW (I'm really tired today).


Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>

On Tue, Mar 31, 2015 at 10:26 AM, Fredrik Höglund <fredrik@kde.org> wrote:

> This function returns true if the given parameter matches the expected
> value, and false otherwise.
>
> An error message is printed if the parameter value doesn't match the
> expected value.
> ---
>  tests/spec/arb_direct_state_access/dsa-utils.c | 17 +++++++++++++++++
>  tests/spec/arb_direct_state_access/dsa-utils.h |  7 +++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/tests/spec/arb_direct_state_access/dsa-utils.c
> b/tests/spec/arb_direct_state_access/dsa-utils.c
> index ec7bb24..f065dbc 100644
> --- a/tests/spec/arb_direct_state_access/dsa-utils.c
> +++ b/tests/spec/arb_direct_state_access/dsa-utils.c
> @@ -77,3 +77,20 @@ dsa_texture_with_unit(GLuint unit)
>  {
>         glUniform1i(dsa_uniform, unit);
>  }
> +
> +bool
> +check_indexed_vao_param_(GLuint vao, GLuint index, GLuint param,
> +                         GLuint expected, const char *file, int line)
> +{
> +       GLuint value;
> +       glGetVertexArrayIndexediv(vao, index, param, (GLint *) &value);
> +
> +       if (value != expected) {
> +               fprintf(stderr, "%s[%u] was %u, expected %u (%s:%d)\n",
> +                       piglit_get_gl_enum_name(param),
> +                       index, value, expected, file, line);
> +               return false;
> +       }
> +
> +       return true;
> +}
> diff --git a/tests/spec/arb_direct_state_access/dsa-utils.h
> b/tests/spec/arb_direct_state_access/dsa-utils.h
> index 7bcf004..707a967 100644
> --- a/tests/spec/arb_direct_state_access/dsa-utils.h
> +++ b/tests/spec/arb_direct_state_access/dsa-utils.h
> @@ -59,6 +59,13 @@ void dsa_init_program(void);
>
>  void dsa_texture_with_unit(GLuint);
>
> +bool check_indexed_vao_param_(GLuint vao, GLuint index, GLuint param,
> +                              GLuint expected, const char *file, int
> line);
> +
> +#define check_indexed_vao_param(vao, index, param, expected) \
> +       check_indexed_vao_param_(vao, index, param, expected, \
> +                                __FILE__, __LINE__)
> +
>  #ifdef __cplusplus
>  } /* end extern "C" */
>  #endif
> --
> 2.1.4
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>