Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

验证层

验证层能够让开发者验证应用程序是否正确使用了 Vulkan API。调试构建和发布构建中均可启用验证层,包括导出后的项目。

备注

启用验证层会对性能产生影响,因此,请只有在实际需要输出来调试程序时才启用。

Windows

Install the Vulkan SDK https://vulkan.lunarg.com/sdk/home, which contains validation layers as part of its default installation. No need to enable any optional features in the installer; installing the core Vulkan SDK suffices. You don't need to reboot after installing the SDK, but you may need to close and reopen your current terminal.

After installing the Vulkan SDK, run Godot with the --gpu-validation command line argument. You can also specify --gpu-abort which will make Godot quit as soon as a validation error happens. This can prevent your system from freezing if a validation error occurs.

macOS

警告

Official Godot macOS builds do not support validation layers, as these are statically linked against the Vulkan SDK. Dynamic linking must be used instead.

In practice, this means that using validation layers on macOS requires you to use a Godot build compiled with the use_volk=yes SCons option. 为 macOS 平台编译. If testing validation layers on an exported project, you must recompile the export template and specify it as a custom export template in your project's macOS export preset.

Install the Vulkan SDK https://vulkan.lunarg.com/sdk/home, which contains validation layers as part of its default installation. No need to enable any optional features in the installer; installing the core Vulkan SDK suffices. You don't need to reboot after installing the SDK, but you may need to close and reopen your current terminal.

After installing the Vulkan SDK, run a Godot binary that was compiled with use_volk=yes SCons option. Specify the --gpu-validation command line argument. You can also specify --gpu-abort which will make Godot quit as soon as a validation error happens. This can prevent your system from freezing if a validation error occurs.

Linux、*BSD

Install Vulkan validation layers from your distribution's repositories:

vulkan-validation-layers

You don't need to reboot after installing the validation layers, but you may need to close and reopen your current terminal.

After installing the package, run Godot with the --gpu-validation command line argument. You can also specify --gpu-abort which will make Godot quit as soon as a validation error happens. This can prevent your system from freezing if a validation error occurs.

Android

After enabling validation layers on Android, a developer can see errors and warning messages in the adb logcat output.

iOS

验证层目前不支持iOS

Web

Validation layers are not supported on the web platform, as there is no support for Vulkan there.

启用验证层

从官方源码构建验证层

To build Android libraries, follow the instructions on Khronos' repository. After a successful build, the libraries will be located in Vulkan-ValidationLayers/build-android/libs.

复制库

Copy libraries from Vulkan-ValidationLayers/build-android/libs to godot/platform/android/java/app/libs/debug/vulkan_validation_layers.

Your Godot source directory tree should look like on the example below:

godot
|-- platform
    |-- android
        |-- java
            |-- app
                |-- libs
                    |-- debug
                        |-- vulkan_validation_layers
                            |-- arm64-v8a
                            |-- armeabi-v7a
                            |-- x86
                            |-- x86_64

If the subdirectory libs/debug/vulkan_validation_layers doesn't exist, create it.

编译并运行 Android 应用

Linked validation layers are automatically loaded and enabled in Android debug builds. You can use Godot's 一键部署 feature to quickly test your project with the validation layers enabled.