blob: 675febca3f8d7cdaf5001cd53f2ac2f029427607 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Vulkan Memory Allocator: VK_AMD_device_coherent_memory</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Vulkan Memory Allocator
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Vulkan Memory Allocator</a></li> </ul>
</div>
</div><!-- top -->
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">VK_AMD_device_coherent_memory </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>VK_AMD_device_coherent_memory is a device extension that enables access to additional memory types with <code>VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD</code> and <code>VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD</code> flag. It is useful mostly for allocation of buffers intended for writing "breadcrumb markers" in between passes or draw calls, which in turn are useful for debugging GPU crash/hang/TDR cases.</p>
<p>When the extension is available but has not been enabled, Vulkan physical device still exposes those memory types, but their usage is forbidden. VMA automatically takes care of that - it returns <code>VK_ERROR_FEATURE_NOT_PRESENT</code> when an attempt to allocate memory of such type is made.</p>
<p>If you want to use this extension in connection with VMA, follow these steps:</p>
<h1><a class="anchor" id="vk_amd_device_coherent_memory_initialization"></a>
Initialization</h1>
<p>1) Call <code>vkEnumerateDeviceExtensionProperties</code> for the physical device. Check if the extension is supported - if returned array of <code>VkExtensionProperties</code> contains "VK_AMD_device_coherent_memory".</p>
<p>2) Call <code>vkGetPhysicalDeviceFeatures2</code> for the physical device instead of old <code>vkGetPhysicalDeviceFeatures</code>. Attach additional structure <code>VkPhysicalDeviceCoherentMemoryFeaturesAMD</code> to <code>VkPhysicalDeviceFeatures2::pNext</code> to be returned. Check if the device feature is really supported - check if <code>VkPhysicalDeviceCoherentMemoryFeaturesAMD::deviceCoherentMemory</code> is true.</p>
<p>3) While creating device with <code>vkCreateDevice</code>, enable this extension - add "VK_AMD_device_coherent_memory" to the list passed as <code>VkDeviceCreateInfo::ppEnabledExtensionNames</code>.</p>
<p>4) While creating the device, also don't set <code>VkDeviceCreateInfo::pEnabledFeatures</code>. Fill in <code>VkPhysicalDeviceFeatures2</code> structure instead and pass it as <code>VkDeviceCreateInfo::pNext</code>. Enable this device feature - attach additional structure <code>VkPhysicalDeviceCoherentMemoryFeaturesAMD</code> to <code>VkPhysicalDeviceFeatures2::pNext</code> and set its member <code>deviceCoherentMemory</code> to <code>VK_TRUE</code>.</p>
<p>5) While creating <a class="el" href="struct_vma_allocator.html" title="Represents main object of this library initialized.">VmaAllocator</a> with <a class="el" href="vk__mem__alloc_8h.html#a200692051ddb34240248234f5f4c17bb" title="Creates Allocator object.">vmaCreateAllocator()</a> inform VMA that you have enabled this extension and feature - add <a class="el" href="vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca2acce4886d8078552efa38878413970f">VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT</a> to <a class="el" href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346" title="Flags for created allocator. Use VmaAllocatorCreateFlagBits enum.">VmaAllocatorCreateInfo::flags</a>.</p>
<h1><a class="anchor" id="vk_amd_device_coherent_memory_usage"></a>
Usage</h1>
<p>After following steps described above, you can create VMA allocations and custom pools out of the special <code>DEVICE_COHERENT</code> and <code>DEVICE_UNCACHED</code> memory types on eligible devices. There are multiple ways to do it, for example:</p>
<ul>
<li>You can request or prefer to allocate out of such memory types by adding <code>VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD</code> to <a class="el" href="struct_vma_allocation_create_info.html#a9166390303ff42d783305bc31c2b6b90" title="Flags that must be set in a Memory Type chosen for an allocation.">VmaAllocationCreateInfo::requiredFlags</a> or <a class="el" href="struct_vma_allocation_create_info.html#a7fe8d81a1ad10b2a2faacacee5b15d6d" title="Flags that preferably should be set in a memory type chosen for an allocation.">VmaAllocationCreateInfo::preferredFlags</a>. Those flags can be freely mixed with other ways of <a class="el" href="choosing_memory_type.html">Choosing memory type</a>, like setting <a class="el" href="struct_vma_allocation_create_info.html#accb8b06b1f677d858cb9af20705fa910" title="Intended usage of memory.">VmaAllocationCreateInfo::usage</a>.</li>
<li>If you manually found memory type index to use for this purpose, force allocation from this specific index by setting <a class="el" href="struct_vma_allocation_create_info.html#a3bf940c0271d85d6ba32a4d820075055" title="Bitmask containing one bit set for every memory type acceptable for this allocation.">VmaAllocationCreateInfo::memoryTypeBits</a> <code>= 1u &lt;&lt; index</code>.</li>
</ul>
<h1><a class="anchor" id="vk_amd_device_coherent_memory_more_information"></a>
More information</h1>
<p>To learn more about this extension, see <a href="https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/chap44.html#VK_AMD_device_coherent_memory">VK_AMD_device_coherent_memory in Vulkan specification</a></p>
<p>Example use of this extension can be found in the code of the sample and test suite accompanying this library. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>