没有合适的资源?快使用搜索试试~ 我知道了~
首页VULKAN开发丰富示例官方推荐书籍
VULKAN开发丰富示例官方推荐书籍
需积分: 50 72 下载量 72 浏览量
更新于2023-03-16
评论 1
收藏 3.01MB PDF 举报
比DX12更牛的游戏图形开发API,效率更高,且是跨平台的,PC和移动一统天下,是移动开的的未来
资源详情
资源评论
资源推荐
Vulkan Tutorial
Alexander Overvoorde
November 2017
Contents
1 Introduction 7
About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
E-book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Tutorial structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Overview 10
Origin of Vulkan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
What it takes to draw a triangle . . . . . . . . . . . . . . . . . . . . . 11
Step 1 - Instance and physical device selection . . . . . . . . . . . 11
Step 2 - Logical device and queue families . . . . . . . . . . . . . 11
Step 3 - Window surface and swap chain . . . . . . . . . . . . . . 12
Step 4 - Image views and framebuffers . . . . . . . . . . . . . . . 12
Step 5 - Render passes . . . . . . . . . . . . . . . . . . . . . . . . 12
Step 6 - Graphics pipeline . . . . . . . . . . . . . . . . . . . . . . 13
Step 7 - Command pools and command buffers . . . . . . . . . . 13
Step 8 - Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
API concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Coding conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Validation layers . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3 Development environment 17
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Vulkan SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
GLFW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
GLM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Setting up Visual Studio . . . . . . . . . . . . . . . . . . . . . . . 21
Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Vulkan SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
GLFW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
GLM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Setting up a makefile project . . . . . . . . . . . . . . . . . . . . 32
4 Base code 37
1
General structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Resource management . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Integrating GLFW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5 Instance 42
Creating an instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Checking for extension support . . . . . . . . . . . . . . . . . . . . . . 44
Cleaning up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6 Validation layers 46
What are validation layers? . . . . . . . . . . . . . . . . . . . . . . . . 46
Using validation layers . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Message callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7 Physical devices and queue families 54
Selecting a physical device . . . . . . . . . . . . . . . . . . . . . . . . . 54
Base device suitability checks . . . . . . . . . . . . . . . . . . . . . . . 55
Queue families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8 Logical device and queues 60
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Specifying the queues to be created . . . . . . . . . . . . . . . . . . . . 61
Specifying used device features . . . . . . . . . . . . . . . . . . . . . . 61
Creating the logical device . . . . . . . . . . . . . . . . . . . . . . . . . 61
Retrieving queue handles . . . . . . . . . . . . . . . . . . . . . . . . . 63
9 Window surface 64
Window surface creation . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Querying for presentation support . . . . . . . . . . . . . . . . . . . . 66
Creating the presentation queue . . . . . . . . . . . . . . . . . . . . . 67
10 Swap chain 69
Checking for swap chain support . . . . . . . . . . . . . . . . . . . . . 69
Querying details of swap chain support . . . . . . . . . . . . . . . . . . 71
Choosing the right settings for the swap chain . . . . . . . . . . . . . . 72
Surface format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Presentation mode . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Swap extent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Creating the swap chain . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Retrieving the swap chain images . . . . . . . . . . . . . . . . . . . . . 79
11 Image views 81
12 Introduction 84
13 Shader modules 88
2
Vertex shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Fragment shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Per-vertex colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Compiling the shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Loading a shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Creating shader modules . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Shader stage creation . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
14 Fixed functions 99
Vertex input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Input assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Viewports and scissors . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Rasterizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Depth and stencil testing . . . . . . . . . . . . . . . . . . . . . . . . . 104
Color blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Dynamic state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Pipeline layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
15 Render passes 108
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Attachment description . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Subpasses and attachment references . . . . . . . . . . . . . . . . . . . 110
Render pass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
16 Conclusion 113
17 Framebuffers 116
18 Command buffers 119
Command pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Command buffer allocation . . . . . . . . . . . . . . . . . . . . . . . . 121
Starting command buffer recording . . . . . . . . . . . . . . . . . . . . 122
Starting a render pass . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Basic drawing commands . . . . . . . . . . . . . . . . . . . . . . . . . 124
Finishing up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
19 Rendering and presentation 125
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Acquiring an image from the swap chain . . . . . . . . . . . . . . . . . 127
Submitting the command buffer . . . . . . . . . . . . . . . . . . . . . . 128
Subpass dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Memory leak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
20 Swap chain recreation 134
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Recreating the swap chain . . . . . . . . . . . . . . . . . . . . . . . . . 134
Window resizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Suboptimal or out-of-date swap chain . . . . . . . . . . . . . . . . . . 137
21 Vertex input description 139
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Vertex shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Vertex data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Binding descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Attribute descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Pipeline vertex input . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
22 Vertex buffer creation 144
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Buffer creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Memory requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Filling the vertex buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Binding the vertex buffer . . . . . . . . . . . . . . . . . . . . . . . . . 149
23 Staging buffer 152
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Transfer queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Abstracting buffer creation . . . . . . . . . . . . . . . . . . . . . . . . 153
Using a staging buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
24 Index buffer 158
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Index buffer creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Using an index buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
25 Descriptor layout and buffer 164
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Vertex shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Descriptor set layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Uniform buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Updating uniform data . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
26 Descriptor pool and sets 172
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Descriptor pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Descriptor set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
4
剩余238页未读,继续阅读
时空观察者9号
- 粉丝: 62
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0