VERY experimental Nintendo Switch 2 emulator
C++
GPU: implement missing ASTC
Fernando Sahmkow94ecd260e385
diff --git a/src/video_core/compatible_formats.cpp b/src/video_core/compatible_formats.cppindex 4e75f33cad..ab4f4d407a 100644--- a/src/video_core/compatible_formats.cpp+++ b/src/video_core/compatible_formats.cpp@@ -126,15 +126,14 @@ constexpr std::array VIEW_CLASS_ASTC_8x8_RGBA{PixelFormat::ASTC_2D_8X8_SRGB,};-// Missing formats:-// PixelFormat::ASTC_2D_10X5_UNORM-// PixelFormat::ASTC_2D_10X5_SRGB--// Missing formats:-// PixelFormat::ASTC_2D_10X6_SRGB+constexpr std::array VIEW_CLASS_ASTC_10x5_RGBA{+ PixelFormat::ASTC_2D_10X5_UNORM,+ PixelFormat::ASTC_2D_10X5_SRGB,+};constexpr std::array VIEW_CLASS_ASTC_10x6_RGBA{PixelFormat::ASTC_2D_10X6_UNORM,+ PixelFormat::ASTC_2D_10X6_SRGB,};constexpr std::array VIEW_CLASS_ASTC_10x8_RGBA{@@ -147,9 +146,10 @@ constexpr std::array VIEW_CLASS_ASTC_10x10_RGBA{PixelFormat::ASTC_2D_10X10_SRGB,};-// Missing formats-// ASTC_2D_12X10_UNORM,-// ASTC_2D_12X10_SRGB,+constexpr std::array VIEW_CLASS_ASTC_12x10_RGBA{+ PixelFormat::ASTC_2D_12X10_UNORM,+ PixelFormat::ASTC_2D_12X10_SRGB,+};constexpr std::array VIEW_CLASS_ASTC_12x12_RGBA{PixelFormat::ASTC_2D_12X12_UNORM,@@ -229,9 +229,11 @@ constexpr Table MakeViewTable() {EnableRange(view, VIEW_CLASS_ASTC_6x6_RGBA);EnableRange(view, VIEW_CLASS_ASTC_8x5_RGBA);EnableRange(view, VIEW_CLASS_ASTC_8x8_RGBA);+ EnableRange(view, VIEW_CLASS_ASTC_10x5_RGBA);EnableRange(view, VIEW_CLASS_ASTC_10x6_RGBA);EnableRange(view, VIEW_CLASS_ASTC_10x8_RGBA);EnableRange(view, VIEW_CLASS_ASTC_10x10_RGBA);+ EnableRange(view, VIEW_CLASS_ASTC_12x10_RGBA);EnableRange(view, VIEW_CLASS_ASTC_12x12_RGBA);return view;}diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cppindex 032a8ebc54..47cccd0e56 100644--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp@@ -861,9 +861,12 @@ GLuint Image::StorageHandle() noexcept {case PixelFormat::ASTC_2D_8X5_SRGB:case PixelFormat::ASTC_2D_5X4_SRGB:case PixelFormat::ASTC_2D_5X5_SRGB:+ case PixelFormat::ASTC_2D_10X5_SRGB:+ case PixelFormat::ASTC_2D_10X6_SRGB:case PixelFormat::ASTC_2D_10X8_SRGB:case PixelFormat::ASTC_2D_6X6_SRGB:case PixelFormat::ASTC_2D_10X10_SRGB:+ case PixelFormat::ASTC_2D_12X10_SRGB:case PixelFormat::ASTC_2D_12X12_SRGB:case PixelFormat::ASTC_2D_8X6_SRGB:case PixelFormat::ASTC_2D_6X5_SRGB:diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.hindex ef1190e1f0..c7dc7e0a18 100644--- a/src/video_core/renderer_opengl/maxwell_to_gl.h+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h@@ -100,10 +100,13 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> FORMAT_TAB{GL_COMPRESSED_RGBA_ASTC_6x6_KHR}, // ASTC_2D_6X6_UNORM{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR}, // ASTC_2D_6X6_SRGB{GL_COMPRESSED_RGBA_ASTC_10x6_KHR}, // ASTC_2D_10X6_UNORM+ {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR}, // ASTC_2D_10X6_SRGB{GL_COMPRESSED_RGBA_ASTC_10x5_KHR}, // ASTC_2D_10X5_UNORM{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR}, // ASTC_2D_10X5_SRGB{GL_COMPRESSED_RGBA_ASTC_10x10_KHR}, // ASTC_2D_10X10_UNORM{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR}, // ASTC_2D_10X10_SRGB+ {GL_COMPRESSED_RGBA_ASTC_12x10_KHR}, // ASTC_2D_12X10_UNORM+ {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR}, // ASTC_2D_12X10_SRGB{GL_COMPRESSED_RGBA_ASTC_12x12_KHR}, // ASTC_2D_12X12_UNORM{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}, // ASTC_2D_12X12_SRGB{GL_COMPRESSED_RGBA_ASTC_8x6_KHR}, // ASTC_2D_8X6_UNORMdiff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cppindex 5dce51be84..8853cf0f73 100644--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp@@ -197,10 +197,13 @@ struct FormatTuple {{VK_FORMAT_ASTC_6x6_UNORM_BLOCK}, // ASTC_2D_6X6_UNORM{VK_FORMAT_ASTC_6x6_SRGB_BLOCK}, // ASTC_2D_6X6_SRGB{VK_FORMAT_ASTC_10x6_UNORM_BLOCK}, // ASTC_2D_10X6_UNORM+ {VK_FORMAT_ASTC_10x6_SRGB_BLOCK}, // ASTC_2D_10X6_SRGB{VK_FORMAT_ASTC_10x5_UNORM_BLOCK}, // ASTC_2D_10X5_UNORM{VK_FORMAT_ASTC_10x5_SRGB_BLOCK}, // ASTC_2D_10X5_SRGB{VK_FORMAT_ASTC_10x10_UNORM_BLOCK}, // ASTC_2D_10X10_UNORM{VK_FORMAT_ASTC_10x10_SRGB_BLOCK}, // ASTC_2D_10X10_SRGB+ {VK_FORMAT_ASTC_12x10_UNORM_BLOCK}, // ASTC_2D_12X10_UNORM+ {VK_FORMAT_ASTC_12x10_SRGB_BLOCK}, // ASTC_2D_12X10_SRGB{VK_FORMAT_ASTC_12x12_UNORM_BLOCK}, // ASTC_2D_12X12_UNORM{VK_FORMAT_ASTC_12x12_SRGB_BLOCK}, // ASTC_2D_12X12_SRGB{VK_FORMAT_ASTC_8x6_UNORM_BLOCK}, // ASTC_2D_8X6_UNORMdiff --git a/src/video_core/surface.cpp b/src/video_core/surface.cppindex 1a76d41781..cb51529e4d 100644--- a/src/video_core/surface.cpp+++ b/src/video_core/surface.cpp@@ -250,10 +250,13 @@ bool IsPixelFormatASTC(PixelFormat format) {case PixelFormat::ASTC_2D_6X6_UNORM:case PixelFormat::ASTC_2D_6X6_SRGB:case PixelFormat::ASTC_2D_10X6_UNORM:+ case PixelFormat::ASTC_2D_10X6_SRGB:case PixelFormat::ASTC_2D_10X5_UNORM:case PixelFormat::ASTC_2D_10X5_SRGB:case PixelFormat::ASTC_2D_10X10_UNORM:case PixelFormat::ASTC_2D_10X10_SRGB:+ case PixelFormat::ASTC_2D_12X10_UNORM:+ case PixelFormat::ASTC_2D_12X10_SRGB:case PixelFormat::ASTC_2D_12X12_UNORM:case PixelFormat::ASTC_2D_12X12_SRGB:case PixelFormat::ASTC_2D_8X6_UNORM:@@ -279,11 +282,13 @@ bool IsPixelFormatSRGB(PixelFormat format) {case PixelFormat::ASTC_2D_8X5_SRGB:case PixelFormat::ASTC_2D_5X4_SRGB:case PixelFormat::ASTC_2D_5X5_SRGB:+ case PixelFormat::ASTC_2D_10X6_SRGB:case PixelFormat::ASTC_2D_10X8_SRGB:case PixelFormat::ASTC_2D_6X6_SRGB:case PixelFormat::ASTC_2D_10X5_SRGB:case PixelFormat::ASTC_2D_10X10_SRGB:case PixelFormat::ASTC_2D_12X12_SRGB:+ case PixelFormat::ASTC_2D_12X10_SRGB:case PixelFormat::ASTC_2D_8X6_SRGB:case PixelFormat::ASTC_2D_6X5_SRGB:return true;diff --git a/src/video_core/surface.h b/src/video_core/surface.hindex 44b79af209..0225d3287f 100644--- a/src/video_core/surface.h+++ b/src/video_core/surface.h@@ -95,10 +95,13 @@ enum class PixelFormat {ASTC_2D_6X6_UNORM,ASTC_2D_6X6_SRGB,ASTC_2D_10X6_UNORM,+ ASTC_2D_10X6_SRGB,ASTC_2D_10X5_UNORM,ASTC_2D_10X5_SRGB,ASTC_2D_10X10_UNORM,ASTC_2D_10X10_SRGB,+ ASTC_2D_12X10_UNORM,+ ASTC_2D_12X10_SRGB,ASTC_2D_12X12_UNORM,ASTC_2D_12X12_SRGB,ASTC_2D_8X6_UNORM,@@ -232,10 +235,13 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_WIDTH_TABLE = {{6, // ASTC_2D_6X6_UNORM6, // ASTC_2D_6X6_SRGB10, // ASTC_2D_10X6_UNORM+ 10, // ASTC_2D_10X6_SRGB10, // ASTC_2D_10X5_UNORM10, // ASTC_2D_10X5_SRGB10, // ASTC_2D_10X10_UNORM10, // ASTC_2D_10X10_SRGB+ 12, // ASTC_2D_12X10_UNORM+ 12, // ASTC_2D_12X10_SRGB12, // ASTC_2D_12X12_UNORM12, // ASTC_2D_12X12_SRGB8, // ASTC_2D_8X6_UNORM@@ -338,10 +344,13 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_HEIGHT_TABLE = {{6, // ASTC_2D_6X6_UNORM6, // ASTC_2D_6X6_SRGB6, // ASTC_2D_10X6_UNORM+ 6, // ASTC_2D_10X6_SRGB5, // ASTC_2D_10X5_UNORM5, // ASTC_2D_10X5_SRGB10, // ASTC_2D_10X10_UNORM10, // ASTC_2D_10X10_SRGB+ 10, // ASTC_2D_12X10_UNORM+ 10, // ASTC_2D_12X10_SRGB12, // ASTC_2D_12X12_UNORM12, // ASTC_2D_12X12_SRGB6, // ASTC_2D_8X6_UNORM@@ -444,10 +453,13 @@ constexpr std::array<u8, MaxPixelFormat> BITS_PER_BLOCK_TABLE = {{128, // ASTC_2D_6X6_UNORM128, // ASTC_2D_6X6_SRGB128, // ASTC_2D_10X6_UNORM+ 128, // ASTC_2D_10X6_SRGB128, // ASTC_2D_10X5_UNORM128, // ASTC_2D_10X5_SRGB128, // ASTC_2D_10X10_UNORM128, // ASTC_2D_10X10_SRGB+ 128, // ASTC_2D_12X10_UNORM+ 128, // ASTC_2D_12X10_SRGB128, // ASTC_2D_12X12_UNORM128, // ASTC_2D_12X12_SRGB128, // ASTC_2D_8X6_UNORMdiff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cppindex 5fc2b2feca..11ced6c38b 100644--- a/src/video_core/texture_cache/format_lookup_table.cpp+++ b/src/video_core/texture_cache/format_lookup_table.cpp@@ -210,6 +210,8 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red,return PixelFormat::ASTC_2D_6X6_SRGB;case Hash(TextureFormat::ASTC_2D_10X6, UNORM, LINEAR):return PixelFormat::ASTC_2D_10X6_UNORM;+ case Hash(TextureFormat::ASTC_2D_10X6, UNORM, SRGB):+ return PixelFormat::ASTC_2D_10X6_SRGB;case Hash(TextureFormat::ASTC_2D_10X5, UNORM, LINEAR):return PixelFormat::ASTC_2D_10X5_UNORM;case Hash(TextureFormat::ASTC_2D_10X5, UNORM, SRGB):@@ -218,6 +220,10 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red,return PixelFormat::ASTC_2D_10X10_UNORM;case Hash(TextureFormat::ASTC_2D_10X10, UNORM, SRGB):return PixelFormat::ASTC_2D_10X10_SRGB;+ case Hash(TextureFormat::ASTC_2D_12X10, UNORM, LINEAR):+ return PixelFormat::ASTC_2D_12X10_UNORM;+ case Hash(TextureFormat::ASTC_2D_12X10, UNORM, SRGB):+ return PixelFormat::ASTC_2D_12X10_SRGB;case Hash(TextureFormat::ASTC_2D_12X12, UNORM, LINEAR):return PixelFormat::ASTC_2D_12X12_UNORM;case Hash(TextureFormat::ASTC_2D_12X12, UNORM, SRGB):diff --git a/src/video_core/texture_cache/formatter.h b/src/video_core/texture_cache/formatter.hindex f1f0a057bc..b971477970 100644--- a/src/video_core/texture_cache/formatter.h+++ b/src/video_core/texture_cache/formatter.h@@ -179,6 +179,8 @@ struct fmt::formatter<VideoCore::Surface::PixelFormat> : fmt::formatter<fmt::strreturn "ASTC_2D_6X6_SRGB";case PixelFormat::ASTC_2D_10X6_UNORM:return "ASTC_2D_10X6_UNORM";+ case PixelFormat::ASTC_2D_10X6_SRGB:+ return "ASTC_2D_10X6_SRGB";case PixelFormat::ASTC_2D_10X5_UNORM:return "ASTC_2D_10X5_UNORM";case PixelFormat::ASTC_2D_10X5_SRGB:@@ -187,6 +189,10 @@ struct fmt::formatter<VideoCore::Surface::PixelFormat> : fmt::formatter<fmt::strreturn "ASTC_2D_10X10_UNORM";case PixelFormat::ASTC_2D_10X10_SRGB:return "ASTC_2D_10X10_SRGB";+ case PixelFormat::ASTC_2D_12X10_UNORM:+ return "ASTC_2D_12X10_UNORM";+ case PixelFormat::ASTC_2D_12X10_SRGB:+ return "ASTC_2D_12X10_SRGB";case PixelFormat::ASTC_2D_12X12_UNORM:return "ASTC_2D_12X12_UNORM";case PixelFormat::ASTC_2D_12X12_SRGB: