libdrm-radeon: unreference buffer once cs stream is submited or on cs clean

BO are referenced once by reloc to make sure that they not destroyed
before we get a chance to flush the cmd stream, so we need to unreference
them once in cs submit or cs erase if cs i never submitted so bo can
be destructed.
main
Jerome Glisse 2008-11-14 12:13:53 +01:00
parent bfbecc5c42
commit 080a45624b
1 changed files with 14 additions and 4 deletions

View File

@ -251,7 +251,7 @@ static int cs_gem_emit(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
uint64_t chunk_array[2];
int r;
int r, i;
chunk_array[0] = (uint64_t)(intptr_t)&csg->chunks[0];
chunk_array[1] = (uint64_t)(intptr_t)&csg->chunks[1];
@ -261,10 +261,11 @@ static int cs_gem_emit(struct radeon_cs *cs)
r = drmCommandWriteRead(cs->csm->fd, DRM_RADEON_CS2,
&csg->cs, sizeof(struct drm_radeon_cs2));
if (r) {
return r;
for (i = 0; i < csg->base.crelocs; i++) {
radeon_bo_unref(csg->relocs_bo[i]);
csg->relocs_bo[i] = NULL;
}
return 0;
return r;
}
static int cs_gem_destroy(struct radeon_cs *cs)
@ -281,7 +282,16 @@ static int cs_gem_destroy(struct radeon_cs *cs)
static int cs_gem_erase(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
int i;
if (csg->relocs_bo) {
for (i = 0; i < csg->base.crelocs; i++) {
if (csg->relocs_bo[i]) {
radeon_bo_unref(csg->relocs_bo[i]);
csg->relocs_bo[i] = NULL;
}
}
}
cs->relocs_total_size = 0;
cs->cdw = 0;
cs->section = 0;