[Mesa-dev] [PATCH] radv: add a write-combining host-local memory type

Edward O'Callaghan funfunctor at folklore1984.net
Wed Oct 26 11:36:06 UTC 2016


Oh that is a nice addition.

Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 10/26/2016 11:57 AM, Fredrik Höglund wrote:
> Add the new memory type between the two device-local types. This makes
> the list of supported memory types look like this:
> 
> 1) DEVICE_LOCAL |              |               |
> 2)              | HOST_VISIBLE | HOST_COHERENT |
> 3) DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT |
> 4)              | HOST_VISIBLE | HOST_COHERENT | HOST_CACHED
> 
> With this order a client that searches for a HOST_VISIBLE and
> HOST_COHERENT memory type using the algorithm described in section
> 10.2 of the Vulkan specification (revision 32) will find the host-
> local memory type first.
> 
> A client that requires the memory type to be HOST_VISIBLE and
> HOST_COHERENT, but not DEVICE_LOCAL is most likely searching for
> a memory type suitable for staging buffers / images.
> ---
>  src/amd/vulkan/radv_device.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index af5a151..897e5dd 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -528,19 +528,24 @@ void radv_GetPhysicalDeviceMemoryProperties(
>  {
>  	RADV_FROM_HANDLE(radv_physical_device, physical_device, physicalDevice);
>  
> -	pMemoryProperties->memoryTypeCount = 3;
> +	pMemoryProperties->memoryTypeCount = 4;
>  	pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
>  		.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
>  		.heapIndex = 0,
>  	};
>  	pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
> +		.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
> +		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
> +		.heapIndex = 1,
> +	};
> +	pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
>  		.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
>  		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
>  		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
>  		.heapIndex = 0,
>  	};
> -	pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
> -		.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|
> +	pMemoryProperties->memoryTypes[3] = (VkMemoryType) {
> +		.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
>  		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
>  		VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
>  		.heapIndex = 1,
> @@ -860,7 +865,7 @@ VkResult radv_AllocateMemory(
>  		return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
>  
>  	uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
> -	if (pAllocateInfo->memoryTypeIndex == 2)
> +	if (pAllocateInfo->memoryTypeIndex == 1 || pAllocateInfo->memoryTypeIndex == 3)
>  		domain = RADEON_DOMAIN_GTT;
>  	else
>  		domain = RADEON_DOMAIN_VRAM;
> @@ -869,6 +874,10 @@ VkResult radv_AllocateMemory(
>  		flags |= RADEON_FLAG_NO_CPU_ACCESS;
>  	else
>  		flags |= RADEON_FLAG_CPU_ACCESS;
> +
> +	if (pAllocateInfo->memoryTypeIndex == 1)
> +		flags |= RADEON_FLAG_GTT_WC;
> +
>  	mem->bo = device->ws->buffer_create(device->ws, alloc_size, 32768,
>  					       domain, flags);
>  
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161026/fbe3f105/attachment.sig>


More information about the mesa-dev mailing list