summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/ra_vk.h
blob: 393c01a3c18d848961b8060ea617b06d75f685c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include "video/out/gpu/ra.h"

#include "common.h"
#include "utils.h"

struct ra *ra_create_vk(struct mpvk_ctx *vk, struct mp_log *log);

// Access to the VkDevice is needed for swapchain creation
VkDevice ra_vk_get_dev(struct ra *ra);

// Allocates a ra_tex that wraps a swapchain image. The contents of the image
// will be invalidated, and access to it will only be internally synchronized.
// So the calling could should not do anything else with the VkImage.
struct ra_tex *ra_vk_wrap_swapchain_img(struct ra *ra, VkImage vkimg,
                                        VkSwapchainCreateInfoKHR info);

// Associates an external semaphore (dependency) with a ra_tex, such that this
// ra_tex will not be used by the ra_vk until the external semaphore fires.
void ra_tex_vk_external_dep(struct ra *ra, struct ra_tex *tex, VkSemaphore dep);

// This function finalizes rendering, transitions `tex` (which must be a
// wrapped swapchain image) into a format suitable for presentation, and returns
// the resulting command buffer (or NULL on error). The caller may add their
// own semaphores to this command buffer, and must submit it afterwards.
struct vk_cmd *ra_vk_submit(struct ra *ra, struct ra_tex *tex);

// May be called on a struct ra of any type. Returns NULL if the ra is not
// a vulkan ra.
struct mpvk_ctx *ra_vk_get(struct ra *ra);

struct vk_external_mem {
#if HAVE_WIN32_DESKTOP
    HANDLE mem_handle;
#else
    int mem_fd;
#endif
    size_t mem_size;
    size_t size;
    size_t offset;
};

// 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);