Validation layers on Shield tablet

Hi,

I’m trying to enable the validation layers in a sample app. But all I got is SIGSEGV when I try to load the shared libraries for the Android version of the layers. I have the standard Shield Tablet with the Vulkan Developer Preview OS. Are layers possibly not supported?

I used this as a tutorial:
https://developer.android.com/ndk/guides/graphics/validation-layer.html

Best regards,

DerRM

I had similar issue on desktop and that was due to using RTLD_LOCAL instead of RTLD_GLOBAL when doing dlopen of libvulkan.so

Let us know when/if you get this working as I plan to do the same thing in a few weeks :)

The strange thing is that vkCreateInstance works fine without any of the optional layers or extensions. If I set these it’s causing a segmentation fault. RTLD_LOCAL or RTLD_GLOBAL unfortunately makes no difference.

Ok, so far I tried to compile the validation layers myself. The Android NDK also supports the validation layers since Android N (API 24). I build my application in armeabi-v7a hard float mode. Some of the validation layers I try to load crash the application right away. Namely VK_LAYER_LUNARG_object_tracker and VK_LAYER_GOOGLE_unique_objects. If I build my application without them I can at least use vkEnumerateInstanceProperties to get a list of the other available validation layers.

The thing is, if I call

std::vector<const char *> m_instanceLayers;
m_instanceLayers.push_back("VK_LAYER_GOOGLE_threading");
m_instanceLayers.push_back("VK_LAYER_LUNARG_parameter_validation");
//m_instanceLayers.push_back("VK_LAYER_LUNARG_object_tracker");
m_instanceLayers.push_back("VK_LAYER_LUNARG_core_validation");
m_instanceLayers.push_back("VK_LAYER_LUNARG_device_limits");
m_instanceLayers.push_back("VK_LAYER_LUNARG_image");
m_instanceLayers.push_back("VK_LAYER_LUNARG_swapchain");
//m_instanceLayers.push_back("VK_LAYER_GOOGLE_unique_objects");

std::vector<const char *> m_instanceExtensions;
m_instanceExtensions.push_back("VK_EXT_debug_report");

VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.enabledLayerCount = static_cast<uint32_t>(m_instanceLayers.size());
instanceCreateInfo.ppEnabledLayerNames = m_instanceLayers.data();
instanceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(m_instanceExtensions.size());
instanceCreateInfo.ppEnabledExtensionNames = m_instanceExtensions.data();

VK_ERROR_CHECK(vkCreateInstance(&instanceCreateInfo, nullptr, &m_instance));

I always get a segmentation fault. I found for example if I only load the VK_LAYER_GOOGLE_threading I can step into the code of the layer. My understanding of the layers so far is that they hook into the core function calls and insert their own logic and call either the next hook or if there are no more layers call directly into the vulkan driver. There is also a pretty good description here: Vulkan-LoaderAndValidationLayers/LoaderAndLayerInterface.md at master · KhronosGroup/Vulkan-LoaderAndValidationLayers · GitHub

In my case the layer is always entered through the vkGetInstanceProcAddr function which is in my example hooked by the VK_LAYER_GOOGLE_threading layer. The problem I ran into was, that at the end of the call the function tries to call into another GetInstanceProcAddr function through a dispatch table. This dispatch table contains all the pointers to the functions down to the vulkan driver. But I have the problem that this table is a nullptr and therefore can not be called, so I get the mentioned segmentation fault. For the dispatch table to be non null it needs to be initialized in the layer. But this only happens in the corresponding vkCreateInstance call. Which in my case is never entered for some reason and so no dispatch table initializiation takes place.

Is something missing in my code or is it really a problem with the current state of the vulkan drivers on Shield Tablet(not K1)?

Edit: Added tombstone from the crash

If analyzed with addr2line it points to this line:
https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/blob/android_layers/layers/threading.cpp#L267

This issue seems to be solved with the newest OTA 4.1 (05/12/2016). Thanks.