LunarG

Copyright © 2015-2022 LunarG, Inc.

Creative Commons

VK_LAYER_LUNARG_screenshot

The VK_LAYER_LUNARG_screenshot layer records frames to image files.

Configuring the Screenshot Layer

For an overview of how to configure layers, refer to the Layers Overview and Configuration document.

The Screenshot Layer settings are documented in the Layer Details section below.

The Screenshot Layer can also be enabled and configured using the Vulkan Configurator included with the Vulkan SDK.

Android

Frame numbers can be specified with the debug.vulkan.screenshot.frames property:

adb shell setprop debug.vulkan.screenshot.frames <framenumbers>

The directory in which to create the image files can be specified with the debug.vulkan.screenshot.dir property:

adb shell setprop debug.vulkan.screenshot.dir <directory>

If debug.vulkan.screenshot.dir is not set or it is set to an empty string, the value of debug.vulkan.screenshot.dir will default to "/sdcard/Android".

For production builds, if the files are to be written to external storage, make sure your application is able to read and write external storage by adding the following to AndroidManifest.xml:

<!-- This allows writing log files to sdcard -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

You may also need to grant it access with package manager. For example, using the Vulkan Cube demo from Khronos/Vulkan-Tools:

adb shell pm grant com.example.VkCube android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.example.VkCube android.permission.WRITE_EXTERNAL_STORAGE

Layer Settings

The options for this layer are specified in VK_LAYER_LUNARG_screenshot.json. The layer option details are documented in the screenshot layer documentation.

Layer Properties

Layer Settings Overview

Label Variables Key Type Default Value Platforms
Frames frames STRING `` WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
Directory dir SAVE_FOLDER `` WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
Format format ENUM USE_SWAPCHAIN_COLORSPACE WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID

Layer Settings Details

Frames

Specifies list of frames to output as screenshots. It is specified as a comma-separated list of frames or a range of frames with a start, count, and optional interval separated by a dash. Setting the variable to "all" will output every frame. Example: "5-8-2" will output frame 5, continue until frame 13, dumping every other frame. Example: "3,8-2" will output frames 3, 8, and 9. If it is not set or it set to an empty string, no screenshots are created.

Methods:
VK_EXT_layer_settings:
const char* data[] = { "" };
VkLayerSettingEXT setting {
 "VK_LAYER_LUNARG_screenshot", "frames", VK_LAYER_SETTING_TYPE_STRING_EXT,
 static_cast<uint32_t>(std::size(data)), data };
vk_layer_settings.txt:
lunarg_screenshot.frames = 
Environment variables:
export VK_LUNARG_SCREENSHOT_FRAMES=
export VK_SCREENSHOT_FRAMES=
export VK_FRAMES=
export VK_SCREENSHOT_FRAMES=
Android system properties:
adb setprop debug.vulkan.lunarg_screenshot.frames 
adb setprop debug.vulkan.screenshot.frames
adb setprop debug.vulkan.frames

Directory

Specifies the directory in which to create the screenshot files. If it is not set or is set to an empty string, the files will be created in the current working directory.

Methods:
VK_EXT_layer_settings:
const char* data[] = { "" };
VkLayerSettingEXT setting {
 "VK_LAYER_LUNARG_screenshot", "dir", VK_LAYER_SETTING_TYPE_STRING_EXT,
 static_cast<uint32_t>(std::size(data)), data };
vk_layer_settings.txt:
lunarg_screenshot.dir = 
Environment variables:
export VK_LUNARG_SCREENSHOT_DIR=
export VK_SCREENSHOT_DIR=
export VK_DIR=
export VK_SCREENSHOT_DIR=
Android system properties:
adb setprop debug.vulkan.lunarg_screenshot.dir 
adb setprop debug.vulkan.screenshot.dir
adb setprop debug.vulkan.dir

Format

Specify a color space for the output. If it is not set, set to null, or set to USE_SWAPCHAIN_COLORSPACE the format will be set to use the same color space as the swapchain object.

Enum Value Label Description Platforms
UNORM UNORM N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
SNORM SNORM N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
USCALED USCALED N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
SSCALED SSCALED N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
UINT UINT N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
SINT SINT N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
SRGB SRGB N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
USE_SWAPCHAIN_COLORSPACE USE_SWAPCHAIN_COLORSPACE N/A WINDOWS_X86, WINDOWS_ARM, LINUX, MACOS, ANDROID
Methods:
VK_EXT_layer_settings:
const char* data[] = { "USE_SWAPCHAIN_COLORSPACE" };
VkLayerSettingEXT setting {
 "VK_LAYER_LUNARG_screenshot", "format", VK_LAYER_SETTING_TYPE_STRING_EXT,
 static_cast<uint32_t>(std::size(data)), data };
vk_layer_settings.txt:
lunarg_screenshot.format = USE_SWAPCHAIN_COLORSPACE
Environment variables:
export VK_LUNARG_SCREENSHOT_FORMAT=USE_SWAPCHAIN_COLORSPACE
export VK_SCREENSHOT_FORMAT=USE_SWAPCHAIN_COLORSPACE
export VK_FORMAT=USE_SWAPCHAIN_COLORSPACE
export VK_SCREENSHOT_FORMAT=USE_SWAPCHAIN_COLORSPACE
Android system properties:
adb setprop debug.vulkan.lunarg_screenshot.format USE_SWAPCHAIN_COLORSPACE
adb setprop debug.vulkan.screenshot.format USE_SWAPCHAIN_COLORSPACE
adb setprop debug.vulkan.format USE_SWAPCHAIN_COLORSPACE