Skip to content

Commit 78e89b3

Browse files
committed
Update
1 parent 4eca54e commit 78e89b3

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

source/Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
此更新日志为纵览更新,对于具体文章的更新位于每个文章的开头的 `更新记录` 中。
55
```
66

7+
## 2024/10/29
8+
9+
>* 更新`资源与内存`文档
10+
711
## 2024/9/14
812

913
>* 更新`纵览`文档

source/ResourceAndMemory.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* 2024/5/21 更新 ``VkMemoryRequirements`` 章节。
1818
* 2024/5/21 增加 ``资源与设备内存绑定`` 章节。
1919
* 2024/9/6 更新 ``对应关系`` 章节。
20+
* 2024/10/29 更新 ``资源与设备内存绑定`` 章节。
2021

2122
在 `资源 <./Resource.html>`_ 章节中我们知道一个资源仅仅是一个 ``虚拟资源句柄`` ,其本质上并没有相应的内存实体用于存储数据。所以在创建完资源后,需要分配内存并与资源进行绑定,用于之后的数据读写。
2223

@@ -209,6 +210,68 @@ VkMemoryRequirements
209210
资源与设备内存绑定
210211
##################
211212

213+
通过之前的介绍,我们已经知道两件事:
214+
215+
* 如何在我们需要的设备内存上申请内存
216+
* 如何创建我们需要的资源
217+
218+
现在 ``资源`` 和 ``设备内存`` 都有了,接下来就可以将两者进行关联,即 ``绑定`` 。
219+
220+
``绑定`` 主要有两种:
221+
222+
* ``缓存`` 与 ``设备内存`` 进行绑定。对应的接口为 ``vkBindBufferMemory(...)`` 。
223+
* ``图片`` 与 ``设备内存`` 进行绑定。对应的接口为 ``vkBindImageMemory(...)`` 。
224+
225+
接口定义如下:
226+
227+
.. code-block:: c++
228+
229+
// 由 VK_VERSION_1_0 提供
230+
VkResult vkBindBufferMemory(
231+
VkDevice device,
232+
VkBuffer buffer,
233+
VkDeviceMemory memory,
234+
VkDeviceSize memoryOffset);
235+
236+
* :bdg-secondary:`device` 对应的逻辑设备。
237+
* :bdg-secondary:`buffer` 对应绑定的缓存。
238+
* :bdg-secondary:`memory` 对应绑定的设备内存。
239+
* :bdg-secondary:`memoryOffset` 对应绑定的设备内存的相对偏移。
240+
241+
.. code-block:: c++
242+
243+
// 由 VK_VERSION_1_0 提供
244+
VkResult vkBindImageMemory(
245+
VkDevice device,
246+
VkImage image,
247+
VkDeviceMemory memory,
248+
VkDeviceSize memoryOffset);
249+
250+
* :bdg-secondary:`device` 对应的逻辑设备。
251+
* :bdg-secondary:`image` 对应绑定的图片。
252+
* :bdg-secondary:`memory` 对应绑定的设备内存。
253+
* :bdg-secondary:`memoryOffset` 对应绑定的设备内存的相对偏移。
254+
255+
其中 ``buffer`` 、 ``memory`` 和 ``image`` 都需要从 ``device`` 中创建出来,这个不需要再赘述。这里主要需要说明一下 ``memoryOffset`` 参数的作用。
256+
257+
在 ``Vulkan`` 中其鼓励用户创建一个大的设备内存,不同的资源占用该设备不同的部分。
258+
259+
260+
261+
262+
263+
264+
265+
266+
267+
268+
269+
270+
271+
272+
273+
274+
212275
.. note::
213276

214277
未完待续

0 commit comments

Comments
 (0)