iris: Unreference some more things on state module teardown
[mesa.git] / src / gallium / drivers / iris / iris_resource.c
index 0751b19267c1d130da712729b93c76a88bb0ac5d..ca8832c5b345d0afd1eda6686f845849ad819f89 100644 (file)
@@ -824,6 +824,12 @@ iris_transfer_map(struct pipe_context *ctx,
    struct iris_resource *res = (struct iris_resource *)resource;
    struct isl_surf *surf = &res->surf;
 
+    /* If we can discard the whole resource, we can also discard the
+     * subrange being accessed.
+     */
+    if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)
+       usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
    if (surf->tiling != ISL_TILING_LINEAR &&
        (usage & PIPE_TRANSFER_MAP_DIRECTLY))
       return NULL;
@@ -841,9 +847,6 @@ iris_transfer_map(struct pipe_context *ctx,
    struct iris_transfer *map = slab_alloc(&ice->transfer_pool);
    struct pipe_transfer *xfer = &map->base;
 
-   // PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
-   // PIPE_TRANSFER_DISCARD_RANGE
-
    if (!map)
       return NULL;
 
@@ -930,6 +933,13 @@ iris_flush_and_dirty_for_history(struct iris_context *ice,
       return;
 
    unsigned flush = PIPE_CONTROL_CS_STALL;
+
+   /* We've likely used the rendering engine (i.e. BLORP) to write to this
+    * surface.  Flush the render cache so the data actually lands.
+    */
+   if (batch->name != IRIS_BATCH_COMPUTE)
+      flush |= PIPE_CONTROL_RENDER_TARGET_FLUSH;
+
    uint64_t dirty = 0ull;
 
    if (res->bind_history & PIPE_BIND_CONSTANT_BUFFER) {