Logical device creation problem: strange queue count number of graphics family

Started by Adro, April 12, 2023, 15:55:23

Previous topic - Next topic



I was setting up everything required for logical device creation. That involves filling VkDeviceQueueCreateInfo.Buffer struct, which I am doing with the following code:

try(MemoryStack stack = MemoryStack.stackPush()) {
            //For creating queues
            VkQueueFamilyProperties.Buffer queueFamilyProperties = physicalDevice.getQueueFamilyProperties();
            int numQueueFamilies = queueFamilyProperties.capacity();
            VkDeviceQueueCreateInfo.Buffer pQueueCreateInfo = VkDeviceQueueCreateInfo.calloc(numQueueFamilies, stack);
            for(int i = 0; i < numQueueFamilies; i++) {
                VkQueueFamilyProperties queueFamily = queueFamilyProperties.get(i);
                FloatBuffer bufPriorities = stack.callocFloat(queueFamily.queueCount());

However, the line
FloatBuffer bufPriorities = stack.callocFloat(queueFamily.queueCount());
sometimes results in "out of stack memory" error. I found that the queueCount() method for the graphics family is sometimes retrieving a large number, whereas other times it retrieves a JVM crash. For instance, it gets me this high number of queues right before the exception is thrown (linked):


Which doesn't make sense. This problem doesn't occur on the laptop I use for develop the Vulkan sample, it happens on another computer I use for testing, which uses graphics card AMD (TM) Vega 8, already supported by the Vulkan specification. What could be the cause?


Hey Adro,

Looks like uninitialized memory to me. Have you verified that all Vulkan calls up to vkGetPhysicalDeviceQueueFamilyProperties haven't produced any errors? Does the large number go away if you zero-fill the queueFamilyProperties buffer before passing it to vkGetPhysicalDeviceQueueFamilyProperties?


Thanks for your quick answer, Spasi.

Here is the code for saving properties, extensions, features, memory and queue family information:

try(MemoryStack stack = MemoryStack.stackPush()) {
            IntBuffer bufInt = stack.callocInt(1);
            vkPhysicalDeviceProperties = VkPhysicalDeviceProperties.calloc();
            vkGetPhysicalDeviceProperties(vkPhysicalDevice, vkPhysicalDeviceProperties);
            vkPhysicalDeviceFeatures = VkPhysicalDeviceFeatures.calloc();
            vkGetPhysicalDeviceFeatures(vkPhysicalDevice, vkPhysicalDeviceFeatures);
            //Queue Family Properties
            vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice,bufInt, null);
            Logger.debug("On physical device creation, it supports {} queue families", bufInt.get(0));
            vkQueueFamilyProperties = VkQueueFamilyProperties.calloc(bufInt.get(0));
            vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, bufInt, 
            //Device extensions
            VkUtils.vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice,(String) null,bufInt,null), 
                    "Cannot retrieve one of the physical devices number of extensions");
            vkDeviceExtensionProperties = VkExtensionProperties.calloc(bufInt.get(0));
            VkUtils.vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice,(String) null, bufInt, 
                    "Cannot retrieve one of the physical devices extensions");
            //Memory properties
            vkPhysicalDeviceMemoryProperties = VkPhysicalDeviceMemoryProperties.calloc();
            vkGetPhysicalDeviceMemoryProperties(vkPhysicalDevice, vkPhysicalDeviceMemoryProperties);

I think on the retrieving of queue family properties everything is fine.


Solved! It was an issue on the code for selecting the proper physical device. I was cleaning the properties even when selected it. This didn't occur on other computers because the bug affected non-discrete GPUs.