diff options
| author | 2018-11-13 03:34:54 +0100 | |
|---|---|---|
| committer | 2018-11-12 18:34:54 -0800 | |
| commit | c8b3f09876e796f3c249f17f7f39e78bc1e3de74 (patch) | |
| tree | f472a868f338f3ed37def141165b75ff2bca5f25 /src | |
| parent | Merge pull request #1650 from FreddyFunk/cast (diff) | |
| download | yuzu-c8b3f09876e796f3c249f17f7f39e78bc1e3de74.tar.gz yuzu-c8b3f09876e796f3c249f17f7f39e78bc1e3de74.tar.xz yuzu-c8b3f09876e796f3c249f17f7f39e78bc1e3de74.zip | |
Implement ASTC_2D_10X8 & ASTC_2D_10X8_SRGB (#1666)
* Implement ASTC_2D_10X8 & ASTC_2D_10X8_SRGB
( needed by Mario+Rabbids Kingdom Battle )
* Small placement correction
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/surface.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/surface.h | 148 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 4 |
4 files changed, 101 insertions, 71 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 894f4f294..24cd88d06 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -314,6 +314,8 @@ static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex | |||
| 314 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB | 314 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB |
| 315 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 | 315 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 |
| 316 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB | 316 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB |
| 317 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8 | ||
| 318 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8_SRGB | ||
| 317 | 319 | ||
| 318 | // Depth formats | 320 | // Depth formats |
| 319 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F | 321 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F |
| @@ -456,6 +458,8 @@ static constexpr GLConversionArray morton_to_gl_fns = { | |||
| 456 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, | 458 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, |
| 457 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, | 459 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, |
| 458 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, | 460 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, |
| 461 | MortonCopy<true, PixelFormat::ASTC_2D_10X8>, | ||
| 462 | MortonCopy<true, PixelFormat::ASTC_2D_10X8_SRGB>, | ||
| 459 | MortonCopy<true, PixelFormat::Z32F>, | 463 | MortonCopy<true, PixelFormat::Z32F>, |
| 460 | MortonCopy<true, PixelFormat::Z16>, | 464 | MortonCopy<true, PixelFormat::Z16>, |
| 461 | MortonCopy<true, PixelFormat::Z24S8>, | 465 | MortonCopy<true, PixelFormat::Z24S8>, |
| @@ -526,6 +530,8 @@ static constexpr GLConversionArray gl_to_morton_fns = { | |||
| 526 | nullptr, | 530 | nullptr, |
| 527 | nullptr, | 531 | nullptr, |
| 528 | nullptr, | 532 | nullptr, |
| 533 | nullptr, | ||
| 534 | nullptr, | ||
| 529 | MortonCopy<false, PixelFormat::Z32F>, | 535 | MortonCopy<false, PixelFormat::Z32F>, |
| 530 | MortonCopy<false, PixelFormat::Z16>, | 536 | MortonCopy<false, PixelFormat::Z16>, |
| 531 | MortonCopy<false, PixelFormat::Z24S8>, | 537 | MortonCopy<false, PixelFormat::Z24S8>, |
| @@ -932,7 +938,9 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma | |||
| 932 | case PixelFormat::ASTC_2D_8X8_SRGB: | 938 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 933 | case PixelFormat::ASTC_2D_8X5_SRGB: | 939 | case PixelFormat::ASTC_2D_8X5_SRGB: |
| 934 | case PixelFormat::ASTC_2D_5X4_SRGB: | 940 | case PixelFormat::ASTC_2D_5X4_SRGB: |
| 935 | case PixelFormat::ASTC_2D_5X5_SRGB: { | 941 | case PixelFormat::ASTC_2D_5X5_SRGB: |
| 942 | case PixelFormat::ASTC_2D_10X8: | ||
| 943 | case PixelFormat::ASTC_2D_10X8_SRGB: { | ||
| 936 | // Convert ASTC pixel formats to RGBA8, as most desktop GPUs do not support ASTC. | 944 | // Convert ASTC pixel formats to RGBA8, as most desktop GPUs do not support ASTC. |
| 937 | u32 block_width{}; | 945 | u32 block_width{}; |
| 938 | u32 block_height{}; | 946 | u32 block_height{}; |
| @@ -967,7 +975,11 @@ static void ConvertFormatAsNeeded_FlushGLBuffer(std::vector<u8>& data, PixelForm | |||
| 967 | case PixelFormat::ASTC_2D_4X4: | 975 | case PixelFormat::ASTC_2D_4X4: |
| 968 | case PixelFormat::ASTC_2D_8X8: | 976 | case PixelFormat::ASTC_2D_8X8: |
| 969 | case PixelFormat::ASTC_2D_4X4_SRGB: | 977 | case PixelFormat::ASTC_2D_4X4_SRGB: |
| 970 | case PixelFormat::ASTC_2D_8X8_SRGB: { | 978 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 979 | case PixelFormat::ASTC_2D_5X5: | ||
| 980 | case PixelFormat::ASTC_2D_5X5_SRGB: | ||
| 981 | case PixelFormat::ASTC_2D_10X8: | ||
| 982 | case PixelFormat::ASTC_2D_10X8_SRGB: { | ||
| 971 | LOG_CRITICAL(HW_GPU, "Conversion of format {} after texture flushing is not implemented", | 983 | LOG_CRITICAL(HW_GPU, "Conversion of format {} after texture flushing is not implemented", |
| 972 | static_cast<u32>(pixel_format)); | 984 | static_cast<u32>(pixel_format)); |
| 973 | UNREACHABLE(); | 985 | UNREACHABLE(); |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 051ad3964..9582dd2ca 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -306,6 +306,8 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format, | |||
| 306 | return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8; | 306 | return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8; |
| 307 | case Tegra::Texture::TextureFormat::ASTC_2D_8X5: | 307 | case Tegra::Texture::TextureFormat::ASTC_2D_8X5: |
| 308 | return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5; | 308 | return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5; |
| 309 | case Tegra::Texture::TextureFormat::ASTC_2D_10X8: | ||
| 310 | return is_srgb ? PixelFormat::ASTC_2D_10X8_SRGB : PixelFormat::ASTC_2D_10X8; | ||
| 309 | case Tegra::Texture::TextureFormat::R16_G16: | 311 | case Tegra::Texture::TextureFormat::R16_G16: |
| 310 | switch (component_type) { | 312 | switch (component_type) { |
| 311 | case Tegra::Texture::ComponentType::FLOAT: | 313 | case Tegra::Texture::ComponentType::FLOAT: |
| @@ -453,6 +455,8 @@ bool IsPixelFormatASTC(PixelFormat format) { | |||
| 453 | case PixelFormat::ASTC_2D_5X5_SRGB: | 455 | case PixelFormat::ASTC_2D_5X5_SRGB: |
| 454 | case PixelFormat::ASTC_2D_8X8_SRGB: | 456 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 455 | case PixelFormat::ASTC_2D_8X5_SRGB: | 457 | case PixelFormat::ASTC_2D_8X5_SRGB: |
| 458 | case PixelFormat::ASTC_2D_10X8: | ||
| 459 | case PixelFormat::ASTC_2D_10X8_SRGB: | ||
| 456 | return true; | 460 | return true; |
| 457 | default: | 461 | default: |
| 458 | return false; | 462 | return false; |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index dfdb8d122..0dd3eb2e4 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -74,19 +74,21 @@ enum class PixelFormat { | |||
| 74 | ASTC_2D_5X4_SRGB = 56, | 74 | ASTC_2D_5X4_SRGB = 56, |
| 75 | ASTC_2D_5X5 = 57, | 75 | ASTC_2D_5X5 = 57, |
| 76 | ASTC_2D_5X5_SRGB = 58, | 76 | ASTC_2D_5X5_SRGB = 58, |
| 77 | ASTC_2D_10X8 = 59, | ||
| 78 | ASTC_2D_10X8_SRGB = 60, | ||
| 77 | 79 | ||
| 78 | MaxColorFormat, | 80 | MaxColorFormat, |
| 79 | 81 | ||
| 80 | // Depth formats | 82 | // Depth formats |
| 81 | Z32F = 59, | 83 | Z32F = 61, |
| 82 | Z16 = 60, | 84 | Z16 = 62, |
| 83 | 85 | ||
| 84 | MaxDepthFormat, | 86 | MaxDepthFormat, |
| 85 | 87 | ||
| 86 | // DepthStencil formats | 88 | // DepthStencil formats |
| 87 | Z24S8 = 61, | 89 | Z24S8 = 63, |
| 88 | S8Z24 = 62, | 90 | S8Z24 = 64, |
| 89 | Z32FS8 = 63, | 91 | Z32FS8 = 65, |
| 90 | 92 | ||
| 91 | MaxDepthStencilFormat, | 93 | MaxDepthStencilFormat, |
| 92 | 94 | ||
| @@ -193,6 +195,8 @@ static constexpr u32 GetCompressionFactor(PixelFormat format) { | |||
| 193 | 4, // ASTC_2D_5X4_SRGB | 195 | 4, // ASTC_2D_5X4_SRGB |
| 194 | 4, // ASTC_2D_5X5 | 196 | 4, // ASTC_2D_5X5 |
| 195 | 4, // ASTC_2D_5X5_SRGB | 197 | 4, // ASTC_2D_5X5_SRGB |
| 198 | 4, // ASTC_2D_10X8 | ||
| 199 | 4, // ASTC_2D_10X8_SRGB | ||
| 196 | 1, // Z32F | 200 | 1, // Z32F |
| 197 | 1, // Z16 | 201 | 1, // Z16 |
| 198 | 1, // Z24S8 | 202 | 1, // Z24S8 |
| @@ -208,70 +212,72 @@ static constexpr u32 GetDefaultBlockWidth(PixelFormat format) { | |||
| 208 | if (format == PixelFormat::Invalid) | 212 | if (format == PixelFormat::Invalid) |
| 209 | return 0; | 213 | return 0; |
| 210 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ | 214 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ |
| 211 | 1, // ABGR8U | 215 | 1, // ABGR8U |
| 212 | 1, // ABGR8S | 216 | 1, // ABGR8S |
| 213 | 1, // ABGR8UI | 217 | 1, // ABGR8UI |
| 214 | 1, // B5G6R5U | 218 | 1, // B5G6R5U |
| 215 | 1, // A2B10G10R10U | 219 | 1, // A2B10G10R10U |
| 216 | 1, // A1B5G5R5U | 220 | 1, // A1B5G5R5U |
| 217 | 1, // R8U | 221 | 1, // R8U |
| 218 | 1, // R8UI | 222 | 1, // R8UI |
| 219 | 1, // RGBA16F | 223 | 1, // RGBA16F |
| 220 | 1, // RGBA16U | 224 | 1, // RGBA16U |
| 221 | 1, // RGBA16UI | 225 | 1, // RGBA16UI |
| 222 | 1, // R11FG11FB10F | 226 | 1, // R11FG11FB10F |
| 223 | 1, // RGBA32UI | 227 | 1, // RGBA32UI |
| 224 | 4, // DXT1 | 228 | 4, // DXT1 |
| 225 | 4, // DXT23 | 229 | 4, // DXT23 |
| 226 | 4, // DXT45 | 230 | 4, // DXT45 |
| 227 | 4, // DXN1 | 231 | 4, // DXN1 |
| 228 | 4, // DXN2UNORM | 232 | 4, // DXN2UNORM |
| 229 | 4, // DXN2SNORM | 233 | 4, // DXN2SNORM |
| 230 | 4, // BC7U | 234 | 4, // BC7U |
| 231 | 4, // BC6H_UF16 | 235 | 4, // BC6H_UF16 |
| 232 | 4, // BC6H_SF16 | 236 | 4, // BC6H_SF16 |
| 233 | 4, // ASTC_2D_4X4 | 237 | 4, // ASTC_2D_4X4 |
| 234 | 1, // G8R8U | 238 | 1, // G8R8U |
| 235 | 1, // G8R8S | 239 | 1, // G8R8S |
| 236 | 1, // BGRA8 | 240 | 1, // BGRA8 |
| 237 | 1, // RGBA32F | 241 | 1, // RGBA32F |
| 238 | 1, // RG32F | 242 | 1, // RG32F |
| 239 | 1, // R32F | 243 | 1, // R32F |
| 240 | 1, // R16F | 244 | 1, // R16F |
| 241 | 1, // R16U | 245 | 1, // R16U |
| 242 | 1, // R16S | 246 | 1, // R16S |
| 243 | 1, // R16UI | 247 | 1, // R16UI |
| 244 | 1, // R16I | 248 | 1, // R16I |
| 245 | 1, // RG16 | 249 | 1, // RG16 |
| 246 | 1, // RG16F | 250 | 1, // RG16F |
| 247 | 1, // RG16UI | 251 | 1, // RG16UI |
| 248 | 1, // RG16I | 252 | 1, // RG16I |
| 249 | 1, // RG16S | 253 | 1, // RG16S |
| 250 | 1, // RGB32F | 254 | 1, // RGB32F |
| 251 | 1, // RGBA8_SRGB | 255 | 1, // RGBA8_SRGB |
| 252 | 1, // RG8U | 256 | 1, // RG8U |
| 253 | 1, // RG8S | 257 | 1, // RG8S |
| 254 | 1, // RG32UI | 258 | 1, // RG32UI |
| 255 | 1, // R32UI | 259 | 1, // R32UI |
| 256 | 8, // ASTC_2D_8X8 | 260 | 8, // ASTC_2D_8X8 |
| 257 | 8, // ASTC_2D_8X5 | 261 | 8, // ASTC_2D_8X5 |
| 258 | 5, // ASTC_2D_5X4 | 262 | 5, // ASTC_2D_5X4 |
| 259 | 1, // BGRA8_SRGB | 263 | 1, // BGRA8_SRGB |
| 260 | 4, // DXT1_SRGB | 264 | 4, // DXT1_SRGB |
| 261 | 4, // DXT23_SRGB | 265 | 4, // DXT23_SRGB |
| 262 | 4, // DXT45_SRGB | 266 | 4, // DXT45_SRGB |
| 263 | 4, // BC7U_SRGB | 267 | 4, // BC7U_SRGB |
| 264 | 4, // ASTC_2D_4X4_SRGB | 268 | 4, // ASTC_2D_4X4_SRGB |
| 265 | 8, // ASTC_2D_8X8_SRGB | 269 | 8, // ASTC_2D_8X8_SRGB |
| 266 | 8, // ASTC_2D_8X5_SRGB | 270 | 8, // ASTC_2D_8X5_SRGB |
| 267 | 5, // ASTC_2D_5X4_SRGB | 271 | 5, // ASTC_2D_5X4_SRGB |
| 268 | 5, // ASTC_2D_5X5 | 272 | 5, // ASTC_2D_5X5 |
| 269 | 5, // ASTC_2D_5X5_SRGB | 273 | 5, // ASTC_2D_5X5_SRGB |
| 270 | 1, // Z32F | 274 | 10, // ASTC_2D_10X8 |
| 271 | 1, // Z16 | 275 | 10, // ASTC_2D_10X8_SRGB |
| 272 | 1, // Z24S8 | 276 | 1, // Z32F |
| 273 | 1, // S8Z24 | 277 | 1, // Z16 |
| 274 | 1, // Z32FS8 | 278 | 1, // Z24S8 |
| 279 | 1, // S8Z24 | ||
| 280 | 1, // Z32FS8 | ||
| 275 | }}; | 281 | }}; |
| 276 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); | 282 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); |
| 277 | return block_width_table[static_cast<std::size_t>(format)]; | 283 | return block_width_table[static_cast<std::size_t>(format)]; |
| @@ -341,6 +347,8 @@ static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { | |||
| 341 | 4, // ASTC_2D_5X4_SRGB | 347 | 4, // ASTC_2D_5X4_SRGB |
| 342 | 5, // ASTC_2D_5X5 | 348 | 5, // ASTC_2D_5X5 |
| 343 | 5, // ASTC_2D_5X5_SRGB | 349 | 5, // ASTC_2D_5X5_SRGB |
| 350 | 8, // ASTC_2D_10X8 | ||
| 351 | 8, // ASTC_2D_10X8_SRGB | ||
| 344 | 1, // Z32F | 352 | 1, // Z32F |
| 345 | 1, // Z16 | 353 | 1, // Z16 |
| 346 | 1, // Z24S8 | 354 | 1, // Z24S8 |
| @@ -416,6 +424,8 @@ static constexpr u32 GetFormatBpp(PixelFormat format) { | |||
| 416 | 128, // ASTC_2D_5X4_SRGB | 424 | 128, // ASTC_2D_5X4_SRGB |
| 417 | 128, // ASTC_2D_5X5 | 425 | 128, // ASTC_2D_5X5 |
| 418 | 128, // ASTC_2D_5X5_SRGB | 426 | 128, // ASTC_2D_5X5_SRGB |
| 427 | 128, // ASTC_2D_10X8 | ||
| 428 | 128, // ASTC_2D_10X8_SRGB | ||
| 419 | 32, // Z32F | 429 | 32, // Z32F |
| 420 | 16, // Z16 | 430 | 16, // Z16 |
| 421 | 32, // Z24S8 | 431 | 32, // Z24S8 |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 3066abf61..a9d134d14 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -202,6 +202,8 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 202 | case TextureFormat::ASTC_2D_5X4: | 202 | case TextureFormat::ASTC_2D_5X4: |
| 203 | case TextureFormat::ASTC_2D_8X8: | 203 | case TextureFormat::ASTC_2D_8X8: |
| 204 | case TextureFormat::ASTC_2D_8X5: | 204 | case TextureFormat::ASTC_2D_8X5: |
| 205 | case TextureFormat::ASTC_2D_10X8: | ||
| 206 | case TextureFormat::ASTC_2D_5X5: | ||
| 205 | case TextureFormat::A8R8G8B8: | 207 | case TextureFormat::A8R8G8B8: |
| 206 | case TextureFormat::A2B10G10R10: | 208 | case TextureFormat::A2B10G10R10: |
| 207 | case TextureFormat::BF10GF11RF11: | 209 | case TextureFormat::BF10GF11RF11: |
| @@ -294,6 +296,8 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat | |||
| 294 | case TextureFormat::BC6H_SF16: | 296 | case TextureFormat::BC6H_SF16: |
| 295 | case TextureFormat::ASTC_2D_4X4: | 297 | case TextureFormat::ASTC_2D_4X4: |
| 296 | case TextureFormat::ASTC_2D_8X8: | 298 | case TextureFormat::ASTC_2D_8X8: |
| 299 | case TextureFormat::ASTC_2D_5X5: | ||
| 300 | case TextureFormat::ASTC_2D_10X8: | ||
| 297 | case TextureFormat::A8R8G8B8: | 301 | case TextureFormat::A8R8G8B8: |
| 298 | case TextureFormat::A2B10G10R10: | 302 | case TextureFormat::A2B10G10R10: |
| 299 | case TextureFormat::A1B5G5R5: | 303 | case TextureFormat::A1B5G5R5: |