mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	render/vulkan: create VkImage with option for _SRGB view, if possible
This commit is contained in:
		
							parent
							
								
									fd4548bb93
								
							
						
					
					
						commit
						88a4b9eefd
					
				
					 1 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
					@ -411,6 +411,15 @@ static struct wlr_texture *vulkan_texture_from_pixels(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	texture_set_format(texture, &fmt->format);
 | 
						texture_set_format(texture, &fmt->format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VkFormat view_formats[2] = {
 | 
				
			||||||
 | 
							fmt->format.vk,
 | 
				
			||||||
 | 
							fmt->format.vk_srgb,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						VkImageFormatListCreateInfoKHR list_info = {
 | 
				
			||||||
 | 
							.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR,
 | 
				
			||||||
 | 
							.pViewFormats = view_formats,
 | 
				
			||||||
 | 
							.viewFormatCount = 2,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
	VkImageCreateInfo img_info = {
 | 
						VkImageCreateInfo img_info = {
 | 
				
			||||||
		.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
 | 
							.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
 | 
				
			||||||
		.imageType = VK_IMAGE_TYPE_2D,
 | 
							.imageType = VK_IMAGE_TYPE_2D,
 | 
				
			||||||
| 
						 | 
					@ -423,7 +432,11 @@ static struct wlr_texture *vulkan_texture_from_pixels(
 | 
				
			||||||
		.extent = (VkExtent3D) { width, height, 1 },
 | 
							.extent = (VkExtent3D) { width, height, 1 },
 | 
				
			||||||
		.tiling = VK_IMAGE_TILING_OPTIMAL,
 | 
							.tiling = VK_IMAGE_TILING_OPTIMAL,
 | 
				
			||||||
		.usage = vulkan_shm_tex_usage,
 | 
							.usage = vulkan_shm_tex_usage,
 | 
				
			||||||
 | 
							.pNext = fmt->shm.has_mutable_srgb ? &list_info : NULL,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						if (fmt->shm.has_mutable_srgb) {
 | 
				
			||||||
 | 
							img_info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res = vkCreateImage(dev, &img_info, NULL, &texture->image);
 | 
						res = vkCreateImage(dev, &img_info, NULL, &texture->image);
 | 
				
			||||||
	if (res != VK_SUCCESS) {
 | 
						if (res != VK_SUCCESS) {
 | 
				
			||||||
| 
						 | 
					@ -571,6 +584,9 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
 | 
				
			||||||
	if (disjoint) {
 | 
						if (disjoint) {
 | 
				
			||||||
		img_info.flags = VK_IMAGE_CREATE_DISJOINT_BIT;
 | 
							img_info.flags = VK_IMAGE_CREATE_DISJOINT_BIT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (mod->has_mutable_srgb) {
 | 
				
			||||||
 | 
							img_info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	VkExternalMemoryImageCreateInfo eimg = {
 | 
						VkExternalMemoryImageCreateInfo eimg = {
 | 
				
			||||||
		.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
 | 
							.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
 | 
				
			||||||
| 
						 | 
					@ -595,6 +611,19 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	eimg.pNext = &mod_info;
 | 
						eimg.pNext = &mod_info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VkFormat view_formats[2] = {
 | 
				
			||||||
 | 
							fmt->format.vk,
 | 
				
			||||||
 | 
							fmt->format.vk_srgb,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						VkImageFormatListCreateInfoKHR list_info = {
 | 
				
			||||||
 | 
							.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR,
 | 
				
			||||||
 | 
							.pViewFormats = view_formats,
 | 
				
			||||||
 | 
							.viewFormatCount = 2,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						if (mod->has_mutable_srgb) {
 | 
				
			||||||
 | 
							mod_info.pNext = &list_info;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	VkImage image;
 | 
						VkImage image;
 | 
				
			||||||
	res = vkCreateImage(dev, &img_info, NULL, &image);
 | 
						res = vkCreateImage(dev, &img_info, NULL, &image);
 | 
				
			||||||
	if (res != VK_SUCCESS) {
 | 
						if (res != VK_SUCCESS) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue