mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
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>
This commit is contained in:
parent
d7164f9579
commit
a654dac122
@ -7,6 +7,7 @@
|
|||||||
typedef struct _TestState
|
typedef struct _TestState
|
||||||
{
|
{
|
||||||
CoglFramebuffer *fb;
|
CoglFramebuffer *fb;
|
||||||
|
CoglContext *context;
|
||||||
} TestState;
|
} TestState;
|
||||||
|
|
||||||
typedef void (* SnippetTestFunc) (TestState *state);
|
typedef void (* SnippetTestFunc) (TestState *state);
|
||||||
@ -590,6 +591,46 @@ test_snippet_order (TestState *state)
|
|||||||
test_utils_check_pixel (165, 5, 0x80ff00ff);
|
test_utils_check_pixel (165, 5, 0x80ff00ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
test_snippet_properties (TestState *state)
|
test_snippet_properties (TestState *state)
|
||||||
{
|
{
|
||||||
@ -651,6 +692,7 @@ tests[] =
|
|||||||
test_replace_vertex_layer,
|
test_replace_vertex_layer,
|
||||||
test_vertex_transform_hook,
|
test_vertex_transform_hook,
|
||||||
test_snippet_order,
|
test_snippet_order,
|
||||||
|
test_naming_texture_units,
|
||||||
test_snippet_properties
|
test_snippet_properties
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -681,6 +723,7 @@ test_cogl_snippets (TestUtilsGTestFixture *fixture,
|
|||||||
TestState state;
|
TestState state;
|
||||||
|
|
||||||
state.fb = shared_state->fb;
|
state.fb = shared_state->fb;
|
||||||
|
state.context = shared_state->ctx;
|
||||||
|
|
||||||
cogl_ortho (/* left, right */
|
cogl_ortho (/* left, right */
|
||||||
0, cogl_framebuffer_get_width (shared_state->fb),
|
0, cogl_framebuffer_get_width (shared_state->fb),
|
||||||
|
Loading…
Reference in New Issue
Block a user