[Mesa-dev] [PATCH] radv: Don't underflow non-visible VRAM size.

Michel Dänzer michel at daenzer.net
Mon Jul 31 03:00:29 UTC 2017


On 31/07/17 06:29 AM, Bas Nieuwenhuizen wrote:
> n some APU situations the reported visible size can be larger than

Missing "I" at the beginning, vim fail? :)


> VRAM size. This properly clamps the value.
> 
> Surprisingly both CTS and spec seem to allow a heap type with size 0,
> so this seemed like the easiest option to me.
> 
> Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
> Fixes: 4ae84efbc5c "radv: Use enum for memory heaps."
> ---
>  src/amd/vulkan/radv_device.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 5244c157c35..b3041b9a47f 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -928,15 +928,17 @@ void radv_GetPhysicalDeviceMemoryProperties(
>  	};
>  
>  	STATIC_ASSERT(RADV_MEM_HEAP_COUNT <= VK_MAX_MEMORY_HEAPS);
> +	uint64_t visible_vram_size = MIN2(physical_device->rad_info.vram_size,
> +	                                  physical_device->rad_info.vram_vis_size);
>  
>  	pMemoryProperties->memoryHeapCount = RADV_MEM_HEAP_COUNT;
>  	pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM] = (VkMemoryHeap) {
>  		.size = physical_device->rad_info.vram_size -
> -				physical_device->rad_info.vram_vis_size,
> +				visible_vram_size,
>  		.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
>  	};
>  	pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = (VkMemoryHeap) {
> -		.size = physical_device->rad_info.vram_vis_size,
> +		.size = visible_vram_size,
>  		.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
>  	};
>  	pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_GTT] = (VkMemoryHeap) {
> 

Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list