iris: set image access correctly
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 14 Sep 2018 07:49:13 +0000 (00:49 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:09 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_state.c

index 83978aebb9945e9706472ac3bffb423307451a53..67460fa2669be4688a94bfa6d16c33acfb952ea3 100644 (file)
@@ -255,8 +255,11 @@ struct iris_shader_state {
    struct iris_state_ref ssbo_surface_state[PIPE_MAX_SHADER_BUFFERS];
 
    /** Shader Storage Images (image load store) */
-   struct pipe_resource *image[PIPE_MAX_SHADER_IMAGES];
-   struct iris_state_ref image_surface_state[PIPE_MAX_SHADER_IMAGES];
+   struct {
+      struct pipe_resource *res;
+      struct iris_state_ref surface_state;
+      unsigned access;
+   } image[PIPE_MAX_SHADER_IMAGES];
 
    struct iris_state_ref sampler_table;
    struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS];
index 0b7cc0db5126926862fc1f7da1c9b69d2dfb59b1..3c33d0cc97f2742a488e45922b7a23eb3fe0013d 100644 (file)
@@ -1513,21 +1513,21 @@ iris_set_shader_images(struct pipe_context *ctx,
       if (p_images && p_images[i].resource) {
          const struct pipe_image_view *img = &p_images[i];
          struct iris_resource *res = (void *) img->resource;
-         pipe_resource_reference(&shs->image[start_slot + i], &res->base);
+         pipe_resource_reference(&shs->image[start_slot + i].res, &res->base);
 
          // XXX: these are not retained forever, use a separate uploader?
          void *map =
             upload_state(ice->state.surface_uploader,
-                         &shs->image_surface_state[start_slot + i],
+                         &shs->image[start_slot + i].surface_state,
                          4 * GENX(RENDER_SURFACE_STATE_length), 64);
          if (!unlikely(map)) {
-            pipe_resource_reference(&shs->image[start_slot + i], NULL);
+            pipe_resource_reference(&shs->image[start_slot + i].res, NULL);
             return;
          }
 
          struct iris_bo *surf_state_bo =
-            iris_resource_bo(shs->image_surface_state[start_slot + i].res);
-         shs->image_surface_state[start_slot + i].offset +=
+            iris_resource_bo(shs->image[start_slot + i].surface_state.res);
+         shs->image[start_slot + i].surface_state.offset +=
             iris_bo_offset_from_base_address(surf_state_bo);
 
          isl_surf_usage_flags_t usage = ISL_SURF_USAGE_STORAGE_BIT;
@@ -1567,8 +1567,8 @@ iris_set_shader_images(struct pipe_context *ctx,
                                   .mocs = MOCS_WB);
          }
       } else {
-         pipe_resource_reference(&shs->image[start_slot + i], NULL);
-         pipe_resource_reference(&shs->image_surface_state[start_slot + i].res,
+         pipe_resource_reference(&shs->image[start_slot + i].res, NULL);
+         pipe_resource_reference(&shs->image[start_slot + i].surface_state.res,
                                  NULL);
       }
    }
@@ -3252,12 +3252,13 @@ static uint32_t
 use_image(struct iris_batch *batch, struct iris_context *ice,
           struct iris_shader_state *shs, int i)
 {
-   if (!shs->image[i])
+   if (!shs->image[i].res)
       return use_null_surface(batch, ice);
 
-   struct iris_state_ref *surf_state = &shs->image_surface_state[i];
+   struct iris_state_ref *surf_state = &shs->image[i].surface_state;
 
-   iris_use_pinned_bo(batch, iris_resource_bo(shs->image[i]), true);
+   iris_use_pinned_bo(batch, iris_resource_bo(shs->image[i].res),
+                      shs->image[i].access & PIPE_IMAGE_ACCESS_WRITE);
    iris_use_pinned_bo(batch, iris_resource_bo(surf_state->res), false);
 
    return surf_state->offset;