radv/amdgpu: Use reference counting for bos.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 4 Feb 2017 22:26:50 +0000 (23:26 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 29 Mar 2017 06:50:48 +0000 (08:50 +0200)
commitb20af5c8d7e607de781ed22694e67e514a133294
tree61d0a310e0def36e3cec29935e48c6c2c6fe30d4
parente527e62e759547577d3afcb1ea5fafcb8530db4c
radv/amdgpu: Use reference counting for bos.

Per the Vulkan spec, memory objects may be deleted before the buffers
and images using them are deleted, although those resources then
cannot be used except for deletion themselves.

For the virtual buffers, we need to access them on resource destruction
to unmap the regions, so this results in a use-after-free. Implement
reference counting to avoid this.

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.h