+ if (setup->state == SETUP_ACTIVE) {
+ struct lp_scene *scene = setup->scene;
+
+ /* Add the clear to existing scene. In the unusual case where
+ * both color and depth-stencil are being cleared when there's
+ * already been some rendering, we could discard the currently
+ * binned scene and start again, but I don't see that as being
+ * a common usage.
+ */
+ struct lp_rast_clear_rb *cc_scene =
+ (struct lp_rast_clear_rb *)
+ lp_scene_alloc_aligned(scene, sizeof(struct lp_rast_clear_rb), 8);
+
+ if (!cc_scene) {
+ return FALSE;
+ }
+
+ cc_scene->cbuf = cbuf;
+ cc_scene->color_val = uc;
+ clearrb_arg.clear_rb = cc_scene;
+
+ if (!lp_scene_bin_everywhere(scene,
+ LP_RAST_OP_CLEAR_COLOR,
+ clearrb_arg))
+ return FALSE;
+ }
+ else {
+ /* Put ourselves into the 'pre-clear' state, specifically to try
+ * and accumulate multiple clears to color and depth_stencil
+ * buffers which the app or state-tracker might issue
+ * separately.
+ */
+ set_scene_state( setup, SETUP_CLEARED, __FUNCTION__ );
+
+ assert(PIPE_CLEAR_COLOR0 == (1 << 2));
+ setup->clear.flags |= 1 << (cbuf + 2);
+ setup->clear.color_val[cbuf] = uc;
+ }
+
+ return TRUE;
+}
+
+static boolean
+lp_setup_try_clear_zs(struct lp_setup_context *setup,
+ double depth,
+ unsigned stencil,
+ unsigned flags)
+{
+ uint64_t zsmask = 0;
+ uint64_t zsvalue = 0;
+ uint32_t zmask32;
+ uint8_t smask8;
+ enum pipe_format format = setup->fb.zsbuf->format;
+
+ LP_DBG(DEBUG_SETUP, "%s state %d\n", __FUNCTION__, setup->state);
+
+ zmask32 = (flags & PIPE_CLEAR_DEPTH) ? ~0 : 0;
+ smask8 = (flags & PIPE_CLEAR_STENCIL) ? ~0 : 0;