{
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;
-
- if (devinfo->gen > 9)
- return false;
-
if (res->aux.usage == ISL_AUX_USAGE_NONE)
return false;
- /* Surface state can only record one fast clear color value. Therefore
- * unless different levels/layers agree on the color it can be used to
- * represent only single level/layer. Here it will be reserved for the
- * first slice (level 0, layer 0).
- */
- if (level > 0 || box->z > 0 || box->depth > 1)
- return false;
-
/* Check for partial clear */
if (box->x > 0 || box->y > 0 ||
box->width < p_res->width0 ||
* during resolves because the resolve operations only know about the
* resource and not the renderbuffer.
*/
- if (render_format != format)
+ if (isl_format_srgb_to_linear(render_format) !=
+ isl_format_srgb_to_linear(format)) {
return false;
+ }
/* XXX: if (irb->mt->supports_fast_clear)
* see intel_miptree_create_for_dri_image()
static union isl_color_value
convert_fast_clear_color(struct iris_context *ice,
struct iris_resource *res,
+ enum isl_format render_format,
const union isl_color_value color)
{
union isl_color_value override_color = color;
}
/* Handle linear to SRGB conversion */
- if (util_format_is_srgb(format)) {
+ if (isl_format_is_srgb(render_format)) {
for (int i = 0; i < 3; i++) {
override_color.f32[i] =
util_format_linear_to_srgb_float(override_color.f32[i]);
const enum isl_aux_state aux_state =
iris_resource_get_aux_state(res, level, box->z);
- color = convert_fast_clear_color(ice, res, color);
+ color = convert_fast_clear_color(ice, res, format, color);
bool color_changed = !!memcmp(&res->aux.clear_color, &color,
sizeof(color));
* is not something that should happen often, we stall on the CPU here
* to resolve the predication, and then proceed.
*/
- iris_resolve_conditional_render(ice);
+ ice->vtbl.resolve_conditional_render(ice);
if (ice->state.predicate == IRIS_PREDICATE_STATE_DONT_RENDER)
return;
+
+ /* If we are clearing to a new clear value, we need to resolve fast
+ * clears from other levels/layers first, since we can't have different
+ * levels/layers with different fast clear colors.
+ */
+ for (unsigned res_lvl = 0; res_lvl < res->surf.levels; res_lvl++) {
+ const unsigned level_layers =
+ iris_get_num_logical_layers(res, res_lvl);
+ for (unsigned layer = 0; layer < level_layers; layer++) {
+ if (res_lvl == level &&
+ layer >= box->z &&
+ layer < box->z + box->depth) {
+ /* We're going to clear this layer anyway. Leave it alone. */
+ continue;
+ }
+
+ enum isl_aux_state aux_state =
+ iris_resource_get_aux_state(res, res_lvl, layer);
+
+ if (aux_state != ISL_AUX_STATE_CLEAR &&
+ aux_state != ISL_AUX_STATE_PARTIAL_CLEAR &&
+ aux_state != ISL_AUX_STATE_COMPRESSED_CLEAR) {
+ /* This slice doesn't have any fast-cleared bits. */
+ continue;
+ }
+
+ /* If we got here, then the level may have fast-clear bits that use
+ * the old clear value. We need to do a color resolve to get rid
+ * of their use of the clear color before we can change it.
+ * Fortunately, few applications ever change their clear color at
+ * different levels/layers, so this shouldn't happen often.
+ */
+ iris_resource_prepare_access(ice, batch, res,
+ res_lvl, 1, layer, 1,
+ res->aux.usage,
+ false);
+ perf_debug(&ice->dbg,
+ "Resolving resource (%p) level %d, layer %d: color changing from "
+ "(%0.2f, %0.2f, %0.2f, %0.2f) to "
+ "(%0.2f, %0.2f, %0.2f, %0.2f)\n",
+ res, res_lvl, layer,
+ res->aux.clear_color.f32[0],
+ res->aux.clear_color.f32[1],
+ res->aux.clear_color.f32[2],
+ res->aux.clear_color.f32[3],
+ color.f32[0], color.f32[1], color.f32[2], color.f32[3]);
+ }
+ }
}
iris_resource_set_clear_color(ice, res, color);
* and again afterwards to ensure that the resolve is complete before we
* do any more regular drawing.
*/
- iris_emit_end_of_pipe_sync(batch, PIPE_CONTROL_RENDER_TARGET_FLUSH);
+ iris_emit_end_of_pipe_sync(batch,
+ "fast clear: pre-flush",
+ PIPE_CONTROL_RENDER_TARGET_FLUSH);
/* If we reach this point, we need to fast clear to change the state to
* ISL_AUX_STATE_CLEAR, or to update the fast clear color (or both).
iris_blorp_surf_for_resource(&ice->vtbl, &surf, p_res, res->aux.usage,
level, true);
- blorp_fast_clear(&blorp_batch, &surf, format,
+ /* In newer gens (> 9), the hardware will do a linear -> sRGB conversion of
+ * the clear color during the fast clear, if the surface format is of sRGB
+ * type. We use the linear version of the surface format here to prevent
+ * that from happening, since we already do our own linear -> sRGB
+ * conversion in convert_fast_clear_color().
+ */
+ blorp_fast_clear(&blorp_batch, &surf, isl_format_srgb_to_linear(format),
level, box->z, box->depth,
box->x, box->y, box->x + box->width,
box->y + box->height);
blorp_batch_finish(&blorp_batch);
- iris_emit_end_of_pipe_sync(batch, PIPE_CONTROL_RENDER_TARGET_FLUSH);
+ iris_emit_end_of_pipe_sync(batch,
+ "fast clear: post flush",
+ PIPE_CONTROL_RENDER_TARGET_FLUSH);
iris_resource_set_aux_state(ice, res, level, box->z,
box->depth, ISL_AUX_STATE_CLEAR);
blorp_flags |= BLORP_BATCH_PREDICATE_ENABLE;
}
+ if (p_res->target == PIPE_BUFFER)
+ util_range_add(&res->valid_buffer_range, box->x, box->x + box->width);
+
iris_batch_maybe_flush(batch, 1500);
bool can_fast_clear = can_fast_clear_color(ice, p_res, level, box,
color, color_write_disable);
blorp_batch_finish(&blorp_batch);
- iris_flush_and_dirty_for_history(ice, batch, res);
+ iris_flush_and_dirty_for_history(ice, batch, res,
+ PIPE_CONTROL_RENDER_TARGET_FLUSH,
+ "cache history: post color clear");
iris_resource_finish_render(ice, res, level,
box->z, box->depth, aux_usage);
* even more complex, so the easiest thing to do when the fast clear
* depth is changing is to stall on the CPU and resolve the predication.
*/
- iris_resolve_conditional_render(ice);
+ ice->vtbl.resolve_conditional_render(ice);
if (ice->state.predicate == IRIS_PREDICATE_STATE_DONT_RENDER)
return;
if (z_res && clear_depth &&
can_fast_clear_depth(ice, z_res, level, box, depth)) {
fast_clear_depth(ice, z_res, level, box, depth);
- iris_flush_and_dirty_for_history(ice, batch, res);
+ iris_flush_and_dirty_for_history(ice, batch, res, 0,
+ "cache history: post fast Z clear");
clear_depth = false;
z_res = false;
}
clear_stencil && stencil_res ? 0xff : 0, stencil);
blorp_batch_finish(&blorp_batch);
- iris_flush_and_dirty_for_history(ice, batch, res);
+ iris_flush_and_dirty_for_history(ice, batch, res, 0,
+ "cache history: post slow ZS clear");
if (z_res) {
iris_resource_finish_depth(ice, z_res, level,