为什么vkGetPhysicalDeviceMemoryProperties返回多个相同的内存类型? [英] Why does vkGetPhysicalDeviceMemoryProperties return multiple identical memory types?

查看:219
本文介绍了为什么vkGetPhysicalDeviceMemoryProperties返回多个相同的内存类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在初始化期间在Vulkan中收集有关我的设备的一些信息,并找到vkGetPhysicalDeviceMemoryProperties返回的一组唯一的(或相当相似的)内存类型:

So, I'm gathering some info about my device in Vulkan during initialization and find a unique (or rather, quite similar) set of memory types returned by vkGetPhysicalDeviceMemoryProperties:

Device Name: GeForce GTX 1060 3GB
Device ID: 7170
Device Type: 2
Device Vendor ID: 4318
Device API Version: 4194369 (1.0.65)
Device Driver Version: 1636843520 (390.65)
Device Heaps:
    0 -> Size: 3133145088 Flags: 1
    1 -> Size: 8523874304 Flags: 0
Device Memory:
    0 -> Index: 1 Flags: 0
    1 -> Index: 1 Flags: 0
    2 -> Index: 1 Flags: 0
    3 -> Index: 1 Flags: 0
    4 -> Index: 1 Flags: 0
    5 -> Index: 1 Flags: 0
    6 -> Index: 1 Flags: 0
    7 -> Index: 0 Flags: 1
    8 -> Index: 0 Flags: 1
    9 -> Index: 1 Flags: 6
    10 -> Index: 1 Flags: 14

我坐下来考虑...我应该选择哪一个?除了七个相同的主机本地内存类型外,我们还有两个相同的设备内存类型。一定有某些原因,所以我要穿越互联网深入我的冒险之旅!

I sit down and contemplate... which one should I chose? Excluding the seven identical host local memory types, we still have two identical device memory types. There must be some reason for this, so I head out on my adventure through the depths of the internet!

StackOverflow似乎没有任何相似之处,并且Google返回了Nvidia的一些正式文档似乎并未广泛涉及内存类型,因此Vulkan文档是否有很多功能? vkGetPhysicalDeviceMemoryProperties VkPhysicalDeviceMemoryProperties VkMemoryType 似乎没有提供有关多种相同内存类型的任何有见地的信息。也许官方Vulkan编程指南(其源代码仍未发布)可以涉及到此话题?不幸的是,我的快速浏览似乎使我进入了第10页,在此之后,似乎没有提及任何有关相同内存类型的内容(但是紧随其后的队列部分确实提及了相同的队列系列)。

StackOverflow doesn't seem to have anything similar, and Google returns some official documents from Nvidia that don't seem to touch on memory types extensively, so maybe the Vulkan documentation has something juicy? vkGetPhysicalDeviceMemoryProperties, VkPhysicalDeviceMemoryProperties and VkMemoryType don't seem to offer any insightful information on the topic of multiple identical memory types. Maybe the official Vulkan programming guide (whose source code still hasn't been published by the way) can touch on this topic? Unfortunately, it seems my quick glance has lead me to page 10 and beyond which doesn't seem to mention anything about identical memory types (but the queue section right after it does mention about identical queue families).

为什么会有多种内存类型,更重要的是我应该选择哪一种?如果要分配多个缓冲区,是否应该替换不同的类型就像您要使用队列一样

Why am I getting multiple memory types, and more importantly which one should I chose? Should I alternate the different types if I want to allocate multiple buffers like you would do with queues?

推荐答案

就Vulkan规范而言:

As far as the Vulkan specification is concerned:


  • VkMemoryRequirements :: memoryTypeBits 告诉您可以使用的类型

  • 在相同的内存类型标志的情况下,应按性能对其进行排序

  • VkMemoryRequirements::memoryTypeBits tells you which types you can use
  • in case of same memory type flags, they should be ordered by performance

因此,最佳/预期的做法是:

So, the best/expected practice is:

1)确定要/需要的标志。

2)进一步用 VkMemoryRequirements允许的类型过滤列表: :memoryTypeBits

3)如果剩余任何类型,请选择第一个。 (或者从具有更少标志的第1步开始。)

1) Decide which flags you want/need.
2) Further filter the list with those types allowed by VkMemoryRequirements::memoryTypeBits
3) If there are any types left pick the first one. (Or start from step 1 with even less flags.)

Vulkan不一定知道(并报告)所有内容。但是,只要您坚持上述条件,就可以了。

The Vulkan does not necessarily know (and report) everything. But as long as you stick to the above you should be fine.

您的Vulkan内存类型是什么? NVIDIA的文章似乎描述了主机本地类型的情况:

The What’s your Vulkan Memory Type? NVIDIA article seems to describe what is happening for the host-local types:


在OpenGL或DirectX 11中,驱动程序通常通过在设备内存和设备内存过度使用的情况下在设备本地和系统内存之间移动资源来支持应用程序的资源分配。如果用户选择的图像质量设置超出了可用设备本地内存量,则会发生这种情况。

In OpenGL or DirectX 11, the driver traditionally has been supporting the application’s resource allocation by moving resources between device local and system memory in case of oversubscription of device memory, which can happen if the user might select image quality settings that exceed the amount of available device local memory.

[...]

要启用此功能,我们将公开其他主机本地内存类型:

To enable this, we are exposing additional host-local memory types:


  • 缓冲区的内存类型

  • 任何格式的彩色图像的存储类型

  • 每种深度/模具形式的深度/模板图像的单独存储类型在系统内存中

数学似乎可以检查出:1(用于缓冲区)+ 1(对于图像)+ 5(似乎与该GPU上支持的深度格式相匹配)= 7。

The math seems to check out: 1(for buffers) + 1(for images) + 5(which seems to match supported depth formats on this GPU) = 7.

我希望设备本地类型具有相似的原理。规范:可能一种用于深度资源,一种用于图像和缓冲区。

I would expect similar rationale for the device local types. SPECULATION: Possibly one for depth resources and one for images and buffers.

这篇关于为什么vkGetPhysicalDeviceMemoryProperties返回多个相同的内存类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆