iris: Implement ALT mode for ARB_{vertex,fragment}_shader
[mesa.git] / src / gallium / drivers / iris / iris_resolve.c
index 06f44c022b9d660cd5d8b25cf3c182422433b20b..737bcfe0e90fb26cb1b6b9a0e1e0b2c84f154234 100644 (file)
@@ -39,11 +39,11 @@ static void
 resolve_sampler_views(struct iris_batch *batch,
                       struct iris_shader_state *shs)
 {
-   for (int i = 0; i < shs->num_textures; i++) {
-      struct iris_sampler_view *isv = shs->textures[i];
-      if (!isv)
-         continue;
+   uint32_t views = shs->bound_sampler_views;
 
+   while (views) {
+      const int i = u_bit_scan(&views);
+      struct iris_sampler_view *isv = shs->textures[i];
       struct iris_resource *res = (void *) isv->base.texture;
 
       // XXX: aux tracking
@@ -51,6 +51,22 @@ resolve_sampler_views(struct iris_batch *batch,
    }
 }
 
+static void
+resolve_image_views(struct iris_batch *batch,
+                    struct iris_shader_state *shs)
+{
+   uint32_t views = shs->bound_image_views;
+
+   while (views) {
+      const int i = u_bit_scan(&views);
+      struct pipe_resource *res = shs->image[i].res;
+
+      // XXX: aux tracking
+      iris_cache_flush_for_read(batch, iris_resource_bo(res));
+   }
+}
+
+
 /**
  * \brief Resolve buffers before drawing.
  *
@@ -58,15 +74,11 @@ resolve_sampler_views(struct iris_batch *batch,
  * enabled depth texture, and flush the render cache for any dirty textures.
  */
 void
-iris_predraw_resolve_inputs(struct iris_context *ice,
-                            struct iris_batch *batch)
+iris_predraw_resolve_inputs(struct iris_batch *batch,
+                            struct iris_shader_state *shs)
 {
-   for (gl_shader_stage stage = 0; stage < MESA_SHADER_STAGES; stage++) {
-      struct iris_shader_state *shs = &ice->state.shaders[stage];
-      resolve_sampler_views(batch, shs);
-   }
-
-   // XXX: storage images
+   resolve_sampler_views(batch, shs);
+   resolve_image_views(batch, shs);
 }
 
 void