i915g: Release old fragment shader sampler views with current pipe
authorStuart Abercrombie <sabercrombie@chromium.org>
Thu, 11 Apr 2013 17:57:43 +0000 (10:57 -0700)
committerStéphane Marchesin <marcheu@chromium.org>
Thu, 18 Apr 2013 01:15:12 +0000 (18:15 -0700)
We were trying to use a destroy method from a deleted context.
This fix is based on what's in the svga driver.

Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
src/gallium/drivers/i915/i915_state.c

index 37ad1ed61c8ec4c3484e3dff2da1176a80714b84..4a4faa5298c082630d5877a43c3bee8c819b8ce5 100644 (file)
@@ -711,13 +711,18 @@ static void i915_set_fragment_sampler_views(struct pipe_context *pipe,
        !memcmp(i915->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
-   for (i = 0; i < num; i++)
+   for (i = 0; i < num; i++) {
+      /* Note: we're using pipe_sampler_view_release() here to work around
+       * a possible crash when the old view belongs to another context that
+       * was already destroyed.
+       */
+      pipe_sampler_view_release(pipe, &i915->fragment_sampler_views[i]);
       pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
                                   views[i]);
+   }
 
    for (i = num; i < i915->num_fragment_sampler_views; i++)
-      pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
-                                  NULL);
+      pipe_sampler_view_release(pipe, &i915->fragment_sampler_views[i]);
 
    i915->num_fragment_sampler_views = num;