From a782197d216b2343abe04045b9bb3076864aca80 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sun, 14 Oct 2018 17:37:05 -0700 Subject: vo_gpu: vulkan: Add arbitrary user data for an ra_vk_buf This is arguably a little contrived, but in the case of CUDA interop, we have to track additional state on the cuda side for each exported buffer. If we want to be able to manage buffers with an ra_buf_pool, we need some way to keep that CUDA state associated with each created buffer. The easiest way to do that is to attach it directly to the buffers. --- video/out/vulkan/ra_vk.c | 12 ++++++++++++ video/out/vulkan/ra_vk.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/video/out/vulkan/ra_vk.c b/video/out/vulkan/ra_vk.c index 1548b8c785..80019fa4bc 100644 --- a/video/out/vulkan/ra_vk.c +++ b/video/out/vulkan/ra_vk.c @@ -693,8 +693,20 @@ struct ra_buf_vk { // "current" metadata, can change during course of execution VkPipelineStageFlags current_stage; VkAccessFlags current_access; + // Arbitrary user data for the creator of a buffer + void *user_data; }; +void ra_vk_buf_set_user_data(struct ra_buf *buf, void *user_data) { + struct ra_buf_vk *vk_priv = buf->priv; + vk_priv->user_data = user_data; +} + +void *ra_vk_buf_get_user_data(struct ra_buf *buf) { + struct ra_buf_vk *vk_priv = buf->priv; + return vk_priv->user_data; +} + static void vk_buf_deref(struct ra *ra, struct ra_buf *buf) { if (!buf) diff --git a/video/out/vulkan/ra_vk.h b/video/out/vulkan/ra_vk.h index 89eb310146..393c01a3c1 100644 --- a/video/out/vulkan/ra_vk.h +++ b/video/out/vulkan/ra_vk.h @@ -43,3 +43,9 @@ struct vk_external_mem { // Export an ra_buf for importing by another api. bool ra_vk_buf_get_external_info(struct ra *ra, struct ra_buf *buf, struct vk_external_mem *ret); + +// Set the buffer user data +void ra_vk_buf_set_user_data(struct ra_buf *buf, void *priv); + +// Get the buffer user data +void *ra_vk_buf_get_user_data(struct ra_buf *buf); -- cgit v1.2.3