From 1b05828090997016f24549fc6ee5b505996fc333 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sun, 4 Dec 2022 07:35:23 +0100 Subject: [PATCH] use of VkvgCreateInfo to create vkvg device --- include/vkvg.h | 30 +++++++++++++++++++++++++++--- src/vkvg_device.c | 8 ++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/include/vkvg.h b/include/vkvg.h index 3483a1e..ba719c6 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -544,7 +544,31 @@ void vkvg_matrix_get_scale (const vkvg_matrix_t *matrix, float *sx, float *sy); * Device holds the font cache so that each time a context draws text, the same cache is used. * * @{ */ - +/** + * @brief vkvg device creation structure + * + * Structure used to pass parameter to the device creation method. + * + * @code + * x_new = xx * x + xy * y + x0; + * y_new = yx * x + yy * y + y0; + * @endcode + * + * @samples: sample count. + * @inst: vulkan instance used to create device, may be null to create a new instance. + * @phy: vulkan physical device to create vkvg device for, may be null. + * @vkdev: vulkan logical device, may be null to create a new one. + * @qFamIdx: graphic queue family index, ignored if vkdev is NULL. + * @qIndex: queue index, ignored if vkdev is NULL. + */ +typedef struct { + VkSampleCountFlags samples; + VkInstance inst; + VkPhysicalDevice phy; + VkDevice vkdev; + uint32_t qFamIdx; + uint32_t qIndex; +}vkvg_device_create_info_t; /** * @brief Set device ready for multithreading. * @@ -573,7 +597,7 @@ void vkvg_device_set_context_cache_size (VkvgDevice dev, uint32_t maxCount); /** * @brief Create a new vkvg device. * - * Create a new #VkvgDevice owning vulkan instance and device. + * Create a new #VkvgDevice. * * On success, create a new vkvg device and set its reference count to 1. * On error, you may query the device status by calling @ref vkvg_device_status. Error could be @@ -586,7 +610,7 @@ void vkvg_device_set_context_cache_size (VkvgDevice dev, uint32_t maxCount); * to #vkvg_surface_resolve() or */ vkvg_public -VkvgDevice vkvg_device_create (VkSampleCountFlags samples, bool deferredResolve); +VkvgDevice vkvg_device_create (vkvg_device_create_info_t* info); /** * @brief Create a new vkvg device from an existing vulkan logical device. * diff --git a/src/vkvg_device.c b/src/vkvg_device.c index b3d0107..b5e5b45 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -269,7 +269,7 @@ const void* vkvg_get_device_requirements (VkPhysicalDeviceFeatures* pEnabledFeat } -VkvgDevice vkvg_device_create (VkSampleCountFlags samples, bool deferredResolve) { +VkvgDevice vkvg_device_create (vkvg_device_create_info_t* info) { LOG(VKVG_LOG_INFO, "CREATE Device\n"); VkvgDevice dev = (vkvg_device*)calloc(1,sizeof(vkvg_device)); if (!dev) { @@ -323,8 +323,8 @@ VkvgDevice vkvg_device_create (VkSampleCountFlags samples, bool deferredResolve) if (!_device_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) pi = phys[0]; - if (!(pi->properties.limits.framebufferColorSampleCounts&samples)) { - LOG(VKVG_LOG_ERR, "CREATE Device failed: sample count not supported: %d\n", samples); + if (!(pi->properties.limits.framebufferColorSampleCounts & info->samples)) { + LOG(VKVG_LOG_ERR, "CREATE Device failed: sample count not supported: %d\n", info->samples); dev->status = VKVG_STATUS_DEVICE_ERROR; vkh_app_free_phyinfos (phyCount, phys); vkh_app_destroy (app); @@ -365,7 +365,7 @@ VkvgDevice vkvg_device_create (VkSampleCountFlags samples, bool deferredResolve) vkh_device_get_phy(vkhd), vkh_device_get_vkdev(vkhd), pi->gQueue, 0, - samples, deferredResolve); + info->samples, deferredResolve); dev->vkhDev = vkhd; -- 2.47.3