Mesa (radeon-rewrite): radeon: fixup destroy texture object exit path and update LRU

Dave Airlie airlied at kemper.freedesktop.org
Tue Feb 17 01:18:30 UTC 2009


Module: Mesa
Branch: radeon-rewrite
Commit: 7c7ff659ce7684f44b064c09cdca6436d2c2bf64
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c7ff659ce7684f44b064c09cdca6436d2c2bf64

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Feb 17 11:17:22 2009 +1000

radeon: fixup destroy texture object exit path and update LRU

the destroy path was doing bad things with structure names, make it do less
bad things, use container_of instead

---

 src/mesa/drivers/dri/radeon/radeon_bo_legacy.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
index 65b0a9a..1cc039c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
@@ -32,6 +32,7 @@
  *      Jérôme Glisse <glisse at freedesktop.org>
  */
 #include <stdio.h>
+#include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -51,7 +52,6 @@
 
 struct bo_legacy {
     struct radeon_bo    base;
-    driTextureObject    tobj_base;
     int                 map_count;
     uint32_t            pending;
     int                 is_pending;
@@ -85,11 +85,15 @@ struct bo_manager_legacy {
     unsigned                    *free_handles;
 };
 
+#define container_of(ptr, type, member) ({                      \
+        const __typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+        (type *)( (char *)__mptr - offsetof(type,member) );})
+
 static void bo_legacy_tobj_destroy(void *data, driTextureObject *t)
 {
-    struct bo_legacy *bo_legacy;
+    struct bo_legacy *bo_legacy = container_of(t, struct bo_legacy, dri_texture_obj);
+
 
-    bo_legacy = (struct bo_legacy*)((char*)t)-sizeof(struct radeon_bo);
     bo_legacy->got_dri_texture_obj = 0;
     bo_legacy->validated = 0;
 }
@@ -535,6 +539,9 @@ static int bo_vram_validate(struct radeon_bo *bo,
         bo_legacy->got_dri_texture_obj = 1;
         bo_legacy->dirty = 1;
     }
+
+    if (bo_legacy->got_dri_texture_obj)
+      driUpdateTextureLRU(&bo_legacy->dri_texture_obj);
     if (bo_legacy->dirty) {
         /* Copy to VRAM using a blit.
          * All memory is 4K aligned. We're using 1024 pixels wide blits.




More information about the mesa-commit mailing list