diff options
| author | 2017-02-08 22:07:34 -0800 | |
|---|---|---|
| committer | 2017-02-08 22:07:34 -0800 | |
| commit | 2889372e47624e368df0d0361cb38b8100f047dd (patch) | |
| tree | 183cd1cd6edb60ab566bd1fe181b712643bef30c /src/video_core/texture | |
| parent | Merge pull request #2539 from Kloen/re-killing-warnings (diff) | |
| parent | VideoCore: Move Regs to its own file (diff) | |
| download | yuzu-2889372e47624e368df0d0361cb38b8100f047dd.tar.gz yuzu-2889372e47624e368df0d0361cb38b8100f047dd.tar.xz yuzu-2889372e47624e368df0d0361cb38b8100f047dd.zip | |
Merge pull request #2482 from yuriks/pica-refactor
Split up monolithic Regs struct
Diffstat (limited to 'src/video_core/texture')
| -rw-r--r-- | src/video_core/texture/texture_decode.cpp | 38 | ||||
| -rw-r--r-- | src/video_core/texture/texture_decode.h | 12 |
2 files changed, 25 insertions, 25 deletions
diff --git a/src/video_core/texture/texture_decode.cpp b/src/video_core/texture/texture_decode.cpp index f611a1aa9..40d363184 100644 --- a/src/video_core/texture/texture_decode.cpp +++ b/src/video_core/texture/texture_decode.cpp | |||
| @@ -10,12 +10,12 @@ | |||
| 10 | #include "common/math_util.h" | 10 | #include "common/math_util.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "common/vector_math.h" | 12 | #include "common/vector_math.h" |
| 13 | #include "video_core/pica.h" | 13 | #include "video_core/regs_texturing.h" |
| 14 | #include "video_core/texture/etc1.h" | 14 | #include "video_core/texture/etc1.h" |
| 15 | #include "video_core/texture/texture_decode.h" | 15 | #include "video_core/texture/texture_decode.h" |
| 16 | #include "video_core/utils.h" | 16 | #include "video_core/utils.h" |
| 17 | 17 | ||
| 18 | using TextureFormat = Pica::Regs::TextureFormat; | 18 | using TextureFormat = Pica::TexturingRegs::TextureFormat; |
| 19 | 19 | ||
| 20 | namespace Pica { | 20 | namespace Pica { |
| 21 | namespace Texture { | 21 | namespace Texture { |
| @@ -82,32 +82,32 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 82 | using VideoCore::MortonInterleave; | 82 | using VideoCore::MortonInterleave; |
| 83 | 83 | ||
| 84 | switch (info.format) { | 84 | switch (info.format) { |
| 85 | case Regs::TextureFormat::RGBA8: { | 85 | case TextureFormat::RGBA8: { |
| 86 | auto res = Color::DecodeRGBA8(source + MortonInterleave(x, y) * 4); | 86 | auto res = Color::DecodeRGBA8(source + MortonInterleave(x, y) * 4); |
| 87 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; | 87 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | case Regs::TextureFormat::RGB8: { | 90 | case TextureFormat::RGB8: { |
| 91 | auto res = Color::DecodeRGB8(source + MortonInterleave(x, y) * 3); | 91 | auto res = Color::DecodeRGB8(source + MortonInterleave(x, y) * 3); |
| 92 | return {res.r(), res.g(), res.b(), 255}; | 92 | return {res.r(), res.g(), res.b(), 255}; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | case Regs::TextureFormat::RGB5A1: { | 95 | case TextureFormat::RGB5A1: { |
| 96 | auto res = Color::DecodeRGB5A1(source + MortonInterleave(x, y) * 2); | 96 | auto res = Color::DecodeRGB5A1(source + MortonInterleave(x, y) * 2); |
| 97 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; | 97 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | case Regs::TextureFormat::RGB565: { | 100 | case TextureFormat::RGB565: { |
| 101 | auto res = Color::DecodeRGB565(source + MortonInterleave(x, y) * 2); | 101 | auto res = Color::DecodeRGB565(source + MortonInterleave(x, y) * 2); |
| 102 | return {res.r(), res.g(), res.b(), 255}; | 102 | return {res.r(), res.g(), res.b(), 255}; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | case Regs::TextureFormat::RGBA4: { | 105 | case TextureFormat::RGBA4: { |
| 106 | auto res = Color::DecodeRGBA4(source + MortonInterleave(x, y) * 2); | 106 | auto res = Color::DecodeRGBA4(source + MortonInterleave(x, y) * 2); |
| 107 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; | 107 | return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())}; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | case Regs::TextureFormat::IA8: { | 110 | case TextureFormat::IA8: { |
| 111 | const u8* source_ptr = source + MortonInterleave(x, y) * 2; | 111 | const u8* source_ptr = source + MortonInterleave(x, y) * 2; |
| 112 | 112 | ||
| 113 | if (disable_alpha) { | 113 | if (disable_alpha) { |
| @@ -118,17 +118,17 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | case Regs::TextureFormat::RG8: { | 121 | case TextureFormat::RG8: { |
| 122 | auto res = Color::DecodeRG8(source + MortonInterleave(x, y) * 2); | 122 | auto res = Color::DecodeRG8(source + MortonInterleave(x, y) * 2); |
| 123 | return {res.r(), res.g(), 0, 255}; | 123 | return {res.r(), res.g(), 0, 255}; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | case Regs::TextureFormat::I8: { | 126 | case TextureFormat::I8: { |
| 127 | const u8* source_ptr = source + MortonInterleave(x, y); | 127 | const u8* source_ptr = source + MortonInterleave(x, y); |
| 128 | return {*source_ptr, *source_ptr, *source_ptr, 255}; | 128 | return {*source_ptr, *source_ptr, *source_ptr, 255}; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | case Regs::TextureFormat::A8: { | 131 | case TextureFormat::A8: { |
| 132 | const u8* source_ptr = source + MortonInterleave(x, y); | 132 | const u8* source_ptr = source + MortonInterleave(x, y); |
| 133 | 133 | ||
| 134 | if (disable_alpha) { | 134 | if (disable_alpha) { |
| @@ -138,7 +138,7 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | case Regs::TextureFormat::IA4: { | 141 | case TextureFormat::IA4: { |
| 142 | const u8* source_ptr = source + MortonInterleave(x, y); | 142 | const u8* source_ptr = source + MortonInterleave(x, y); |
| 143 | 143 | ||
| 144 | u8 i = Color::Convert4To8(((*source_ptr) & 0xF0) >> 4); | 144 | u8 i = Color::Convert4To8(((*source_ptr) & 0xF0) >> 4); |
| @@ -152,7 +152,7 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | case Regs::TextureFormat::I4: { | 155 | case TextureFormat::I4: { |
| 156 | u32 morton_offset = MortonInterleave(x, y); | 156 | u32 morton_offset = MortonInterleave(x, y); |
| 157 | const u8* source_ptr = source + morton_offset / 2; | 157 | const u8* source_ptr = source + morton_offset / 2; |
| 158 | 158 | ||
| @@ -162,7 +162,7 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 162 | return {i, i, i, 255}; | 162 | return {i, i, i, 255}; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | case Regs::TextureFormat::A4: { | 165 | case TextureFormat::A4: { |
| 166 | u32 morton_offset = MortonInterleave(x, y); | 166 | u32 morton_offset = MortonInterleave(x, y); |
| 167 | const u8* source_ptr = source + morton_offset / 2; | 167 | const u8* source_ptr = source + morton_offset / 2; |
| 168 | 168 | ||
| @@ -176,9 +176,9 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | case Regs::TextureFormat::ETC1: | 179 | case TextureFormat::ETC1: |
| 180 | case Regs::TextureFormat::ETC1A4: { | 180 | case TextureFormat::ETC1A4: { |
| 181 | bool has_alpha = (info.format == Regs::TextureFormat::ETC1A4); | 181 | bool has_alpha = (info.format == TextureFormat::ETC1A4); |
| 182 | size_t subtile_size = has_alpha ? 16 : 8; | 182 | size_t subtile_size = has_alpha ? 16 : 8; |
| 183 | 183 | ||
| 184 | // ETC1 further subdivides each 8x8 tile into four 4x4 subtiles | 184 | // ETC1 further subdivides each 8x8 tile into four 4x4 subtiles |
| @@ -214,8 +214,8 @@ Math::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned int | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, | 217 | TextureInfo TextureInfo::FromPicaRegister(const TexturingRegs::TextureConfig& config, |
| 218 | const Regs::TextureFormat& format) { | 218 | const TexturingRegs::TextureFormat& format) { |
| 219 | TextureInfo info; | 219 | TextureInfo info; |
| 220 | info.physical_address = config.GetPhysicalAddress(); | 220 | info.physical_address = config.GetPhysicalAddress(); |
| 221 | info.width = config.width; | 221 | info.width = config.width; |
diff --git a/src/video_core/texture/texture_decode.h b/src/video_core/texture/texture_decode.h index 5c636939a..8507cfeb8 100644 --- a/src/video_core/texture/texture_decode.h +++ b/src/video_core/texture/texture_decode.h | |||
| @@ -6,27 +6,27 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/vector_math.h" | 8 | #include "common/vector_math.h" |
| 9 | #include "video_core/pica.h" | 9 | #include "video_core/regs_texturing.h" |
| 10 | 10 | ||
| 11 | namespace Pica { | 11 | namespace Pica { |
| 12 | namespace Texture { | 12 | namespace Texture { |
| 13 | 13 | ||
| 14 | /// Returns the byte size of a 8*8 tile of the specified texture format. | 14 | /// Returns the byte size of a 8*8 tile of the specified texture format. |
| 15 | size_t CalculateTileSize(Pica::Regs::TextureFormat format); | 15 | size_t CalculateTileSize(TexturingRegs::TextureFormat format); |
| 16 | 16 | ||
| 17 | struct TextureInfo { | 17 | struct TextureInfo { |
| 18 | PAddr physical_address; | 18 | PAddr physical_address; |
| 19 | unsigned int width; | 19 | unsigned int width; |
| 20 | unsigned int height; | 20 | unsigned int height; |
| 21 | ptrdiff_t stride; | 21 | ptrdiff_t stride; |
| 22 | Pica::Regs::TextureFormat format; | 22 | TexturingRegs::TextureFormat format; |
| 23 | 23 | ||
| 24 | static TextureInfo FromPicaRegister(const Pica::Regs::TextureConfig& config, | 24 | static TextureInfo FromPicaRegister(const TexturingRegs::TextureConfig& config, |
| 25 | const Pica::Regs::TextureFormat& format); | 25 | const TexturingRegs::TextureFormat& format); |
| 26 | 26 | ||
| 27 | /// Calculates stride from format and width, assuming that the entire texture is contiguous. | 27 | /// Calculates stride from format and width, assuming that the entire texture is contiguous. |
| 28 | void SetDefaultStride() { | 28 | void SetDefaultStride() { |
| 29 | stride = Pica::Texture::CalculateTileSize(format) * (width / 8); | 29 | stride = CalculateTileSize(format) * (width / 8); |
| 30 | } | 30 | } |
| 31 | }; | 31 | }; |
| 32 | 32 | ||