mirror of
https://github.com/status-im/Vulkan-Docs.git
synced 2025-02-17 08:46:32 +00:00
* Bump API patch number and header version number to 54 for this update. Github Issues: Internal Issues: * Fix tessellation domain to have an upper-left origin in the <<img-tessellation-topology-ul, tessellation toplogy image>> and related language. CTS and all implementations were already doing this, it was just a documentation bug that it was flipped to lower-left (internal issue 603). * Add a section to the style guide describing how VUID tags are changed and removed when the corresponding Valid Usage statements are modified (internal issue 829). * Add explicit Valid Usage statement to slink:VkPipelineDynamicStateCreateInfo to require that members of pname:pDynamicStates must be unique (internal issue 851). New Extensions: * `VK_KHR_16bit_storage` * `VK_KHR_dedicated_allocation` * `VK_KHR_external_fence` * `VK_KHR_external_fence_capabilities` * `VK_KHR_external_fence_fd` * `VK_KHR_external_fence_win32` * `VK_KHR_get_memory_requirements2` * `VK_KHR_storage_buffer_storage_class` * `VK_KHR_variable_pointers` Extensions Promoted From KHX To KHR Status: * `VK_KHR_external_memory` * `VK_KHR_external_memory_capabilities` * `VK_KHR_external_memory_fd` * `VK_KHR_external_memory_win32` * `VK_KHR_external_semaphore` * `VK_KHR_external_semaphore_capabilities` * `VK_KHR_external_semaphore_fd` * `VK_KHR_external_semaphore_win32` * `VK_KHR_win32_keyed_mutex`
170 lines
5.0 KiB
Plaintext
170 lines
5.0 KiB
Plaintext
// Copyright (c) 2016-2017 Khronos Group. This work is licensed under a
|
|
// Creative Commons Attribution 4.0 International License; see
|
|
// http://creativecommons.org/licenses/by/4.0/
|
|
|
|
[[VK_KHR_dedicated_allocation]]
|
|
== VK_KHR_dedicated_allocation
|
|
|
|
*Name String*::
|
|
+VK_KHR_dedicated_allocation+
|
|
*Extension Type*::
|
|
Device extension
|
|
*Registered Extension Number*::
|
|
128
|
|
*Status*::
|
|
Draft.
|
|
*Last Modified Date*::
|
|
2017-02-27
|
|
*Revision*::
|
|
1
|
|
*IP Status*::
|
|
No known IP claims.
|
|
*Dependencies*::
|
|
- This extension is written against version 1.0 of the Vulkan API.
|
|
- Requires +VK_KHR_get_memory_requirements2+.
|
|
*Contributors*::
|
|
- Jeff Bolz, NVIDIA
|
|
- Jason Ekstrand, Intel
|
|
*Contacts*::
|
|
- Jason Ekstrand (jason.ekstrand 'at' intel.com)
|
|
|
|
This extension enables resources to be bound to a dedicated allocation,
|
|
rather than suballocated.
|
|
For any particular resource, applications can: query whether a dedicated
|
|
allocation is recommended, in which case using a dedicated allocation may:
|
|
improve the performance of access to that resource.
|
|
Normal device memory allocations must support multiple resources per
|
|
allocation, memory aliasing and sparse binding, which could interfere with
|
|
some optimizations.
|
|
Applications should query the implementation for when a dedicated allocation
|
|
may: be beneficial by adding sname:VkMemoryDedicatedRequirementsKHR to the
|
|
pname:pNext chain of its call to fname:vkGetImageMemoryRequirements2KHR.
|
|
Certain external handle types and external images or buffers may: also
|
|
depend on dedicated allocations on implementations that associate image or
|
|
buffer metadata with OS-level memory objects.
|
|
|
|
This extension adds a two small structures to memory requirements querying
|
|
and memory allocation: a new structure that flags whether an image/buffer
|
|
should have a dedicated allocation, and a structure indicating the image or
|
|
buffer that an allocation will be bound to.
|
|
|
|
=== New Object Types
|
|
|
|
None.
|
|
|
|
=== New Enum Constants
|
|
|
|
* Extending elink:VkStructureType:
|
|
** ename:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR
|
|
** ename:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR
|
|
|
|
=== New Enums
|
|
|
|
None.
|
|
|
|
=== New Structures
|
|
|
|
* slink:VkMemoryDedicatedRequirementsKHR
|
|
* slink:VkMemoryDedicatedAllocateInfoKHR
|
|
|
|
=== New Functions
|
|
|
|
None.
|
|
|
|
=== Issues
|
|
|
|
None.
|
|
|
|
=== Examples
|
|
|
|
[source,c++]
|
|
--------------------------------------
|
|
|
|
// Create an image with a dedicated allocation based on the
|
|
// implementation's preference
|
|
|
|
VkImageCreateInfo imageCreateInfo =
|
|
{
|
|
// Image creation parameters
|
|
};
|
|
|
|
VkImage image;
|
|
VkResult result = vkCreateImage(
|
|
device,
|
|
&imageCreateInfo,
|
|
NULL, // pAllocator
|
|
&image);
|
|
|
|
VkMemoryDedicatedRequirementsKHR dedicatedRequirements =
|
|
{
|
|
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR,
|
|
NULL, // pNext
|
|
};
|
|
|
|
VkMemoryRequirements2KHR memoryRequirements =
|
|
{
|
|
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
|
|
&dedicatedAllocationRequirements, // pNext
|
|
};
|
|
|
|
const VkImageMemoryRequirementsInfo2KHR imageRequirementsInfo =
|
|
{
|
|
VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR,
|
|
NULL, // pNext
|
|
image
|
|
};
|
|
|
|
vkGetImageMemoryRequirements2KHR(
|
|
device,
|
|
&imageRequirementsInfo,
|
|
&memoryRequirements);
|
|
|
|
if (dedicatedRequirements.prefersDedicatedAllocation) {
|
|
// Allocate memory with VkMemoryDedicatedAllocateInfoKHR::image
|
|
// pointing to the image we are allocating the memory for
|
|
|
|
VkMemoryDedicatedAllocateInfoKHR dedicatedInfo =
|
|
{
|
|
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, // sType
|
|
NULL, // pNext
|
|
image, // image
|
|
VK_NULL_HANDLE, // buffer
|
|
};
|
|
|
|
VkMemoryAllocateInfo memoryAllocateInfo =
|
|
{
|
|
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType
|
|
&dedicatedInfo, // pNext
|
|
memoryRequirements.size, // allocationSize
|
|
FindMemoryTypeIndex(memoryRequirements.memoryTypeBits), // memoryTypeIndex
|
|
};
|
|
|
|
VkDeviceMemory memory;
|
|
vkAllocateMemory(
|
|
device,
|
|
&memoryAllocateInfo,
|
|
NULL, // pAllocator
|
|
&memory);
|
|
|
|
// Bind the image to the memory
|
|
|
|
vkBindImageMemory(
|
|
device,
|
|
image,
|
|
memory,
|
|
0);
|
|
} else {
|
|
// Take the normal memory sub-allocation path
|
|
}
|
|
|
|
--------------------------------------
|
|
|
|
=== Version History
|
|
|
|
* Revision 1, 2017-02-27 (James Jones)
|
|
- Copy content from VK_NV_dedicated_allocation
|
|
- Add some references to external object interactions to the overview.
|
|
|
|
* Revision 2, 2017-03-27 (Jason Ekstrand)
|
|
- Rework the extension to be query-based
|