diff options
| -rw-r--r-- | src/video_core/morton.cpp | 315 | ||||
| -rw-r--r-- | src/video_core/morton.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 8 |
4 files changed, 146 insertions, 187 deletions
diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp index b68f4fb13..9692ce143 100644 --- a/src/video_core/morton.cpp +++ b/src/video_core/morton.cpp | |||
| @@ -16,12 +16,12 @@ namespace VideoCore { | |||
| 16 | using Surface::GetBytesPerPixel; | 16 | using Surface::GetBytesPerPixel; |
| 17 | using Surface::PixelFormat; | 17 | using Surface::PixelFormat; |
| 18 | 18 | ||
| 19 | using MortonCopyFn = void (*)(u32, u32, u32, u32, u32, u32, u8*, std::size_t, VAddr); | 19 | using MortonCopyFn = void (*)(u32, u32, u32, u32, u32, u32, u8*, VAddr); |
| 20 | using ConversionArray = std::array<MortonCopyFn, Surface::MaxPixelFormat>; | 20 | using ConversionArray = std::array<MortonCopyFn, Surface::MaxPixelFormat>; |
| 21 | 21 | ||
| 22 | template <bool morton_to_linear, PixelFormat format> | 22 | template <bool morton_to_linear, PixelFormat format> |
| 23 | static void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 depth, | 23 | static void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 depth, |
| 24 | u32 tile_width_spacing, u8* buffer, std::size_t buffer_size, VAddr addr) { | 24 | u32 tile_width_spacing, u8* buffer, VAddr addr) { |
| 25 | constexpr u32 bytes_per_pixel = GetBytesPerPixel(format); | 25 | constexpr u32 bytes_per_pixel = GetBytesPerPixel(format); |
| 26 | 26 | ||
| 27 | // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual | 27 | // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual |
| @@ -42,142 +42,138 @@ static void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static constexpr ConversionArray morton_to_linear_fns = { | 44 | static constexpr ConversionArray morton_to_linear_fns = { |
| 45 | // clang-format off | 45 | MortonCopy<true, PixelFormat::ABGR8U>, |
| 46 | MortonCopy<true, PixelFormat::ABGR8U>, | 46 | MortonCopy<true, PixelFormat::ABGR8S>, |
| 47 | MortonCopy<true, PixelFormat::ABGR8S>, | 47 | MortonCopy<true, PixelFormat::ABGR8UI>, |
| 48 | MortonCopy<true, PixelFormat::ABGR8UI>, | 48 | MortonCopy<true, PixelFormat::B5G6R5U>, |
| 49 | MortonCopy<true, PixelFormat::B5G6R5U>, | 49 | MortonCopy<true, PixelFormat::A2B10G10R10U>, |
| 50 | MortonCopy<true, PixelFormat::A2B10G10R10U>, | 50 | MortonCopy<true, PixelFormat::A1B5G5R5U>, |
| 51 | MortonCopy<true, PixelFormat::A1B5G5R5U>, | 51 | MortonCopy<true, PixelFormat::R8U>, |
| 52 | MortonCopy<true, PixelFormat::R8U>, | 52 | MortonCopy<true, PixelFormat::R8UI>, |
| 53 | MortonCopy<true, PixelFormat::R8UI>, | 53 | MortonCopy<true, PixelFormat::RGBA16F>, |
| 54 | MortonCopy<true, PixelFormat::RGBA16F>, | 54 | MortonCopy<true, PixelFormat::RGBA16U>, |
| 55 | MortonCopy<true, PixelFormat::RGBA16U>, | 55 | MortonCopy<true, PixelFormat::RGBA16UI>, |
| 56 | MortonCopy<true, PixelFormat::RGBA16UI>, | 56 | MortonCopy<true, PixelFormat::R11FG11FB10F>, |
| 57 | MortonCopy<true, PixelFormat::R11FG11FB10F>, | 57 | MortonCopy<true, PixelFormat::RGBA32UI>, |
| 58 | MortonCopy<true, PixelFormat::RGBA32UI>, | 58 | MortonCopy<true, PixelFormat::DXT1>, |
| 59 | MortonCopy<true, PixelFormat::DXT1>, | 59 | MortonCopy<true, PixelFormat::DXT23>, |
| 60 | MortonCopy<true, PixelFormat::DXT23>, | 60 | MortonCopy<true, PixelFormat::DXT45>, |
| 61 | MortonCopy<true, PixelFormat::DXT45>, | 61 | MortonCopy<true, PixelFormat::DXN1>, |
| 62 | MortonCopy<true, PixelFormat::DXN1>, | 62 | MortonCopy<true, PixelFormat::DXN2UNORM>, |
| 63 | MortonCopy<true, PixelFormat::DXN2UNORM>, | 63 | MortonCopy<true, PixelFormat::DXN2SNORM>, |
| 64 | MortonCopy<true, PixelFormat::DXN2SNORM>, | 64 | MortonCopy<true, PixelFormat::BC7U>, |
| 65 | MortonCopy<true, PixelFormat::BC7U>, | 65 | MortonCopy<true, PixelFormat::BC6H_UF16>, |
| 66 | MortonCopy<true, PixelFormat::BC6H_UF16>, | 66 | MortonCopy<true, PixelFormat::BC6H_SF16>, |
| 67 | MortonCopy<true, PixelFormat::BC6H_SF16>, | 67 | MortonCopy<true, PixelFormat::ASTC_2D_4X4>, |
| 68 | MortonCopy<true, PixelFormat::ASTC_2D_4X4>, | 68 | MortonCopy<true, PixelFormat::BGRA8>, |
| 69 | MortonCopy<true, PixelFormat::BGRA8>, | 69 | MortonCopy<true, PixelFormat::RGBA32F>, |
| 70 | MortonCopy<true, PixelFormat::RGBA32F>, | 70 | MortonCopy<true, PixelFormat::RG32F>, |
| 71 | MortonCopy<true, PixelFormat::RG32F>, | 71 | MortonCopy<true, PixelFormat::R32F>, |
| 72 | MortonCopy<true, PixelFormat::R32F>, | 72 | MortonCopy<true, PixelFormat::R16F>, |
| 73 | MortonCopy<true, PixelFormat::R16F>, | 73 | MortonCopy<true, PixelFormat::R16U>, |
| 74 | MortonCopy<true, PixelFormat::R16U>, | 74 | MortonCopy<true, PixelFormat::R16S>, |
| 75 | MortonCopy<true, PixelFormat::R16S>, | 75 | MortonCopy<true, PixelFormat::R16UI>, |
| 76 | MortonCopy<true, PixelFormat::R16UI>, | 76 | MortonCopy<true, PixelFormat::R16I>, |
| 77 | MortonCopy<true, PixelFormat::R16I>, | 77 | MortonCopy<true, PixelFormat::RG16>, |
| 78 | MortonCopy<true, PixelFormat::RG16>, | 78 | MortonCopy<true, PixelFormat::RG16F>, |
| 79 | MortonCopy<true, PixelFormat::RG16F>, | 79 | MortonCopy<true, PixelFormat::RG16UI>, |
| 80 | MortonCopy<true, PixelFormat::RG16UI>, | 80 | MortonCopy<true, PixelFormat::RG16I>, |
| 81 | MortonCopy<true, PixelFormat::RG16I>, | 81 | MortonCopy<true, PixelFormat::RG16S>, |
| 82 | MortonCopy<true, PixelFormat::RG16S>, | 82 | MortonCopy<true, PixelFormat::RGB32F>, |
| 83 | MortonCopy<true, PixelFormat::RGB32F>, | 83 | MortonCopy<true, PixelFormat::RGBA8_SRGB>, |
| 84 | MortonCopy<true, PixelFormat::RGBA8_SRGB>, | 84 | MortonCopy<true, PixelFormat::RG8U>, |
| 85 | MortonCopy<true, PixelFormat::RG8U>, | 85 | MortonCopy<true, PixelFormat::RG8S>, |
| 86 | MortonCopy<true, PixelFormat::RG8S>, | 86 | MortonCopy<true, PixelFormat::RG32UI>, |
| 87 | MortonCopy<true, PixelFormat::RG32UI>, | 87 | MortonCopy<true, PixelFormat::R32UI>, |
| 88 | MortonCopy<true, PixelFormat::R32UI>, | 88 | MortonCopy<true, PixelFormat::ASTC_2D_8X8>, |
| 89 | MortonCopy<true, PixelFormat::ASTC_2D_8X8>, | 89 | MortonCopy<true, PixelFormat::ASTC_2D_8X5>, |
| 90 | MortonCopy<true, PixelFormat::ASTC_2D_8X5>, | 90 | MortonCopy<true, PixelFormat::ASTC_2D_5X4>, |
| 91 | MortonCopy<true, PixelFormat::ASTC_2D_5X4>, | 91 | MortonCopy<true, PixelFormat::BGRA8_SRGB>, |
| 92 | MortonCopy<true, PixelFormat::BGRA8_SRGB>, | 92 | MortonCopy<true, PixelFormat::DXT1_SRGB>, |
| 93 | MortonCopy<true, PixelFormat::DXT1_SRGB>, | 93 | MortonCopy<true, PixelFormat::DXT23_SRGB>, |
| 94 | MortonCopy<true, PixelFormat::DXT23_SRGB>, | 94 | MortonCopy<true, PixelFormat::DXT45_SRGB>, |
| 95 | MortonCopy<true, PixelFormat::DXT45_SRGB>, | 95 | MortonCopy<true, PixelFormat::BC7U_SRGB>, |
| 96 | MortonCopy<true, PixelFormat::BC7U_SRGB>, | 96 | MortonCopy<true, PixelFormat::ASTC_2D_4X4_SRGB>, |
| 97 | MortonCopy<true, PixelFormat::ASTC_2D_4X4_SRGB>, | 97 | MortonCopy<true, PixelFormat::ASTC_2D_8X8_SRGB>, |
| 98 | MortonCopy<true, PixelFormat::ASTC_2D_8X8_SRGB>, | 98 | MortonCopy<true, PixelFormat::ASTC_2D_8X5_SRGB>, |
| 99 | MortonCopy<true, PixelFormat::ASTC_2D_8X5_SRGB>, | 99 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, |
| 100 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, | 100 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, |
| 101 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, | 101 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, |
| 102 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, | 102 | MortonCopy<true, PixelFormat::ASTC_2D_10X8>, |
| 103 | MortonCopy<true, PixelFormat::ASTC_2D_10X8>, | 103 | MortonCopy<true, PixelFormat::ASTC_2D_10X8_SRGB>, |
| 104 | MortonCopy<true, PixelFormat::ASTC_2D_10X8_SRGB>, | 104 | MortonCopy<true, PixelFormat::Z32F>, |
| 105 | MortonCopy<true, PixelFormat::Z32F>, | 105 | MortonCopy<true, PixelFormat::Z16>, |
| 106 | MortonCopy<true, PixelFormat::Z16>, | 106 | MortonCopy<true, PixelFormat::Z24S8>, |
| 107 | MortonCopy<true, PixelFormat::Z24S8>, | 107 | MortonCopy<true, PixelFormat::S8Z24>, |
| 108 | MortonCopy<true, PixelFormat::S8Z24>, | 108 | MortonCopy<true, PixelFormat::Z32FS8>, |
| 109 | MortonCopy<true, PixelFormat::Z32FS8>, | ||
| 110 | // clang-format on | ||
| 111 | }; | 109 | }; |
| 112 | 110 | ||
| 113 | static constexpr ConversionArray linear_to_morton_fns = { | 111 | static constexpr ConversionArray linear_to_morton_fns = { |
| 114 | // clang-format off | 112 | MortonCopy<false, PixelFormat::ABGR8U>, |
| 115 | MortonCopy<false, PixelFormat::ABGR8U>, | 113 | MortonCopy<false, PixelFormat::ABGR8S>, |
| 116 | MortonCopy<false, PixelFormat::ABGR8S>, | 114 | MortonCopy<false, PixelFormat::ABGR8UI>, |
| 117 | MortonCopy<false, PixelFormat::ABGR8UI>, | 115 | MortonCopy<false, PixelFormat::B5G6R5U>, |
| 118 | MortonCopy<false, PixelFormat::B5G6R5U>, | 116 | MortonCopy<false, PixelFormat::A2B10G10R10U>, |
| 119 | MortonCopy<false, PixelFormat::A2B10G10R10U>, | 117 | MortonCopy<false, PixelFormat::A1B5G5R5U>, |
| 120 | MortonCopy<false, PixelFormat::A1B5G5R5U>, | 118 | MortonCopy<false, PixelFormat::R8U>, |
| 121 | MortonCopy<false, PixelFormat::R8U>, | 119 | MortonCopy<false, PixelFormat::R8UI>, |
| 122 | MortonCopy<false, PixelFormat::R8UI>, | 120 | MortonCopy<false, PixelFormat::RGBA16F>, |
| 123 | MortonCopy<false, PixelFormat::RGBA16F>, | 121 | MortonCopy<false, PixelFormat::RGBA16U>, |
| 124 | MortonCopy<false, PixelFormat::RGBA16U>, | 122 | MortonCopy<false, PixelFormat::RGBA16UI>, |
| 125 | MortonCopy<false, PixelFormat::RGBA16UI>, | 123 | MortonCopy<false, PixelFormat::R11FG11FB10F>, |
| 126 | MortonCopy<false, PixelFormat::R11FG11FB10F>, | 124 | MortonCopy<false, PixelFormat::RGBA32UI>, |
| 127 | MortonCopy<false, PixelFormat::RGBA32UI>, | 125 | MortonCopy<false, PixelFormat::DXT1>, |
| 128 | MortonCopy<false, PixelFormat::DXT1>, | 126 | MortonCopy<false, PixelFormat::DXT23>, |
| 129 | MortonCopy<false, PixelFormat::DXT23>, | 127 | MortonCopy<false, PixelFormat::DXT45>, |
| 130 | MortonCopy<false, PixelFormat::DXT45>, | 128 | MortonCopy<false, PixelFormat::DXN1>, |
| 131 | MortonCopy<false, PixelFormat::DXN1>, | 129 | MortonCopy<false, PixelFormat::DXN2UNORM>, |
| 132 | MortonCopy<false, PixelFormat::DXN2UNORM>, | 130 | MortonCopy<false, PixelFormat::DXN2SNORM>, |
| 133 | MortonCopy<false, PixelFormat::DXN2SNORM>, | 131 | MortonCopy<false, PixelFormat::BC7U>, |
| 134 | MortonCopy<false, PixelFormat::BC7U>, | 132 | MortonCopy<false, PixelFormat::BC6H_UF16>, |
| 135 | MortonCopy<false, PixelFormat::BC6H_UF16>, | 133 | MortonCopy<false, PixelFormat::BC6H_SF16>, |
| 136 | MortonCopy<false, PixelFormat::BC6H_SF16>, | 134 | // TODO(Subv): Swizzling ASTC formats are not supported |
| 137 | // TODO(Subv): Swizzling ASTC formats are not supported | 135 | nullptr, |
| 138 | nullptr, | 136 | MortonCopy<false, PixelFormat::BGRA8>, |
| 139 | MortonCopy<false, PixelFormat::BGRA8>, | 137 | MortonCopy<false, PixelFormat::RGBA32F>, |
| 140 | MortonCopy<false, PixelFormat::RGBA32F>, | 138 | MortonCopy<false, PixelFormat::RG32F>, |
| 141 | MortonCopy<false, PixelFormat::RG32F>, | 139 | MortonCopy<false, PixelFormat::R32F>, |
| 142 | MortonCopy<false, PixelFormat::R32F>, | 140 | MortonCopy<false, PixelFormat::R16F>, |
| 143 | MortonCopy<false, PixelFormat::R16F>, | 141 | MortonCopy<false, PixelFormat::R16U>, |
| 144 | MortonCopy<false, PixelFormat::R16U>, | 142 | MortonCopy<false, PixelFormat::R16S>, |
| 145 | MortonCopy<false, PixelFormat::R16S>, | 143 | MortonCopy<false, PixelFormat::R16UI>, |
| 146 | MortonCopy<false, PixelFormat::R16UI>, | 144 | MortonCopy<false, PixelFormat::R16I>, |
| 147 | MortonCopy<false, PixelFormat::R16I>, | 145 | MortonCopy<false, PixelFormat::RG16>, |
| 148 | MortonCopy<false, PixelFormat::RG16>, | 146 | MortonCopy<false, PixelFormat::RG16F>, |
| 149 | MortonCopy<false, PixelFormat::RG16F>, | 147 | MortonCopy<false, PixelFormat::RG16UI>, |
| 150 | MortonCopy<false, PixelFormat::RG16UI>, | 148 | MortonCopy<false, PixelFormat::RG16I>, |
| 151 | MortonCopy<false, PixelFormat::RG16I>, | 149 | MortonCopy<false, PixelFormat::RG16S>, |
| 152 | MortonCopy<false, PixelFormat::RG16S>, | 150 | MortonCopy<false, PixelFormat::RGB32F>, |
| 153 | MortonCopy<false, PixelFormat::RGB32F>, | 151 | MortonCopy<false, PixelFormat::RGBA8_SRGB>, |
| 154 | MortonCopy<false, PixelFormat::RGBA8_SRGB>, | 152 | MortonCopy<false, PixelFormat::RG8U>, |
| 155 | MortonCopy<false, PixelFormat::RG8U>, | 153 | MortonCopy<false, PixelFormat::RG8S>, |
| 156 | MortonCopy<false, PixelFormat::RG8S>, | 154 | MortonCopy<false, PixelFormat::RG32UI>, |
| 157 | MortonCopy<false, PixelFormat::RG32UI>, | 155 | MortonCopy<false, PixelFormat::R32UI>, |
| 158 | MortonCopy<false, PixelFormat::R32UI>, | 156 | nullptr, |
| 159 | nullptr, | 157 | nullptr, |
| 160 | nullptr, | 158 | nullptr, |
| 161 | nullptr, | 159 | MortonCopy<false, PixelFormat::BGRA8_SRGB>, |
| 162 | MortonCopy<false, PixelFormat::BGRA8_SRGB>, | 160 | MortonCopy<false, PixelFormat::DXT1_SRGB>, |
| 163 | MortonCopy<false, PixelFormat::DXT1_SRGB>, | 161 | MortonCopy<false, PixelFormat::DXT23_SRGB>, |
| 164 | MortonCopy<false, PixelFormat::DXT23_SRGB>, | 162 | MortonCopy<false, PixelFormat::DXT45_SRGB>, |
| 165 | MortonCopy<false, PixelFormat::DXT45_SRGB>, | 163 | MortonCopy<false, PixelFormat::BC7U_SRGB>, |
| 166 | MortonCopy<false, PixelFormat::BC7U_SRGB>, | 164 | nullptr, |
| 167 | nullptr, | 165 | nullptr, |
| 168 | nullptr, | 166 | nullptr, |
| 169 | nullptr, | 167 | nullptr, |
| 170 | nullptr, | 168 | nullptr, |
| 171 | nullptr, | 169 | nullptr, |
| 172 | nullptr, | 170 | nullptr, |
| 173 | nullptr, | 171 | nullptr, |
| 174 | nullptr, | 172 | MortonCopy<false, PixelFormat::Z32F>, |
| 175 | MortonCopy<false, PixelFormat::Z32F>, | 173 | MortonCopy<false, PixelFormat::Z16>, |
| 176 | MortonCopy<false, PixelFormat::Z16>, | 174 | MortonCopy<false, PixelFormat::Z24S8>, |
| 177 | MortonCopy<false, PixelFormat::Z24S8>, | 175 | MortonCopy<false, PixelFormat::S8Z24>, |
| 178 | MortonCopy<false, PixelFormat::S8Z24>, | 176 | MortonCopy<false, PixelFormat::Z32FS8>, |
| 179 | MortonCopy<false, PixelFormat::Z32FS8>, | ||
| 180 | // clang-format on | ||
| 181 | }; | 177 | }; |
| 182 | 178 | ||
| 183 | static MortonCopyFn GetSwizzleFunction(MortonSwizzleMode mode, Surface::PixelFormat format) { | 179 | static MortonCopyFn GetSwizzleFunction(MortonSwizzleMode mode, Surface::PixelFormat format) { |
| @@ -191,45 +187,6 @@ static MortonCopyFn GetSwizzleFunction(MortonSwizzleMode mode, Surface::PixelFor | |||
| 191 | return morton_to_linear_fns[static_cast<std::size_t>(format)]; | 187 | return morton_to_linear_fns[static_cast<std::size_t>(format)]; |
| 192 | } | 188 | } |
| 193 | 189 | ||
| 194 | /// 8x8 Z-Order coordinate from 2D coordinates | ||
| 195 | static u32 MortonInterleave(u32 x, u32 y) { | ||
| 196 | static const u32 xlut[] = {0x00, 0x01, 0x04, 0x05, 0x10, 0x11, 0x14, 0x15}; | ||
| 197 | static const u32 ylut[] = {0x00, 0x02, 0x08, 0x0a, 0x20, 0x22, 0x28, 0x2a}; | ||
| 198 | return xlut[x % 8] + ylut[y % 8]; | ||
| 199 | } | ||
| 200 | |||
| 201 | /// Calculates the offset of the position of the pixel in Morton order | ||
| 202 | static u32 GetMortonOffset(u32 x, u32 y, u32 bytes_per_pixel) { | ||
| 203 | // Images are split into 8x8 tiles. Each tile is composed of four 4x4 subtiles each | ||
| 204 | // of which is composed of four 2x2 subtiles each of which is composed of four texels. | ||
| 205 | // Each structure is embedded into the next-bigger one in a diagonal pattern, e.g. | ||
| 206 | // texels are laid out in a 2x2 subtile like this: | ||
| 207 | // 2 3 | ||
| 208 | // 0 1 | ||
| 209 | // | ||
| 210 | // The full 8x8 tile has the texels arranged like this: | ||
| 211 | // | ||
| 212 | // 42 43 46 47 58 59 62 63 | ||
| 213 | // 40 41 44 45 56 57 60 61 | ||
| 214 | // 34 35 38 39 50 51 54 55 | ||
| 215 | // 32 33 36 37 48 49 52 53 | ||
| 216 | // 10 11 14 15 26 27 30 31 | ||
| 217 | // 08 09 12 13 24 25 28 29 | ||
| 218 | // 02 03 06 07 18 19 22 23 | ||
| 219 | // 00 01 04 05 16 17 20 21 | ||
| 220 | // | ||
| 221 | // This pattern is what's called Z-order curve, or Morton order. | ||
| 222 | |||
| 223 | const unsigned int block_height = 8; | ||
| 224 | const unsigned int coarse_x = x & ~7; | ||
| 225 | |||
| 226 | u32 i = MortonInterleave(x, y); | ||
| 227 | |||
| 228 | const unsigned int offset = coarse_x * block_height; | ||
| 229 | |||
| 230 | return (i + offset) * bytes_per_pixel; | ||
| 231 | } | ||
| 232 | |||
| 233 | static u32 MortonInterleave128(u32 x, u32 y) { | 190 | static u32 MortonInterleave128(u32 x, u32 y) { |
| 234 | // 128x128 Z-Order coordinate from 2D coordinates | 191 | // 128x128 Z-Order coordinate from 2D coordinates |
| 235 | static constexpr u32 xlut[] = { | 192 | static constexpr u32 xlut[] = { |
| @@ -325,14 +282,14 @@ static u32 GetMortonOffset128(u32 x, u32 y, u32 bytes_per_pixel) { | |||
| 325 | 282 | ||
| 326 | void MortonSwizzle(MortonSwizzleMode mode, Surface::PixelFormat format, u32 stride, | 283 | void MortonSwizzle(MortonSwizzleMode mode, Surface::PixelFormat format, u32 stride, |
| 327 | u32 block_height, u32 height, u32 block_depth, u32 depth, u32 tile_width_spacing, | 284 | u32 block_height, u32 height, u32 block_depth, u32 depth, u32 tile_width_spacing, |
| 328 | u8* buffer, std::size_t buffer_size, VAddr addr) { | 285 | u8* buffer, VAddr addr) { |
| 329 | |||
| 330 | GetSwizzleFunction(mode, format)(stride, block_height, height, block_depth, depth, | 286 | GetSwizzleFunction(mode, format)(stride, block_height, height, block_depth, depth, |
| 331 | tile_width_spacing, buffer, buffer_size, addr); | 287 | tile_width_spacing, buffer, addr); |
| 332 | } | 288 | } |
| 333 | 289 | ||
| 334 | void MortonCopyPixels128(u32 width, u32 height, u32 bytes_per_pixel, u32 linear_bytes_per_pixel, | 290 | void MortonCopyPixels128(MortonSwizzleMode mode, u32 width, u32 height, u32 bytes_per_pixel, |
| 335 | u8* morton_data, u8* linear_data, bool morton_to_linear) { | 291 | u32 linear_bytes_per_pixel, u8* morton_data, u8* linear_data) { |
| 292 | const bool morton_to_linear = mode == MortonSwizzleMode::MortonToLinear; | ||
| 336 | u8* data_ptrs[2]; | 293 | u8* data_ptrs[2]; |
| 337 | for (u32 y = 0; y < height; ++y) { | 294 | for (u32 y = 0; y < height; ++y) { |
| 338 | for (u32 x = 0; x < width; ++x) { | 295 | for (u32 x = 0; x < width; ++x) { |
diff --git a/src/video_core/morton.h b/src/video_core/morton.h index 065f59ce3..b565204b5 100644 --- a/src/video_core/morton.h +++ b/src/video_core/morton.h | |||
| @@ -13,9 +13,9 @@ enum class MortonSwizzleMode { MortonToLinear, LinearToMorton }; | |||
| 13 | 13 | ||
| 14 | void MortonSwizzle(MortonSwizzleMode mode, VideoCore::Surface::PixelFormat format, u32 stride, | 14 | void MortonSwizzle(MortonSwizzleMode mode, VideoCore::Surface::PixelFormat format, u32 stride, |
| 15 | u32 block_height, u32 height, u32 block_depth, u32 depth, u32 tile_width_spacing, | 15 | u32 block_height, u32 height, u32 block_depth, u32 depth, u32 tile_width_spacing, |
| 16 | u8* buffer, std::size_t buffer_size, VAddr addr); | 16 | u8* buffer, VAddr addr); |
| 17 | 17 | ||
| 18 | void MortonCopyPixels128(u32 width, u32 height, u32 bytes_per_pixel, u32 linear_bytes_per_pixel, | 18 | void MortonCopyPixels128(MortonSwizzleMode mode, u32 width, u32 height, u32 bytes_per_pixel, |
| 19 | u8* morton_data, u8* linear_data, bool morton_to_linear); | 19 | u32 linear_bytes_per_pixel, u8* morton_data, u8* linear_data); |
| 20 | 20 | ||
| 21 | } // namespace VideoCore | 21 | } // namespace VideoCore |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index e9eb6e921..bd1409660 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -446,7 +446,7 @@ void SwizzleFunc(const MortonSwizzleMode& mode, const SurfaceParams& params, | |||
| 446 | MortonSwizzle(mode, params.pixel_format, params.MipWidth(mip_level), | 446 | MortonSwizzle(mode, params.pixel_format, params.MipWidth(mip_level), |
| 447 | params.MipBlockHeight(mip_level), params.MipHeight(mip_level), | 447 | params.MipBlockHeight(mip_level), params.MipHeight(mip_level), |
| 448 | params.MipBlockDepth(mip_level), 1, params.tile_width_spacing, | 448 | params.MipBlockDepth(mip_level), 1, params.tile_width_spacing, |
| 449 | gl_buffer.data() + offset_gl, gl_size, params.addr + offset); | 449 | gl_buffer.data() + offset_gl, params.addr + offset); |
| 450 | offset += layer_size; | 450 | offset += layer_size; |
| 451 | offset_gl += gl_size; | 451 | offset_gl += gl_size; |
| 452 | } | 452 | } |
| @@ -455,7 +455,7 @@ void SwizzleFunc(const MortonSwizzleMode& mode, const SurfaceParams& params, | |||
| 455 | MortonSwizzle(mode, params.pixel_format, params.MipWidth(mip_level), | 455 | MortonSwizzle(mode, params.pixel_format, params.MipWidth(mip_level), |
| 456 | params.MipBlockHeight(mip_level), params.MipHeight(mip_level), | 456 | params.MipBlockHeight(mip_level), params.MipHeight(mip_level), |
| 457 | params.MipBlockDepth(mip_level), depth, params.tile_width_spacing, | 457 | params.MipBlockDepth(mip_level), depth, params.tile_width_spacing, |
| 458 | gl_buffer.data(), gl_buffer.size(), params.addr + offset); | 458 | gl_buffer.data(), params.addr + offset); |
| 459 | } | 459 | } |
| 460 | } | 460 | } |
| 461 | 461 | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 8b510b6ae..b97576309 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -167,9 +167,11 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf | |||
| 167 | Memory::RasterizerFlushVirtualRegion(framebuffer_addr, size_in_bytes, | 167 | Memory::RasterizerFlushVirtualRegion(framebuffer_addr, size_in_bytes, |
| 168 | Memory::FlushMode::Flush); | 168 | Memory::FlushMode::Flush); |
| 169 | 169 | ||
| 170 | VideoCore::MortonCopyPixels128(framebuffer.width, framebuffer.height, bytes_per_pixel, 4, | 170 | constexpr u32 linear_bpp = 4; |
| 171 | Memory::GetPointer(framebuffer_addr), | 171 | VideoCore::MortonCopyPixels128(VideoCore::MortonSwizzleMode::MortonToLinear, |
| 172 | gl_framebuffer_data.data(), true); | 172 | framebuffer.width, framebuffer.height, bytes_per_pixel, |
| 173 | linear_bpp, Memory::GetPointer(framebuffer_addr), | ||
| 174 | gl_framebuffer_data.data()); | ||
| 173 | 175 | ||
| 174 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(framebuffer.stride)); | 176 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(framebuffer.stride)); |
| 175 | 177 | ||