+static void
+clear_color(struct iris_context *ice,
+ struct pipe_resource *p_res,
+ unsigned level,
+ const struct pipe_box *box,
+ bool render_condition_enabled,
+ enum isl_format format,
+ union isl_color_value color)
+{
+ struct iris_resource *res = (void *) p_res;
+
+ struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];
+ const struct gen_device_info *devinfo = &batch->screen->devinfo;
+ enum blorp_batch_flags blorp_flags = 0;
+
+ if (render_condition_enabled) {
+ if (ice->state.predicate == IRIS_PREDICATE_STATE_DONT_RENDER)
+ return;
+
+ if (ice->state.predicate == IRIS_PREDICATE_STATE_USE_BIT)
+ blorp_flags |= BLORP_BATCH_PREDICATE_ENABLE;
+ }
+
+ iris_batch_maybe_flush(batch, 1500);
+
+ struct blorp_batch blorp_batch;
+ blorp_batch_init(&ice->blorp, &blorp_batch, batch, blorp_flags);
+
+ bool color_write_disable[4] = { false, false, false, false };
+ struct blorp_surf surf;
+ iris_blorp_surf_for_resource(&surf, p_res, ISL_AUX_USAGE_NONE, true);
+
+ if (!isl_format_supports_rendering(devinfo, format) &&
+ isl_format_is_rgbx(format))
+ format = isl_format_rgbx_to_rgba(format);
+
+ blorp_clear(&blorp_batch, &surf, format, ISL_SWIZZLE_IDENTITY,
+ level, box->z, box->depth, box->x, box->y,
+ box->x + box->width, box->y + box->height,
+ color, color_write_disable);
+
+ blorp_batch_finish(&blorp_batch);
+ iris_flush_and_dirty_for_history(ice, batch, res);
+}
+
+
+static void
+clear_depth_stencil(struct iris_context *ice,
+ struct pipe_resource *p_res,
+ unsigned level,
+ const struct pipe_box *box,
+ bool render_condition_enabled,
+ bool clear_depth,
+ bool clear_stencil,
+ float depth,
+ uint8_t stencil)
+{
+ struct iris_resource *res = (void *) p_res;
+
+ struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];
+ enum blorp_batch_flags blorp_flags = 0;
+
+ if (render_condition_enabled) {
+ if (ice->state.predicate == IRIS_PREDICATE_STATE_DONT_RENDER)
+ return;
+
+ if (ice->state.predicate == IRIS_PREDICATE_STATE_USE_BIT)
+ blorp_flags |= BLORP_BATCH_PREDICATE_ENABLE;
+ }
+
+ iris_batch_maybe_flush(batch, 1500);
+
+ struct blorp_batch blorp_batch;
+ blorp_batch_init(&ice->blorp, &blorp_batch, batch, blorp_flags);
+
+ struct iris_resource *z_res;
+ struct iris_resource *stencil_res;
+ struct blorp_surf z_surf;
+ struct blorp_surf stencil_surf;
+
+ iris_get_depth_stencil_resources(p_res, &z_res, &stencil_res);
+
+ if (z_res) {
+ iris_blorp_surf_for_resource(&z_surf, &z_res->base,
+ ISL_AUX_USAGE_NONE, true);
+ }
+
+ if (stencil_res) {
+ iris_blorp_surf_for_resource(&stencil_surf, &stencil_res->base,
+ ISL_AUX_USAGE_NONE, true);
+ }
+
+ blorp_clear_depth_stencil(&blorp_batch, &z_surf, &stencil_surf,
+ level, box->z, box->depth,
+ box->x, box->y,
+ box->x + box->width,
+ box->y + box->height,
+ clear_depth && z_res, depth,
+ clear_stencil && stencil_res ? 0xff : 0, stencil);
+
+ blorp_batch_finish(&blorp_batch);
+ iris_flush_and_dirty_for_history(ice, batch, res);
+}
+