/* venus implements VK_ANDROID_native_buffer up to spec version 7 */
#define VN_ANDROID_NATIVE_BUFFER_SPEC_VERSION 7
-struct vn_device;
-struct vn_image;
-
struct vn_android_wsi {
/* command pools, one per queue family */
VkCommandPool *cmd_pools;
uint32_t *queue_family_indices;
};
-VkResult
-vn_image_from_anb(struct vn_device *dev,
- const VkImageCreateInfo *image_info,
- const VkNativeBufferANDROID *anb_info,
- const VkAllocationCallbacks *alloc,
- struct vn_image **out_img);
-
#ifdef ANDROID
+
VkResult
vn_android_wsi_init(struct vn_device *dev,
const VkAllocationCallbacks *alloc);
void
vn_android_wsi_fini(struct vn_device *dev,
const VkAllocationCallbacks *alloc);
+
+static inline const VkNativeBufferANDROID *
+vn_android_find_native_buffer(const VkImageCreateInfo *create_info)
+{
+ return vk_find_struct_const(create_info->pNext, NATIVE_BUFFER_ANDROID);
+}
+
+VkResult
+vn_image_from_anb(struct vn_device *dev,
+ const VkImageCreateInfo *image_info,
+ const VkNativeBufferANDROID *anb_info,
+ const VkAllocationCallbacks *alloc,
+ struct vn_image **out_img);
+
#else
+
static inline VkResult
vn_android_wsi_init(UNUSED struct vn_device *dev,
UNUSED const VkAllocationCallbacks *alloc)
{
return;
}
-#endif
+
+static inline const VkNativeBufferANDROID *
+vn_android_find_native_buffer(const VkImageCreateInfo *create_info)
+{
+ return NULL;
+}
+
+static inline VkResult
+vn_image_from_anb(struct vn_device *dev,
+ const VkImageCreateInfo *image_info,
+ const VkNativeBufferANDROID *anb_info,
+ const VkAllocationCallbacks *alloc,
+ struct vn_image **out_img)
+{
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+}
+
+#endif /* ANDROID */
#endif /* VN_ANDROID_H */
struct vn_image *img;
VkResult result;
-#ifdef VN_USE_WSI_PLATFORM
const struct wsi_image_create_info *wsi_info =
- vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
+ vn_wsi_find_wsi_image_create_info(pCreateInfo);
+ const VkNativeBufferANDROID *anb_info =
+ vn_android_find_native_buffer(pCreateInfo);
+
if (wsi_info) {
assert(wsi_info->scanout);
result = vn_wsi_create_scanout_image(dev, pCreateInfo, alloc, &img);
- goto out;
- }
-#endif
-
-#ifdef ANDROID
- const VkNativeBufferANDROID *anb_info =
- vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID);
- if (anb_info) {
+ } else if (anb_info) {
result = vn_image_from_anb(dev, pCreateInfo, anb_info, alloc, &img);
- goto out;
+ } else {
+ result = vn_image_create(dev, pCreateInfo, alloc, &img);
}
-#endif
-
- result = vn_image_create(dev, pCreateInfo, alloc, &img);
-out:
if (result != VK_SUCCESS)
return vn_error(dev->instance, result);
void
vn_wsi_fini(struct vn_physical_device *physical_dev);
+static inline const struct wsi_image_create_info *
+vn_wsi_find_wsi_image_create_info(const VkImageCreateInfo *create_info)
+{
+ return vk_find_struct_const(create_info->pNext,
+ WSI_IMAGE_CREATE_INFO_MESA);
+}
+
VkResult
vn_wsi_create_scanout_image(struct vn_device *dev,
const VkImageCreateInfo *create_info,
{
}
-#endif
+static inline const struct wsi_image_create_info *
+vn_wsi_find_wsi_image_create_info(const VkImageCreateInfo *create_info)
+{
+ return NULL;
+}
+
+static inline VkResult
+vn_wsi_create_scanout_image(struct vn_device *dev,
+ const VkImageCreateInfo *create_info,
+ const VkAllocationCallbacks *alloc,
+ struct vn_image **out_img)
+{
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+}
+
+#endif /* VN_USE_WSI_PLATFORM */
#endif /* VN_WSI_H */