mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
xrt: Added support for XR Swapchain flags
This commit is contained in:
parent
557172f8ae
commit
2d016b3385
|
@ -219,7 +219,7 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_images; i++) {
|
for (uint32_t i = 0; i < num_images; i++) {
|
||||||
ret = vk_create_image_from_fd(
|
ret = vk_create_image_from_fd(
|
||||||
&c->vk, format, width, height, array_size, mip_count,
|
&c->vk, bits, format, width, height, array_size, mip_count,
|
||||||
&sc->xscfd->images[i], &sc->base.images[i],
|
&sc->xscfd->images[i], &sc->base.images[i],
|
||||||
&sc->base.mems[i]);
|
&sc->base.mems[i]);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
|
|
|
@ -236,6 +236,7 @@ err:
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
vk_create_image_from_fd(struct vk_bundle *vk,
|
vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
|
enum xrt_swapchain_usage_bits swapchain_usage,
|
||||||
int64_t format,
|
int64_t format,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
|
@ -258,9 +259,24 @@ vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
image_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_COLOR) != 0) {
|
||||||
image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
image_usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
image_usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_TRANSFER_SRC) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_TRANSFER_DST) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_SAMPLED) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
VkImageCreateInfo info = {
|
VkImageCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
|
|
|
@ -281,6 +281,7 @@ vk_get_memory_type(struct vk_bundle *vk,
|
||||||
*/
|
*/
|
||||||
VkResult
|
VkResult
|
||||||
vk_create_image_from_fd(struct vk_bundle *vk,
|
vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
|
enum xrt_swapchain_usage_bits swapchain_usage,
|
||||||
int64_t format,
|
int64_t format,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
|
|
|
@ -63,6 +63,7 @@ swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
|
||||||
|
|
||||||
static VkResult
|
static VkResult
|
||||||
create_image_fd(struct comp_compositor *c,
|
create_image_fd(struct comp_compositor *c,
|
||||||
|
enum xrt_swapchain_usage_bits swapchain_usage,
|
||||||
int64_t format,
|
int64_t format,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
|
@ -94,9 +95,24 @@ create_image_fd(struct comp_compositor *c,
|
||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
image_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_COLOR) != 0) {
|
||||||
image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
image_usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
image_usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_TRANSFER_SRC) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_TRANSFER_DST) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
|
}
|
||||||
|
if ((swapchain_usage & XRT_SWAPCHAIN_USAGE_SAMPLED) != 0) {
|
||||||
|
image_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
VkImageCreateInfo info = {
|
VkImageCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
|
@ -244,7 +260,7 @@ comp_swapchain_create(struct xrt_compositor *xc,
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_images; i++) {
|
for (uint32_t i = 0; i < num_images; i++) {
|
||||||
ret =
|
ret =
|
||||||
create_image_fd(c, format, width, height, array_size,
|
create_image_fd(c, bits, format, width, height, array_size,
|
||||||
mip_count, &sc->images[i].image,
|
mip_count, &sc->images[i].image,
|
||||||
&sc->images[i].memory, &sc->base.images[i]);
|
&sc->images[i].memory, &sc->base.images[i]);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
|
|
|
@ -47,7 +47,13 @@ enum xrt_swapchain_create_flags
|
||||||
*/
|
*/
|
||||||
enum xrt_swapchain_usage_bits
|
enum xrt_swapchain_usage_bits
|
||||||
{
|
{
|
||||||
XRT_SWAPCHAIN_USAGE_COLOR = (1 << 0),
|
XRT_SWAPCHAIN_USAGE_COLOR = 0x00000001,
|
||||||
|
XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL = 0x00000002,
|
||||||
|
XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS = 0x00000004,
|
||||||
|
XRT_SWAPCHAIN_USAGE_TRANSFER_SRC = 0x00000008,
|
||||||
|
XRT_SWAPCHAIN_USAGE_TRANSFER_DST = 0x00000010,
|
||||||
|
XRT_SWAPCHAIN_USAGE_SAMPLED = 0x00000020,
|
||||||
|
XRT_SWAPCHAIN_USAGE_MUTABLE_FORMAT = 0x00000040
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in a new issue