video_core: Add ETC2 texture compression format support

Adds comprehensive support for ETC2 compressed texture formats (ETC2_RGB,
ETC2_RGBA, ETC2_RGB_PTA) in both UNORM and SRGB variants. This addresses
rendering issues in games like Hogwarts Legacy that use these formats.

Changes:
- Add ETC2 texture format enums (TextureFormat::ETC2_RGB_SRGB,
  ETC2_RGBA_SRGB) and component types (SNORM_FORCE_FP16, UNORM_FORCE_FP16)
- Implement format lookup mappings for all ETC2 variants in
  format_lookup_table.cpp
- Add PixelFormat enum values and block size tables for ETC2 formats
- Integrate ETC2 support into Vulkan backend with proper VkFormat mappings
- Add IsOptimalEtc2Supported() device capability check
- Update texture cache to handle ETC2 format conversion when needed
- Add ETC2 format cases to PixelFormat formatter for logging
- Improve shader environment texture handle validation with graceful
  fallback for invalid handles

Fixes assertion failures for texture formats 90 and 99, enabling proper
rendering of ETC2 compressed textures using native Vulkan support.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-12-28 11:57:18 +10:00
parent 2028150ebf
commit 855a38ee97
10 changed files with 172 additions and 59 deletions

View File

@@ -109,6 +109,12 @@ enum class PixelFormat {
ASTC_2D_6X5_UNORM,
ASTC_2D_6X5_SRGB,
E5B9G9R9_FLOAT,
ETC2_RGB_UNORM,
ETC2_RGBA_UNORM,
ETC2_RGB_PTA_UNORM,
ETC2_RGB_SRGB,
ETC2_RGBA_SRGB,
ETC2_RGB_PTA_SRGB,
MaxColorFormat,
@@ -250,6 +256,12 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_WIDTH_TABLE = {{
6, // ASTC_2D_6X5_UNORM
6, // ASTC_2D_6X5_SRGB
1, // E5B9G9R9_FLOAT
4, // ETC2_RGB_UNORM
4, // ETC2_RGBA_UNORM
4, // ETC2_RGB_PTA_UNORM
4, // ETC2_RGB_SRGB
4, // ETC2_RGBA_SRGB
4, // ETC2_RGB_PTA_SRGB
1, // D32_FLOAT
1, // D16_UNORM
1, // X8_D24_UNORM
@@ -360,6 +372,12 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_HEIGHT_TABLE = {{
5, // ASTC_2D_6X5_UNORM
5, // ASTC_2D_6X5_SRGB
1, // E5B9G9R9_FLOAT
4, // ETC2_RGB_UNORM
4, // ETC2_RGBA_UNORM
4, // ETC2_RGB_PTA_UNORM
4, // ETC2_RGB_SRGB
4, // ETC2_RGBA_SRGB
4, // ETC2_RGB_PTA_SRGB
1, // D32_FLOAT
1, // D16_UNORM
1, // X8_D24_UNORM
@@ -470,6 +488,12 @@ constexpr std::array<u8, MaxPixelFormat> BITS_PER_BLOCK_TABLE = {{
128, // ASTC_2D_6X5_UNORM
128, // ASTC_2D_6X5_SRGB
32, // E5B9G9R9_FLOAT
64, // ETC2_RGB_UNORM
128, // ETC2_RGBA_UNORM
64, // ETC2_RGB_PTA_UNORM
64, // ETC2_RGB_SRGB
128, // ETC2_RGBA_SRGB
64, // ETC2_RGB_PTA_SRGB
32, // D32_FLOAT
16, // D16_UNORM
32, // X8_D24_UNORM
@@ -507,6 +531,8 @@ bool IsPixelFormatASTC(PixelFormat format);
bool IsPixelFormatBCn(PixelFormat format);
bool IsPixelFormatETC2(PixelFormat format);
bool IsPixelFormatSRGB(PixelFormat format);
bool IsPixelFormatInteger(PixelFormat format);