summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2013-08-29 14:14:35 +0100
committerNeil Roberts <neil@linux.intel.com>2013-09-02 15:40:15 +0100
commit5ea57b14f5ec7d52ae378f4ca64574ef56342f56 (patch)
tree266b95f4e0e4c1dd0885121ae81f6266dd2ee5fa /tests
parentc28fc054788e88627bcc2346f4c4c368870ff777 (diff)
downloadcogl-5ea57b14f5ec7d52ae378f4ca64574ef56342f56.tar.gz
Add a conformance test for using cogl_point_coord in a shader
This adds a modification to the test-point-sprite test which uses a shader snippet which directly references cogl_point_coord instead of relying on cogl_pipeline_set_layer_point_sprite_coords_enabled to replace the texture coordinates with the point coords. Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/conform/test-conform-main.c4
-rw-r--r--tests/conform/test-point-sprite.c81
2 files changed, 66 insertions, 19 deletions
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 83a631e8..fe3b87c3 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -117,6 +117,10 @@ main (int argc, char **argv)
ADD_TEST (test_point_sprite_orientation,
TEST_REQUIREMENT_POINT_SPRITE,
TEST_KNOWN_FAILURE);
+ ADD_TEST (test_point_sprite_glsl,
+ TEST_REQUIREMENT_POINT_SPRITE |
+ TEST_REQUIREMENT_GLSL,
+ 0);
ADD_TEST (test_version, 0, 0);
diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
index 797673dd..4471a741 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -19,7 +19,8 @@ tex_data[3 * 2 * 2] =
};
static void
-do_test (CoglBool check_orientation)
+do_test (CoglBool check_orientation,
+ CoglBool use_glsl)
{
int fb_width = cogl_framebuffer_get_width (test_fb);
int fb_height = cogl_framebuffer_get_height (test_fb);
@@ -27,7 +28,6 @@ do_test (CoglBool check_orientation)
CoglError *error = NULL;
CoglTexture2D *tex_2d;
CoglPipeline *pipeline, *solid_pipeline;
- CoglBool res;
int tex_height;
cogl_framebuffer_orthographic (test_fb,
@@ -61,20 +61,60 @@ do_test (CoglBool check_orientation)
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
- res = cogl_pipeline_set_layer_point_sprite_coords_enabled (pipeline,
+ cogl_pipeline_set_layer_filters (pipeline,
+ 0, /* layer_index */
+ COGL_PIPELINE_FILTER_NEAREST,
+ COGL_PIPELINE_FILTER_NEAREST);
+ cogl_pipeline_set_point_size (pipeline, POINT_SIZE);
+
+ /* If we're using GLSL then we don't need to enable point sprite
+ * coords and we can just directly reference cogl_point_coord in the
+ * snippet */
+ if (use_glsl)
+ {
+ CoglSnippet *snippet =
+ cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
+ NULL, /* declarations */
+ NULL /* post */);
+ static const char source[] =
+ " cogl_texel = texture2D (cogl_sampler, cogl_point_coord);\n";
+
+ cogl_snippet_set_replace (snippet, source);
+
+ /* Keep a reference to the original pipeline because there is no
+ * way to remove a snippet in order to recreate the solid
+ * pipeline */
+ solid_pipeline = cogl_pipeline_copy (pipeline);
+
+ cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
+
+ cogl_object_unref (snippet);
+ }
+ else
+ {
+ CoglBool res =
+ cogl_pipeline_set_layer_point_sprite_coords_enabled (pipeline,
/* layer_index */
0,
/* enable */
TRUE,
&error);
- g_assert (res == TRUE);
- g_assert (error == NULL);
+ g_assert (res == TRUE);
+ g_assert (error == NULL);
- cogl_pipeline_set_layer_filters (pipeline,
- 0, /* layer_index */
- COGL_PIPELINE_FILTER_NEAREST,
- COGL_PIPELINE_FILTER_NEAREST);
- cogl_pipeline_set_point_size (pipeline, POINT_SIZE);
+ solid_pipeline = cogl_pipeline_copy (pipeline);
+
+ res =
+ cogl_pipeline_set_layer_point_sprite_coords_enabled (solid_pipeline,
+ /* layer_index */
+ 0,
+ /* enable */
+ FALSE,
+ &error);
+
+ g_assert (res == TRUE);
+ g_assert (error == NULL);
+ }
prim = cogl_primitive_new_p2t2 (test_ctx,
COGL_VERTICES_MODE_POINTS,
@@ -85,13 +125,7 @@ do_test (CoglBool check_orientation)
/* Render the primitive again without point sprites to make sure
disabling it works */
- solid_pipeline = cogl_pipeline_copy (pipeline);
- cogl_pipeline_set_layer_point_sprite_coords_enabled (solid_pipeline,
- /* layer_index */
- 0,
- /* enable */
- FALSE,
- &error);
+
cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb,
POINT_SIZE * 2, /* x */
@@ -142,11 +176,20 @@ do_test (CoglBool check_orientation)
void
test_point_sprite (void)
{
- do_test (FALSE /* don't check orientation */);
+ do_test (FALSE /* don't check orientation */,
+ FALSE /* don't use GLSL */);
}
void
test_point_sprite_orientation (void)
{
- do_test (TRUE /* check orientation */);
+ do_test (TRUE /* check orientation */,
+ FALSE /* don't use GLSL */);
+}
+
+void
+test_point_sprite_glsl (void)
+{
+ do_test (FALSE /* don't check orientation */,
+ TRUE /* use GLSL */);
}