yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

vk_texture_cache: Use nearest neighbor scaling when available

This commit is contained in:
ameerj 2021-09-18 20:50:00 -04:00 committed by Fernando Sahmkow
parent 27af298e78
commit 16017ac450
4 changed files with 36 additions and 29 deletions

View File

@ -395,33 +395,6 @@ OGLTexture MakeImage(const VideoCommon::ImageInfo& info, GLenum gl_internal_form
UNREACHABLE_MSG("Invalid image format={}", format); UNREACHABLE_MSG("Invalid image format={}", format);
return GL_R32UI; 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 } // Anonymous namespace
ImageBufferMap::~ImageBufferMap() { ImageBufferMap::~ImageBufferMap() {

View File

@ -37,6 +37,7 @@ using VideoCommon::ImageInfo;
using VideoCommon::ImageType; using VideoCommon::ImageType;
using VideoCommon::SubresourceRange; using VideoCommon::SubresourceRange;
using VideoCore::Surface::IsPixelFormatASTC; using VideoCore::Surface::IsPixelFormatASTC;
using VideoCore::Surface::IsPixelFormatInteger;
namespace { namespace {
constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { 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, .width = info.size.width,
.height = info.size.height, .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.RequestOutsideRenderPassOperationContext();
scheduler.Record([dst_image, src_image, extent, resources, aspect_mask, resolution, type, 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) { const auto scale_up = [&](u32 value) {
return std::max<u32>((value * resolution.up_scale) >> resolution.down_shift, 1U); 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, cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, nullptr, nullptr, read_barriers); 0, nullptr, nullptr, read_barriers);
cmdbuf.BlitImage(src_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst_image, 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, cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
0, nullptr, nullptr, write_barriers); 0, nullptr, nullptr, write_barriers);
}); });

View File

@ -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) { std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
} }

View File

@ -460,6 +460,8 @@ bool IsPixelFormatASTC(PixelFormat format);
bool IsPixelFormatSRGB(PixelFormat format); bool IsPixelFormatSRGB(PixelFormat format);
bool IsPixelFormatInteger(PixelFormat format);
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format);