Vulkan: Bad Alloc thrown on vkCreateDevice()
Tried to debug my vk app with renderdoc, without success.
OS: Win10 64Bit with VS15 Community Graphics: AMD Radeon R9 200 Series
I added the VK_LAYER_RENDERDOC_Capture to my list of active instance & device layers
Without activating the renderdoc capture layer, my app works fine

im using the renderdoc version, which was installed by the vk sdk 1.0.5
You shouldn't manually add the renderdoc layer to your instance & device layers. This might work but it might break in future or might break right now :). Try launching through the UI, or if you want to run manually then enable the environment variable ENABLE_VULKAN_RENDERDOC_CAPTURE=1 in your debugger.
If that still crashes, can you share your application? Or if that's not possible can you post the VkDeviceCreateInfo you are passing and let me know your OS and HW configuration?
Thanks for the infos. I tried launching the app through the renderdoc ui. It behaves kind of weird. sometimes the app starts & triggers an runtime assert, sometimes it just closes itself. When i press retry in the assert messagebox, nothing happens except that the app closes again.
std::vector<const char*> enabled_device_layers;
std::vector<const char*> enabled_device_extensions;
enabled_device_layers.push_back("VK_LAYER_LUNARG_standard_validation");
enabled_device_extensions.push_back("VK_KHR_swapchain");
//fill present info
float present_prio = 1.0f;
VkDeviceQueueCreateInfo present_queue_info;
present_queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
present_queue_info.pNext = nullptr;
present_queue_info.flags = 0;
present_queue_info.queueFamilyIndex = *p_presentIndex;
present_queue_info.queueCount = 1;
present_queue_info.pQueuePriorities = &present_prio;
//fill transfer info
float transfer_prio = 0.5f;
VkDeviceQueueCreateInfo transfer_queue_info;
transfer_queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
transfer_queue_info.pNext = nullptr;
transfer_queue_info.flags = 0;
transfer_queue_info.queueFamilyIndex = *p_transferIndex;
transfer_queue_info.queueCount = 1;
transfer_queue_info.pQueuePriorities = &transfer_prio;
VkDeviceQueueCreateInfo infos[2];
infos[0] = present_queue_info;
infos[1] = transfer_queue_info;
VkDeviceCreateInfo device_info;
device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
device_info.pNext = nullptr;
device_info.flags = 0;
device_info.queueCreateInfoCount = 2;
device_info.pQueueCreateInfos = infos;
device_info.enabledLayerCount = enabled_device_layers.size();
device_info.ppEnabledLayerNames = enabled_device_layers.data();
device_info.enabledExtensionCount = enabled_device_extensions.size();
device_info.ppEnabledExtensionNames = enabled_device_extensions.data();
device_info.pEnabledFeatures = nullptr;
VkResult err = vkCreateDevice(p_device, &device_info, nullptr, &m_device);
Im using Windows10 Pro x64, Visual Studio 2015 Community Update 2(Update 1 gave the same error).
CPU: Intel i5-4690 GPU: AMD Radeon R9 280 Driver: Crimson Software v.16.3.2
Attached the output of vkinfo.exe vkinfo.txt
Hope that helps, thank you :)
Thanks for the info. The code seems reasonable to me from looking but I will try to build a minimal sample around it to see if I can find the problem. If you're able to share e.g. executables or anything that would really help :).
One other thing, what happens if you try to capture the cube or tri samples from the SDK? Do you encounter the same crash there?
Here is my app's executable :) debug_x64.zip epilepsy warning
As you asked for, i tried to capture the tri & cube sample from the SDK,
First i captured the x64 versions. The tri sample shows the same symptoms as my app,except that no assertion is triggered, while capturing the cube sample works just fine.
Capturing the x86 versions of the samples yields other results. Both samples run fine, but pressing the "trigger capture" or "queue capture" buttons don't do anything.
P.S.: I'm running RenderDoc v0.27 x64
Thanks! I will try this when I get the chance. This sounds very strange.
When you capture the x86 versions, do you get the renderdoc overlay showing in the application? Is there any difference between clicking "trigger capture" and pressing F12 in the application itself?
The overlay doesn't appears on both samples, and it seems not to make any difference between 'clicking "trigger capture" and pressing F12 in the application itself', just nothing happens. (sorry, to lazy to write, so quoting you :) )
Oh of course. There was a bug with x86 capture in the released renderdoc version that came with the SDK, that was only fixed recently on master branch. I think the released renderdoc version won't work at all for x86 which is probably why you're seeing those results - the layer is completely inactive.
Okay, i'll try the current master :)
I tried running the debug_x64.exe locally, but unfortunately I get a crash when running it normally, without renderdoc attached. On all three systems I have (nv/win7, amd/win10, intel/win10) I get an abort() call from a failed assertion:
c:\users\roman\documents\projects\amphetamine\src\rendering\amphetamizer.cpp:99 (res == VK_SUCCESS)
Any ideas?
looks like that one call to vkCreateInstance() returns something else than VK_SUCCESS.
I hardcoded some stuff, so i have set these instance layers and extensions:
Layers:
- VK_LAYER_LUNARG_standard_validation
Extensions: -VK_EXT_debug_report -VK_KHR_swapchain -VK_KHR_surface -VK_KHR_win32_surface
also i set the Api Version to 1.0.5 .
Maybe some of the extensions are not present in your implementation?
Ah, the extensions should be fine but the meta-layer might not be working. For some reason my system-installed loader doesn't recognise it, although I should be running 1.0.5. I'll try and sort that out.
Never mind, I'm an idiot and I found the bug. Fix incoming!
Yeah, i hade many weird issues because of that meta layer, but i'm glad i could help. Renderdoc is a very nice tool! I appreciate your work very much. Thanks!
So that commit should fix the bad_alloc abort().
On AMD I still have another crash inside vkCreateImage that dies inside the ICD - I'm asking to see if I can find out why it's dying.
On nvidia the application still crashes on that assert without renderdoc attached. I've checked and the VK_LAYER_LUNARG_standard_validation is working now (I installed sdk 1.0.5) so I'm not sure what's going wrong. If it were vkCreateDevice that was failing I might expect that, since your code above I think will fail on nvidia since there is only one queue family and from my testing the device creation will fail if you ask for the same queue family twice (once for p_presentIndex and once for p_transferIndex). I don't know why vkCreateInstance would fail though and I can't debug any further.
All right, I can repro that crash - I'm not yet sure if it's a wrong parameter or not, but we'll take a look.
I just tried a second time and it worked - could this be something is not initialized correctly and we randomly get lucky?
Sorry, I wasn't paying too much attention and didn't notice this issue. I'll have a look shoortly.
@the-mech : Would you mind sharing the source code for the app, please?
@baldurk Thanks, I tried that commit and my app works now with renderdoc, despite the renderdoc layer may be messing with my vkCreateSwapchain() call.
I'm not @home at the moment, I will share my code around tuesday with you @DominikWitczakAMD
@Anteru My app is just a little experimenting with vulkan, so im not cleaning up after usage, thus no calls to vkDestroyInstance() etc.. Maybe that causes the random luckiness? :D
@the-mech : Did the crash turn out to be an app-side issue? If not, can we have a look at the source code to ensure it's not driver-related?