About This Book

This book is about Vulkan. Vulkan is an application programming interface (API) for controlling devices such as graphics processing units (GPUs). Although Vulkan is a logical successor to OpenGL, it is quite different from OpenGL in form. One of the things that experienced practitioners will notice about Vulkan is that it is very verbose. You need to write a lot of application code to get Vulkan to do anything useful, let alone anything remarkable. Many of the things that an OpenGL driver would do are now the responsibility of the Vulkan application writer. These things include synchronization, scheduling, memory management, and so on. As such, you will find a good deal of this book dedicated to such topics, even though they are general topics applicable to more than just Vulkan.

The intended audience for this book is experienced programmers who are already familiar with other graphics and compute APIs. As such, many graphics-related topics are discussed without deep introduction, there are some forward references, and code samples are incomplete or illustrative in scope rather than being complete programs that you can type in. The sample code available from the book’s website is complete and tested, however, and should serve as a good reference to follow along with.

Vulkan is intended to be used as the interface between large, complex graphics and compute applications and graphics hardware. Many of the features and responsibilities previously assumed by drivers implementing APIs such as OpenGL now fall to the application. Complex game engines, large rendering packages, and commercial middleware are well-suited to this task; they have more information about their specific behavior than any driver could hope to have. Vulkan is not well-suited to simple test applications; neither is it a suitable aid for teaching graphics concepts.

In the first chapters of this book, we introduce Vulkan and some of the fundamental concepts that frame the API. As we progress through the Vulkan system, we cover more advanced topics, eventually producing a more complex rendering system that shows off some of the unique aspects of Vulkan and demonstrates its capabilities.

In Chapter 1, “Overview of Vulkan,” we provide a brief introduction to Vulkan and the concepts that form its foundation. We cover the basics of creating Vulkan objects and show the basics of getting started with the Vulkan system.

In Chapter 2, “Memory and Resources,” we introduce the memory system of Vulkan, perhaps the most fundamental part of the interface. We show how to allocate memory used by the Vulkan device and by Vulkan drivers and system components running inside your application.

In Chapter 3, “Queues and Commands,” we cover command buffers and introduce the queues to which they are submitted. We show how Vulkan processes work and how your application can build packets of commands to be sent to the device for execution.

In Chapter 4, “Moving Data,” we introduce our first few Vulkan commands, all of which are focused on moving data. We use the concepts first discussed in Chapter 3 to build command buffers that can copy and format data stored in the resources and memory introduced in Chapter 2.

In Chapter 5, “Presentation,” we show how to get images produced by your application onto the screen. Presentation is the term used for interacting with a window system, which is platform-specific, so this chapter delves into some platform-specific topics.

In Chapter 6, “Shaders and Pipelines,” we introduce SPIR-V, the binary shading language used by Vulkan. We also introduce the pipeline object; show how one is constructed using SPIR-V shaders; and then introduce compute pipelines, which can be used to do computation work with Vulkan.

In Chapter 7, “Graphics Pipelines,” we build upon what we covered in Chapter 6 and introduce the graphics pipeline, which includes all of the configuration necessary to render graphical primitives with Vulkan.

In Chapter 8, “Drawing,” we discuss the various drawing commands available in Vulkan, including indexed and nonindexed draws, instancing, and indirect commands. We show how to get data into the graphics pipeline and how to draw more complex geometries than were introduced in Chapter 7.

In Chapter 9, “Geometry Processing,” we dig deeper into the first half of the Vulkan graphics pipeline and take another look at the tessellation and geometry shader stages. We show some of the more advanced things that these stages can do and cover the pipeline up to the rasterization stage.

In Chapter 10, “Fragment Processing,” we pick up where Chapter 9 left off and cover everything that happens during and after rasterization in order to turn your geometry into a stream of pixels that can be displayed to the user.

In Chapter 11, “Synchronization,” we cover the various synchronization primitives available to the Vulkan application, including fences, events, and semaphores. Together, these form the foundation of any application that makes efficient use of the parallel nature of Vulkan.

In Chapter 12, “Getting Data Back,” we reverse the direction of communication used in previous chapters and discuss the issues involved in reading data from Vulkan into your application. We show how to time operations executed by a Vulkan device, how to gather statistics about the operation of Vulkan devices, and how to get data produced by Vulkan back into your application.

Finally, in Chapter 13, “Multipass Rendering,” we revisit a number of topics covered earlier, tying things together to produce a more advanced application—a deferred rendering application using complex multipass architecture and multiple queues for processing.

The appendix to this book contains a table of the command buffer building functions available to Vulkan applications, providing a quick reference to determine their attributes.

Vulkan is a large, complex, and new system. It is extremely difficult to cover every corner of the API in a book of this scope. The reader is encouraged to thoroughly read the Vulkan specification in addition to this book, as well as to read other books on using heterogeneous compute systems and computer graphics with other APIs. Such material will provide a good foundation in the mathematics and other concepts assumed by this book.

About the Sample Code

The sample code that accompanies this book is available from our website (http://www.vulkanprogrammingguide.com). One thing that seasoned users of other graphics APIs will notice is that Vulkan is very verbose. This is primarily because many of the responsibilities historically assumed by drivers have been delegated to your application. In many cases, however, simple boilerplate code will do the job just fine. Therefore, we have created a simple application framework that deals with much of the functionality that will be common to all samples and real-world applications. This does not mean that this book is a tutorial on how to use our framework. This is simply a practical matter of keeping code samples concise.

Of course, as we discuss specific Vulkan functionality throughout the book, we will include snippets of code, many of which may actually come from the book’s sample framework rather than from any particular example. Some features discussed in the book may not have examples in the code package. This is particularly true of some advanced features that are relevant primarily to large-scale applications. There is no such thing as a short, simple Vulkan example. In many cases, a single example program demonstrates the use of many features. The features that each example uses are listed in that example’s read-me file. Again, there is not a 1:1 correspondence between examples and listings in this book and specific examples in the sample code. It shall be assumed that anyone that files a bug asking for a 1:1 list of which samples go with which chapter has not read this paragraph. Such bugs will be summarily closed, quoting this very sentence.

The sample code is designed to link against the latest official Vulkan SDK from LunarG, which is available from http://lunarg.com/vulkan-sdk/. At the time of writing, the latest SDK version is 1.0.22. Newer versions of the SDK are designed to be backward-compatible with older versions, so we recommend that users obtain the latest available version of the SDK before attempting to compile and run the sample applications. The SDK also comes with some samples of its own, and we suggest running those to verify that the SDK and drivers are installed correctly.

In addition to the Vulkan SDK, you will need a working installation of CMake in order to create the build environment for the samples. You will also need an up-to-date compiler. The code samples make use of several C++11 features and rely heavily on the C++ standard libraries for things like threading and synchronization primitives. These features are known to be problematic in early versions of various compiler runtimes, so please make sure that your compilers are up to date. We have tested with Microsoft Visual Studio 2015 on Windows and with GCC 5.3 on Linux. The samples have been tested on 64-bit Windows 7, Windows 10, and Ubuntu 16.10 with recent drivers from AMD, Intel, and NVIDIA.

It should be noted that Vulkan is a cross-platform, cross-vendor, and cross-device system. Many of these samples should work on Android and other mobile platforms. We hope to port the samples to as many of these platforms as possible in the future and would very much appreciate help and contributions from you, the reader.

Errata

Vulkan is a new technology. At the time of writing, the specification has been available for only a matter of weeks. Although the author and contributor had a hand in creating the Vulkan specification, it’s large and complex and had many contributors. Some of the code in the book is not fully tested, and although it is believed to be correct, it may contain errors. As we were putting the samples together, available Vulkan implementations still had bugs, the validation layers didn’t catch as many errors as they could, and the specification itself had gaps and unclear sections. Like the readers, we are still learning Vulkan, so although this text was edited for technical accuracy, we depend on readers to view any updates by visiting this book’s website:

http://www.vulkanprogrammingguide.com

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.195.112