cogl/pipeline-state: Move out working unit test to separate file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
This commit is contained in:
parent
ae0f6c549f
commit
16a7f77701
@ -41,8 +41,6 @@
|
|||||||
#include "cogl-pipeline-state-private.h"
|
#include "cogl-pipeline-state-private.h"
|
||||||
#include "cogl-snippet-private.h"
|
#include "cogl-snippet-private.h"
|
||||||
|
|
||||||
#include <test-fixtures/test-unit.h>
|
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#ifndef GL_FUNC_ADD
|
#ifndef GL_FUNC_ADD
|
||||||
@ -1588,39 +1586,3 @@ _cogl_pipeline_hash_fragment_snippets_state (CoglPipeline *authority,
|
|||||||
_cogl_pipeline_snippet_list_hash (&authority->big_state->fragment_snippets,
|
_cogl_pipeline_snippet_list_hash (&authority->big_state->fragment_snippets,
|
||||||
&state->hash);
|
&state->hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_TEST (check_blend_constant_ancestry,
|
|
||||||
0 /* no requirements */,
|
|
||||||
0 /* no known failures */)
|
|
||||||
{
|
|
||||||
CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
|
|
||||||
CoglNode *node;
|
|
||||||
int pipeline_length = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Repeatedly making a copy of a pipeline and changing the same
|
|
||||||
* state (in this case the blend constant) shouldn't cause a long
|
|
||||||
* chain of pipelines to be created because the redundant ancestry
|
|
||||||
* should be pruned. */
|
|
||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
CoglColor color;
|
|
||||||
CoglPipeline *tmp_pipeline;
|
|
||||||
|
|
||||||
cogl_color_init_from_4f (&color, i / 20.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
tmp_pipeline = cogl_pipeline_copy (pipeline);
|
|
||||||
cogl_object_unref (pipeline);
|
|
||||||
pipeline = tmp_pipeline;
|
|
||||||
|
|
||||||
cogl_pipeline_set_blend_constant (pipeline, &color);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (node = (CoglNode *) pipeline; node; node = node->parent)
|
|
||||||
pipeline_length++;
|
|
||||||
|
|
||||||
g_assert_cmpint (pipeline_length, <=, 2);
|
|
||||||
|
|
||||||
cogl_object_unref (pipeline);
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,7 @@ cogl_unit_tests = [
|
|||||||
['test-bitmask', true],
|
['test-bitmask', true],
|
||||||
['test-pipeline-cache', true],
|
['test-pipeline-cache', true],
|
||||||
['test-pipeline-state-known-failure', false],
|
['test-pipeline-state-known-failure', false],
|
||||||
|
['test-pipeline-state', true],
|
||||||
]
|
]
|
||||||
|
|
||||||
test_env = environment()
|
test_env = environment()
|
||||||
|
47
src/tests/cogl/unit/test-pipeline-state.c
Normal file
47
src/tests/cogl/unit/test-pipeline-state.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include "cogl-config.h"
|
||||||
|
|
||||||
|
#include "cogl/cogl.h"
|
||||||
|
#include "cogl/cogl-pipeline-state.h"
|
||||||
|
#include "tests/cogl-test-utils.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_pipeline_state_blend_constant_ancestry (void)
|
||||||
|
{
|
||||||
|
CoglPipeline *pipeline;
|
||||||
|
CoglNode *node;
|
||||||
|
int pipeline_length = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Repeatedly making a copy of a pipeline and changing the same
|
||||||
|
* state (in this case the blend constant) shouldn't cause a long
|
||||||
|
* chain of pipelines to be created because the redundant ancestry
|
||||||
|
* should be pruned. */
|
||||||
|
|
||||||
|
pipeline = cogl_pipeline_new (test_ctx);
|
||||||
|
|
||||||
|
for (i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
CoglColor color;
|
||||||
|
CoglPipeline *tmp_pipeline;
|
||||||
|
|
||||||
|
cogl_color_init_from_4f (&color, i / 20.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
tmp_pipeline = cogl_pipeline_copy (pipeline);
|
||||||
|
cogl_object_unref (pipeline);
|
||||||
|
pipeline = tmp_pipeline;
|
||||||
|
|
||||||
|
cogl_pipeline_set_blend_constant (pipeline, &color);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (node = (CoglNode *) pipeline; node; node = node->parent)
|
||||||
|
pipeline_length++;
|
||||||
|
|
||||||
|
g_assert_cmpint (pipeline_length, <=, 2);
|
||||||
|
|
||||||
|
cogl_object_unref (pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
COGL_TEST_SUITE (
|
||||||
|
g_test_add_func ("/pipeline-state/blend-constant-ancestry",
|
||||||
|
test_pipeline_state_blend_constant_ancestry);
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user