Mesa (master): r300g: fix segfault when resizing a DRI2 framebuffer

Marek Olšák mareko at kemper.freedesktop.org
Sun May 2 11:10:09 UTC 2010


Module: Mesa
Branch: master
Commit: 45d79af644349882b4990b775737405be7cd1aa2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=45d79af644349882b4990b775737405be7cd1aa2

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun May  2 01:55:44 2010 +0200

r300g: fix segfault when resizing a DRI2 framebuffer

Resetting tiling flags might happen after a texture is destroyed...
Looking at the kernel sources, we don't actually need to reset the tiling
flags.

---

 src/gallium/drivers/r300/r300_state.c |   41 +++-----------------------------
 1 files changed, 4 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 9319dad..e337245 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -538,46 +538,12 @@ static void r300_set_stencil_ref(struct pipe_context* pipe,
 }
 
 /* This switcheroo is needed just because of goddamned MACRO_SWITCH. */
-static void r300_fb_update_tiling_flags(struct r300_context *r300,
+static void r300_fb_set_tiling_flags(struct r300_context *r300,
                                const struct pipe_framebuffer_state *old_state,
                                const struct pipe_framebuffer_state *new_state)
 {
     struct r300_texture *tex;
-    unsigned i, j, level;
-
-    /* Reset tiling flags for old surfaces to default values. */
-    for (i = 0; i < old_state->nr_cbufs; i++) {
-        for (j = 0; j < new_state->nr_cbufs; j++) {
-            if (old_state->cbufs[i]->texture == new_state->cbufs[j]->texture) {
-                break;
-            }
-        }
-        /* If not binding the surface again... */
-        if (j != new_state->nr_cbufs) {
-            continue;
-        }
-
-        tex = r300_texture(old_state->cbufs[i]->texture);
-
-        if (tex) {
-            r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
-                                            tex->pitch[0],
-                                            tex->microtile,
-                                            tex->macrotile);
-        }
-    }
-    if (old_state->zsbuf &&
-        (!new_state->zsbuf ||
-         old_state->zsbuf->texture != new_state->zsbuf->texture)) {
-        tex = r300_texture(old_state->zsbuf->texture);
-
-        if (tex) {
-            r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
-                                            tex->pitch[0],
-                                            tex->microtile,
-                                            tex->macrotile);
-        }
-    }
+    unsigned i, level;
 
     /* Set tiling flags for new surfaces. */
     for (i = 0; i < new_state->nr_cbufs; i++) {
@@ -644,7 +610,8 @@ static void
         r300->dsa_state.dirty = TRUE;
     }
 
-    r300_fb_update_tiling_flags(r300, r300->fb_state.state, state);
+    /* The tiling flags are dependent on the surface miplevel, unfortunately. */
+    r300_fb_set_tiling_flags(r300, r300->fb_state.state, state);
 
     memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state));
 




More information about the mesa-commit mailing list