#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "util/u_inlines.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
#include "util/u_upload_mgr.h"
#include "util/ralloc.h"
#include "iris_context.h"
{
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 (res->aux.usage == ISL_AUX_USAGE_NONE)
+ if (INTEL_DEBUG & DEBUG_NO_FAST_CLEAR)
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)
+ if (!isl_aux_usage_has_fast_clears(res->aux.usage))
return false;
/* Check for partial clear */
if (box->x > 0 || box->y > 0 ||
- box->width < p_res->width0 ||
- box->height < p_res->height0) {
+ box->width < minify(p_res->width0, level) ||
+ box->height < minify(p_res->height0, level)) {
return false;
}
* 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).
blorp_batch_init(&ice->blorp, &blorp_batch, batch, blorp_flags);
struct blorp_surf surf;
- iris_blorp_surf_for_resource(&ice->vtbl, &surf, p_res, res->aux.usage,
- level, true);
+ iris_blorp_surf_for_resource(&ice->vtbl, &batch->screen->isl_dev, &surf,
+ p_res, res->aux.usage, level, true);
/* 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
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);
}
if (p_res->target == PIPE_BUFFER)
- util_range_add(&res->valid_buffer_range, box->x, box->x + box->width);
+ util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + box->width);
iris_batch_maybe_flush(batch, 1500);
box->z, box->depth, aux_usage);
struct blorp_surf surf;
- iris_blorp_surf_for_resource(&ice->vtbl, &surf, p_res, aux_usage, level,
- true);
+ iris_blorp_surf_for_resource(&ice->vtbl, &batch->screen->isl_dev, &surf,
+ p_res, aux_usage, level, true);
struct blorp_batch blorp_batch;
blorp_batch_init(&ice->blorp, &blorp_batch, batch, blorp_flags);
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);
float depth)
{
struct pipe_resource *p_res = (void *) res;
+ struct pipe_context *ctx = (void *) ice;
+ struct iris_screen *screen = (void *) ctx->screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
+
+ if (INTEL_DEBUG & DEBUG_NO_FAST_CLEAR)
+ return false;
/* Check for partial clears */
if (box->x > 0 || box->y > 0 ||
if (!(res->aux.has_hiz & (1 << level)))
return false;
- return true;
+ return blorp_can_hiz_clear_depth(devinfo, &res->surf, res->aux.usage,
+ level, box->z, box->x, box->y,
+ box->x + box->width,
+ box->y + box->height);
}
static void
* 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;
}
return;
}
- if (z_res) {
+ if (clear_depth && z_res) {
iris_resource_prepare_depth(ice, batch, z_res, level, box->z, box->depth);
- iris_blorp_surf_for_resource(&ice->vtbl, &z_surf, &z_res->base,
- z_res->aux.usage, level, true);
+ iris_blorp_surf_for_resource(&ice->vtbl, &batch->screen->isl_dev,
+ &z_surf, &z_res->base, z_res->aux.usage,
+ level, true);
}
struct blorp_batch blorp_batch;
blorp_batch_init(&ice->blorp, &blorp_batch, batch, blorp_flags);
- if (stencil_res) {
- iris_blorp_surf_for_resource(&ice->vtbl, &stencil_surf,
- &stencil_res->base, stencil_res->aux.usage,
- level, true);
+ uint8_t stencil_mask = clear_stencil && stencil_res ? 0xff : 0;
+ if (stencil_mask) {
+ iris_resource_prepare_access(ice, batch, stencil_res, level, 1, box->z,
+ box->depth, stencil_res->aux.usage, false);
+ iris_blorp_surf_for_resource(&ice->vtbl, &batch->screen->isl_dev,
+ &stencil_surf, &stencil_res->base,
+ stencil_res->aux.usage, level, true);
}
blorp_clear_depth_stencil(&blorp_batch, &z_surf, &stencil_surf,
box->x + box->width,
box->y + box->height,
clear_depth && z_res, depth,
- clear_stencil && stencil_res ? 0xff : 0, stencil);
+ stencil_mask, 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) {
+ if (clear_depth && z_res) {
iris_resource_finish_depth(ice, z_res, level,
box->z, box->depth, true);
}
+
+ if (stencil_mask) {
+ iris_resource_finish_write(ice, stencil_res, level, box->z, box->depth,
+ stencil_res->aux.usage);
+ }
}
/**
uint8_t stencil = 0;
if (fmt_desc->unpack_z_float)
- fmt_desc->unpack_z_float(&depth, 0, data, 0, 1, 1);
+ util_format_unpack_z_float(p_res->format, &depth, data, 1);
if (fmt_desc->unpack_s_8uint)
- fmt_desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1);
+ util_format_unpack_s_8uint(p_res->format, &stencil, data, 1);
clear_depth_stencil(ice, p_res, level, box, true, true, true,
depth, stencil);