summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-02-10 16:58:31 +0000
committerNeil Roberts <neil@linux.intel.com>2012-02-13 17:29:29 +0000
commita654dac122ea88ce1a942015e4b328ad6ae814af (patch)
treec094b7a1ac528ba4a1ced1051fa2dc0383e7cd4e
parentd7164f9579d92f383fb6e7db26cfcd92a93f63b6 (diff)
downloadcogl-a654dac122ea88ce1a942015e4b328ad6ae814af.tar.gz
test-snippets: Add a test case for sampling arbitrary units
This adds a sub-test that samples from two texture units by naming their layer numbers. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--tests/conform/test-snippets.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 2692b093..655b3404 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -7,6 +7,7 @@
typedef struct _TestState
{
CoglFramebuffer *fb;
+ CoglContext *context;
} TestState;
typedef void (* SnippetTestFunc) (TestState *state);
@@ -591,6 +592,46 @@ test_snippet_order (TestState *state)
}
static void
+test_naming_texture_units (TestState *state)
+{
+ CoglPipeline *pipeline;
+ CoglSnippet *snippet;
+ CoglTexture *tex1, *tex2;
+
+ /* Test that we can sample from an arbitrary texture unit by naming
+ its layer number */
+
+ snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
+ NULL,
+ NULL);
+ cogl_snippet_set_replace (snippet,
+ "cogl_color_out = "
+ "texture2D (cogl_sampler100, vec2 (0.0, 0.0)) + "
+ "texture2D (cogl_sampler200, vec2 (0.0, 0.0));");
+
+ tex1 = test_utils_create_color_texture (state->context, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (state->context, 0x00ff00ff);
+
+ pipeline = cogl_pipeline_new ();
+
+ cogl_pipeline_set_layer_texture (pipeline, 100, tex1);
+ cogl_pipeline_set_layer_texture (pipeline, 200, tex2);
+
+ cogl_pipeline_add_snippet (pipeline, snippet);
+
+ cogl_push_source (pipeline);
+ cogl_rectangle (0, 0, 10, 10);
+ cogl_pop_source ();
+
+ cogl_object_unref (pipeline);
+ cogl_object_unref (snippet);
+ cogl_object_unref (tex1);
+ cogl_object_unref (tex2);
+
+ test_utils_check_pixel (5, 5, 0xffff00ff);
+}
+
+static void
test_snippet_properties (TestState *state)
{
CoglSnippet *snippet;
@@ -651,6 +692,7 @@ tests[] =
test_replace_vertex_layer,
test_vertex_transform_hook,
test_snippet_order,
+ test_naming_texture_units,
test_snippet_properties
};
@@ -681,6 +723,7 @@ test_cogl_snippets (TestUtilsGTestFixture *fixture,
TestState state;
state.fb = shared_state->fb;
+ state.context = shared_state->ctx;
cogl_ortho (/* left, right */
0, cogl_framebuffer_get_width (shared_state->fb),