summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@cl.no>2013-10-10 18:10:52 +0200
committerRobert Bragg <robert@linux.intel.com>2013-10-28 15:59:18 +0000
commit71406438c5357eb4e0ef03e940c5456a536602a0 (patch)
tree549411a482035fabe1edbf087ac8b2873e60799d /tests
parent9bd1ee544667cfe7ecae479ec7f778446dd8f326 (diff)
downloadcogl-71406438c5357eb4e0ef03e940c5456a536602a0.tar.gz
Add API to control per-framebuffer depth writing
Add framebuffer methods cogl_framebuffer_[gs]et_depth_write_enabled() and backend bits to pass the state on to glDepthMask(). This allows us to enable or disable depth writing per-framebuffer, which if disabled saves us some work in glClear(). When rendering, the flag is combined with the pipeline's depth writing flag using a logical AND. Depth writing is enabled by default. https://bugzilla.gnome.org/show_bug.cgi?id=709827 Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/conform/test-depth-test.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/conform/test-depth-test.c b/tests/conform/test-depth-test.c
index 7dca65fc..7b9cdf77 100644
--- a/tests/conform/test-depth-test.c
+++ b/tests/conform/test-depth-test.c
@@ -28,6 +28,7 @@ typedef struct
CoglBool test_enable;
CoglDepthTestFunction test_function;
CoglBool write_enable;
+ CoglBool fb_write_enable;
float range_near;
float range_far;
} TestDepthState;
@@ -62,6 +63,7 @@ draw_rectangle (TestState *state,
cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
+ cogl_framebuffer_set_depth_write_enabled (test_fb, rect_state->fb_write_enable);
cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
cogl_framebuffer_draw_rectangle (test_fb,
@@ -120,6 +122,7 @@ paint (TestState *state)
FALSE, /* depth test enable */
COGL_DEPTH_TEST_FUNCTION_ALWAYS,
TRUE, /* depth write enable */
+ TRUE, /* FB depth write enable */
0, 1 /* depth range */
};
/* Furthest */
@@ -129,6 +132,7 @@ paint (TestState *state)
TRUE, /* depth test enable */
COGL_DEPTH_TEST_FUNCTION_ALWAYS,
TRUE, /* depth write enable */
+ TRUE, /* FB depth write enable */
0, 1 /* depth range */
};
/* In the middle */
@@ -138,6 +142,7 @@ paint (TestState *state)
TRUE, /* depth test enable */
COGL_DEPTH_TEST_FUNCTION_NEVER,
TRUE, /* depth write enable */
+ TRUE, /* FB depth write enable */
0, 1 /* depth range */
};
@@ -165,6 +170,19 @@ paint (TestState *state)
test_depth (state, 4, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
0x0000ffff); /* expected */
+
+ rect1_state.write_enable = TRUE;
+ rect1_state.fb_write_enable = FALSE;
+ test_depth (state, 4, 0, /* position */
+ &rect0_state, &rect1_state, &rect2_state,
+ 0x0000ffff); /* expected */
+
+ /* Re-enable FB depth writing to verify state flush */
+ rect1_state.write_enable = TRUE;
+ rect1_state.fb_write_enable = TRUE;
+ test_depth (state, 4, 0, /* position */
+ &rect0_state, &rect1_state, &rect2_state,
+ 0x00ff00ff); /* expected */
}
/* Check that the depth buffer values can be mapped into different
@@ -178,6 +196,7 @@ paint (TestState *state)
TRUE, /* depth test enable */
COGL_DEPTH_TEST_FUNCTION_ALWAYS,
TRUE, /* depth write enable */
+ TRUE, /* FB depth write enable */
0.5, 1 /* depth range */
};
/* Furthest by depth, nearest by depth range */
@@ -187,6 +206,7 @@ paint (TestState *state)
TRUE, /* depth test enable */
COGL_DEPTH_TEST_FUNCTION_GREATER,
TRUE, /* depth write enable */
+ TRUE, /* FB depth write enable */
0, 0.5 /* depth range */
};