Implement a software ETC2 texture decoder (#4121)

* Implement a software ETC2 texture decoder

* Fix output size calculation for non-2D textures

* Address PR feedback
This commit is contained in:
gdkchan 2022-12-21 20:39:58 -03:00 committed by GitHub
parent 219f63ff4e
commit f906eb06c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 763 additions and 10 deletions

View file

@ -857,9 +857,23 @@ namespace Ryujinx.Graphics.Gpu.Image
result = decoded;
}
else if (!_context.Capabilities.SupportsR4G4Format && Format == Format.R4G4Unorm)
else if (!_context.Capabilities.SupportsEtc2Compression && Format.IsEtc2())
{
result = PixelConverter.ConvertR4G4ToR4G4B4A4(result);
switch (Format)
{
case Format.Etc2RgbaSrgb:
case Format.Etc2RgbaUnorm:
result = ETC2Decoder.DecodeRgba(result, width, height, depth, levels, layers);
break;
case Format.Etc2RgbPtaSrgb:
case Format.Etc2RgbPtaUnorm:
result = ETC2Decoder.DecodePta(result, width, height, depth, levels, layers);
break;
case Format.Etc2RgbSrgb:
case Format.Etc2RgbUnorm:
result = ETC2Decoder.DecodeRgb(result, width, height, depth, levels, layers);
break;
}
}
else if (!TextureCompatibility.HostSupportsBcFormat(Format, Target, _context.Capabilities))
{
@ -895,6 +909,10 @@ namespace Ryujinx.Graphics.Gpu.Image
break;
}
}
else if (!_context.Capabilities.SupportsR4G4Format && Format == Format.R4G4Unorm)
{
result = PixelConverter.ConvertR4G4ToR4G4B4A4(result);
}
return result;
}