• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include::meta/VK_NV_dedicated_allocation.txt[]
2
3*Last Modified Date*::
4    2016-05-31
5*IP Status*::
6    No known IP claims.
7*Contributors*::
8  - Jeff Bolz, NVIDIA
9
10This extension allows device memory to be allocated for a particular buffer
11or image resource, which on some devices can significantly improve the
12performance of that resource.
13Normal device memory allocations must support memory aliasing and sparse
14binding, which could interfere with optimizations like framebuffer
15compression or efficient page table usage.
16This is important for render targets and very large resources, but need not
17(and probably should not) be used for smaller resources that can benefit
18from suballocation.
19
20This extension adds a few small structures to resource creation and memory
21allocation: a new structure that flags whether am image/buffer will have a
22dedicated allocation, and a structure indicating the image or buffer that an
23allocation will be bound to.
24
25=== New Object Types
26
27None.
28
29=== New Enum Constants
30
31  * Extending elink:VkStructureType:
32  ** ename:VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV
33  ** ename:VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV
34  ** ename:VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV
35
36=== New Enums
37
38None.
39
40=== New Structures
41
42  * slink:VkDedicatedAllocationImageCreateInfoNV
43  * slink:VkDedicatedAllocationBufferCreateInfoNV
44  * slink:VkDedicatedAllocationMemoryAllocateInfoNV
45
46=== New Functions
47
48None.
49
50=== Issues
51
52None.
53
54=== Examples
55
56[source,c++]
57--------------------------------------
58
59    // Create an image with
60    // VkDedicatedAllocationImageCreateInfoNV::dedicatedAllocation
61    // set to VK_TRUE
62
63    VkDedicatedAllocationImageCreateInfoNV dedicatedImageInfo =
64    {
65        VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV,            // sType
66        NULL,                                                                   // pNext
67        VK_TRUE,                                                                // dedicatedAllocation
68    };
69
70    VkImageCreateInfo imageCreateInfo =
71    {
72        VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,    // sType
73        &dedicatedImageInfo                     // pNext
74        // Other members set as usual
75    };
76
77    VkImage image;
78    VkResult result = vkCreateImage(
79        device,
80        &imageCreateInfo,
81        NULL,                       // pAllocator
82        &image);
83
84    VkMemoryRequirements memoryRequirements;
85    vkGetImageMemoryRequirements(
86        device,
87        image,
88        &memoryRequirements);
89
90    // Allocate memory with VkDedicatedAllocationMemoryAllocateInfoNV::image
91    // pointing to the image we are allocating the memory for
92
93    VkDedicatedAllocationMemoryAllocateInfoNV dedicatedInfo =
94    {
95        VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV,             // sType
96        NULL,                                                                       // pNext
97        image,                                                                      // image
98        VK_NULL_HANDLE,                                                             // buffer
99    };
100
101    VkMemoryAllocateInfo memoryAllocateInfo =
102    {
103        VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,                 // sType
104        &dedicatedInfo,                                         // pNext
105        memoryRequirements.size,                                // allocationSize
106        FindMemoryTypeIndex(memoryRequirements.memoryTypeBits), // memoryTypeIndex
107    };
108
109    VkDeviceMemory memory;
110    vkAllocateMemory(
111        device,
112        &memoryAllocateInfo,
113        NULL,                       // pAllocator
114        &memory);
115
116    // Bind the image to the memory
117
118    vkBindImageMemory(
119        device,
120        image,
121        memory,
122        0);
123
124--------------------------------------
125
126=== Version History
127
128 * Revision 1, 2016-05-31 (Jeff Bolz)
129   - Internal revisions
130