CSharpGL(56)[译]Vulkan入门(转)

阅读目录(Content)

CSharpGL(56)[译]Vulkan入门

本文是对(http://ogldev.atspace.co.uk/www/tutorial50/tutorial50.html)的翻译,作为学习Vulkan的一次尝试。

不翻译的话,每次都在看第一句,那就学不完了。

回到顶部(go to top)

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).

你可能听过Vulkan,Khronos创建的新的图形API。Khronos是负责开发OpenGL的非盈利组织。

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出现24年后,Vulkan于2016年2月被发布。它放弃了当前的模型,它是全新的标准。

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.

我不会上来就抛出一堆新的特性的细节。简单来说,相比OpenGL,Vulkan底层得多,给开发者提供了巨大的能量和提升性能的机会。

But with 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.

开发者必须负责各种方面,例如命令缓存、同步、内存管理,这些之前都是驱动的责任。

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.

基于开发者对应用程序结构的知识,他可以调整Vulkan API的用法,获得更高的系统性能。

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.

最让人吃惊的,恕我直言,是在屏幕上显示第一个三角形所需的巨大代码量。

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.

相比在最初的教程中我们写的那几行OpenGL代码,这是很大的改变,也是写Vulkan教程的难点。

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

因此,像OGLDEV往常一样,我将一步一步地展开本教程。

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

我们将在多个教程中完成第一个三角形示例,在每个教程中进展一点点。

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.

另外,我不展示一大段API,而是展示有设计思路的软件。我希望这能便于读者理解。

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

这个设计以教学为目的,等你学会了,就可以扔掉了。

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:

随着代码,我们将一个个地学习Vulkan核心组件。现在我们先看一下概览图:

This diagram is by all means not a complete representation.

当然这个图并没有展示所有的组件。

It includes only the major components that will probably be present 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教程。

回到顶部(go to top)

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.

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

原文地址:https://www.cnblogs.com/strugglerisnd/p/10992498.html

时间: 2024-11-02 11:08:07

CSharpGL(56)[译]Vulkan入门(转)的相关文章

CSharpGL(56)[译]Vulkan入门

本文是对(http://ogldev.atspace.co.uk/www/tutorial50/tutorial50.html)的翻译,作为学习Vulkan的一次尝试. 不翻译的话,每次都在看第一句,那就学不完了. Background 背景 You've probably heard by now quite a bit about Vulkan, the new Graphics API from Khronos (the non profit organization responsibl

CSharpGL(57)[译]Vulkan清空屏幕

本文是对(http://ogldev.atspace.co.uk/www/tutorial51/tutorial51.html)的翻译,作为学习Vulkan的一次尝试. 不翻译的话,每次都在看第一句,那就学不完了. Background 背景 +BIT祝威+悄悄在此留下版了个权的信息说: Welcome back. I hope that you've been able to complete the previous tutorial successfully and you are now

[译]Vulkan教程(03)开发环境

这是我翻译(https://vulkan-tutorial.com)上的Vulkan教程的第3篇. In this chapter we'll set up your environment for developing Vulkan applications and install some useful libraries. All of the tools we'll use, with the exception of the compiler, are compatible with

[译]Vulkan教程(08)逻辑设备和队列

Introduction 入门 After selecting a physical device to use we need to set up a logical device to interface with it. The logical device creation process is similar to the instance creation process and describes the features we want to use. We also need

[译]Vulkan教程(20)重建交换链

Swap chain recreation 重建交换链 Introduction 入门 The application we have now successfully draws a triangle, but there are some circumstances that it isn't handling properly yet. It is possible for the window surface to change such that the swap chain is n

[译]Vulkan教程(21)顶点input描述

Vertex input description 顶点input描述 Introduction 入门 In the next few chapters, we're going to replace the hardcoded vertex data in the vertex shader with a vertex buffer in memory. We'll start with the easiest approach of creating a CPU visible buffer

[译]zookpeer 入门教程

入门:分布式应用程序协调服务 ZooKeeper 本文档包含的信息来帮助你的ZooKeeper快速入门.它是在开发人员希望能够尝试一下主要目的,并包含安装简单说明一个ZooKeeper的服 务器,几个命令,以验证它是否正在运行,一个简单的编程示例.最后,为了方便,还有更多的关于安装复杂,几节,例如运行复制的部署和优化事务日志.然而, 对于商业部署的完整说明,请参阅的ZooKeeper管理员指南. 先决条件 见管理员指南中的系统要求. 下载 从Apache下载镜像下载最近的稳定版本 ,从而得到 Z

CSharpGL(31)[译]OpenGL渲染管道那些事

+BIT祝威+悄悄在此留下版了个权的信息说: 开始 自认为对OpenGL的掌握到了一个小瓶颈,现在回头细细地捋一遍OpenGL渲染管道应当是一个不错的突破口. 本文通过阅读.翻译和扩展(https://www.opengl.org/wiki/Rendering_Pipeline_Overview)的方式,来逐步回顾总结一下OpenGL渲染管道,从而串联起OpenGL的所有知识点,并期望能在更高的层次上有所领悟. 另外,(https://www.opengl.org/wiki/Rendering_

[译] React 入门指南

原文链接:The React Quick Start Guide 这篇文章将概括性的介绍一下如何用 ReactJS 进行开发.我将介绍一些基础知识,不会有过于深入的分析.你可以结合这些代码阅读本文.更新:本文已经由 Hugo Bessa 翻译了葡萄牙语版. 一些概念 React 的 API 非常少,简单易懂易用.在正式开始之前先介绍几个概念,一个一个来. React 元素 是表现为 HTML 元素的 JavaScript 对象,他们并不真实存在于浏览器中.他们最终表现为类似h1, div 或 s