summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-02-17 14:48:49 +1000
committerDave Airlie <airlied@redhat.com>2009-02-17 14:48:49 +1000
commit9c040745fe1d8c6cad3ac79030ead13fbcb5ae4d (patch)
tree159628c16c869546aa81eb1d5d89cb095dc4d3f0 /src/mesa/drivers
parent7ce6af25e56e28a819c38e60b4371caea3c8b5b0 (diff)
radeon: legacy texMem interface fixups.
The texmem.c interface is wildly messed up it really wants to own the objects so let it, pain in the ass but this code should work a lot better now
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_bo_legacy.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
index 93838b5d92..93ca325e88 100644
--- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
@@ -49,18 +49,23 @@
#include "radeon_common.h"
#include "radeon_bocs_wrapper.h"
+/* no seriously texmem.c is this screwed up */
+struct bo_legacy_texture_object {
+ driTextureObject base;
+ struct bo_legacy *parent;
+};
struct bo_legacy {
struct radeon_bo base;
int map_count;
uint32_t pending;
int is_pending;
- int validated;
int static_bo;
int got_dri_texture_obj;
- int dirty;
uint32_t offset;
- driTextureObject dri_texture_obj;
+ struct bo_legacy_texture_object *tobj;
+ int validated;
+ int dirty;
void *ptr;
struct bo_legacy *next, *prev;
struct bo_legacy *pnext, *pprev;
@@ -85,17 +90,14 @@ 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 = container_of(t, struct bo_legacy, dri_texture_obj);
-
-
- bo_legacy->got_dri_texture_obj = 0;
- bo_legacy->validated = 0;
+ struct bo_legacy_texture_object *tobj = (struct bo_legacy_texture_object *)t;
+
+ if (tobj->parent) {
+ tobj->parent->got_dri_texture_obj = 0;
+ tobj->parent->validated = 0;
+ }
}
static void inline clean_handles(struct bo_manager_legacy *bom)
@@ -247,7 +249,6 @@ static void legacy_track_pending(struct bo_manager_legacy *boml, int debug)
static int legacy_wait_any_pending(struct bo_manager_legacy *boml)
{
struct bo_legacy *bo_legacy;
- struct bo_legacy *next;
legacy_get_current_age(boml);
bo_legacy = boml->pending_bos.pnext;
@@ -377,6 +378,8 @@ static void bo_free(struct bo_legacy *bo_legacy)
/* dma buffers */
bo_dma_free(&bo_legacy->base);
} else {
+ driDestroyTextureObject(&bo_legacy->tobj->base);
+ bo_legacy->tobj = NULL;
/* free backing store */
free(bo_legacy->ptr);
}
@@ -522,10 +525,12 @@ static int bo_vram_validate(struct radeon_bo *bo,
int r;
if (!bo_legacy->got_dri_texture_obj) {
- make_empty_list(&bo_legacy->dri_texture_obj);
- bo_legacy->dri_texture_obj.totalSize = bo->size;
+ bo_legacy->tobj = CALLOC(sizeof(struct bo_legacy_texture_object));
+ bo_legacy->tobj->parent = bo_legacy;
+ make_empty_list(&bo_legacy->tobj->base);
+ bo_legacy->tobj->base.totalSize = bo->size;
r = driAllocateTexture(&boml->texture_heap, 1,
- &bo_legacy->dri_texture_obj);
+ &bo_legacy->tobj->base);
if (r) {
uint8_t *segfault=NULL;
fprintf(stderr, "Ouch! vram_validate failed %d\n", r);
@@ -533,14 +538,15 @@ static int bo_vram_validate(struct radeon_bo *bo,
return -1;
}
bo_legacy->offset = boml->texture_offset +
- bo_legacy->dri_texture_obj.memBlock->ofs;
+ bo_legacy->tobj->base.memBlock->ofs;
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) {
+ driUpdateTextureLRU(&bo_legacy->tobj->base);
+
+ if (bo_legacy->dirty || bo_legacy->tobj->base.dirty_images[0]) {
/* Copy to VRAM using a blit.
* All memory is 4K aligned. We're using 1024 pixels wide blits.
*/
@@ -578,6 +584,7 @@ static int bo_vram_validate(struct radeon_bo *bo,
}
} while (ret == -EAGAIN);
bo_legacy->dirty = 0;
+ bo_legacy->tobj->base.dirty_images[0] = 0;
}
return 0;
}
@@ -646,6 +653,7 @@ void radeon_bo_manager_legacy_dtor(struct radeon_bo_manager *bom)
bo_free(bo_legacy);
bo_legacy = next;
}
+ driDestroyTextureHeap(boml->texture_heap);
free(boml->free_handles);
free(boml);
}
@@ -689,7 +697,7 @@ struct radeon_bo_manager *radeon_bo_manager_legacy_ctor(struct radeon_screen *sc
(drmTextureRegionPtr)scrn->sarea->tex_list[0],
&scrn->sarea->tex_age[0],
&bom->texture_swapped,
- sizeof(struct bo_legacy),
+ sizeof(struct bo_legacy_texture_object),
&bo_legacy_tobj_destroy);
bom->texture_offset = scrn->texOffset[0];