iris: Bring back check for srgb and fast clear color.
[mesa.git] / src / gallium / drivers / iris / iris_resolve.c
index bec3117f1a0c45f6ef4dfd93581719be63c8a59c..08d139fcdf7f11d5e6c84f0de70f0dc88509f73e 100644 (file)
@@ -176,6 +176,11 @@ iris_predraw_resolve_framebuffer(struct iris_context *ice,
       if (z_res) {
          iris_resource_prepare_depth(ice, batch, z_res, zs_surf->u.tex.level,
                                      zs_surf->u.tex.first_layer, num_layers);
+         iris_cache_flush_for_depth(batch, z_res->bo);
+      }
+
+      if (s_res) {
+         iris_cache_flush_for_depth(batch, s_res->bo);
       }
    }
 
@@ -191,8 +196,11 @@ iris_predraw_resolve_framebuffer(struct iris_context *ice,
                                         ice->state.blend_enables & (1u << i),
                                         draw_aux_buffer_disabled[i]);
 
-      // XXX: NEW_AUX_STATE
-      ice->state.draw_aux_usage[i] = aux_usage;
+      if (ice->state.draw_aux_usage[i] != aux_usage) {
+         ice->state.draw_aux_usage[i] = aux_usage;
+         /* XXX: Need to track which bindings to make dirty */
+         ice->state.dirty |= IRIS_ALL_DIRTY_BINDINGS;
+      }
 
       iris_resource_prepare_render(ice, batch, res, surf->view.base_level,
                                    surf->view.base_array_layer,
@@ -200,7 +208,7 @@ iris_predraw_resolve_framebuffer(struct iris_context *ice,
                                    aux_usage);
 
       iris_cache_flush_for_render(batch, res->bo, surf->view.format,
-                                  ISL_AUX_USAGE_NONE);
+                                  aux_usage);
    }
 }
 
@@ -406,8 +414,8 @@ iris_resolve_color(struct iris_context *ice,
    //DBG("%s to mt %p level %u layer %u\n", __FUNCTION__, mt, level, layer);
 
    struct blorp_surf surf;
-   iris_blorp_surf_for_resource(&surf, &res->base, res->aux.usage, level,
-                                true);
+   iris_blorp_surf_for_resource(&ice->vtbl, &surf, &res->base, res->aux.usage,
+                                level, true);
 
    iris_batch_maybe_flush(batch, 1500);
 
@@ -449,7 +457,8 @@ iris_mcs_partial_resolve(struct iris_context *ice,
    assert(res->aux.usage == ISL_AUX_USAGE_MCS);
 
    struct blorp_surf surf;
-   iris_blorp_surf_for_resource(&surf, &res->base, res->aux.usage, 0, true);
+   iris_blorp_surf_for_resource(&ice->vtbl, &surf, &res->base, res->aux.usage,
+                                0, true);
 
    struct blorp_batch blorp_batch;
    blorp_batch_init(&ice->blorp, &blorp_batch, batch, 0);
@@ -523,7 +532,7 @@ sample_with_hiz(const struct gen_device_info *devinfo,
  *   - 7.5.3.2 Depth Buffer Resolve
  *   - 7.5.3.3 Hierarchical Depth Buffer Resolve
  */
-static void
+void
 iris_hiz_exec(struct iris_context *ice,
               struct iris_batch *batch,
               struct iris_resource *res,
@@ -587,8 +596,8 @@ iris_hiz_exec(struct iris_context *ice,
    iris_batch_maybe_flush(batch, 1500);
 
    struct blorp_surf surf;
-   iris_blorp_surf_for_resource(&surf, &res->base, ISL_AUX_USAGE_HIZ,
-                                level, true);
+   iris_blorp_surf_for_resource(&ice->vtbl, &surf, &res->base,
+                                ISL_AUX_USAGE_HIZ, level, true);
 
    struct blorp_batch blorp_batch;
    blorp_batch_init(&ice->blorp, &blorp_batch, batch,
@@ -805,12 +814,12 @@ iris_resource_prepare_ccs_access(struct iris_context *ice,
           * pass-through state.  (You can also think of this as being both a
           * resolve and an ambiguate in one operation.)
           */
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_PASS_THROUGH);
          break;
 
       case ISL_AUX_OP_PARTIAL_RESOLVE:
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_COMPRESSED_NO_CLEAR);
          break;
 
@@ -841,10 +850,10 @@ iris_resource_finish_ccs_write(struct iris_context *ice,
                 aux_usage == ISL_AUX_USAGE_CCS_D);
 
          if (aux_usage == ISL_AUX_USAGE_CCS_E) {
-            iris_resource_set_aux_state(res, level, layer, 1,
+            iris_resource_set_aux_state(ice, res, level, layer, 1,
                                         ISL_AUX_STATE_COMPRESSED_CLEAR);
          } else if (aux_state != ISL_AUX_STATE_PARTIAL_CLEAR) {
-            iris_resource_set_aux_state(res, level, layer, 1,
+            iris_resource_set_aux_state(ice, res, level, layer, 1,
                                         ISL_AUX_STATE_PARTIAL_CLEAR);
          }
          break;
@@ -856,7 +865,7 @@ iris_resource_finish_ccs_write(struct iris_context *ice,
 
       case ISL_AUX_STATE_PASS_THROUGH:
          if (aux_usage == ISL_AUX_USAGE_CCS_E) {
-            iris_resource_set_aux_state(res, level, layer, 1,
+            iris_resource_set_aux_state(ice, res, level, layer, 1,
                                         ISL_AUX_STATE_COMPRESSED_NO_CLEAR);
          } else {
             /* Nothing to do */
@@ -873,7 +882,7 @@ iris_resource_finish_ccs_write(struct iris_context *ice,
       switch (aux_state) {
       case ISL_AUX_STATE_CLEAR:
          assert(aux_usage == ISL_AUX_USAGE_CCS_D);
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_PARTIAL_CLEAR);
          break;
 
@@ -909,7 +918,7 @@ iris_resource_prepare_mcs_access(struct iris_context *ice,
    case ISL_AUX_STATE_COMPRESSED_CLEAR:
       if (!fast_clear_supported) {
          iris_mcs_partial_resolve(ice, batch, res, layer, 1);
-         iris_resource_set_aux_state(res, 0, layer, 1,
+         iris_resource_set_aux_state(ice, res, 0, layer, 1,
                                      ISL_AUX_STATE_COMPRESSED_NO_CLEAR);
       }
       break;
@@ -935,7 +944,7 @@ iris_resource_finish_mcs_write(struct iris_context *ice,
 
    switch (iris_resource_get_aux_state(res, 0, layer)) {
    case ISL_AUX_STATE_CLEAR:
-      iris_resource_set_aux_state(res, 0, layer, 1,
+      iris_resource_set_aux_state(ice, res, 0, layer, 1,
                                   ISL_AUX_STATE_COMPRESSED_CLEAR);
       break;
 
@@ -992,13 +1001,13 @@ iris_resource_prepare_hiz_access(struct iris_context *ice,
 
       switch (hiz_op) {
       case ISL_AUX_OP_FULL_RESOLVE:
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_RESOLVED);
          break;
 
       case ISL_AUX_OP_AMBIGUATE:
          /* The HiZ resolve operation is actually an ambiguate */
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_PASS_THROUGH);
          break;
 
@@ -1019,7 +1028,7 @@ iris_resource_finish_hiz_write(struct iris_context *ice,
    switch (iris_resource_get_aux_state(res, level, layer)) {
    case ISL_AUX_STATE_CLEAR:
       assert(aux_usage == ISL_AUX_USAGE_HIZ);
-      iris_resource_set_aux_state(res, level, layer, 1,
+      iris_resource_set_aux_state(ice, res, level, layer, 1,
                                   ISL_AUX_STATE_COMPRESSED_CLEAR);
       break;
 
@@ -1030,17 +1039,17 @@ iris_resource_finish_hiz_write(struct iris_context *ice,
 
    case ISL_AUX_STATE_RESOLVED:
       if (aux_usage == ISL_AUX_USAGE_HIZ) {
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_COMPRESSED_NO_CLEAR);
       } else {
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_AUX_INVALID);
       }
       break;
 
    case ISL_AUX_STATE_PASS_THROUGH:
       if (aux_usage == ISL_AUX_USAGE_HIZ) {
-         iris_resource_set_aux_state(res, level, layer, 1,
+         iris_resource_set_aux_state(ice, res, level, layer, 1,
                                      ISL_AUX_STATE_COMPRESSED_NO_CLEAR);
       }
       break;
@@ -1176,7 +1185,8 @@ iris_resource_get_aux_state(const struct iris_resource *res,
 }
 
 void
-iris_resource_set_aux_state(struct iris_resource *res, uint32_t level,
+iris_resource_set_aux_state(struct iris_context *ice,
+                            struct iris_resource *res, uint32_t level,
                             uint32_t start_layer, uint32_t num_layers,
                             enum isl_aux_state aux_state)
 {
@@ -1194,8 +1204,8 @@ iris_resource_set_aux_state(struct iris_resource *res, uint32_t level,
    for (unsigned a = 0; a < num_layers; a++) {
       if (res->aux.state[level][start_layer + a] != aux_state) {
          res->aux.state[level][start_layer + a] = aux_state;
-         // XXX: dirty works differently
-         // brw->ctx.NewDriverState |= BRW_NEW_AUX_STATE;
+         /* XXX: Need to track which bindings to make dirty */
+         ice->state.dirty |= IRIS_ALL_DIRTY_BINDINGS;
       }
    }
 }
@@ -1361,12 +1371,10 @@ iris_resource_render_aux_usage(struct iris_context *ice,
        * formats.  However, there are issues with blending where it doesn't
        * properly apply the sRGB curve to the clear color when blending.
        */
-      /* XXX:
       if (devinfo->gen >= 9 && blend_enabled &&
           isl_format_is_srgb(render_format) &&
-          !isl_color_value_is_zero_one(res->fast_clear_color, render_format))
+          !isl_color_value_is_zero_one(res->aux.clear_color, render_format))
          return ISL_AUX_USAGE_NONE;
-         */
 
       if (res->aux.usage == ISL_AUX_USAGE_CCS_E &&
           format_ccs_e_compat_with_resource(devinfo, res, render_format))