From ab4962c4e446024d248b93d62e1dda1a9e837e2e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 12 Jan 2022 20:50:50 +0000 Subject: [PATCH] Implement additional texture formats, including BCn BCeNabler is required for BCn textures, the pre-swizzled formats will be removed when arbitary swizzle support is added later. --- .../gpu/interconnect/graphics_context.h | 4 ++ app/src/main/cpp/skyline/gpu/texture/format.h | 42 +++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h index e0e207fd..a1bd9780 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -1675,6 +1675,7 @@ namespace skyline::gpu::interconnect { TIC_FORMAT_CASE_ST(ticFormat, skFormat, Float, swizzleX, swizzleY, swizzleZ, swizzleW) switch (format.Raw()) { + TIC_FORMAT_CASE_NORM_INT(R8, R8R001, R, Zero, Zero, OneFloat); TIC_FORMAT_CASE_ST(B5G6R5, R5G6B5, Unorm, B, G, R, OneFloat); TIC_FORMAT_CASE_NORM_INT(A8R8G8B8, R8G8B8A8, R, G, B, A); TIC_FORMAT_CASE_NORM_INT(A8R8G8B8, A8B8G8R8, A, R, G, B); @@ -1682,6 +1683,9 @@ namespace skyline::gpu::interconnect { TIC_FORMAT_CASE_NORM_INT_FLOAT(R16G16B16A16, R16G16B16A16, R, G, B, A); TIC_FORMAT_CASE_NORM_INT(A2B10G10R10, A2B10G10R10, R, G, B, A); TIC_FORMAT_CASE_ST(Astc4x4, Astc4x4, Unorm, R, G, B, A); + TIC_FORMAT_CASE_ST(Dxt1, Bc1, Unorm, R, G, B, A); + TIC_FORMAT_CASE_ST(Dxn1, Bc4111R, Unorm, OneFloat, OneFloat, OneFloat, R); + TIC_FORMAT_CASE_ST(Dxn1, Bc4RRR1, Unorm, R, R, R, OneFloat); default: throw exception("Cannot translate TIC format: 0x{:X}", static_cast(format.Raw())); diff --git a/app/src/main/cpp/skyline/gpu/texture/format.h b/app/src/main/cpp/skyline/gpu/texture/format.h index eaa79077..c4ed542f 100644 --- a/app/src/main/cpp/skyline/gpu/texture/format.h +++ b/app/src/main/cpp/skyline/gpu/texture/format.h @@ -32,11 +32,15 @@ namespace skyline::gpu::format { #define FORMAT_INT_FLOAT(name, bitsPerBlock, format, ...) \ FORMAT_SUFF_INT_FLOAT(name, bitsPerBlock, format,, ##__VA_ARGS__) - #define FORMAT_SUFF_NORM_INT(name, bitsPerBlock, format, fmtSuffix, ...) \ - FORMAT_SUFF_INT(name, bitsPerBlock, format, fmtSuffix, ##__VA_ARGS__); \ + #define FORMAT_SUFF_NORM(name, bitsPerBlock, format, fmtSuffix, ...) \ FORMAT(name ## Unorm, bitsPerBlock, format ## Unorm ## fmtSuffix, ##__VA_ARGS__); \ FORMAT(name ## Snorm, bitsPerBlock, format ## Snorm ## fmtSuffix, ##__VA_ARGS__) + #define FORMAT_SUFF_NORM_INT(name, bitsPerBlock, format, fmtSuffix, ...) \ + FORMAT_SUFF_INT(name, bitsPerBlock, format, fmtSuffix, ##__VA_ARGS__); \ + FORMAT_SUFF_NORM(name, bitsPerBlock, format, fmtSuffix, ##__VA_ARGS__) + + #define FORMAT_NORM_INT(name, bitsPerBlock, format, ...) \ FORMAT_SUFF_NORM_INT(name, bitsPerBlock, format,, ##__VA_ARGS__) @@ -58,6 +62,8 @@ namespace skyline::gpu::format { // Color formats FORMAT_NORM_INT_SRGB(R8, 8, eR8); + FORMAT_NORM_INT_SRGB(R8R001, 8, eR8); + FORMAT_NORM_INT_FLOAT(R16, 16, eR16); FORMAT_NORM_INT_SRGB(R8G8, 16, eR8G8); FORMAT(R5G6B5Unorm, 16, eR5G6B5UnormPack16); @@ -90,7 +96,37 @@ namespace skyline::gpu::format { }); // Compressed Colour Formats - FORMAT_SUFF_UNORM_SRGB(Astc4x4, 128, eAstc4x4, Block); + FORMAT_SUFF_UNORM_SRGB(Bc1, 64, eBc1Rgba, Block, + .blockWidth = 4, + .blockHeight = 4 + ); + + FORMAT_SUFF_NORM(Bc4111R, 64, eBc4, Block, + .blockWidth = 4, + .blockHeight = 4, + .swizzle = { + .red = swc::One, + .green = swc::One, + .blue = swc::One, + .alpha = swc::Red + } + ); + + FORMAT_SUFF_NORM(Bc4RRR1, 64, eBc4, Block, + .blockWidth = 4, + .blockHeight = 4, + .swizzle = { + .red = swc::Red, + .green = swc::Red, + .blue = swc::Red, + .alpha = swc::One + } + ); + + FORMAT_SUFF_UNORM_SRGB(Astc4x4, 128, eAstc4x4, Block, + .blockWidth = 4, + .blockHeight = 4 + ); // Depth/Stencil Formats FORMAT(D32Float, 32, eD32Sfloat, vka::eDepth);