CSharpGL (56) [translated] Vulkan entry (rpm)

CSharpGL (56) [translated] Getting Vulkan

This article is ( http://ogldev.atspace.co.uk/www/tutorial50/tutorial50.html translation) as an attempt to learn Vulkan.

Do not translate words, each time looking at the first sentence, it would not finish the school. 

Background Background

You've probably heard by now quite a bit about Vulkan, the new Graphics API from Khronos (the non profit organization responsible for the development of OpenGL).

You may have heard Vulkan, new graphics API Khronos created. Khronos OpenGL is responsible for the development of non-profit organizations.

Vulkan was announced in Feb-2016 and after 24 years with OpenGL it is a completely new standard and a departure from the current model.

OpenGL appeared after 24 years, Vulkan in February 2016 was released. It abandoned the current model, which is the new standard.

I won't go into many details about the various features of Vulkan only to say that in comparison to OpenGL it is much more low level and provides a lot of power and performance opportunities for the developer.

I will not throw up on the details of a bunch of new features. In simple terms, compared to OpenGL, Vulkan underlying much energy offers great opportunities for developers and enhance performance.

But with great power comes great responsibility.

But great power comes great responsibility.

The developer has to take charge of various aspects such as command buffer, synchronization and memory management that were previously the sole responsibility of the driver.

Developers must be responsible for various aspects, such as the command cache, synchronization, memory management, which before were the responsibility of driving.

Through the unique knowledge that the developer has about the way the application is structured, the usage of the Vulkan API can be tailored in a way to increase the overall performance of the system.

Knowledge-based developer of the application structure, he can adjust the use of Vulkan API, and higher system performance.

 

The thing that surprises people the most, IMHO, about Vulkan is the amount of code that must be written only to get the first triangle on the screen.

The most surprising, IMHO, is a huge amount of code required for the first triangle on the screen.

Comparing this to the few lines we had to write in OpenGL in the first few tutorials this is a major change and becomes a challenge when one tries to write a tutorial about it.

Compared to the initial tutorial we write a few lines of code OpenGL, which is a big change, but also the difficulty of writing Vulkan tutorial.

Therefore, as always with OGLDEV, I'll try to present the material step by step.

So, like OGLDEV usual, I will unfold step by step tutorial.

We will develop our first triangle demo in a few tutorials, making additional progress in each one.

We will complete the first example of a triangle in multiple tutorial, a little bit of progress in each tutorial.

In addition, instead of laying out the dozens of APIs in one long piece of code I'll present a simple software design that I hope will make it simpler for you to understand without imposing too much restrictions on your future apps.

Also, I do not show a large section of API, but to show there is a software design ideas. I hope that this will facilitate the reader's understanding.

Consider this an educational design which you are free to throw away later.

The design for the purpose of teaching, and so you learn, you can throw away.

 

We will study the core components of Vulkan one by one as we make progress through the code so at this point I just want to present a diagram of the general picture:

With the codes, one by one we will learn Vulkan core components. Now we look at the overview:

 

 

This diagram is by all means not a complete representation.

Of course, this figure does not show all the components.

It includes only the major components that will probably be present in most applications.

It only contains the main components will be used in most applications.

The connectors between the objects represent the dependencies between them at creation or enumeration time.

对象之间的连线表示在创建或枚举时的依赖关系。

For example, in order to create a surface you need an instance object and when you enumerate the physical devices on your system you also need an instance.

例如,为了创建一个surface,你需要一个instance对象;当你枚举你系统上的物理设备时,你也需要一个instance对象。

The two colors roughly describe the software design that we will use.

两种颜色粗略地描述了我们将使用的软件设计方案。

The dark red objects will go into something I call the "core" and the light green objects will go into the "app".

暗红色对象将属于“core”,浅绿色对象将属于“app”。

We will later see why this makes sense.

我们稍后再看为什么是这样。

The application code that you will write will actually inherit from "app" and all of its members will be available for you for further use.

应用程序代码将继承自app,app的所有成员以后都将可用。

I hope this design will provide a solid base to develop future Vulkan tutorials.

我希望这样的设计能提供一个坚实的基础,用于开发将来的Vulkan教程。

 

System Setup 系统安装

The first thing we need to do is to make sure your system supports Vulkan and get everything ready for development.

我们要做的第一件事,是确保你的系统支持Vulkan,准备好开发所需的一切。

You need to verify that your graphics card supports Vulkan and install the latest drivers for it.

你需要验证你的图形卡是否支持Vulkan,并安装最新的驱动程序。

Since Vulkan is still new it's best to check for drivers updates often because hardware vendors will probably fix a lot of bugs before everything stabilizes.

由于Vulkan还很新,最好经常检查驱动更新,因为硬件厂商可能会在驱动稳定前修复很多bug。

Since there are many GPUs available I can't provide much help here.

由于有太多种GPU,我这里爱莫能助。

Updating/installing the driver on Windows should be fairly simple.

在Windows上更新/安装驱动应该相当简单。

On Linux the process may be a bit more involved.

在Linux上,就有点难缠。

My main development system is Linux Fedora and I have a GT710 card by NVIDIA.

我的开发系统是Linux的Fedora版本,显卡是NVIDIA的GT710。

NVIDIA provide a binary run file which can only be installed from the command line.

NVIDIA提供一个二进制运行文件,只能从命令行安装。

Other vendors have their own processes.

其他厂商有各自的方式。

On Linux you can use the 'lspci' to scan your system for devices and see what GPU you have.

在Linux上你可以用'lspci'命令扫描你的系统,看看有哪些设备,用的什么GPU。

You can use the '-v', '-vv' and '-vvv' options to get increasingly more info on your devices.

你可以用'-v'、'-vv'、'-vvv'来得到你的设备的越来越详细的信息。

 

The second thing we need is the Vulkan SDK by Khronos, available here.

第二件事,我们需要Khronos的Vulkan SDK,可在此下载。

The SDK includes the headers and libraries we need as well as many samples that you can use to get more info beyond what this tutorial provides.

SDK包含头文件和库文件,很多示例,比本教程多得多的信息。

At the time of writing this the latest version is 1.0.30.0 and I urge you to update often because the SDK is in active development.

写作本文时最新版本是1.0.30.0,我推荐读者时常更新,因为SDK还处于活跃地开发中。

That version number will be used throughout the next few sections so make sure you change it according to the version you have.

接下来的章节都将使用这个版本号,所以,根据你的版本号,相应地替换之。

 

Linux

Khronos provides a package only for Ubuntu in the form of an executable run file.

Khronos只给Ubuntu提供了一个可执行文件。

Executing this file should install everything for you but on Fedora I encoutered some difficulties so I used the following procedure (which is also forward looking in terms of writing the code later):

执行这个文件就可以安装所需的一切。但是在Fedora上我遇到了一些困难,所以我用下述步骤(也是预览一下代码):

  • bash$ chmod +x vulkansdk-linux-x86_64-1.0.30.0.run
  • base$ ./vulkansdk-linux-x86_64-1.0.30.0.run --target VulkanSDK-1.0.30.0 --noexec
  • base$ ln -s ~/VulkanSDK-1.0.30/1.0.30.0 ~/VulkanSDK

The above commands extract the contents of the package without running its internal scripts.

上述命令提取出包的内容,并执行里面的脚本。

After extraction the directory VulkanSDK-1.0.30.0 will contain a directory called 1.0.30.0 where the actual content of the package will be located.

提取完成后,文件夹VulkanSDK-1.0.30.0会包含一个子文件夹1.0.30.0,里面是实际的内容。

Let's assume I ran the above commands in my home directory (a.k.a in bash as '~') so we should end up with a '~/VulkanSDK' symbolic link to the directory with the actual content (directories such as 'source', 'samples', etc).

假定我是在home文件夹下运行的上述命令(即'~'),那么会有一个'~/VulkanSDK'符号链接到实际内容(文件夹'source'、'samples'等)。

This link makes it easier to switch your development environment to newer versions of the SDK.

这个链接使得切换到SDK的新版本更容易。

It points to the location of the headers and libraries that we need.

它指向我们需要的头文件和库文件的位置。

We will see later how to connect them to the rest of the system. Now do the following:

稍后我们将看到如何将它们连接到系统的其他部分。现在执行下述命令:

  • bash$ cd VulkanSDK/1.0.30.0
  • bash$ ./build_examples.sh

If everything went well the examples were built into 'examples/build'.

如果一切顺利,示例会出现在文件夹'examples/build'

To run the examples you must first cd into that directory.

为运行示例,你首先要进入这个文件夹。

You can now run './cube' and './vulkaninfo' to make sure Vulkan runs on your system and get some useful information on the driver.

你现在可以运行'./cube'和'./vulkaninfo'命令来确认Vulkan跑在你的系统上了,还可以得到一些驱动的有用信息。

Hopefully everything is OK so far so we want to create some symbolic links that will make the files we need for development easily accessible from our working environment.

单元一切顺利,目前我们想创建一些符号链接,方便我们使用开发过程中会用到的文件。

Change to the root user (by executing 'su' and entering the root password) and execute the following:

跳到root用户(执行'su'命令,输入root密码),执行下述命令:

  • bash# ln -s /home/<your username>/VulkanSDK/x86_x64/include/vulkan /usr/include
  • base# ln -s /home/<your username>/VulkanSDK/x86_x64/lib/libvulkan.so.1 /usr/lib64
  • base# ln -s /usr/lib64/libvulkan.so.1 /usr/lib64/libvulkan.so

What we did in the above three commands is to create a symbolic link from /usr/include to the vulkan header directory.

上述3个命令,创建了一个从/usr/include到Vulkan头文件夹的符号链接。

We also created a couple of symbolic links to the shared object files against which we are going to link our executables.

我们还创建了一些共享对象的符号链接,今后会将我们的程序链接到这些共享对象。

Guess you like

Origin www.cnblogs.com/strugglerisnd/p/10992498.html
#56
rpm