KhronosGroup/Vulkan-ExtensionLayer

Using VK_LAYER_KHRONOS_timeline_semaphore on android with renderdoc

raphaelthegreat opened this issue · 11 comments

I wanted to use VK_LAYER_KHRONOS_timeline_semaphore to port my existing renderer which uses timeline semaphores heavilly to android. However I've faced on issue where renderdoc is unable to open any capture since the layer isn't globally visible. Does any method exist to make these extension layers visible to renderdoc and other applications in general?

@spencer-lunarg I'm not very familiar with Android usage. Do you have advice?

So I am going to argue that unless we messed up the way the layer is hooked up, this is not a Vulkan-ExtensionLayer issues.

since the layer isn't globally visible.

I guess I am not sure what that means, if you are packaging the layer with your app (in the same APK) when you run the app (to capture it) it should be visible

How are you enabling the extension in your app? If you are explicit enabling it at VkInstance creation time, I am not sure why RenderDoc would not be able to see it when it runs

this is not a Vulkan-ExtensionLayer issues

I guess that's true but I asked the same question on the renderdoc side and didn't receive a concrete answer. Also since the layer is supported on android there should be a method to perform renderdoc captures even on rooted devices only.

if you are packaging the layer with your app (in the same APK) when you run the app (to capture it) it should be visible

This is what I'm doing (put the compiled layer library in jniLibs). Renderdoc doesn't see it

If you are explicit enabling it at VkInstance creation time, I am not sure why RenderDoc would not be able to see it when it runs

I'm adding the layer name in ppEnabledLayerNames not sure if there's a more explicit way.

I guess that's true but I asked the same question on the renderdoc side and didn't receive a concrete answer.

Is this a public issue you asked, can you link it, or if it was a private message put the response here, it might be a valid answer, just might assume more deeper understanding of the Android Layer system

I'm adding the layer name in ppEnabledLayerNames not sure if there's a more explicit way.

That is the explicit way, just making sure!

Closing due to inactivity. If more assistance is needed please visit the vulkan discord.

@gpucode
FYI I managed to get this working by having the extension *.so files packaged inside the RenderDoc remote replay APK (org.renderdoc.renderdoccmd.arm64.apk).

This way the extension layers are advertised to the org.renderdoc.renderdoccmd.arm64 app through vkEnumerateInstanceLayerProperties by the loader.
(The replay app needs to see the layers, since that is what is executing the Vulkan API commands when replaying your capture, not your app.)

This commit James2022-rgb/renderdoc@81e63e3 makes it so that when you build RenderDoc for Android, the *.so files are packaged inside the APK.
I also wrote a blog post about this (Japanese).

I look forward to hearing suggestions for a better or more streamlined way to do this; not being able to use RenderDoc when using the extension layers on Android was a huge blocker for me :)

@James2022-rgb (記事を読めた)

One question, is the org.renderdoc.renderdoccmd.arm64 a debug app, can you run-as it as described in
https://developer.android.com/ndk/guides/graphics/validation-layer

@mark-lunarg how is this done with Gfxrconstruct, if you trace an app that is using a VEL layer, how does the gfxrecon-replay app work?

@spencer-lunarg
Thank you.
org.renderdoc.renderdoccmd.arm64 indeed has android:debuggable="true" but the run-as method doesn't seem to work,
which I think is because of this piece of code for RenderDoc:

https://github.com/baldurk/renderdoc/blob/52cfb0e08394b9e95cbbae774644a1271750397a/renderdoc/android/android.cpp#L634-L643

Android::adbExecCommand(deviceID, "shell setprop debug.vulkan.layers :", ".", true);
Android::adbExecCommand(deviceID, "shell settings delete global enable_gpu_debug_layers", ".",
                          true);
Android::adbExecCommand(deviceID, "shell settings delete global gpu_debug_app", ".", true);
Android::adbExecCommand(deviceID, "shell settings delete global gpu_debug_layer_app", ".", true);
Android::adbExecCommand(deviceID, "shell settings delete global gpu_debug_layers", ".", true);
Android::adbExecCommand(deviceID, "shell settings delete global gpu_debug_layers_gles", ".", true);

That is, it undoes all the GPU debug layer settings outlined in the Android Developers article.
(confirmed with adb shell settings list global)

it undoes all the GPU debug layer settings outlined in the Android Developers article.

Wow, ok so clearly this is Renderdoc in a "trust no one" situation

Curious if you have raised this as a concern on the Renderdoc issue yet (curious on Baldur thoughts)

Curious if you have raised this as a concern on the Renderdoc issue yet (curious on Baldur thoughts)

Not on the GitHub repo.
But another person was asking Baldur on the RenderDoc discord on 2022-12-27 whether it was possible to package the layers inside the renderdoccmd APK,
and his answer was that that was not something he was going to do officially.
I mentioned then that I might do some further research into this, but I've only managed to get it working this month.

So I think that's the last time Baldur has ever heard of this issue?

Oh nice, I bet this will be quite useful for other extension layers like the shader object one. About this issue, it's no longer relevant for my case because I switched to a custom timeline semaphore emulation in the application which works in renderdoc. Given that this won't be supported officially, an idea would be to make a script that repackages the official app with the layer libraries.