i965: When an RB gets a new region, clear the old from the state cache.
authorEric Anholt <eric@anholt.net>
Wed, 5 May 2010 05:02:18 +0000 (22:02 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 5 May 2010 05:06:12 +0000 (22:06 -0700)
This prevents memory usage explosion in blender due to the state cache
hanging on to old fake frontbuffer regions.  Sigh at blender still
using frontbuffer rendering.

Bug #24119.

src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
src/mesa/drivers/dri/intel/intel_pixel_draw.c

index 8ee9a292a1b593a87354414115f6878ae292b679..8c947c41b445dd13c8dbb8a8379296136c7e0d09 100644 (file)
@@ -362,7 +362,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        if (buffers[i].attachment == __DRI_BUFFER_DEPTH)
          depth_region = region;
 
-       intel_renderbuffer_set_region(rb, region);
+       intel_renderbuffer_set_region(intel, rb, region);
        intel_region_release(&region);
 
        if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
@@ -374,7 +374,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                   continue;
 
             intel_region_reference(&stencil_region, region);
-            intel_renderbuffer_set_region(rb, stencil_region);
+            intel_renderbuffer_set_region(intel, rb, stencil_region);
             intel_region_release(&stencil_region);
          }
        }
index 8278d12bb9002543a998988ea5201cfcd4cb86e4..7162c9f5bd653b31cba43878d8725818c2b686b5 100644 (file)
@@ -42,7 +42,9 @@
 #include "intel_fbo.h"
 #include "intel_mipmap_tree.h"
 #include "intel_regions.h"
-
+#ifndef I915
+#include "brw_state.h"
+#endif
 
 #define FILE_DEBUG_FLAG DEBUG_FBO
 
@@ -280,7 +282,8 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
 
 void
-intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
+intel_renderbuffer_set_region(struct intel_context *intel,
+                             struct intel_renderbuffer *rb,
                              struct intel_region *region)
 {
    struct intel_region *old;
@@ -288,6 +291,12 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
    old = rb->region;
    rb->region = NULL;
    intel_region_reference(&rb->region, region);
+#ifndef I915
+   if (old) {
+      brw_state_cache_bo_delete(&brw_context(&intel->ctx)->surface_cache,
+                               old->buffer);
+   }
+#endif
    intel_region_release(&old);
 }
 
index 72413f7369445fe040f3b25f9b67b6d82675a496..028f657d12d48c5d9cf8d3a2e2095ea3a87a07bf 100644 (file)
@@ -82,7 +82,8 @@ intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
 
 
 extern void
-intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
+intel_renderbuffer_set_region(struct intel_context *intel,
+                             struct intel_renderbuffer *irb,
                              struct intel_region *region);
 
 
index bd1dd13fb7d058f6961e7397a9a748290a25f1e7..a40b232fff88c52cfb3598392a967120fa1a38db 100644 (file)
@@ -167,7 +167,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
    irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888);
    irb->Base.Width = depth_irb->Base.Width;
    irb->Base.Height = depth_irb->Base.Height;
-   intel_renderbuffer_set_region(irb, depth_irb->region);
+   intel_renderbuffer_set_region(intel, irb, depth_irb->region);
 
    /* Create a name for our renderbuffer, which lets us use other mesa
     * rb functions for convenience.