当前位置: 首页 > news >正文

在 Windows Subsystem for Linux (WSL2) 的 Ubuntu 系统上配置 Vulkan 开发环境

在 Windows Subsystem for Linux (WSL2) 的 Ubuntu 系统上配置 Vulkan 开发环境

Vulkan Tutorial
https://vulkan-tutorial.com/

Development environment - Linux
https://vulkan-tutorial.com/Development_environment

1. Vulkan - Cross platform 3D Graphics

https://www.vulkan.org/

Vulkan is a new generation graphics and compute API that provides high-efficiency, cross-platform access to modern graphics processing units (GPUs), which are used in a wide variety of devices from PCs and consoles to mobile phones and embedded platforms. The Vulkan API was created by the Khronos Group, a consortium of technology hardware and software companies.

Vulkan is a low-overhead, cross-platform API, open standard for 3D graphics and computing. Vulkan targets high-performance real-time 3D graphics applications, such as video games and interactive media. Vulkan is intended to offer higher performance and more efficient CPU and GPU usage compared to older OpenGL and Direct3D 11 APIs. It provides a considerably lower-level API for the application than the older APIs, making Vulkan comparable to Apple’s Metal API and Microsoft’s Direct3D 12 and harder to use than the higher-level OpenGL and Direct3D 11 APIs. In addition to its lower CPU usage, Vulkan is designed to allow developers to better distribute work among multiple CPU cores.
Vulkan 是一个低开销、跨平台的 3D graphics and computing 的应用程序接口 (API)。Vulkan 针对全平台实时 3D 图形程序而设计,并提供高性能与更均衡的 CPU 与 GPU 利用率。Vulkan 是一个底层 API,而且能执行并行任务,Vulkan 还能更好地分配多个 CPU 核心的使用。

Vulkan was first announced by the non-profit Khronos Group at GDC 2015. The Vulkan API was initially referred to as the “next generation OpenGL initiative”, or “OpenGL next” by Khronos, but use of those names was discontinued when “Vulkan” was announced.
Vulkan 由 Khronos Group 在 2015 年游戏开发者大会 (GDC) 上发表。正式宣布 Vulkan 之后这些名字就没有再使用了。

Vulkan is derived from and built upon components of AMD’s Mantle API, which was donated by AMD to Khronos with the intent of giving Khronos a foundation on which to begin developing a low-level API that they could standardize across the industry.
Vulkan 基于 AMD’s Mantle API 构建,AMD 将其捐赠给 Khronos Group,给予该组织开发底层 API 的基础,使其像 OpenGL 一样成为行业标准。

Vulkan offers lower overhead, more direct control over the GPU, and lower CPU usage.
Vulkan 旨在提供更低的 CPU 开销与更直接的 GPU 控制。

console [kənˈsəʊl]:vt. 安慰,抚慰,慰藉 n. (机器、电子设备等的) 控制台,操纵台,仪表板
consortium [kənˈsɔː(r)tiəm]:n. 联盟,(合作进行某项工程的) 财团,银团,联营企业

All of the tools we’ll use, with the exception of the compiler, are compatible with Windows, Linux and MacOS.

1.1 Vulkan Packages

https://www.vulkan.org/tools

Essentials tools, documentation and libraries for every Vulkan developer.

The most important components you’ll need for developing Vulkan applications on Linux are the Vulkan loader, validation layers, and a couple of command-line utilities to test whether your machine is Vulkan-capable.
在 Linux 上开发 Vulkan 应用程序所需的最重要组件是 Vulkan 加载器、校验层和命令行程序,用于测试你的机器是否支持 Vulkan。

  • sudo apt install vulkan-tools: Command-line utilities, most importantly vulkaninfo and vkcube. Run these to confirm your machine supports Vulkan.
  • sudo apt install libvulkan-dev: Installs Vulkan loader. The loader looks up the functions in the driver at runtime, similarly to GLEW for OpenGL.
  • sudo apt install vulkan-validationlayers-dev spirv-tools: Installs the standard validation layers and required SPIR-V tools. These are crucial when debugging Vulkan applications, and we’ll discuss them in the upcoming chapter.

Remember to run vkcube and ensure you see the following pop up in a window:
在这里插入图片描述

You don’t have to create an account, but it will give you access to some additional documentation that may be useful to you.
Vulkan SDK 可以从 LunarG 的网站上免费下载。

在这里插入图片描述

  • Vulkan SDK for Windows, Linux, and macOS
    https://vulkan.lunarg.com/

LunarG has developed the quintessential developer SDK including build tools, documentation, libraries and more.

  • Android NDK
    https://developer.android.com/ndk/guides/graphics

Google gives you everything you need to incorporate Vulkan into your Android games and other apps where graphics performance is key.

Visit the Android developer website to download the API, samples, and documentation: resources to help you hit the ground running.

  • Arm Mali SDK
    https://github.com/ARM-software/vulkan-sdk

ARM’s Vulkan Software Development Kit is a collection of resources to help you build Vulkan applications for a platform with a Mali GPU and an ARM processor. You can use it for creating new applications, training, and exploration of implementation possibilities.

  • PowerVR SDK
    https://github.com/powervr-graphics/Native_SDK

The PowerVR SDK is an open source codebase to help with the development of graphics applications for PowerVR and other platforms. It consists of two main parts: the Framework and a set of examples.

quintessential [.kwɪntɪ'senʃ(ə)l]:adj. 精髓的,最完美的
essential [ɪ'senʃ(ə)l]:n. 要点,要素,实质,必需品 adj. 完全必要的,必不可少的,极其重要的,本质的

1.2 下载 Vulkan SDK (Linux)

https://vulkan.lunarg.com/
https://vulkan.lunarg.com/sdk/home

Download the latest Vulkan SDK from vulkan.LunarG.com.

You should have a compiler that supports C++17 (GCC 7+ or Clang 5+). You’ll also need make.

在这里插入图片描述

The Khronos Vulkan API is an explicit, low-overhead, cross-platform graphics and compute API. Vulkan provides applications with control over the system execution and the system memory to maximize application efficiency on a wide variety of devices from PCs and consoles to mobile phones and embedded platforms.

The Vulkan SDK enables Vulkan developers to develop Vulkan applications. The Vulkan SDK includes:

  • Vulkan API usage validation thanks to the Khronos Validation layer.
  • Vulkan Layers configuration thanks to Vulkan Configurator.
  • SPIR-V Shader compilation, optimization and validation thanks to DXC, SPIR-V Tools and SPIR-V Cross.
  • Vulkan API capture and replay for Vulkan debugging thanks to GFXReconstruct.
  • Vulkan system report thanks to Vulkan Installation Analyzer (VIA), Vulkan Hardware Capability Viewer, and Vulkan Info.
  • Third-party libraries and tools such as Volk, and VMA.

Note: The Vulkan Installation Analyzer may be deprecated at some point in the future. The Vulkan loader debugging output has been expanded to replace this tool.

All documentation for the SDK can be found and downloaded online at vulkan.lunarg.com.

Important: This SDK does not install Vulkan drivers!! It only provides tools and libraries for application development and debugging. If you are looking for drivers, please refer to your system GPU vendor’s website.

With each SDK release, a release of the Khronos Validation Layer binaries for Android are released on the Validation layer Repository. The Android binaries are not included in this SDK.

Version 1.3.239.0:

  • SDK - SDK Installer
    vulkansdk-linux-x86_64-1.3.239.0.tar.gz (330MB)

  • SDK Config - Config.json
    config.json (0MB)

在这里插入图片描述

复制链接地址:
在这里插入图片描述

yongqiang@yongqiang:~$ mkdir vulkan_sdk
yongqiang@yongqiang:~$ cd vulkan_sdk/
yongqiang@yongqiang:~/vulkan_sdk$ wget https://sdk.lunarg.com/sdk/download/1.3.239.0/linux/config.json
--2023-02-23 23:54:28--  https://sdk.lunarg.com/sdk/download/1.3.239.0/linux/config.json
Resolving sdk.lunarg.com (sdk.lunarg.com)... 104.26.0.199, 172.67.73.90, 104.26.1.199, ...
Connecting to sdk.lunarg.com (sdk.lunarg.com)|104.26.0.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8921 (8.7K) [application/json]
Saving to: ‘config.json’config.json                   100%[=================================================>]   8.71K  --.-KB/s    in 0.006s2023-02-23 23:54:30 (1.39 MB/s) - ‘config.json’ saved [8921/8921]yongqiang@yongqiang:~/vulkan_sdk$ wget https://sdk.lunarg.com/sdk/download/1.3.239.0/linux/vulkansdk-linux-x86_64-1.3.239.0.tar.gz
--2023-02-23 23:54:48--  https://sdk.lunarg.com/sdk/download/1.3.239.0/linux/vulkansdk-linux-x86_64-1.3.239.0.tar.gz
Resolving sdk.lunarg.com (sdk.lunarg.com)... 104.26.0.199, 172.67.73.90, 104.26.1.199, ...
Connecting to sdk.lunarg.com (sdk.lunarg.com)|104.26.0.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346518877 (330M) [application/octet-stream]
Saving to: ‘vulkansdk-linux-x86_64-1.3.239.0.tar.gz’vulkansdk-linux-x86_64-1.3.239.0 100%[========================================================>] 330.47M  11.3MB/s    in 37s2023-02-23 23:55:26 (8.91 MB/s) - ‘vulkansdk-linux-x86_64-1.3.239.0.tar.gz’ saved [346518877/346518877]yongqiang@yongqiang:~/vulkan_sdk$
yongqiang@yongqiang:~/vulkan_sdk$ ls -l
total 338412
-rw-r--r-- 1 yongqiang yongqiang      8921 Jan 28 02:44 config.json
-rw-r--r-- 1 yongqiang yongqiang 346518877 Jan 28 02:45 vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan_sdk$
yongqiang@yongqiang:~/vulkan_sdk$ chmod a+x ./vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan_sdk$
yongqiang@yongqiang:~/vulkan_sdk$ ls -l
total 338412
-rw-r--r-- 1 yongqiang yongqiang      8921 Jan 28 02:44 config.json
-rwxr-xr-x 1 yongqiang yongqiang 346518877 Jan 28 02:45 vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan_sdk$

1.2.1 Vulkan Docs

https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html

Getting Started with the Linux Tarball Vulkan SDK
在这里插入图片描述

1.2.2 SDK Versioning

The components in this SDK are built with a specific version of Khronos Vulkan API header, whose version is reflected in the SDK’s version number. For example, SDK version v.w.xx.0 indicates the SDK uses the Vulkan header revision where:

  • v is the Vulkan major version
  • w is the Vulkan minor version
  • xx is the Vulkan patch version (e.g., 24)

The last number in the SDK version indicates the revision of an SDK for the given Vulkan header revision. It is used in case it is necessary to release multiple SDKs for the same version of Vulkan.

For example, SDK version 1.1.70.0 indicates the SDK uses Vulkan header revision 1.1.70.

Note: A more recent SDK version number does not indicate an application cannot be developed for earlier Vulkan versions. As well, an older SDK version can not be used to develop applications for a newer version of Vulkan. For example, the 1.1.130.0 SDK can be used to develop Vulkan 1.0 applications but cannot be used to develop applications for Vulkan 1.2. Furthermore, the presence of a 1.2.xx SDK does not necessarily indicate a system can actually run Vulkan 1.2. A Vulkan 1.2 driver is required for applications to use most Vulkan 1.2 functionality.

presence [ˈprez(ə)ns]:n. 存在,出现,在场,出席

Once you have installed a Vulkan driver on your system, there is a version for your Vulkan Loader, and a version for each physical device.

  1. Vulkan Instance Version. This is the version of your Vulkan Loader. If you run vulkaninfo, the Vulkan Instance Version is the first item reported.
  2. For each physical device, there is an apiVersion. The apiVersion is the version of your Vulkan driver. You can find the apiVersion for each physical device from your vulkaninfo output under the section labeled “Device Properties and Extensions”.

1.3 System requirements

Your Linux development and host systems must meet specific hardware and software requirements to install the Vulkan SDK and create Vulkan applications. You will need a Vulkan ICD to execute Vulkan applications.
需要一个 Vulkan ICD 来执行 Vulkan 应用程序。

The Vulkan SDK is supported on 64-bit Linux systems. This guide provides instructions for the following Linux distributions:

  • Ubuntu 20.04 and 22.04
  • Fedora CoreOS (36 and 37)
  • Arch Linux (latest)

LunarG does extensive testing on the Ubuntu distributions and touch testing on the other Linux distributions. Additional Linux distributions may work but have not been verified. If the pre-built binaries don’t run on your system we provide the source and a helper script to build these components. Also, you can search your distribution’s package manager for Vulkan development libraries.
LunarG 在 Ubuntu 发行版上进行了大量测试,并在其他 Linux 发行版上进行了 touch testing。其他 Linux 发行版可能有效,但尚未经过验证。如果预构建的二进制文件不能在您的系统上运行,我们会提供源代码和帮助脚本来构建这些组件。此外,您还可以在您的发行版包管理器中搜索 Vulkan 开发库。

Otherwise you may download and build from publicly available repositories. Everything provided in the SDK is open source.
SDK 中提供的所有内容都是开源的。

The following list are the core repositories that the SDK is composed of:

  • Khronos Vulkan Headers: https://github.com/KhronosGroup/Vulkan-Headers
  • Khronos Vulkan Loader source: https://github.com/KhronosGroup/Vulkan-Loader
  • Khronos Vulkan Validation Layers source: https://github.com/KhronosGroup/Vulkan-ValidationLayers
  • Khronos Vulkan Tools source: https://github.com/KhronosGroup/Vulkan-Tools
  • LunarG Vulkan Tools source: https://github.com/LunarG/VulkanTools
  • Khronos glslang source: https://github.com/KhronosGroup/glslang
  • Google Shaderc source: https://github.com/google/shaderc
  • Khronos SPIRV-Headers source: https://github.com/KhronosGroup/SPIRV-Headers
  • Khronos SPIRV-Tools source: https://github.com/KhronosGroup/SPIRV-Tools
  • Khronos SPIRV-Cross source: https://github.com/KhronosGroup/SPIRV-Cross
  • LunarG GFXReconstruct source: https://github.com/LunarG/gfxreconstruct
  • Khronos SPIRV-Reflect source: https://github.com/KhronosGroup/SPIRV-Reflect
  • Khronos Vulkan Extension Layer source: https://github.com/KhronosGroup/Vulkan-ExtensionLayer
  • Khronos Vulkan Profiles: https://github.com/KhronosGroup/Vulkan-Profiles
  • Microsoft DirectX Shader Compiler: https://github.com/microsoft/DirectXShaderCompiler
  • Volk Vulkan Meta Loader: https://github.com/zeux/volk
  • Vulkan Memory Allocator Library: https://gpuopen.com/vulkan-memory-allocator/
  • Vulkan Caps Viewer: https://github.com/SaschaWillems/VulkanCapsViewer

You will find instructions to build all of the above in their respective repositories.

1.3.1 Ubuntu distributions (20.04 and 22.04)

Upgrade your system to be current on package updates:

sudo apt update && sudo apt upgrade -y

If you want to clone and build any of the repositories using the vulkansdk script, install the following prerequisite packages:

sudo apt install libglm-dev cmake libxcb-dri3-0 libxcb-present0 libpciaccess0 \
libpng-dev libxcb-keysyms1-dev libxcb-dri3-dev libx11-dev g++ gcc g++-multilib \
libmirclient-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libxcb-ewmh-dev \
git python python3 bison libx11-xcb-dev liblz4-dev libzstd-dev python3-distutils \
ocaml-core ninja-build pkg-config libxml2-dev wayland-protocols python3-jsonschema

For ubuntu 20.04, to install qt5 run:

sudo apt install qt5-default

For Ubuntu 22.04, to install qt5 run:

sudo apt install qtbase5-dev

Minimum CMake 3.17.2 version is required.

1.4 安装 Vulkan SDK (Linux)

The Vulkan SDK installation process consists of extracting the tar file into a desired directory. The extracted file is a folder in the form 1.x.yy.z and can be placed anywhere on your system.
Vulkan SDK 安装过程包括将 tar 文件提取到所需目录中。提取的文件是一个文件夹,格式为 1.x.yy.z,可以放在系统的任何位置。

  1. Create a work directory.

These instructions assume you want to install the SDK under a folder called vulkan, which can be placed anywhere on your system. In this case, it is your HOME directory.

cd ~
mkdir vulkan
cd vulkan
  1. Generate the sha256sum and ensure it matches with the one listed on vulkan.lunarg.com located next to the SDK download link.

Assuming you had downloaded the package to /home/yongqiang/vulkan:
sha256sum ./vulkansdk-linux-x86_64-1.x.yy.z.tar.gz

yongqiang@yongqiang:~/vulkan$ pwd
/home/yongqiang/vulkan
yongqiang@yongqiang:~/vulkan$
yongqiang@yongqiang:~/vulkan$ ls -l
total 338412
-rw-r--r-- 1 yongqiang yongqiang      8921 Jan 28 02:44 config.json
-rwxr-xr-x 1 yongqiang yongqiang 346518877 Jan 28 02:45 vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan$
yongqiang@yongqiang:~/vulkan$ sha256sum ./vulkansdk-linux-x86_64-1.3.239.0.tar.gz
1ac4e3b23f27570535026506fd9fcaf5ed56f8562c87cdd60afe7adf58b037e8  ./vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan$
  1. Extract the SDK package.

Assuming you had downloaded the package to /home/yongqiang/vulkan:
tar xf ./vulkansdk-linux-x86_64-1.x.yy.z.tar.gz

yongqiang@yongqiang:~/vulkan$ tar xf ./vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan$ ls -l
total 338416
drwxr-xr-x 5 yongqiang yongqiang      4096 Jan 28 02:43 1.3.239.0
-rw-r--r-- 1 yongqiang yongqiang      8921 Jan 28 02:44 config.json
-rwxr-xr-x 1 yongqiang yongqiang 346518877 Jan 28 02:45 vulkansdk-linux-x86_64-1.3.239.0.tar.gz
yongqiang@yongqiang:~/vulkan$
  1. Install runtime dependencies if they are not already installed:

Ubuntu 22.04:

sudo apt install qtbase5-dev libxcb-xinput0 libxcb-xinerama0

Ubuntu 20.04:

sudo apt install qt5-default libxcb-xinput0 libxcb-xinerama0

Note: Packaging of the Linux Vulkan SDK has changed from a .run file to a .tar.gz file starting from release version 1.1.77.0 and forward. The run file previously created a VulkanSDK directory and then expanded the SDK into the VulkanSDK/1.1.xx.y directory. The .tar.gz file now simply extracts the SDK into a directory of the form 1.x.yy.z.
从发布版本 1.1.77.0 开始,Linux Vulkan SDK 的打包已从 .run 文件更改为 .tar.gz 文件。

1.4.1 Tar file contents

The table below describes the filesystem unpacked from the SDK tar file, which appears under the top-level 1.x.yy.z directory created when the SDK was extracted. The top-level SDK directory contains a platform-specific folder; for 64-bit Intel CPU targets, it is named x86_64.

DirectoryDescription
x86_64/binVulkan tools and commands
x86_64/includeHeader files useful for your Vulkan application. Includes Vulkan, shader tools, etc.
x86_64/libVulkan loader library and layer runtime libraries
x86_64/etc/vulkan/explicit_layer.d.json manifest files for Vulkan validation layers
x86_64/share/vulkanConfigurations for profiles and Vulkan registry information
configSample layer settings file
sourceSource files
manifest [ˈmænɪfest]:v. 表明,显现,使人注意到 adj. 明显的,显而易见的 n. 旅客名单
yongqiang@yongqiang:~/vulkan/1.3.239.0$ ls -l
total 52
-rw-r--r--  1 yongqiang yongqiang   944 Jan 28 02:43 LICENSE.txt
-rw-r--r--  1 yongqiang yongqiang   304 Jan 28 02:43 README.txt
drwxr-xr-x  2 yongqiang yongqiang  4096 Jan 28 02:43 config
-rw-r--r--  1 yongqiang yongqiang   582 Jan 28 02:23 setup-env.sh
drwxr-xr-x 21 yongqiang yongqiang  4096 Jan 28 02:22 source
-rwxr-xr-x  1 yongqiang yongqiang 25975 Jan 28 02:23 vulkansdk
drwxr-xr-x  7 yongqiang yongqiang  4096 Jan 28 02:20 x86_64
yongqiang@yongqiang:~/vulkan/1.3.239.0$
yongqiang@yongqiang:~/vulkan/1.3.239.0$ cd x86_64/
yongqiang@yongqiang:~/vulkan/1.3.239.0/x86_64$ ls -l
total 20
drwxr-xr-x  2 yongqiang yongqiang 4096 Jan 28 02:43 bin
drwxr-xr-x  3 yongqiang yongqiang 4096 Jan 28 02:20 etc
drwxr-xr-x 13 yongqiang yongqiang 4096 Jan 28 02:43 include
drwxr-xr-x  3 yongqiang yongqiang 4096 Jan 28 02:43 lib
drwxr-xr-x  4 yongqiang yongqiang 4096 Jan 28 02:43 share
yongqiang@yongqiang:~/vulkan/1.3.239.0/x86_64$

1.4.2 System file locations

If you have installed a Vulkan driver from a GPU vendor, you may wish to verify there is a .json manifest file for that driver installed. This will normally be located in either /etc/vulkan/icd.d/ or /usr/share/vulkan/icd.d (though other locations are possible). These directories will contain one or more Vulkan driver .json manifest files, which are not modified by the SDK installer. Refer to the Vulkan Loader guide in the “ICD Discovery on Linux” section for detailed information on ICD and layer library search order and paths for this platform.
如果你安装了来自 GPU 供应商的 Vulkan driver,你可能希望验证安装了该驱动程序的 .json manifest file。通常位于 /etc/vulkan/icd.d//usr/share/vulkan/icd.d (尽管其他位置也是可能的)。这些目录将包含一个或多个 Vulkan driver .json manifest files,SDK 安装程序不会修改这些文件。

yongqiang@yongqiang:~$ cd /etc/vulkan
yongqiang@yongqiang:/etc/vulkan$ ls
explicit_layer.d  icd.d  implicit_layer.d
yongqiang@yongqiang:/etc/vulkan$ cd icd.d/
yongqiang@yongqiang:/etc/vulkan/icd.d$ ls
yongqiang@yongqiang:/etc/vulkan/icd.d$yongqiang@yongqiang:~$ cd /usr/share/vulkan/
yongqiang@yongqiang:/usr/share/vulkan$ ls
explicit_layer.d  icd.d  implicit_layer.d  registry
yongqiang@yongqiang:/usr/share/vulkan$
yongqiang@yongqiang:/usr/share/vulkan$ cd icd.d/
yongqiang@yongqiang:/usr/share/vulkan/icd.d$ ls
intel_icd.x86_64.json  lvp_icd.x86_64.json  radeon_icd.x86_64.json
yongqiang@yongqiang:/usr/share/vulkan/icd.d$

1.4.3 Set up the runtime environment

Because you installed the Vulkan SDK in a location of your choice, you need to set environment variables to locate the Vulkan SDK components. These variables are identified in the table below. The VULKAN_SDK environment variable is set to the platform-specific directory in your SDK installation (e.g. ~/vulkan/1.x.yy.z/x86_64). The rest of the variables are set using paths relative to VULKAN_SDK:

Environment VariableFile/Path to IncludeNotes
PATH$VULKAN_SDK/binSDK executables
LD_LIBRARY_PATH$VULKAN_SDK/libDynamically-loaded libraries (e.g., layers)
VK_LAYER_PATH$VULKAN_SDK/etc/vulkan/explicit_layer.dOnly the SDK layer manifest .json files
VK_ADD_LAYER_PATH$VULKAN_SDK/etc/vulkan/explicit_layer.dThe SDK and system layer manifest .json files

The script sets the VK_ADD_LAYER_PATH environment variable to find the SDK layers first, followed by any layers installed on your system. VK_LAYER_PATH overrides VK_ADD_LAYER_PATH completely, so the script unsets VK_LAYER_PATH if it is set before the script is executed. You can set VK_LAYER_PATH after running the setup script if you wish to specify a custom path that does not include the system layer paths.

Use the source command to load that script into your current shell:

source ~/vulkan/1.x.yy.z/setup-env.sh

Of course, you would replace xx and y with the actual SDK version numbers.

Alternatively you can setup your paths by setting these environment variables yourself:

export VULKAN_SDK=~/vulkan/1.x.yy.z/x86_64
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d
yongqiang@yongqiang:~/vulkan/1.3.239.0/x86_64$ pwd
/home/yongqiang/vulkan/1.3.239.0/x86_64
yongqiang@yongqiang:~/vulkan/1.3.239.0/x86_64$

环境变量:

export VULKAN_SDK=~/vulkan/1.3.239.0/x86_64
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d
yongqiang@yongqiang:~$ vim ~/.bashrc
yongqiang@yongqiang:~$ cat ~/.bashrc

相同的用户打开新的终端时生效,或者手动 source ~/.bashrc 生效,仅对当前用户有效。

yongqiang@yongqiang:~$ source ~/.bashrc

在这里插入图片描述

1.4.4 Environment variable persistence

Note that sourcing the setup-env.sh script or running export commands only set the environment variables for your current shell session. They do not permanently “setup” any of this configuration for other shell sessions or future logins.
请注意,setup-env.sh 脚本或运行 export 命令只会为当前的 shell 会话设置环境变量。他们不会为其他 shell 会话或未来的登录永久地设置任何此配置。

For example, on most Ubuntu desktop systems, adding a line to your .profile file to source the setup-env.sh file sets up the environment variables for you for both shells and programs started from the graphical environment in a desktop session. This should make the environment variables available to desktop tools such as cmake-gui, Qt Creator, or Android Studio.
在你的 .profile 文件中添加一行以执行 setup-env.sh 文件的代码,为你从桌面图形环境启动的 shell 和程序设置环境变量。

persistence [pə(r)ˈsɪstəns]:n. 坚持,持续存在,锲而不舍,维持

1.5 Copying SDK Files to System Directories (不推荐使用)

The binaries included in the SDK are all built from public repositories. You can build each repository from source or it may just be easier to copy the files from the SDK into your system paths. There are also Ubuntu packages that makes installing these files even easier.
你可以从源代码构建每个 repository,或者将文件从 SDK 复制到你的系统路径中可能会更容易。

If you want to install SDK files to your system directories, here are some examples to do so. (Note: some system paths could be different depending on what Linux distro you use)

  • Vulkan Header Files
    sudo cp -r $VULKAN_SDK/include/vulkan/ /usr/local/include/

  • Vulkan Loader Files
    sudo cp -P $VULKAN_SDK/lib/libvulkan.so* /usr/local/lib/

  • Vulkan Layer Files
    sudo cp $VULKAN_SDK/lib/libVkLayer_*.so /usr/local/lib/
    sudo mkdir -p /usr/local/share/vulkan/explicit_layer.d
    sudo cp $VULKAN_SDK/etc/vulkan/explicit_layer.d/VkLayer_*.json /usr/local/share/vulkan/explicit_layer.d

You may need to run sudo ldconfig to refresh system loader search cache.
您可能需要运行 sudo ldconfig 来刷新系统加载程序搜索缓存。

1.6 Uninstalling the SDK

To uninstall the SDK simply remove your local installation directory. e.g.

rm -rf ~/vulkan/1.x.yy.z

1.7 Verify the SDK Installation

Verify the installation of the Vulkan SDK by running:

  • Vulkan Installation Analyzer (VIA) with the command:
yongqiang@yongqiang:~$ vkvia
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
VIA_INFO:    SDK Found! - Will attempt to run tests
VIA_INFO:       Attempting to run ./vkcube in /home/yongqiang/vulkan/1.3.239.0/x86_64/bin
VIA_INFO:           Command-line: ./vkcube --c 100 --suppress_popups
Selected GPU 0: llvmpipe (LLVM 12.0.0, 256 bits), type: Cpu
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
VIA_INFO:           Command-line: ./vkcube --c 100 --suppress_popups --validate
WARNING : GENERAL - Message Id Number: 0 | Message Id Name: Loader Messageloader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_radeon.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)Objects - 1Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 0x555c1ff71300WARNING : GENERAL - Message Id Number: 0 | Message Id Name: Loader Messageloader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so supports Vulkan 1.1, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)Objects - 1Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 0x555c1ff71300WARNING : GENERAL - Message Id Number: 0 | Message Id Name: Loader Messageloader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_intel.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)Objects - 1Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 0x555c1ff71300Selected GPU 0: llvmpipe (LLVM 12.0.0, 256 bits), type: Cpu
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
SUCCESS: Vulkan analysis completed properly using Vulkan 1.1
yongqiang@yongqiang:~$
  • Vulkan Info with the command:
yongqiang@yongqiang:~$ vulkaninfo
WARNING: [Loader Message] Code 0 : loader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_radeon.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)
WARNING: [Loader Message] Code 0 : loader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so supports Vulkan 1.1, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)
WARNING: [Loader Message] Code 0 : loader_scanned_icd_add: Driver /usr/lib/x86_64-linux-gnu/libvulkan_intel.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)
WARNING: [Loader Message] Code 0 : Layer VK_LAYER_MESA_device_select uses API version 1.2 which is older than the application specified API version of 1.3. May cause issues.
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
==========
VULKANINFO
==========Vulkan Instance Version: 1.3.239Instance Extensions: count = 20
...
  • Vulkan Cube with the command:
yongqiang@yongqiang:~$ vkcube
Selected GPU 0: llvmpipe (LLVM 12.0.0, 256 bits), type: Cpu
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
yongqiang@yongqiang:~$

在这里插入图片描述

2. Graphics Library Framework (GLFW)

https://www.glfw.org/

GLFW (Graphics Library Framework) is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contexts and surfaces, receiving input and events.
GLFW (Graphics Library Framework) 是一个开源轻量级工具程序库。GLFW 的主要功能是创建并管理窗口和上下文,同时还提供了处理手柄、键盘、鼠标输入的功能。

GLFW is written in C and supports Windows, macOS, X11 and Wayland.

GLFW is licensed under the zlib/libpng license.

Vulkan by itself is a platform agnostic API and does not include tools for creating a window to display the rendered results. To benefit from the cross-platform advantages of Vulkan and to avoid the horrors of Win32, we’ll use the GLFW library to create a window, which supports Windows, Linux and MacOS. There are other libraries available for this purpose, like SDL, but the advantage of GLFW is that it also abstracts away some of the other platform-specific things in Vulkan besides just window creation.
Vulkan 是一个平台无关的 API,不包含用于创建窗口以显示渲染结果的工具。为了跨平台和避免陷入 Win32 细节中去,我们将使用 GLFW 库创建窗口,它支持 Windows、Linux 和 MacOS。有其他库可完成类似功能,如 SDL,但 GLFW 的优势在于,除了窗口创建之外,它还抽象出 Vulkan 中其他一些特定于平台的内容。

2.1 安装 GLFW

https://www.glfw.org/download.html

The current version is 3.3.8, which was released on July 22, 2022.

  • Source package

This package contains the complete source code with CMake build files, documentation, examples and test programs. It is the recommended download for all platforms and offers the most control.

The master branch is our integration branch for the next feature release while the 3.3-stable branch only adds bug fixes for patch releases.

  • Windows pre-compiled binaries

These packages contain the GLFW header files, documentation and release mode static libraries, DLLs and import libraries for Visual C++ 2010-2019 and the 2022 preview, MinGW-w64 and plain MinGW.

Binaries for Visual C++ 2010 and plain MinGW are only available in the 32-bit package.

  • macOS pre-compiled binaries

This package contains the GLFW header files, documentation and release mode static and dynamic libraries for macOS 10.8 and later. Both Intel, ARM and Universal binaries are included.

  • Linux and BSD binaries

Check if your package system provides GLFW 3.3.8 or another version new enough to be useful to you.

If not, please download and compile GLFW from source. A source package is available above, or you could clone it from GitHub.
https://github.com/glfw/glfw
https://www.glfw.org/docs/latest/compile.html

We’ll be installing GLFW from the following command:

sudo apt install libglfw3-dev

3. OpenGL Mathematics (GLM)

https://github.com/g-truc/glm

在这里插入图片描述

OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.

GLM provides classes and functions designed and implemented with the same naming conventions and functionality than GLSL so that anyone who knows GLSL, can use GLM as well in C++.

Unlike DirectX 12, Vulkan does not include a library for linear algebra operations, so we’ll have to download one. GLM is a nice library that is designed for use with graphics APIs and is also commonly used with OpenGL.
与 DirectX 12 不同,Vulkan 不包含用于线性代数运算的库,因此我们必须下载一个。GLM 是一个很好的库,专为与图形 API 一起使用而设计,也常与 OpenGL 一起使用。

GLM is a header-only library.
GLM 是一个只有头文件的库。

3.1 安装 GLM

https://github.com/g-truc/glm/releases

GLM is written in C++98 but can take advantage of C++11 when supported by the compiler.

It is a header-only library that can be installed from the libglm-dev or glm-devel package:

sudo apt install libglm-dev

4. Shader Compiler

We have just about all we need, except we’ll want a program to compile shaders from the human-readable GLSL to bytecode.

Two popular shader compilers are Khronos Group’s glslangValidator and Google’s glslc. The latter has a familiar GCC- and Clang-like usage, so we’ll go with that: on Ubuntu, download Google’s unofficial binaries and copy glslc to your /usr/local/bin. Note you may need to sudo depending on your permissions.

To test, run glslc and it should rightfully complain we didn’t pass any shaders to compile:

yongqiang@yongqiang:~$ glslc
glslc: error: no input files
yongqiang@yongqiang:~$

shaderc/downloads.md
https://github.com/google/shaderc/blob/main/downloads.md

Debug - Linux - gcc:

yongqiang@yongqiang:~/vulkan$ ls install*
install.tgz
yongqiang@yongqiang:~/vulkan$
yongqiang@yongqiang:~/vulkan$ chmod a+x install.tgz
yongqiang@yongqiang:~/vulkan$
yongqiang@yongqiang:~/vulkan$ tar -xzvf install.tgz
...
yongqiang@yongqiang:~/vulkan$ ls install*
install.tgzinstall:
bin  include  lib  share
yongqiang@yongqiang:~/vulkan$
yongqiang@yongqiang:~/vulkan/install/bin$ pwd
/home/yongqiang/vulkan/install/bin
yongqiang@yongqiang:~/vulkan/install/bin$
yongqiang@yongqiang:~/vulkan/install/bin$ sudo cp ./glslc /usr/local/bin/
[sudo] password for yongqiang:
yongqiang@yongqiang:~/vulkan/install/bin$

5. Setting up a makefile project

Create a new directory at a convenient location with a name like VulkanTest. Create a source file called main.cpp and insert the following code.

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>#include <iostream>int main() {glfwInit();glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);GLFWwindow* window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);uint32_t extensionCount = 0;vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);std::cout << extensionCount << " extensions supported\n";glm::mat4 matrix;glm::vec4 vec;auto test = matrix * vec;while(!glfwWindowShouldClose(window)) {glfwPollEvents();}glfwDestroyWindow(window);glfwTerminate();return 0;
}

Create a new empty file called Makefile.

CFLAGS 变量来指定编译选项。
We’ll first define a couple of variables to simplify the remainder of the file. Define a CFLAGS variable that will specify the basic compiler flags:

CFLAGS = -std=c++17 -O2

We’re going to use modern C++ (-std=c++17), and we’ll set optimization level to -O2. We can remove -O2 to compile programs faster, but we should remember to place it back for release builds.

LDFLAGS 变量来指定链接选项。
Similarly, define the linker flags in a LDFLAGS variable:

LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi

The flag -lglfw is for GLFW, -lvulkan links with the Vulkan function loader and the remaining flags are low-level system libraries that GLFW needs. The remaining flags are dependencies of GLFW itself: the threading and window management.

It is possible that the Xxf68vm and Xi libraries are not yet installed on your system.
安装 Xxf68vm and Xi libraries:

sudo apt install libxxf86vm-dev libxi-dev
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ make test
g++ -std=c++17 -O2 -o VulkanTest main.cpp -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
/usr/bin/ld: cannot find -lXxf86vm
/usr/bin/ld: cannot find -lXi
collect2: error: ld returned 1 exit status
make: *** [Makefile:5: VulkanTest] Error 1
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ sudo apt install libxxf86vm-dev libxi-dev
[sudo] password for yongqiang:
Reading package lists... Done
...
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$

Specifying the rule to compile VulkanTest is straightforward now. Make sure to use tabs for indentation instead of spaces.

VulkanTest: main.cppg++ $(CFLAGS) -o VulkanTest main.cpp $(LDFLAGS)

Verify that this rule works by saving the makefile and running make in the directory with main.cpp and Makefile. This should result in a VulkanTest executable.

We’ll now define two more rules, test and clean, where the former will run the executable and the latter will remove a built executable:

.PHONY: test cleantest: VulkanTest./VulkanTestclean:rm -f VulkanTest

Running make test should show the program running successfully, and displaying the number of Vulkan extensions. The application should exit with the success return code (0) when you close the empty window. You should now have a complete makefile that resembles the following:

CFLAGS = -std=c++17 -O2
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXiVulkanTest: main.cppg++ $(CFLAGS) -o VulkanTest main.cpp $(LDFLAGS).PHONY: test cleantest: VulkanTest./VulkanTestclean:rm -f VulkanTest

You can now use this directory as a template for your Vulkan projects. Make a copy, rename it to something like HelloTriangle and remove all of the code in main.cpp.

yongqiang@yongqiang:~$ mkdir vulkan_workspace
yongqiang@yongqiang:~$ cd vulkan_workspace/
yongqiang@yongqiang:~/vulkan_workspace$ mkdir vulkan_basic_test
yongqiang@yongqiang:~/vulkan_workspace$ cd vulkan_basic_test/
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ touch main.cpp
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ vim main.cpp
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ touch Makefile
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ vim Makefile
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ make clean
rm -f VulkanTest
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$ make test
g++ -std=c++17 -O2 -o VulkanTest main.cpp -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
./VulkanTest
20 extensions supported
yongqiang@yongqiang:~/vulkan_workspace/vulkan_basic_test$

在这里插入图片描述

The number of extensions should be non-zero.

6. Terminology

DXC: Microsoft’s Open Source DirectX Shader Compiler
Installable Client Driver (ICD): A Vulkan compatible display driver (Vulkan 兼容的显示驱动程序)
OpenGL Shading Language (GLSL)
DirectX High-Level Shading Language (HLSL)
SPIR-V: Standard Portable Intermediate Representation is a cross-API intermediate language (IL) that natively represents parallel compute and graphics programs
VMA: The Vulkan Memory Allocator library provided by AMD.
Vulkan Instance: The Vulkan API object that stores all per-application states
Vulkan Layer: A library designed to work as a plug-in for the loader. It usually serves to provide validation and debugging functionality to applications
Vulkan Loader: A library which implements the Vulkan API entry points and manages layers, extensions, and drivers. It is found in the independent hardware vendor driver installs

References

https://yongqiang.blog.csdn.net/
Vulkan Tutorial https://vulkan-tutorial.com/
Vulkan 教程 https://geek-docs.com/vulkan/vulkan-tutorial/vulkan-tutorial-index.html
https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html

相关文章:

在 Windows Subsystem for Linux (WSL2) 的 Ubuntu 系统上配置 Vulkan 开发环境

在 Windows Subsystem for Linux (WSL2) 的 Ubuntu 系统上配置 Vulkan 开发环境Vulkan Tutorial https://vulkan-tutorial.com/ Development environment - Linux https://vulkan-tutorial.com/Development_environment 1. Vulkan - Cross platform 3D Graphics https://www…...

放苹果HJ61

入门题目 把m个同样的苹果放在n个同样的盘子里&#xff0c;允许有的盘子空着不放&#xff0c;问共有多少种不同的分法&#xff1f;注意&#xff1a;如果有7个苹果和3个盘子&#xff0c;&#xff08;5&#xff0c;1&#xff0c;1&#xff09;和&#xff08;1&#xff0c;5&#…...

Windows下,OPC UA移植,open62541移植

OPC通信标准的核心是互通性 (Interoperability) 和标准化 (Standardization) 问题。传统的OPC技术在控制级别很好地解决了硬件设备间的互通性问题,在企业层面的通信标准化是同样需要的。OPC UA之前的访问规范都是基于微软的COM/DCOM技术, 这会给新增层面的通信带来不可根除的…...

【Tomcat与Servlet篇1】认识Tomcat与Maven

目录 一、什么是Tomcat 二、Tomcat的几个重要目录 conf文件​编辑 Server.xml logs文件 Webapps目录 三、如何使用Tomcat 但是&#xff0c;如果出现了点击之后进行闪退的情况&#xff0c;那又是怎么回事呢&#xff1f; 原因1&#xff1a;环境变量没有配置 原因2&#…...

C++类和对象:拷贝构造函数和运算符重载

目录 一. 拷贝构造函数 1.1 什么是拷贝构造函数 1.2 编译器默认生成的拷贝构造函数 1.3 拷贝构造函数特性总结 二. 运算符重载 2.1 运算符重载概述 2.2 比较运算符重载&#xff08;> > < <&#xff09; 2.2.1 >运算符的重载 2.2.2 运算符的重载 2.…...

【IntelliJ IDEA】idea plugins搜索不出来,如何找到插件的解决方案

一、背景描述安装好IDEA后&#xff0c;想下载一些插件来使用&#xff0c;因为IDEA非常方便的一点就是插件使用非常的方便&#xff0c;但是经常会发现进入到插件市场无法搜索到插件的情况&#xff0c;这个时候就有点烦人了。那么怎么解决这个问题呢&#xff1f;以下会把我能想到…...

移动端自动化测试(一)appium环境搭建

自动化测试有主要有两个分类&#xff0c;接口自动化和ui自动化&#xff0c;ui自动化呢又分移动端的和web端的&#xff0c;当然还有c/s架构的&#xff0c;这种桌面程序应用的自动化&#xff0c;使用QTP&#xff0c;只不过现在没人做了。 web自动化呢&#xff0c;现在基本上都是…...

5 逻辑回归及Python实现

1 主要思想 分类就是分割数据&#xff1a; 两个条件属性&#xff1a;直线&#xff1b;三个条件属性&#xff1a;平面&#xff1b;更多条件属性&#xff1a;超平面。 使用数据&#xff1a; 5.1,3.5,0 4.9,3,0 4.7,3.2,0 4.6,3.1,0 5,3.6,0 5.4,3.9,0 . . . 6.2,2.9,1 5.1,2.5…...

技术干货 | Modelica建模秘籍之状态变量

在很多领域都有“系统”这个概念&#xff0c;它描述的往往是一些复杂关系的总和。假如我们将系统看做一个黑箱&#xff0c;那么&#xff0c;在系统的作用下&#xff0c;外界的输入有时会产生令人意想不到的输出&#xff0c;“蝴蝶效应”就是其中的典型案例。图1 一只南美洲亚马…...

LeetCode 2574. 左右元素和的差值

给你一个下标从 0 开始的整数数组 nums &#xff0c;请你找出一个下标从 0 开始的整数数组 answer &#xff0c;其中&#xff1a; answer.length nums.length answer[i] |leftSum[i] - rightSum[i]| 其中&#xff1a; leftSum[i] 是数组 nums 中下标 i 左侧元素之和。如果不…...

rollup环境配置

VUE2.x源码学习笔记 1. rollup环境配置 首先在VScode中新建文件夹vue_sc&#xff0c;然后终端打开定位到打开的文件夹&#xff0c;输入“npm init -y”初始化配置项&#xff0c;运行成功之后文件夹新增package.json文件 继续在终端运行"npm install babel/preset-env ba…...

二分查找与二分答案、递推与递归、双指针、并查集和单调队列

二分查找与二分答案 文章目录二分查找与二分答案应用总结例题木材加工题目背景题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示数据规模与约定思路代码递归与递推应用总结[NOIP2003 普及组] 栈题目背景题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示思…...

如何进行域名购买,获取免费ssl证书,使用springboot绑定ssl证书

前言 小编我将用CSDN记录软件开发求学之路上亲身所得与所学的心得与知识&#xff0c;有兴趣的小伙伴可以关注一下&#xff01;也许一个人独行&#xff0c;可以走的很快&#xff0c;但是一群人结伴而行&#xff0c;才能走的更远&#xff01;让我们在成长的道路上互相学习&#…...

LabVIEW网络服务安全2

LabVIEW网络服务安全2在客户端应用程序中创建签名对请求进行签名要求您具有能够从客户端的编程语言调用的MD5摘要算法以及SHA256加密摘要算法的实现。这两种算法通常都可用于大多数平台。还需要&#xff1a;1. 要使用的HTTP方法的字符串&#xff08;“GET”、“POST”、“PUT”…...

java动态代理

目录儿一、代理模式的作用二、实现代理的方式三、动态代理的实现3.1 jdk动态代理3.2 cglib动态代理一、代理模式的作用 功能增强: 基于某个功能&#xff0c;再增加一些功能。 &#xff08;比如目标类只负责核心功能&#xff0c;其他附属功能通过代理类完成。代理类的方法名与目…...

Python 简单可变、复杂可变、简单不可变、复杂不可变类型的copy、deepcopy的行为

copy模块&#xff1a;copy&#xff1a;浅拷贝deepcopy&#xff1a;深拷贝简单可变类型、复杂可变的copy()、deepcopy()&#xff1a;简单不可变、复杂不可变类型的copy()、deepcopy()&#xff1a;结论&#xff1a;对于简单类型的可变类型copy是深拷贝&#xff0c;改变了该拷贝变…...

QML Item

在QML中所有的可视项目都继承自Item&#xff0c;虽然Item本身没有可视化的外观&#xff0c;但它定义了可视化项目的所有属性。 Item可以作为容器使用&#xff1a; Item{Rectangle{id:retc}Rectangle{id:retc1}Rectangle{id:retc2}Rectangle{id:retc3}} item拥有children属性…...

使用xca工具生成自签证书

本文使用 xca 生成自签证书。 概述 之前使用 openssl 生成证书&#xff0c;在 golang 中测试&#xff0c;发现客户端连接失败&#xff0c;经查发现是Subject Alternative Name不支持导致的。因虚拟机 openssl 版本较低&#xff0c;有个功能无法实现&#xff0c;且升级麻烦&…...

Unity IOS 通过命令行导出IPA

新建一个文件然后输入如下内容 #!/usr/bin/env sh /Applications/Unity/Hub/Editor/2020.1.5f1c1/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath /Users/zyt/Test -executeMethod Test.BuildEditor.BuildApp cd /Users/zyt/Test/Xcode/unity-xcode xcodebuil…...

「架构」全链路异步模式

总结自尼恩的全链路异步&#xff1a;网关纯异步化网关层的特点&#xff1a;不需要访问业务数据库只做协议转换和流量转发特点是 IO 密集型&#xff0c;特别适合纯异步的架构&#xff0c;可以极大的节省资源。如何进行网关异步化&#xff1f;使用高性能的通信框架Netty&#xff…...

CleanMyMac4.20最新版新增功能及电脑清理垃圾使用教程

CleanMyMac4.20作为知名的Mac清理工具&#xff0c;仅需一键即可快速而安全地清理系统垃圾&#xff0c;释放磁盘空间&#xff0c;因此一直深受Mac用户的喜爱。在不断更新的版本中&#xff0c;CleanMyMac已经不仅仅满足于只做简单的Mac清理工具&#xff0c;而是为Mac用户提供更多…...

Vue2的tsx开发入门完全指南

本篇文章尽量不遗漏重要环节&#xff0c;本着真正分享的心态&#xff0c;不做标题党 下面进入正题&#xff1a; 由于现在vue的官方脚手架已经非常完善我们就不单独配置webpack了&#xff0c;节省大量的时间成本。 首先使用vue/cli创建一个vue模版项目&#xff08;记得是vue/…...

GLSL shader学习系列1-Hello World

这是GLSL shader系列第一篇文章&#xff0c;本文学习目标&#xff1a; 安装编辑工具编写hello world程序 安装插件 我使用VSCode编写shader代码&#xff0c;在VSCode上有两个好用的插件需要先装一下&#xff1a; Shader languages support for VS Code glsl-canvas&#xf…...

Codeforces Round #851 (Div. 2)(A~D)

A. One and Two给出一个数组&#xff0c;该数组仅由1和2组成&#xff0c;问是否有最小的k使得k位置的前缀积和后缀积相等。思路&#xff1a;计算2个数的前缀和即可&#xff0c;遍历判断。AC Code&#xff1a;#include <bits/stdc.h>typedef long long ll; const int N 1…...

内存保护_1:Tricore芯片MPU模块介绍

上一篇 | 返回主目录 | 下一篇 内存保护_1&#xff1a;Tricore芯片MPU模块介绍1 何为MPU2 MPU相关的硬件子系统2.1 基于地址范围保护逻辑说明2.1.1 地址范围寄存器2.1.2 读、写、执行权限寄存器2.1.3 保护集设置位2.1.4 内存保护功能使能位2.1.5 核的内存保护范围获取说明2.1.6…...

Vue3 -- PDF展示、添加签名(带笔锋)、导出

文章目录笔锋签名方案一实现要点实现过程组件引用页面元素添加引用实现代码效果展示缺点方案二修改页面元素替换引用修改代码效果展示完整代码地址实现功能的时候采用了两个方案&#xff0c;主要是第一个方案最后的实现效果并不太理想&#xff0c;但实现起来比较简单&#xff0…...

行测-判断推理-图形推理-样式规律-属性规律-曲直性

左边的图全是由曲线构成的选C1 3 5全是由曲线构成的2 4 6全是由直线构成的第三行的图形有曲有直选A1 3 5有曲有直2 4 6全是直线选D图形有曲有直&#xff0c;排除B D外曲内直->内曲外直->外曲内直->内曲外直->外曲内直->内曲外直所以问号出的图形应该是内曲外直选…...

idea集成Alibaba Cloud Toolkit插件

idea集成Alibaba Cloud Toolkit插件 ​ 使用该插件主要是简化打包、上传、启动服务的相关操作。 ​ 很早之前的方式是使用开发工具&#xff08;eclipse,idea&#xff09;&#xff0c;使用maven命令完成项目打包&#xff08;这里指jar&#xff09;&#xff0c;然后通过shell工…...

Win11 文件夹打开慢或卡顿解决方案

问题 目前是 2023/2/27, 我的 Win11 系统点开一个文件夹要等待 2-3 秒才能加载出来, 使用体验极差。网上查阅大量资料, 有些人在系统更新后这个情况就消失了, 但是我这一直存在, 系统也是当前的最新版, 没有修复。 目前得出的结论是, 因为 Win11 的工具栏占用了过多的资源, 需…...

【PostgreSQL的idle in transaction连接状态】

在平时查询pg_stat_activity这个视图的时候&#xff0c;每一行包含了一个进程的相关信息&#xff0c;包含当前正在执行的SQL&#xff0c;或者会话的状态等等&#xff0c;state字段表示当前进程的状态。在PostgreSQL数据库里&#xff0c;其实代码里总共定义了7种BackendState&am…...

wordpress域名临时域名/网络公关

1、pom添加以下依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 之后更新maven 2、在application.properties中可以配置thymeleaf模板解析器属性 #t…...

wordpress internal/电脑优化设置

一个偶然的机缘&#xff0c;好像要做直播相关的项目 为了筹备&#xff0c;前期做一些只是储备&#xff0c;于是开始学习ffmpeg 这是学习的第一课 做一个简单的播放器&#xff0c;播放视频画面帧 思路是&#xff0c;将视频文件解码&#xff0c;得到帧&#xff0c;然后使用定时器…...

django做待办事项网站/百度智能云

1. typeof null object 不同的对象在底层都表示为二进制&#xff0c;在Javascript中二进制前三位都为0的话会被判断为Object类型&#xff0c;null的二进制表示全为0&#xff0c;自然前三位也是0&#xff0c;所以执行typeof时会返回"object"。 2. 数组的字符串键值如…...

网站怎么推广最/手机系统优化

心血来潮&#xff0c;昨天看见群里讨论一段图片转pdf的代码&#xff0c;直接拿过来发现不能用&#xff0c;原来是因为代码中传的文件对象不对&#xff0c;源码中说传递的是一个文件路径或一个文件对象。他传的是一个文件名&#xff0c;很是尴尬。 想了想&#xff0c;主要原因还…...

用typecho做的网站/平台运营推广

Hello,大家好&#xff0c;我是BoBo一个喜欢做公众号&#xff0c;但是做的又有点糙的非科班小编。这里没有华丽的排版&#xff0c;也没有长长的套路&#xff0c;有的只是一颗真心&#xff0c;喜欢公众号&#xff0c;分享汁源给大家&#xff0c;一起学习&#xff0c;共同进步。今…...

网站开发管理系统有哪些/东莞seo外包

2017年9月13日 17:12:20 星期三 gitbook 可以将markdown格式的文件编译成html格式 放在当前目录里的_book目录里(需要手动创建, 也可以指定编译后的html文件放到哪里) 它有几个文件需要注意: SUMMARY.md: 用markdown格式书写的目录 (常用 *, , - 开头表示无序列表) book.json: …...