mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
nvk: Fix nvk_heap_free() for contiguous heaps
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26035>
This commit is contained in:
parent
57d6722d79
commit
0ce49d4347
1 changed files with 20 additions and 10 deletions
|
|
@ -224,20 +224,30 @@ nvk_heap_free_locked(struct nvk_device *dev, struct nvk_heap *heap,
|
|||
{
|
||||
assert(addr + size > addr);
|
||||
|
||||
for (uint32_t bo_idx = 0; bo_idx < heap->bo_count; bo_idx++) {
|
||||
if (addr < heap->bos[bo_idx].bo->offset)
|
||||
continue;
|
||||
if (heap->contiguous) {
|
||||
assert(heap->bo_count == 1);
|
||||
uint64_t bo_offset = addr;
|
||||
|
||||
uint64_t bo_offset = addr - heap->bos[bo_idx].bo->offset;
|
||||
if (bo_offset >= heap->bos[bo_idx].bo->size)
|
||||
continue;
|
||||
|
||||
assert(bo_offset + size <= heap->bos[bo_idx].bo->size);
|
||||
uint64_t vma = encode_vma(bo_idx, bo_offset);
|
||||
assert(bo_offset + size <= heap->bos[0].bo->size);
|
||||
uint64_t vma = encode_vma(0, bo_offset);
|
||||
|
||||
util_vma_heap_free(&heap->heap, vma, size);
|
||||
} else {
|
||||
for (uint32_t bo_idx = 0; bo_idx < heap->bo_count; bo_idx++) {
|
||||
if (addr < heap->bos[bo_idx].bo->offset)
|
||||
continue;
|
||||
|
||||
break;
|
||||
uint64_t bo_offset = addr - heap->bos[bo_idx].bo->offset;
|
||||
if (bo_offset >= heap->bos[bo_idx].bo->size)
|
||||
continue;
|
||||
|
||||
assert(bo_offset + size <= heap->bos[bo_idx].bo->size);
|
||||
uint64_t vma = encode_vma(bo_idx, bo_offset);
|
||||
|
||||
util_vma_heap_free(&heap->heap, vma, size);
|
||||
return;
|
||||
}
|
||||
assert(!"Failed to find heap BO");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue