mirror of
				https://git.tardis.systems/mirrors/yuzu
				synced 2025-10-31 10:44:49 +01:00 
			
		
		
		
	vk_texture_cache: Use nearest neighbor scaling when available
This commit is contained in:
		
							parent
							
								
									27af298e78
								
							
						
					
					
						commit
						16017ac450
					
				| @ -395,33 +395,6 @@ OGLTexture MakeImage(const VideoCommon::ImageInfo& info, GLenum gl_internal_form | ||||
|     UNREACHABLE_MSG("Invalid image format={}", format); | ||||
|     return GL_R32UI; | ||||
| } | ||||
| 
 | ||||
| [[nodiscard]] bool IsPixelFormatInteger(PixelFormat format) { | ||||
|     switch (format) { | ||||
|     case PixelFormat::A8B8G8R8_SINT: | ||||
|     case PixelFormat::A8B8G8R8_UINT: | ||||
|     case PixelFormat::A2B10G10R10_UINT: | ||||
|     case PixelFormat::R8_SINT: | ||||
|     case PixelFormat::R8_UINT: | ||||
|     case PixelFormat::R16G16B16A16_SINT: | ||||
|     case PixelFormat::R16G16B16A16_UINT: | ||||
|     case PixelFormat::R32G32B32A32_UINT: | ||||
|     case PixelFormat::R32G32B32A32_SINT: | ||||
|     case PixelFormat::R32G32_SINT: | ||||
|     case PixelFormat::R16_UINT: | ||||
|     case PixelFormat::R16_SINT: | ||||
|     case PixelFormat::R16G16_UINT: | ||||
|     case PixelFormat::R16G16_SINT: | ||||
|     case PixelFormat::R8G8_SINT: | ||||
|     case PixelFormat::R8G8_UINT: | ||||
|     case PixelFormat::R32G32_UINT: | ||||
|     case PixelFormat::R32_UINT: | ||||
|     case PixelFormat::R32_SINT: | ||||
|         return true; | ||||
|     default: | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| } // Anonymous namespace
 | ||||
| 
 | ||||
| ImageBufferMap::~ImageBufferMap() { | ||||
|  | ||||
| @ -37,6 +37,7 @@ using VideoCommon::ImageInfo; | ||||
| using VideoCommon::ImageType; | ||||
| using VideoCommon::SubresourceRange; | ||||
| using VideoCore::Surface::IsPixelFormatASTC; | ||||
| using VideoCore::Surface::IsPixelFormatInteger; | ||||
| 
 | ||||
| namespace { | ||||
| constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | ||||
| @ -603,9 +604,13 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con | ||||
|         .width = info.size.width, | ||||
|         .height = info.size.height, | ||||
|     }; | ||||
|     const bool is_zeta = (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != 0; | ||||
|     const bool is_int_format = IsPixelFormatInteger(info.format); | ||||
|     const VkFilter vk_filter = (is_zeta || is_int_format) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR; | ||||
| 
 | ||||
|     scheduler.RequestOutsideRenderPassOperationContext(); | ||||
|     scheduler.Record([dst_image, src_image, extent, resources, aspect_mask, resolution, type, | ||||
|                       scaling](vk::CommandBuffer cmdbuf) { | ||||
|                       scaling, vk_filter](vk::CommandBuffer cmdbuf) { | ||||
|         const auto scale_up = [&](u32 value) { | ||||
|             return std::max<u32>((value * resolution.up_scale) >> resolution.down_shift, 1U); | ||||
|         }; | ||||
| @ -723,7 +728,7 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con | ||||
|         cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, | ||||
|                                0, nullptr, nullptr, read_barriers); | ||||
|         cmdbuf.BlitImage(src_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst_image, | ||||
|                          VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, regions, VK_FILTER_NEAREST); | ||||
|                          VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, regions, vk_filter); | ||||
|         cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
|                                0, nullptr, nullptr, write_barriers); | ||||
|     }); | ||||
|  | ||||
| @ -279,6 +279,33 @@ bool IsPixelFormatSRGB(PixelFormat format) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool IsPixelFormatInteger(PixelFormat format) { | ||||
|     switch (format) { | ||||
|     case PixelFormat::A8B8G8R8_SINT: | ||||
|     case PixelFormat::A8B8G8R8_UINT: | ||||
|     case PixelFormat::A2B10G10R10_UINT: | ||||
|     case PixelFormat::R8_SINT: | ||||
|     case PixelFormat::R8_UINT: | ||||
|     case PixelFormat::R16G16B16A16_SINT: | ||||
|     case PixelFormat::R16G16B16A16_UINT: | ||||
|     case PixelFormat::R32G32B32A32_UINT: | ||||
|     case PixelFormat::R32G32B32A32_SINT: | ||||
|     case PixelFormat::R32G32_SINT: | ||||
|     case PixelFormat::R16_UINT: | ||||
|     case PixelFormat::R16_SINT: | ||||
|     case PixelFormat::R16G16_UINT: | ||||
|     case PixelFormat::R16G16_SINT: | ||||
|     case PixelFormat::R8G8_SINT: | ||||
|     case PixelFormat::R8G8_UINT: | ||||
|     case PixelFormat::R32G32_UINT: | ||||
|     case PixelFormat::R32_UINT: | ||||
|     case PixelFormat::R32_SINT: | ||||
|         return true; | ||||
|     default: | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | ||||
|     return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | ||||
| } | ||||
|  | ||||
| @ -460,6 +460,8 @@ bool IsPixelFormatASTC(PixelFormat format); | ||||
| 
 | ||||
| bool IsPixelFormatSRGB(PixelFormat format); | ||||
| 
 | ||||
| bool IsPixelFormatInteger(PixelFormat format); | ||||
| 
 | ||||
| std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | ||||
| 
 | ||||
| u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user