mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 11:38:05 +02:00
nvk: support exporting buffers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
e2d0be7d08
commit
32830a2d07
3 changed files with 27 additions and 0 deletions
|
|
@ -283,3 +283,22 @@ nvk_GetDeviceMemoryCommitment(VkDevice device,
|
|||
|
||||
*pCommittedMemoryInBytes = mem->bo->size;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_GetMemoryFdKHR(VkDevice _device,
|
||||
const VkMemoryGetFdInfoKHR *pGetFdInfo,
|
||||
int *pFD)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_device, device, _device);
|
||||
VK_FROM_HANDLE(nvk_device_memory, memory, pGetFdInfo->memory);
|
||||
|
||||
switch (pGetFdInfo->handleType) {
|
||||
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
|
||||
if (nouveau_ws_bo_dma_buf(memory->bo, pFD))
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
return VK_SUCCESS;
|
||||
default:
|
||||
assert(!"unsupported handle type");
|
||||
return vk_error(device, VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <nouveau_drm.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
|
@ -121,3 +122,9 @@ nouveau_ws_bo_wait(struct nouveau_ws_bo *bo, enum nouveau_ws_bo_map_flags flags)
|
|||
|
||||
return !drmCommandWrite(bo->fd, DRM_NOUVEAU_GEM_CPU_PREP, &req, sizeof(req));
|
||||
}
|
||||
|
||||
int
|
||||
nouveau_ws_bo_dma_buf(struct nouveau_ws_bo *bo, int *fd)
|
||||
{
|
||||
return drmPrimeHandleToFD(bo->fd, bo->handle, DRM_CLOEXEC, fd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct nouveau_ws_bo *nouveau_ws_bo_new_tiled(struct nouveau_ws_device *,
|
|||
void nouveau_ws_bo_destroy(struct nouveau_ws_bo *);
|
||||
void *nouveau_ws_bo_map(struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags);
|
||||
bool nouveau_ws_bo_wait(struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags flags);
|
||||
int nouveau_ws_bo_dma_buf(struct nouveau_ws_bo *, int *fd);
|
||||
|
||||
static inline void
|
||||
nouveau_ws_bo_ref(struct nouveau_ws_bo *bo)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue