again:
- done_age = rmesa->radeon.radeonScreen->scratch[2];
+ done_age = rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH];
for (i = rmesa->rmm->u_last + 1; i > 0; i --) {
if (rmesa->rmm->u_list[i].ptr == NULL) {
exit(1);
} else {
#ifdef MM_DEBUG
- fprintf(stderr, "really freed %d at age %x\n", i, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "really freed %d at age %x\n", i, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
if (i == rmesa->rmm->u_last)
rmesa->rmm->u_last --;
//fprintf(stderr, "alloc %p at id %d\n", rmesa->rmm->u_list[i].ptr, i);
#ifdef MM_DEBUG
- fprintf(stderr, "allocated %d at age %x\n", i, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "allocated %d at age %x\n", i, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
return i;
{
unsigned long long ull;
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
drm_r300_cmd_header_t *cmd;
cmd = r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
- cmd[0].scratch.reg = 2;
+ cmd[0].scratch.reg = RADEON_MM_SCRATCH;
cmd[0].scratch.n_bufs = 1;
cmd[0].scratch.flags = 0;
cmd ++;
void *radeon_mm_map(r300ContextPtr rmesa, int id, int access)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
void *ptr;
int tries = 0;
return NULL;
}
- while(rmesa->rmm->u_list[id].age > rmesa->radeon.radeonScreen->scratch[2] && tries++ < 1000)
+ while(rmesa->rmm->u_list[id].age > rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH] && tries++ < 1000)
usleep(10);
if (tries >= 1000) {
fprintf(stderr, "Idling failed (%x vs %x)\n",
- rmesa->rmm->u_list[id].age, rmesa->radeon.radeonScreen->scratch[2]);
+ rmesa->rmm->u_list[id].age, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
return NULL;
}
void radeon_mm_unmap(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
if(rmesa->rmm->u_list[id].mapped == 0)
void radeon_mm_free(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[2]);
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
if(id == 0)
_mesa_delete_buffer_object(ctx, obj);
}
+void r300_evict_vbos(GLcontext *ctx, int amount)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ const struct _mesa_HashTable *hash = ctx->Shared->BufferObjects;
+ GLuint k = _mesa_HashFirstEntry(hash);
+ struct gl_buffer_object *obj;
+ struct r300_buffer_object *r300_obj;
+ GLvoid *data;
+
+ while (amount > 0 && k) {
+ obj = (struct gl_buffer_object *) _mesa_HashLookup(hash, k);
+ r300_obj = (struct r300_buffer_object *) obj;
+
+ if (obj->OnCard && obj->Size) {
+ obj->Data = _mesa_malloc(obj->Size);
+
+ data = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_R);
+ _mesa_memcpy(obj->Data, data, obj->Size);
+ radeon_mm_unmap(rmesa, r300_obj->id);
+
+ radeon_mm_free(rmesa, r300_obj->id);
+ r300_obj->id = 0;
+ obj->OnCard = GL_FALSE;
+
+ amount -= obj->Size;
+ }
+
+ k = _mesa_HashNextEntry(hash, k);
+ }
+
+}
+
void r300_init_vbo_funcs(struct dd_function_table *functions)
{
functions->NewBufferObject = r300NewBufferObject;