Monado OpenXR Runtime
vk_compositor_flags.c File Reference

Flags helpers for compositor swapchain images. More...

#include "xrt/xrt_handles.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "vk/vk_helpers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for vk_compositor_flags.c:

Macros

#define CASE_COLOR(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
 
#define CASE_DS(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
 
#define CASE_COLOR(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_COLOR_BIT;
 
#define CASE_DS(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
 
#define CASE_D(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_DEPTH_BIT;
 
#define CASE_S(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_STENCIL_BIT;
 
#define CASE_COLOR(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_COLOR_BIT;
 
#define CASE_DS(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_DEPTH_BIT;
 
#define CASE_D(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_DEPTH_BIT;
 
#define CASE_S(FORMAT)   case VK_FORMAT_##FORMAT: return VK_IMAGE_ASPECT_STENCIL_BIT;
 
#define TEST(XRT_BIT, VK_FORMAT_BIT, VK_USAGE_BIT)
 

Functions

static bool check_feature (VkFormat format, enum xrt_swapchain_usage_bits usage, VkFormatFeatureFlags format_features, VkFormatFeatureFlags flag)
 
VkExternalMemoryHandleTypeFlags vk_cb_get_buffer_external_handle_type (struct vk_bundle *vk)
 Return the extern handle type that a buffer should be created with. More...
 
VkAccessFlags vk_csci_get_barrier_access_mask (enum xrt_swapchain_usage_bits bits)
 Returns the access flags for the compositor to app barriers. More...
 
VkImageLayout vk_csci_get_barrier_optimal_layout (VkFormat format)
 Return the optimal layout for this format, this is the layout as given to the app so is bound to the OpenXR spec. More...
 
VkImageAspectFlags vk_csci_get_barrier_aspect_mask (VkFormat format)
 Return the barrier aspect mask for this format, this is intended for the barriers that flush the data out before and after transfers between the application and compositor. More...
 
VkImageAspectFlags vk_csci_get_image_view_aspect (VkFormat format, enum xrt_swapchain_usage_bits bits)
 For images views created by the compositor to sample the images, what aspect should be set. More...
 
VkImageUsageFlags vk_csci_get_image_usage_flags (struct vk_bundle *vk, VkFormat format, enum xrt_swapchain_usage_bits bits)
 Returns the usage bits for a given selected format and usage. More...
 
VkExternalMemoryHandleTypeFlags vk_csci_get_image_external_handle_type (struct vk_bundle *vk, struct xrt_image_native *xin)
 Return the extern handle type that a image should be created with. More...
 
void vk_csci_get_image_external_support (struct vk_bundle *vk, VkFormat image_format, enum xrt_swapchain_usage_bits bits, VkExternalMemoryHandleTypeFlags handle_type, bool *out_importable, bool *out_exportable)
 Get whether a given image can be imported/exported for a handle type. More...
 

Detailed Description

Flags helpers for compositor swapchain images.

These functions all concern only the compositor swapchain images that are shared between the compositor and the application. That's why they are grouped together and they are here because they need to be shared between the vk_image_collection and comp_swapchain code so that they apply the same flags everywhere.

CSCI = Compositor SwapChain Images.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Christoph Haag chris.nosp@m.toph.nosp@m..haag.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Benjamin Saunders ben.e.nosp@m..sau.nosp@m.nders.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Macro Definition Documentation

◆ TEST

#define TEST (   XRT_BIT,
  VK_FORMAT_BIT,
  VK_USAGE_BIT 
)
Value:
if ((bits & XRT_BIT) != 0) { \
if (!check_feature(format, XRT_BIT, prop.optimalTilingFeatures, VK_FORMAT_BIT)) { \
return 0; \
} \
image_usage |= VK_USAGE_BIT; \
}

Function Documentation

◆ vk_cb_get_buffer_external_handle_type()

VkExternalMemoryHandleTypeFlags vk_cb_get_buffer_external_handle_type ( struct vk_bundle vk)

Return the extern handle type that a buffer should be created with.

cb = Compositor Buffer.

Referenced by render_buffer_init_exportable().

◆ vk_csci_get_barrier_access_mask()

VkAccessFlags vk_csci_get_barrier_access_mask ( enum xrt_swapchain_usage_bits  bits)

Returns the access flags for the compositor to app barriers.

CSCI = Compositor SwapChain Images.

◆ vk_csci_get_barrier_aspect_mask()

VkImageAspectFlags vk_csci_get_barrier_aspect_mask ( VkFormat  format)

Return the barrier aspect mask for this format, this is intended for the barriers that flush the data out before and after transfers between the application and compositor.

CSCI = Compositor SwapChain Images.

References VK_CSCI_FORMATS.

◆ vk_csci_get_barrier_optimal_layout()

VkImageLayout vk_csci_get_barrier_optimal_layout ( VkFormat  format)

Return the optimal layout for this format, this is the layout as given to the app so is bound to the OpenXR spec.

CSCI = Compositor SwapChain Images.

References VK_CSCI_FORMATS.

◆ vk_csci_get_image_external_handle_type()

VkExternalMemoryHandleTypeFlags vk_csci_get_image_external_handle_type ( struct vk_bundle vk,
struct xrt_image_native xin 
)

Return the extern handle type that a image should be created with.

CSCI = Compositor SwapChain Images.

References xrt_image_native::is_dxgi_handle.

Referenced by vk_create_image_from_native().

◆ vk_csci_get_image_external_support()

void vk_csci_get_image_external_support ( struct vk_bundle vk,
VkFormat  image_format,
enum xrt_swapchain_usage_bits  bits,
VkExternalMemoryHandleTypeFlags  handle_type,
bool *  out_importable,
bool *  out_exportable 
)

Get whether a given image can be imported/exported for a handle type.

CSCI = Compositor SwapChain Images.

References vk_csci_get_image_usage_flags().

Referenced by vk_create_image_from_native().

◆ vk_csci_get_image_usage_flags()

VkImageUsageFlags vk_csci_get_image_usage_flags ( struct vk_bundle vk,
VkFormat  format,
enum xrt_swapchain_usage_bits  bits 
)

Returns the usage bits for a given selected format and usage.

For color formats always adds:

  • VK_IMAGE_USAGE_SAMPLED_BIT for compositor reading in shaders.

For depth & stencil formats always adds:

  • VK_IMAGE_USAGE_SAMPLED_BIT for compositor reading in shaders.

For depth formats always adds:

  • VK_IMAGE_USAGE_SAMPLED_BIT for compositor reading in shaders.

For stencil formats always adds:

  • VK_IMAGE_USAGE_SAMPLED_BIT for compositor reading in shaders.

CSCI = Compositor SwapChain Images.

Referenced by vk_create_image_from_native(), and vk_csci_get_image_external_support().

◆ vk_csci_get_image_view_aspect()

VkImageAspectFlags vk_csci_get_image_view_aspect ( VkFormat  format,
enum xrt_swapchain_usage_bits  bits 
)

For images views created by the compositor to sample the images, what aspect should be set.

For color it's the color, for depth and stencil it's only depth as both are disallowed by the Vulkan spec, for depth only depth, and for stencil only it's stencil.

CSCI = Compositor SwapChain Images.

References VK_CSCI_FORMATS.

Referenced by do_post_create_vulkan_setup().