radeon: fix pointer dangling
authorJerome Glisse <glisse@freedesktop.org>
Sun, 16 Nov 2008 16:58:43 +0000 (17:58 +0100)
committerJerome Glisse <glisse@freedesktop.org>
Sun, 16 Nov 2008 16:58:43 +0000 (17:58 +0100)
src/mesa/drivers/dri/r300/Makefile
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_screen.c

index d0616aaca6e26b7925f01d880f38eee988aa4634..cbb09e6ce5913489004fc89825afb4964d609824 100644 (file)
@@ -57,8 +57,7 @@ C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
 
 DRIVER_DEFINES = -DCOMPILE_R300 -DR200_MERGED=0 \
        -DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300 \
-#      -DRADEON_BO_TRACK_REF \
-#      -DRADEON_BO_TRACK_OPEN \
+#      -DRADEON_BO_TRACK \
        -Wall
 
 SYMLINKS = \
index b8740e298badaab5a081a38d90195904d48f1de7..9d0ed698e160ec70c89cfe9b88a99bf18fb7bba6 100644 (file)
@@ -83,6 +83,7 @@ int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller)
        r300->cmdbuf.flushing = 1;
     if (r300->cmdbuf.cs->cdw) {
         ret = radeon_cs_emit(r300->cmdbuf.cs);
+        r300->hw.all_dirty = 1;
     }
     radeon_cs_erase(r300->cmdbuf.cs);
        r300->cmdbuf.flushing = 0;
@@ -208,8 +209,7 @@ void r300EmitState(r300ContextPtr r300)
        if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_PRIMS))
                fprintf(stderr, "%s\n", __FUNCTION__);
 
-       if (r300->cmdbuf.cs->cdw && !r300->hw.is_dirty
-           && !r300->hw.all_dirty)
+       if (r300->cmdbuf.cs->cdw && !r300->hw.is_dirty && !r300->hw.all_dirty)
                return;
 
        /* To avoid going across the entire set of states multiple times, just check
@@ -325,7 +325,7 @@ static void emit_cb_offset(r300ContextPtr r300, struct r300_state_atom * atom)
     if (r300->radeon.radeonScreen->driScreen->dri2.enabled) {
         rrb = fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
     }
-       if (!rrb) {
+       if (!rrb || !rrb->bo) {
                fprintf(stderr, "no rrb\n");
                return;
        }
index d2628633d484d67dbd56a526bbb613b7f9fb7313..4405b7a3f50fc0ab6e0eecaeb02e6331a9256223 100644 (file)
@@ -169,6 +169,7 @@ static void r300EmitVec(GLcontext * ctx, struct r300_aos *aos,
        uint32_t *out;
     uint32_t bo_size;
 
+    memset(aos, 0, sizeof(struct r300_aos));
        if (stride == 0) {
         bo_size = size * 4;
                count = 1;
@@ -428,7 +429,6 @@ int r300EmitArrays(GLcontext * ctx)
                for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
                        swizzle[i][ci] = ci;
                }
-
                r300EmitVec(ctx, &rmesa->state.aos[i],
                                vb->AttribPtr[tab[i]]->data,
                                vb->AttribPtr[tab[i]]->size,
@@ -486,8 +486,7 @@ void r300ReleaseArrays(GLcontext * ctx)
        }
        for (i = 0; i < rmesa->state.aos_count; i++) {
                if (rmesa->state.aos[i].bo) {
-                       radeon_bo_unref(rmesa->state.aos[i].bo);
-                       rmesa->state.aos[i].bo = 0;
+                       rmesa->state.aos[i].bo = radeon_bo_unref(rmesa->state.aos[i].bo);
                }
        }
 }
index 30efc0b6dbcd9b94dcf6aca080e80f88c6d91916..4fea82289106d564aff25c98a1dcf26a16f4f254 100644 (file)
@@ -510,10 +510,6 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
     if (t->mt) {
         t->mt = NULL;
     }
-    if (rImage->bo) {
-        radeon_bo_unref(rImage->bo);
-        rImage->bo = NULL;
-    }
     if (rImage->mt) {
         r300_miptree_unreference(rImage->mt);
         rImage->mt = NULL;
index 3a1ab8d96ed706e4504656aaed498d2219a77b31..2f4d06110f918552d9eda54605447ce8943f723a 100644 (file)
@@ -199,27 +199,33 @@ void radeonCleanupContext(radeonContextPtr radeon)
     rb = (void *)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_DEPTH].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     fb = (void*)radeon->dri.readable->driverPrivate;
     rb = (void *)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_DEPTH].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
 
        /* _mesa_destroy_context() might result in calls to functions that
index 79cc4c8c8efd6d47c92ba094bc87ec1aefdf7716..9b5f2201b299fe4ddb30d43277ca74bd2240ea75 100644 (file)
@@ -1179,6 +1179,7 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
 
     radeonSetSpanFunctions(ret);
 
+    ret->bo = NULL;
     return ret;
 }
 
@@ -1365,14 +1366,17 @@ radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
     rb = (void *)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
     rb = (void *)fb->Attachment[BUFFER_DEPTH].Renderbuffer;
     if (rb && rb->bo) {
         radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
     }
    _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
 }