From 40bfc9a0cebc5a49a371d99d1164502f2de28b7f Mon Sep 17 00:00:00 2001 From: tx00100xt Date: Sun, 5 Jun 2022 22:34:41 +0300 Subject: [PATCH] Removing a fixed structure VkPhysicalDeviceFeatures, getting this structure using vkGetPhysicalDeviceFeatures --- SamTFE/Sources/Engine/Graphics/Gfx_Vulkan.cpp | 8 +++++--- SamTFE/Sources/Engine/Graphics/Vulkan/SvkMain.h | 3 ++- SamTFE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp | 11 +++++++++-- SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp | 8 +++++--- SamTSE/Sources/Engine/Graphics/Vulkan/SvkMain.h | 3 ++- SamTSE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp | 11 +++++++++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/SamTFE/Sources/Engine/Graphics/Gfx_Vulkan.cpp b/SamTFE/Sources/Engine/Graphics/Gfx_Vulkan.cpp index 11bc575c..8e69d4af 100755 --- a/SamTFE/Sources/Engine/Graphics/Gfx_Vulkan.cpp +++ b/SamTFE/Sources/Engine/Graphics/Gfx_Vulkan.cpp @@ -439,7 +439,8 @@ void SvkMain::Reset_Vulkan() gl_VkPhysDevice = VK_NULL_HANDLE; gl_VkPhMemoryProperties = {}; gl_VkPhProperties = {}; - gl_VkPhFeatures = {}; + gl_VkPhFeatures[0] = {}; + gl_VkPhFeatures[1] = {}; gl_VkPhSurfCapabilities = {}; gl_VkQueueFamGraphics = 0; @@ -798,8 +799,9 @@ BOOL SvkMain::CreateDevice() VkDeviceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; createInfo.queueCreateInfoCount = (uint32_t)queueInfos.Count(); - createInfo.pQueueCreateInfos = &queueInfos[0]; - createInfo.pEnabledFeatures = &features; + createInfo.pQueueCreateInfos = &queueInfos[0]; + //createInfo.pEnabledFeatures = &features; + createInfo.pEnabledFeatures = &gl_VkPhFeatures[gl_vkNumDev]; createInfo.enabledExtensionCount = (uint32_t)gl_VkPhysDeviceExtensions.Count(); createInfo.ppEnabledExtensionNames = &gl_VkPhysDeviceExtensions[0]; #if SVK_ENABLE_VALIDATION diff --git a/SamTFE/Sources/Engine/Graphics/Vulkan/SvkMain.h b/SamTFE/Sources/Engine/Graphics/Vulkan/SvkMain.h index b4adfe55..ca462ba3 100755 --- a/SamTFE/Sources/Engine/Graphics/Vulkan/SvkMain.h +++ b/SamTFE/Sources/Engine/Graphics/Vulkan/SvkMain.h @@ -125,7 +125,8 @@ class SvkMain VkPhysicalDevice gl_VkPhysDevice; VkPhysicalDeviceMemoryProperties gl_VkPhMemoryProperties; VkPhysicalDeviceProperties gl_VkPhProperties; - VkPhysicalDeviceFeatures gl_VkPhFeatures; + VkPhysicalDeviceFeatures gl_VkPhFeatures[2]; + INDEX gl_vkNumDev; VkSurfaceCapabilitiesKHR gl_VkPhSurfCapabilities; CStaticArray gl_VkPhSurfFormats; CStaticArray gl_VkPhSurfPresentModes; diff --git a/SamTFE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp b/SamTFE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp index 0f7c36d9..b3c20895 100755 --- a/SamTFE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp +++ b/SamTFE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp @@ -347,6 +347,11 @@ BOOL SvkMain::PickPhysicalDevice() VK_CHECKERROR(r) ASSERT(physDeviceCount > 0); + // vulkan devices count + if (physDeviceCount > 2) { + physDeviceCount = 2; + } + CPrintF("Vulkan: Physical Devices Count: %d\n", physDeviceCount); for (uint32_t i = 0; i < physDeviceCount; i++) @@ -361,7 +366,7 @@ BOOL SvkMain::PickPhysicalDevice() uint32_t formatsCount = 0, presentModesCount = 0; gl_VkPhysDevice = physDevice; - vkGetPhysicalDeviceFeatures(physDevice, &gl_VkPhFeatures); + vkGetPhysicalDeviceFeatures(physDevice, &gl_VkPhFeatures[i]); vkGetPhysicalDeviceMemoryProperties(physDevice, &gl_VkPhMemoryProperties); vkGetPhysicalDeviceProperties(physDevice, &gl_VkPhProperties); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physDevice, gl_VkSurface, &gl_VkPhSurfCapabilities); @@ -461,7 +466,9 @@ BOOL SvkMain::PickPhysicalDevice() gl_VkMaxSampleCount = VK_SAMPLE_COUNT_1_BIT; CPrintF("Vulkan: VK_SAMPLE_COUNT_2_BIT\n"); } - + + gl_vkNumDev = i; + CPrintF("Vulkan: Physical Device Number: %d\n", i); return TRUE; } } diff --git a/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp b/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp index 11bc575c..8e69d4af 100755 --- a/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp +++ b/SamTSE/Sources/Engine/Graphics/Gfx_Vulkan.cpp @@ -439,7 +439,8 @@ void SvkMain::Reset_Vulkan() gl_VkPhysDevice = VK_NULL_HANDLE; gl_VkPhMemoryProperties = {}; gl_VkPhProperties = {}; - gl_VkPhFeatures = {}; + gl_VkPhFeatures[0] = {}; + gl_VkPhFeatures[1] = {}; gl_VkPhSurfCapabilities = {}; gl_VkQueueFamGraphics = 0; @@ -798,8 +799,9 @@ BOOL SvkMain::CreateDevice() VkDeviceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; createInfo.queueCreateInfoCount = (uint32_t)queueInfos.Count(); - createInfo.pQueueCreateInfos = &queueInfos[0]; - createInfo.pEnabledFeatures = &features; + createInfo.pQueueCreateInfos = &queueInfos[0]; + //createInfo.pEnabledFeatures = &features; + createInfo.pEnabledFeatures = &gl_VkPhFeatures[gl_vkNumDev]; createInfo.enabledExtensionCount = (uint32_t)gl_VkPhysDeviceExtensions.Count(); createInfo.ppEnabledExtensionNames = &gl_VkPhysDeviceExtensions[0]; #if SVK_ENABLE_VALIDATION diff --git a/SamTSE/Sources/Engine/Graphics/Vulkan/SvkMain.h b/SamTSE/Sources/Engine/Graphics/Vulkan/SvkMain.h index b4adfe55..ca462ba3 100755 --- a/SamTSE/Sources/Engine/Graphics/Vulkan/SvkMain.h +++ b/SamTSE/Sources/Engine/Graphics/Vulkan/SvkMain.h @@ -125,7 +125,8 @@ class SvkMain VkPhysicalDevice gl_VkPhysDevice; VkPhysicalDeviceMemoryProperties gl_VkPhMemoryProperties; VkPhysicalDeviceProperties gl_VkPhProperties; - VkPhysicalDeviceFeatures gl_VkPhFeatures; + VkPhysicalDeviceFeatures gl_VkPhFeatures[2]; + INDEX gl_vkNumDev; VkSurfaceCapabilitiesKHR gl_VkPhSurfCapabilities; CStaticArray gl_VkPhSurfFormats; CStaticArray gl_VkPhSurfPresentModes; diff --git a/SamTSE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp b/SamTSE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp index 0f7c36d9..b3c20895 100755 --- a/SamTSE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp +++ b/SamTSE/Sources/Engine/Graphics/Vulkan/SvkUtils.cpp @@ -347,6 +347,11 @@ BOOL SvkMain::PickPhysicalDevice() VK_CHECKERROR(r) ASSERT(physDeviceCount > 0); + // vulkan devices count + if (physDeviceCount > 2) { + physDeviceCount = 2; + } + CPrintF("Vulkan: Physical Devices Count: %d\n", physDeviceCount); for (uint32_t i = 0; i < physDeviceCount; i++) @@ -361,7 +366,7 @@ BOOL SvkMain::PickPhysicalDevice() uint32_t formatsCount = 0, presentModesCount = 0; gl_VkPhysDevice = physDevice; - vkGetPhysicalDeviceFeatures(physDevice, &gl_VkPhFeatures); + vkGetPhysicalDeviceFeatures(physDevice, &gl_VkPhFeatures[i]); vkGetPhysicalDeviceMemoryProperties(physDevice, &gl_VkPhMemoryProperties); vkGetPhysicalDeviceProperties(physDevice, &gl_VkPhProperties); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physDevice, gl_VkSurface, &gl_VkPhSurfCapabilities); @@ -461,7 +466,9 @@ BOOL SvkMain::PickPhysicalDevice() gl_VkMaxSampleCount = VK_SAMPLE_COUNT_1_BIT; CPrintF("Vulkan: VK_SAMPLE_COUNT_2_BIT\n"); } - + + gl_vkNumDev = i; + CPrintF("Vulkan: Physical Device Number: %d\n", i); return TRUE; } }