Why does vkGetPhysicalDeviceMemoryProperties return multiple identical memory types?

前端 未结 1 1373
清歌不尽
清歌不尽 2020-12-20 16:59

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 vkGetPhysicalDevice

相关标签:
1条回答
  • 2020-12-20 17:10

    As far as the Vulkan specification is concerned:

    • 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) 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.)

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

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

    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:

    • A memory type for buffers
    • A memory type for color images of any format
    • Separate memory types for depth/stencil images for each depth/stencil format in system memory

    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.

    0 讨论(0)
提交回复
热议问题