diff options
| author | 2019-05-10 23:02:14 -0300 | |
|---|---|---|
| committer | 2019-06-20 21:36:12 -0300 | |
| commit | 2131f715730580dfeb692acdf3ae3e62ffd455c1 (patch) | |
| tree | fd567bf0f803fec889822f1a4101f141891a7391 /src | |
| parent | gl_texture_cache: Make main views be proxy textures instead of a full view. (diff) | |
| download | yuzu-2131f715730580dfeb692acdf3ae3e62ffd455c1.tar.gz yuzu-2131f715730580dfeb692acdf3ae3e62ffd455c1.tar.xz yuzu-2131f715730580dfeb692acdf3ae3e62ffd455c1.zip | |
surface_params: Optimize CreateForTexture
Instead of using Common::AlignUp, use Common::AlignBits to align the
texture compression factor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/surface.h | 142 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_params.cpp | 6 |
2 files changed, 76 insertions, 72 deletions
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index b783e4b27..8e98033f3 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -122,71 +122,71 @@ enum class SurfaceTarget { | |||
| 122 | TextureCubeArray, | 122 | TextureCubeArray, |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| 125 | constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ | 125 | inline constexpr std::array<u32, MaxPixelFormat> compression_factor_shift_table = {{ |
| 126 | 1, // ABGR8U | 126 | 0, // ABGR8U |
| 127 | 1, // ABGR8S | 127 | 0, // ABGR8S |
| 128 | 1, // ABGR8UI | 128 | 0, // ABGR8UI |
| 129 | 1, // B5G6R5U | 129 | 0, // B5G6R5U |
| 130 | 1, // A2B10G10R10U | 130 | 0, // A2B10G10R10U |
| 131 | 1, // A1B5G5R5U | 131 | 0, // A1B5G5R5U |
| 132 | 1, // R8U | 132 | 0, // R8U |
| 133 | 1, // R8UI | 133 | 0, // R8UI |
| 134 | 1, // RGBA16F | 134 | 0, // RGBA16F |
| 135 | 1, // RGBA16U | 135 | 0, // RGBA16U |
| 136 | 1, // RGBA16UI | 136 | 0, // RGBA16UI |
| 137 | 1, // R11FG11FB10F | 137 | 0, // R11FG11FB10F |
| 138 | 1, // RGBA32UI | 138 | 0, // RGBA32UI |
| 139 | 4, // DXT1 | 139 | 2, // DXT1 |
| 140 | 4, // DXT23 | 140 | 2, // DXT23 |
| 141 | 4, // DXT45 | 141 | 2, // DXT45 |
| 142 | 4, // DXN1 | 142 | 2, // DXN1 |
| 143 | 4, // DXN2UNORM | 143 | 2, // DXN2UNORM |
| 144 | 4, // DXN2SNORM | 144 | 2, // DXN2SNORM |
| 145 | 4, // BC7U | 145 | 2, // BC7U |
| 146 | 4, // BC6H_UF16 | 146 | 2, // BC6H_UF16 |
| 147 | 4, // BC6H_SF16 | 147 | 2, // BC6H_SF16 |
| 148 | 4, // ASTC_2D_4X4 | 148 | 2, // ASTC_2D_4X4 |
| 149 | 1, // BGRA8 | 149 | 0, // BGRA8 |
| 150 | 1, // RGBA32F | 150 | 0, // RGBA32F |
| 151 | 1, // RG32F | 151 | 0, // RG32F |
| 152 | 1, // R32F | 152 | 0, // R32F |
| 153 | 1, // R16F | 153 | 0, // R16F |
| 154 | 1, // R16U | 154 | 0, // R16U |
| 155 | 1, // R16S | 155 | 0, // R16S |
| 156 | 1, // R16UI | 156 | 0, // R16UI |
| 157 | 1, // R16I | 157 | 0, // R16I |
| 158 | 1, // RG16 | 158 | 0, // RG16 |
| 159 | 1, // RG16F | 159 | 0, // RG16F |
| 160 | 1, // RG16UI | 160 | 0, // RG16UI |
| 161 | 1, // RG16I | 161 | 0, // RG16I |
| 162 | 1, // RG16S | 162 | 0, // RG16S |
| 163 | 1, // RGB32F | 163 | 0, // RGB32F |
| 164 | 1, // RGBA8_SRGB | 164 | 0, // RGBA8_SRGB |
| 165 | 1, // RG8U | 165 | 0, // RG8U |
| 166 | 1, // RG8S | 166 | 0, // RG8S |
| 167 | 1, // RG32UI | 167 | 0, // RG32UI |
| 168 | 1, // R32UI | 168 | 0, // R32UI |
| 169 | 4, // ASTC_2D_8X8 | 169 | 2, // ASTC_2D_8X8 |
| 170 | 4, // ASTC_2D_8X5 | 170 | 2, // ASTC_2D_8X5 |
| 171 | 4, // ASTC_2D_5X4 | 171 | 2, // ASTC_2D_5X4 |
| 172 | 1, // BGRA8_SRGB | 172 | 0, // BGRA8_SRGB |
| 173 | 4, // DXT1_SRGB | 173 | 2, // DXT1_SRGB |
| 174 | 4, // DXT23_SRGB | 174 | 2, // DXT23_SRGB |
| 175 | 4, // DXT45_SRGB | 175 | 2, // DXT45_SRGB |
| 176 | 4, // BC7U_SRGB | 176 | 2, // BC7U_SRGB |
| 177 | 4, // ASTC_2D_4X4_SRGB | 177 | 2, // ASTC_2D_4X4_SRGB |
| 178 | 4, // ASTC_2D_8X8_SRGB | 178 | 2, // ASTC_2D_8X8_SRGB |
| 179 | 4, // ASTC_2D_8X5_SRGB | 179 | 2, // ASTC_2D_8X5_SRGB |
| 180 | 4, // ASTC_2D_5X4_SRGB | 180 | 2, // ASTC_2D_5X4_SRGB |
| 181 | 4, // ASTC_2D_5X5 | 181 | 2, // ASTC_2D_5X5 |
| 182 | 4, // ASTC_2D_5X5_SRGB | 182 | 2, // ASTC_2D_5X5_SRGB |
| 183 | 4, // ASTC_2D_10X8 | 183 | 2, // ASTC_2D_10X8 |
| 184 | 4, // ASTC_2D_10X8_SRGB | 184 | 2, // ASTC_2D_10X8_SRGB |
| 185 | 1, // Z32F | 185 | 0, // Z32F |
| 186 | 1, // Z16 | 186 | 0, // Z16 |
| 187 | 1, // Z24S8 | 187 | 0, // Z24S8 |
| 188 | 1, // S8Z24 | 188 | 0, // S8Z24 |
| 189 | 1, // Z32FS8 | 189 | 0, // Z32FS8 |
| 190 | }}; | 190 | }}; |
| 191 | 191 | ||
| 192 | /** | 192 | /** |
| @@ -195,12 +195,14 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ | |||
| 195 | * compressed image. This is used for maintaining proper surface sizes for compressed | 195 | * compressed image. This is used for maintaining proper surface sizes for compressed |
| 196 | * texture formats. | 196 | * texture formats. |
| 197 | */ | 197 | */ |
| 198 | static constexpr u32 GetCompressionFactor(PixelFormat format) { | 198 | inline constexpr u32 GetCompressionFactorShift(PixelFormat format) { |
| 199 | if (format == PixelFormat::Invalid) | 199 | DEBUG_ASSERT(format != PixelFormat::Invalid); |
| 200 | return 0; | 200 | DEBUG_ASSERT(static_cast<std::size_t>(format) < compression_factor_table.size()); |
| 201 | return compression_factor_shift_table[static_cast<std::size_t>(format)]; | ||
| 202 | } | ||
| 201 | 203 | ||
| 202 | ASSERT(static_cast<std::size_t>(format) < compression_factor_table.size()); | 204 | inline constexpr u32 GetCompressionFactor(PixelFormat format) { |
| 203 | return compression_factor_table[static_cast<std::size_t>(format)]; | 205 | return 1U << GetCompressionFactorShift(format); |
| 204 | } | 206 | } |
| 205 | 207 | ||
| 206 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ | 208 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ |
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp index e7e671d8c..6f39f8468 100644 --- a/src/video_core/texture_cache/surface_params.cpp +++ b/src/video_core/texture_cache/surface_params.cpp | |||
| @@ -76,8 +76,10 @@ SurfaceParams SurfaceParams::CreateForTexture(Core::System& system, | |||
| 76 | params.type = GetFormatType(params.pixel_format); | 76 | params.type = GetFormatType(params.pixel_format); |
| 77 | // TODO: on 1DBuffer we should use the tic info. | 77 | // TODO: on 1DBuffer we should use the tic info. |
| 78 | params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray()); | 78 | params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray()); |
| 79 | params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format)); | 79 | params.width = |
| 80 | params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format)); | 80 | Common::AlignBits(config.tic.Width(), GetCompressionFactorShift(params.pixel_format)); |
| 81 | params.height = | ||
| 82 | Common::AlignBits(config.tic.Height(), GetCompressionFactorShift(params.pixel_format)); | ||
| 81 | params.depth = config.tic.Depth(); | 83 | params.depth = config.tic.Depth(); |
| 82 | if (params.target == SurfaceTarget::TextureCubemap || | 84 | if (params.target == SurfaceTarget::TextureCubemap || |
| 83 | params.target == SurfaceTarget::TextureCubeArray) { | 85 | params.target == SurfaceTarget::TextureCubeArray) { |