1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-02 21:12:23 +00:00
mpv/video/out/vulkan/malloc.h
Niklas Haas 5b6b77b8dc vo_gpu: vulkan: normalize use of *Flags and *FlagBits
FlagBits is just the name of the enum. The actual data type representing
a combination of these flags follows the *Flags convention. (The
relevant difference is that the latter is defined to be uint32_t instead
of left implicit)

For consistency, use *Flags everywhere instead of randomly switching
between *Flags and *FlagBits.

Also fix a wrong type name on `stageFlags`, pointed out by @atomnuker
2017-09-27 00:25:18 +02:00

36 lines
1.3 KiB
C

#pragma once
#include "common.h"
void vk_malloc_init(struct mpvk_ctx *vk);
void vk_malloc_uninit(struct mpvk_ctx *vk);
// Represents a single "slice" of generic (non-buffer) memory, plus some
// metadata for accounting. This struct is essentially read-only.
struct vk_memslice {
VkDeviceMemory vkmem;
size_t offset;
size_t size;
void *priv;
};
void vk_free_memslice(struct mpvk_ctx *vk, struct vk_memslice slice);
bool vk_malloc_generic(struct mpvk_ctx *vk, VkMemoryRequirements reqs,
VkMemoryPropertyFlags flags, struct vk_memslice *out);
// Represents a single "slice" of a larger buffer
struct vk_bufslice {
struct vk_memslice mem; // must be freed by the user when done
VkBuffer buf; // the buffer this memory was sliced from
// For persistently mapped buffers, this points to the first usable byte of
// this slice.
void *data;
};
// Allocate a buffer slice. This is more efficient than vk_malloc_generic for
// when the user needs lots of buffers, since it doesn't require
// creating/destroying lots of (little) VkBuffers.
bool vk_malloc_buffer(struct mpvk_ctx *vk, VkBufferUsageFlags bufFlags,
VkMemoryPropertyFlags memFlags, VkDeviceSize size,
VkDeviceSize alignment, struct vk_bufslice *out);