mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	render/vulkan: add error handling for vulkan_find_mem_type()
The function returns -1 if it doesn't find a suitable memory type.
This commit is contained in:
		
							parent
							
								
									5206cea566
								
							
						
					
					
						commit
						8d6d2101bc
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
					@ -271,12 +271,18 @@ struct wlr_vk_buffer_span vulkan_get_stage_span(struct wlr_vk_renderer *r,
 | 
				
			||||||
	VkMemoryRequirements mem_reqs;
 | 
						VkMemoryRequirements mem_reqs;
 | 
				
			||||||
	vkGetBufferMemoryRequirements(r->dev->dev, buf->buffer, &mem_reqs);
 | 
						vkGetBufferMemoryRequirements(r->dev->dev, buf->buffer, &mem_reqs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int mem_type_index = vulkan_find_mem_type(r->dev,
 | 
				
			||||||
 | 
							VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 | 
				
			||||||
 | 
							VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, mem_reqs.memoryTypeBits);
 | 
				
			||||||
 | 
						if (mem_type_index < 0) {
 | 
				
			||||||
 | 
							wlr_log(WLR_ERROR, "Failed to find memory type");
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	VkMemoryAllocateInfo mem_info = {0};
 | 
						VkMemoryAllocateInfo mem_info = {0};
 | 
				
			||||||
	mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
 | 
						mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
 | 
				
			||||||
	mem_info.allocationSize = mem_reqs.size;
 | 
						mem_info.allocationSize = mem_reqs.size;
 | 
				
			||||||
	mem_info.memoryTypeIndex = vulkan_find_mem_type(r->dev,
 | 
						mem_info.memoryTypeIndex = (uint32_t)mem_type_index;
 | 
				
			||||||
		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 | 
					 | 
				
			||||||
		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, mem_reqs.memoryTypeBits);
 | 
					 | 
				
			||||||
	res = vkAllocateMemory(r->dev->dev, &mem_info, NULL, &buf->memory);
 | 
						res = vkAllocateMemory(r->dev->dev, &mem_info, NULL, &buf->memory);
 | 
				
			||||||
	if (res != VK_SUCCESS) {
 | 
						if (res != VK_SUCCESS) {
 | 
				
			||||||
		wlr_vk_error("vkAllocatorMemory", res);
 | 
							wlr_vk_error("vkAllocatorMemory", res);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue