1、通过下面的接口,可以获得显卡支持的所有内存类型;

MemoryType的类型如下:

2、引用索引3对内存的描述

我们可以通过调用vkGetPhysicalDeviceMemoryProperties查询应用可使用的内存。它会返回请求大小的一个或多个内存堆,或者请求属性的一种或多种内存类型。每种内存类型来自于一个内存堆 - 因此,一个典例就是PC上的一个独立显卡将会有两个堆 - 一个是系统内存,另一个是GPU内存,并且他们各自拥有多种内存类型。内存类型有不同属性。一些内存可以被CPU访问或者不行、GPU和CPU访问一致、有缓存或者无缓存等等。通过调用vkAllocateMemory()可以分配内存,但它需要VkDevice句柄和描述结构体。HostVisibleMemory是可以通过Map方式来完成数据的更新的(vkMapMemory()/vkUnmapMemory())。GL使用者应该熟悉这个概念,但解释给D3D11的用户,vkMapMemory返回的指针可以被hold住被CPU写入当GPU正在使用它们。这些持久化的映射是完全正确的只要你遵守规则并且确定同步了内存访问。

3、VkMemeoryFlagBits

typedef enum VkMemoryHeapFlagBits {
 VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
 VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002,
 VK_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = VK_MEMORY_HEAP_MULTI_INSTANCE_BIT,
 VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkMemoryHeapFlagBits;

VK_MEMORY_HEAP_DEVICE_LOCAL_BIT specifies that the heap corresponds to device local memory.
Device local memory may have different performance characteristics than host local memory,and may support different memory property flags.

• VK_MEMORY_HEAP_MULTI_INSTANCE_BIT specifies that in a logical device representing more than one
physical device, there is a per-physical device instance of the heap memory. By default, an allocation from such a heap will be replicated to each physical device’s instance of the heap.

4、MemoryTypeFlags

typedef enum VkMemoryPropertyFlagBits {
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002,
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004,
VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008,
VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010,
VK_MEMORY_PROPERTY_PROTECTED_BIT = 0x00000020,
VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD = 0x00000040,
VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD = 0x00000080,
VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkMemoryPropertyFlagBits;

VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT bit specifies that memory allocated with this type is the most efficient for device access. This property will be set if and only if the memory type belongs to a heap with the VK_MEMORY_HEAP_DEVICE_LOCAL_BIT set.

• VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT bit specifies that memory allocated with this type can be mapped for host access using vkMapMemory.

• VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bit specifies that the host cache management commands vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges are not needed to flush host writes to the device or make device writes visible to the host, respectively.

• VK_MEMORY_PROPERTY_HOST_CACHED_BIT bit specifies that memory allocated with this type is cached on the host. Host memory accesses to uncached memory are slower than to cached memory,however uncached memory is always host coherent.

• VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT bit specifies that the memory type only allows device access to the memory. Memory types must not have both
VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT and VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set.Additionally, the object’s backing memory may be provided by the implementation lazily as specified in Lazily Allocated Memory.

• VK_MEMORY_PROPERTY_PROTECTED_BIT bit specifies that the memory type only allows device access to the memory, and allows protected queue operations to access the memory. Memory types must not have VK_MEMORY_PROPERTY_PROTECTED_BIT set and any of VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set, or VK_MEMORY_PROPERTY_HOST_COHERENT_BIT set, or VK_MEMORY_PROPERTY_HOST_CACHED_BIT set.

• VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD bit specifies that device accesses to allocations of this memory type are automatically made available and visible.

• VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD bit specifies that memory allocated with this type is not cached on the device. Uncached device memory is always device coherent.

5、Host memory is memory needed by the Vulkan implementation for non-device-visible storage.This memory may be used to store the implementation’s representation and state

of Vulkan objects.

6. Device memory is memory that is visible to the device — for example the contents of the image or buffer objects, which can be natively used by the device.

Device coherence is a useful property for certain debugging use cases (e.g. crash analysis, where performing separate coherence actions could mean values are not
reported correctly). However, device coherent accesses may be slower than equivalent accesses without device coherence, particularly if they are also device
uncached. For device uncached memory in particular, repeated accesses to the same or neighbouring memory locations over a short time period (e.g. within a
frame) may be slower than it would be for the equivalent cached memory type. As such, it’s generally inadvisable to use device coherent or device uncached memory
except when really needed.

7.

VulkanMemoryAllocator Github 提供了一个专门针对vulkan内存管理的库。

Reference

1、Vulkan Device Memory

2、https://gpuopen.com/vulkan-device-memory/

3、Images和Buffers

4、vulkan memory management

5、Vulkanised 2018 - Memory Management in Vulkan

Vulkan Device Memory的更多相关文章

  1. [译]Vulkan教程(27)Image

    [译]Vulkan教程(27)Image Images Introduction 入门 The geometry has been colored using per-vertex colors so ...

  2. [译]Vulkan教程(07)物理设备和队列家族

    [译]Vulkan教程(07)物理设备和队列家族 Selecting a physical device 选择一个物理设备 After initializing the Vulkan library ...

  3. Vulkan SDK 之 Depth Buffer

    深度缓冲是可选的,比如渲染一个3D的立方体的时候,就需要用到深度缓冲.Swapchain就算有多个images,此时深度缓冲区也只需要一个.vkCreateSwapchainKHR 会创建所有需要的i ...

  4. ARM: STM32F7: hardfault caused by unaligned memory access

    ARM: STM32F7: hardfault caused by unaligned memory access ARM: STM32F7: 由未对齐的内存访问引起的hardfault异常 Info ...

  5. Android内存管理(4)*官方教程 含「高效内存的16条策略」 Managing Your App's Memory

    Managing Your App's Memory In this document How Android Manages Memory Sharing Memory Allocating and ...

  6. OpenCL memory object 之 Global memory (2)

    转载自:http://www.cnblogs.com/mikewolf2002/archive/2011/12/18/2291584.html 当我们用clCreateBuffer, clCreate ...

  7. OpenCL memory object 之 Global memory (1)

    本文转载自:http://www.cnblogs.com/mikewolf2002/archive/2011/12/17/2291239.html 这篇日志是学习AMD OpenCL文档时候的总结. ...

  8. OpenCL memory object 之 传输优化

    转载自:http://www.cnblogs.com/mikewolf2002/archive/2011/12/18/2291741.html 首先我们了解一些优化时候的术语及其定义: 1.defer ...

  9. GPU编程--Shared Memory(4)

    GPU的内存按照所属对象大致分为三类:线程独有的.block共享的.全局共享的.细分的话,包含global, local, shared, constant, and texture memoey, ...

随机推荐

  1. Spark教程——(4)Spark-shell调用SQLContext(HiveContext)

    启动Spark-shell: [root@node1 ~]# spark-shell Setting default log level to "WARN". To adjust ...

  2. Linux centosVMware 命令 lvm、磁盘故障小案例

    一.lvm命令 LVM:逻辑分区管理,可基于动态的扩展缩小硬件设备的使用空间,注意:lvm磁盘复杂,由于使用lvm,数据丢失恢复起来有一定风险.概念:pv.VG.lvpv(物理卷,有pp基本单位构成) ...

  3. 《N诺机试指南》(一)数组妙用

    题目A: 大家思路有可能是这样: 将输入数据全部存储到一个数组里,然后可以冒泡排序一波,从小到大排序 那么怎么找到重复次数呢:我是这样想的,新定义数组b,原数组a,首先b[0] = a[0],定义指针 ...

  4. 「PA2014」Fiolki

    传送门 Bzoj 解题思路 构造法. 对于每一次的倾倒操作,连边 \(newnode\to u,newnode\to v\). 最后所有的反应都会在构造出来的树上的对应两点的 \(\text{LCA} ...

  5. Commons BeanUtils 中对Map的操作

    CSDN学院招募微信小程序讲师啦 程序员简历优化指南! [观点]移动原生App开发 PK HTML 5开发 云端应用征文大赛,秀绝招,赢无人机! Commons BeanUtils 中对Map的操作 ...

  6. 几种编辑器的markdown-toc生成目录在github上的表现

    Vscode vscode的markdown-toc插件的实现是比较好的, 目前发现的问题就只有在自动生成带链接目录的时候无法正确识别和生成一些特殊的字符. 例如: ▶ 这导致在标题中不能加入特殊字符 ...

  7. Echarts 折线图y轴标签值过长 显示

    参考: https://blog.csdn.net/dandelion_drq/article/details/79270597 改变Y轴单位:https://www.cnblogs.com/cons ...

  8. shell 脚本终止进程

    参考:https://blog.csdn.net/zhaoyue007101/article/details/7699259 $(pidof 进程名关键字)

  9. 编程题目: 两个队列实现栈(Python)

    感觉两个队列实现栈 比 两个栈实现队列 麻烦 1.栈为空:当两个队列都为空的时候,栈为空 2.入栈操作:当队列2为空的时候,将元素入队到队列1:当队列1位空的时候,将元素入队到队列2: 如果队列1 和 ...

  10. linux 下office软件推荐

    概述 最近想使用LINUX下搭建服务器,所以查找一些需要用的软件. linux下最好的office解决办法 其实因为我是不怎么使用office的,我也不知道不同office有什么不一样,直到有一次写奖 ...