Skip to content

Commit 9e3e2c6

Browse files
committed
Update source\ResourceAndMemory.rst
1 parent 78e89b3 commit 9e3e2c6

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
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/11/5
8+
9+
>* 更新`资源与内存`文档
10+
711
## 2024/10/29
812

913
>* 更新`资源与内存`文档

source/Memory.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,8 @@ vkGetDeviceMemoryCommitment
986986

987987
通过之前 ``vkGetPhysicalDeviceMemoryProperties(...)`` 函数我们可以获取到设备的内存信息,现在我们就可以通过这些信息进行内存分配了。为此 ``Vulkan`` 为我们提供了 ``vkAllocateMemory(...)`` 函数进行内存分配。该函数定义如下:
988988

989+
.. _vk_Allocate_Memory:
990+
989991
vkAllocateMemory
990992
----------------------------
991993

source/PhysicalDevice.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ vkEnumeratePhysicalDevices
6262
枚举的 ``VkPhysicalDevice`` 句柄是在调用 ``vkCreateInstance(...)`` 创建 ``VkInstance`` 时驱动内部创建的。换句话说就是:
6363
``VkPhysicalDevice`` 句柄的生命周期与 ``VkInstance`` 相同, ``VkInstance`` 创建 ``VkPhysicalDevice`` 句柄们也会创建, ``VkInstance`` 销毁 ``VkPhysicalDevice`` 句柄们也会销毁。
6464

65+
.. _Get_Physical_Devicce_Properties:
66+
6567
获取物理设备信息
6668
######################
6769

@@ -167,6 +169,8 @@ VkPhysicalDeviceType
167169

168170
其中 ``VkPhysicalDeviceLimits`` 用于表述该设备的一些限制,比如最大支持的图片像素大小。
169171

172+
.. _Vk_Physical_Device_Limits:
173+
170174
VkPhysicalDeviceLimits
171175
*************************
172176

source/ResourceAndMemory.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* 2024/5/21 增加 ``资源与设备内存绑定`` 章节。
1919
* 2024/9/6 更新 ``对应关系`` 章节。
2020
* 2024/10/29 更新 ``资源与设备内存绑定`` 章节。
21+
* 2024/11/5 更新 ``资源与设备内存绑定`` 章节。
2122

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

@@ -254,11 +255,22 @@ VkMemoryRequirements
254255

255256
其中 ``buffer`` 、 ``memory`` 和 ``image`` 都需要从 ``device`` 中创建出来,这个不需要再赘述。这里主要需要说明一下 ``memoryOffset`` 参数的作用。
256257

257-
在 ``Vulkan`` 中其鼓励用户创建一个大的设备内存,不同的资源占用该设备不同的部分
258+
在 ``Vulkan`` 中其鼓励用户创建分配一块大的设备内存,不同的资源占用该设备内存不同的部分。这不仅能够最大化重复利用一块内存,优化内存使用率,也为用户制定自定义内存管理机制提供途径。这样设计的根本原因是: ``Vulkan`` 对于 ``VkDeviceMemory`` 创建的数量有 :bdg-danger:`上限`
258259

260+
:ref:`Get_Physical_Devicce_Properties` 章节中我们知道其内部有 :ref:`Vk_Physical_Device_Limits` 限制信息。其中有 ``maxMemoryAllocationCount`` 成员:
259261

262+
.. code-block:: c++
263+
264+
// 由 VK_VERSION_1_0 提供s
265+
typedef struct VkPhysicalDeviceLimits {
266+
...
267+
uint32_t maxMemoryAllocationCount;
268+
...
269+
} VkPhysicalDeviceLimits;
260270

271+
* :bdg-secondary:`maxMemoryAllocationCount` 可通过 :ref:`vk_Allocate_Memory` 创建的最大同时存在的设备内存数量。且 ``Vulkan`` 要求该限制数量不能小于 ``4096``
261272

273+
.. figure:: ./_static/resource_bind_in_memory.png
262274

263275

264276

2.92 KB
Loading

0 commit comments

Comments
 (0)