From f04108ae3e0cbb3247dfbc51fcda6a82ce00c7f4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 29 May 2022 22:13:36 +0900 Subject: [PATCH] [vulkan] Switch to using vkGetPhysicalDeviceProperties2 Necessary for getting VkPhysicalDeviceMultiviewProperties (and others, but not at this time). --- include/QF/Vulkan/funclist.h | 2 +- include/QF/Vulkan/instance.h | 4 +++- libs/video/renderer/vulkan/device.c | 1 + libs/video/renderer/vulkan/instance.c | 14 +++++++++++--- libs/video/renderer/vulkan/staging.c | 2 +- libs/video/renderer/vulkan/vkparse.c | 2 +- libs/video/renderer/vulkan/vulkan_bsp.c | 6 +++--- libs/video/renderer/vulkan/vulkan_lighting.c | 4 ++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/QF/Vulkan/funclist.h b/include/QF/Vulkan/funclist.h index 94189143d..42da63794 100644 --- a/include/QF/Vulkan/funclist.h +++ b/include/QF/Vulkan/funclist.h @@ -22,7 +22,7 @@ GLOBAL_LEVEL_VULKAN_FUNCTION (vkCreateInstance) #endif INSTANCE_LEVEL_VULKAN_FUNCTION (vkEnumeratePhysicalDevices) -INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceProperties) +INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceProperties2) INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceFeatures) INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceQueueFamilyProperties) INSTANCE_LEVEL_VULKAN_FUNCTION (vkCreateDevice) diff --git a/include/QF/Vulkan/instance.h b/include/QF/Vulkan/instance.h index 692dd5964..c4b18a73a 100644 --- a/include/QF/Vulkan/instance.h +++ b/include/QF/Vulkan/instance.h @@ -42,7 +42,9 @@ typedef struct DARRAY_TYPE(const char *) qfv_debugstack_t; typedef struct qfv_physdev_s { struct qfv_instance_s *instance; VkPhysicalDevice dev; - VkPhysicalDeviceProperties properties; + VkPhysicalDeviceProperties2 properties2; + VkPhysicalDeviceProperties *properties; + VkPhysicalDeviceMultiviewProperties multiViewProperties; VkPhysicalDeviceMemoryProperties memory_properties; } qfv_physdev_t; diff --git a/libs/video/renderer/vulkan/device.c b/libs/video/renderer/vulkan/device.c index 5dc2e331a..47df21745 100644 --- a/libs/video/renderer/vulkan/device.c +++ b/libs/video/renderer/vulkan/device.c @@ -151,6 +151,7 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions) }; VkPhysicalDeviceFeatures features = { .geometryShader = 1, + .multiViewport = 1, }; VkDeviceCreateInfo dCreateInfo = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, 0, 0, diff --git a/libs/video/renderer/vulkan/instance.c b/libs/video/renderer/vulkan/instance.c index 588ea4c34..562063e89 100644 --- a/libs/video/renderer/vulkan/instance.c +++ b/libs/video/renderer/vulkan/instance.c @@ -279,7 +279,15 @@ QFV_CreateInstance (vulkan_ctx_t *ctx, qfv_physdev_t *dev = &inst->devices[i]; dev->instance = inst; dev->dev = physDev; - ifunc->vkGetPhysicalDeviceProperties (physDev, &dev->properties); + dev->properties2 = (VkPhysicalDeviceProperties2) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, + .pNext = &dev->multiViewProperties, + }; + dev->multiViewProperties = (VkPhysicalDeviceMultiviewProperties) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES, + }; + ifunc->vkGetPhysicalDeviceProperties2 (physDev, &dev->properties2); + dev->properties = &dev->properties2.properties; ifunc->vkGetPhysicalDeviceMemoryProperties (physDev, &dev->memory_properties); } @@ -306,8 +314,8 @@ QFV_GetMaxSampleCount (qfv_physdev_t *physdev) { VkSampleCountFlagBits maxSamples = VK_SAMPLE_COUNT_64_BIT; VkSampleCountFlagBits counts; - counts = min (physdev->properties.limits.framebufferColorSampleCounts, - physdev->properties.limits.framebufferDepthSampleCounts); + counts = min (physdev->properties->limits.framebufferColorSampleCounts, + physdev->properties->limits.framebufferDepthSampleCounts); while (maxSamples && maxSamples > counts) { maxSamples >>= 1; } diff --git a/libs/video/renderer/vulkan/staging.c b/libs/video/renderer/vulkan/staging.c index 09b54954d..cf3073959 100644 --- a/libs/video/renderer/vulkan/staging.c +++ b/libs/video/renderer/vulkan/staging.c @@ -41,7 +41,7 @@ qfv_stagebuf_t * QFV_CreateStagingBuffer (qfv_device_t *device, const char *name, size_t size, VkCommandPool cmdPool) { - size_t atom = device->physDev->properties.limits.nonCoherentAtomSize; + size_t atom = device->physDev->properties->limits.nonCoherentAtomSize; qfv_devfuncs_t *dfunc = device->funcs; dstring_t *str = dstring_new (); diff --git a/libs/video/renderer/vulkan/vkparse.c b/libs/video/renderer/vulkan/vkparse.c index c75681f8b..f9a462c0e 100644 --- a/libs/video/renderer/vulkan/vkparse.c +++ b/libs/video/renderer/vulkan/vkparse.c @@ -1092,7 +1092,7 @@ parse_object (vulkan_ctx_t *ctx, memsuper_t *memsuper, plitem_t *plist, {"frames", &vulkan_frameset_t_type, &ctx->frames}, {"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples}, {"physDevLimits", &VkPhysicalDeviceLimits_type, - &ctx->device->physDev->properties.limits }, + &ctx->device->physDev->properties->limits }, {QFV_PROPERTIES, &cexpr_plitem, &parsectx.properties}, {} }; diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 43dbd4a67..a3f7582bf 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -436,7 +436,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx) } } - size_t atom = device->physDev->properties.limits.nonCoherentAtomSize; + size_t atom = device->physDev->properties->limits.nonCoherentAtomSize; size_t atom_mask = atom - 1; size_t frames = bctx->frames.size; size_t index_buffer_size = index_count * frames * sizeof (uint32_t); @@ -1118,7 +1118,7 @@ Vulkan_Bsp_Flush (vulkan_ctx_t *ctx) qfv_devfuncs_t *dfunc = device->funcs; bspctx_t *bctx = ctx->bsp_context; bspframe_t *bframe = &bctx->frames.a[ctx->curFrame]; - size_t atom = device->physDev->properties.limits.nonCoherentAtomSize; + size_t atom = device->physDev->properties->limits.nonCoherentAtomSize; size_t atom_mask = atom - 1; size_t index_offset = bframe->index_offset; size_t index_size = bframe->index_count * sizeof (uint32_t); @@ -1424,7 +1424,7 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx) size_t entid_count = Vulkan_Scene_MaxEntities (ctx); size_t entid_size = entid_count * sizeof (uint32_t); - size_t atom = device->physDev->properties.limits.nonCoherentAtomSize; + size_t atom = device->physDev->properties->limits.nonCoherentAtomSize; size_t atom_mask = atom - 1; entid_size = (entid_size + atom_mask) & ~atom_mask; bctx->entid_buffer diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index cf22da875..414031f8f 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -362,7 +362,7 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx) lframe->shadowWrite.dstBinding = 0; lframe->shadowWrite.descriptorCount = min (MaxLights, - device->physDev->properties.limits.maxPerStageDescriptorSamplers); + device->physDev->properties->limits.maxPerStageDescriptorSamplers); lframe->shadowWrite.pImageInfo = lframe->shadowInfo; } free (shadow_set); @@ -578,7 +578,7 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; qfv_physdev_t *physDev = device->physDev; - int maxLayers = physDev->properties.limits.maxImageArrayLayers; + int maxLayers = physDev->properties->limits.maxImageArrayLayers; lightingdata_t *ldata = lctx->ldata; light_t *lights = ldata->lights.a; int numLights = ldata->lights.size;