ARM-software / vktrace-arm

Vktrace arm fork
Other
20 stars 14 forks source link

Tracing and Replaying #7

Open xidian10000 opened 7 months ago

xidian10000 commented 7 months ago

Tracing

Tracing apps is similar to tracing normal ones. You can follow most of the tracing steps you've already known. What's new is setting some environment variables. The following steps will guide you:

Tracing for all apps:

For tracing most apps, we need to set these environment variables:

export VKTRACE_ENABLE_REBINDMEMORY_ALIGNEDSIZE=1

the optional variables:

export VKTRACE_PAGEGUARD_ENABLE_SYNC_GPU_DATA_BACK=1
export VKTRACE_FORCE_FIFO=1
export VKTRACE_DELAY_SIGNAL_FENCE_FRAMES=3

Fastforwarding for all traces:

For fastforwarding most traces, we need to set these environment variables:

export VKTRACE_ENABLE_REBINDMEMORY_ALIGNEDSIZE=1
export VKTRACE_DISABLE_CAPTUREREPLAY_FEATURE=1

the optional variables:

export VKTRACE_PAGEGUARD_ENABLE_SYNC_GPU_DATA_BACK=1
export VKTRACE_FORCE_FIFO=1
export VKTRACE_DELAY_SIGNAL_FENCE_FRAMES=3

The above environment variables are valid on Android:

adb shell setprop NAME 'value' , such as:

adb shell setprop  VKTRACE_ENABLE_REBINDMEMORY_ALIGNEDSIZE 1

adb shell setprop VKTRACE_PAGEGUARD_ENABLE_SYNC_GPU_DATA_BACK  1
adb shell setprop VKTRACE_FORCE_FIFO 1
adb shell setprop VKTRACE_DELAY_SIGNAL_FENCE_FRAMES  3
xidian10000 commented 7 months ago

Replaying

Replaying ray query/ray tracing traces need add special parameters. The following steps will guide you:

./vkreplay -h
vkreplay info: vkreplay  available options about ray query/ray tracing:
vkreplay info:   -drcr, --disableRQAndRTPCaptureReplay <uint>  Disable capture replay features. Bitfield where accelerationStructure=1, bufferDeviceAddress=2, rayTracingPipelineShaderGroupHandle=4.
vkreplay info:   -spc, --specialPatternConfig <uint>  Special Pattern Config: 0:None, 1:PatternA, other reserve.

Replaying with ray tracing capture replay feature:

./vkreplay ... -drcr 0 ... (default the value of drcr is 0, except drcr is written to vktrace header

Replaying without ray tracing capture replay feature:

./vkreplay ... -drcr 7  ...  (the drcr option can be used with combined values)

If the buffer device addresses in the memory of buffer need be remapped:

./vkreplay ... -drcr 7 -spc 1 ...  (the drcr option can be used with combined values)

The above environment variables are valid on Android

xidian10000 commented 5 months ago

The trace layer, api dump layer .., all enabled layers are set globally by default.

From Android 14, the system UI calls will be captured with the app too. So there is need select hwui.renderer to use skiagl or enable layers on a per-app basis to capture or dump traces.

Android HWUI debug options "debug.hwui.renderer ": Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL or Vulkan. Accepted values are "opengl", "skiagl", and vulkan".

Before capturing vktrace, set the following variable to disable the Vulkan usage for the HWUI :

 adb shell setprop debug.hwui.renderer 'skiagl'

After capturing vktrace, set the following variable to restore the Vulkan usage for the HWUI:

 adb shell setprop debug.hwui.renderer 'skiavk'
xidian10000 commented 3 months ago

For vktrace 4.1 or below, if you install vkreplay.apk to Android 14 or above, must use the following ADB command:

adb install --bypass-low-target-sdk-block vkreplay.apk

On devices upgrading to Android 14, any apps with a targetSdkVersion lower than 23 will remain installed. details at : https://developer.android.com/about/versions/14/behavior-changes-all