Vulkan Cookbook 第四章 资源和内存

在本章中我们将介绍以下内容:

创建缓冲区
为缓冲区分配和绑定内存对象
设置缓冲区内存屏障
创建缓冲区视图
创建图像
分配内存对象和将其绑定到图像
设置图像内存屏障
创建图像视图
创建2D图像和视图
使用立方体图像视图创建分层2D图像
映射、更新和取消映射主机可见内存
在缓冲区之间复制数据
将数据从缓冲区复制到图像
将数据从图像复制到缓冲区
使用暂存缓冲区更新设备本地内存绑定的缓冲区
使用暂存缓冲区更新设备本地内存绑定的图像
销毁图像视图
摧毁图像销毁缓冲区视图
释放内存对象
销毁缓冲区

介绍

在Vlukan中有两种非常重要的资源类型可以储存数据--缓冲区和图像。缓冲区代表线形数据数组。与OpenGL的纹理类似,图像表示一种(通常)特定于给定硬件(所以我们不知道哪部内存结构)的方式组织的一、二、或三维数据。缓冲区和图像可用于各种目的:在着色器中,我们可以从中读取或采样数据,或者将数据储存在其中。图像可以用作颜色或深度/模版附件(渲染目标),这意味着我们可以渲染它们。缓冲区还可以储存间接绘制期间使用的顶点属性、索引或参数。
非常重要的是,在资源创建期间必须指定每个提到的用法(我们可以同时提供其中的许多用法)。当我们改变应用程序中使用给定资源的方式时,还需要通知驱动程序。
与OpenGL等高级API相反,Vulkan中的缓冲区和图像没有自己的储存空间。它们要求我们专门创建和绑定适当的内存对象。
在本章中,我们将学习如何使用这些资源以及如何为它们分配内存并将其绑定到它们。我们还将学习如何将数据从CPU上传到GPU,以及如何在资源之间复制数据。

Computer graphics have a very long and interesting history. Many APIs or custom approaches to the generation of 2D or 3D images have come and gone. A landmark in this history was the invention of OpenGL, one of the first graphics libraries, which allowed us to create real-time, high-performance 3D graphics, and which was available for everyone on multiple operating systems. It is still developed and widely used even today. And this year we can celebrate its 25th birthday! But many things have changed since OpenGL was created. The graphics hardware industry is evolving very quickly. And recently, to accommodate these changes, a new approach to 3D graphics rendering was presented. It took the form of a low-level access to the graphics hardware. OpenGL was designed as a high-level API, which allows users to easily render images on screen. But this high-level approach, convenient for users, is difficult for graphics drivers to handle. This is one of the main reasons for restricting the hardware to show its full potential. The new approach tries to overcome these struggles–it gives users much more control over the hardware, but also many more responsibilities. This way application developers can release the full potential of the graphics hardware, because the drivers no longer block them. Low-level access allows drivers to be much smaller, much thinner. But these benefits come at the expense of much more work that needs to done by the developers. The first evangelist of the new approach to graphics rendering was a Mantle API designed by AMD. When it proved that low-level access can give considerable performance benefits, other companies started working on their own graphics libraries. One of the most notable representatives of the new trend were Metal API, designed by Apple, and DirectX 12, developed by Microsoft. But all of the above libraries were developed with specific operating systems and/or hardware in mind. There was no open and multiplatform standard such as OpenGL. Until last year. Year 2016 saw the release of the Vulkan API, developed by Khronos consortium, which maintains the OpenGL library. Vulkan also represents the new approach, a low-level access to the graphics hardware, but unlike the other libraries it is available for everyone on multiple operating systems and hardware platforms–from high-performance desktop computers with Windows or Linux operating systems, to mobile devices with Android OS. And as it is still being very new, there are few resources teaching developers how to use it. This book tries to fill this gap.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值