diff options
| author | 2019-05-07 21:55:55 -0300 | |
|---|---|---|
| committer | 2019-06-20 21:36:12 -0300 | |
| commit | 16e8625a301b1f43ecebe459a40bf33f89322032 (patch) | |
| tree | 900468e7f6276ad57b29dfa0c462d24df38dfcde /src/video_core/texture_cache | |
| parent | surface_base: Silence truncation warnings and minor renames and reordering (diff) | |
| download | yuzu-16e8625a301b1f43ecebe459a40bf33f89322032.tar.gz yuzu-16e8625a301b1f43ecebe459a40bf33f89322032.tar.xz yuzu-16e8625a301b1f43ecebe459a40bf33f89322032.zip | |
surface_base: Split BreakDown into layered and non-layered variants
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/surface_base.h | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 7cc122158..0cfb835d9 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h | |||
| @@ -106,32 +106,32 @@ public: | |||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | bool MatchesTopology(const SurfaceParams& rhs) const { | 108 | bool MatchesTopology(const SurfaceParams& rhs) const { |
| 109 | const u32 src_bpp = params.GetBytesPerPixel(); | 109 | const u32 src_bpp{params.GetBytesPerPixel()}; |
| 110 | const u32 dst_bpp = rhs.GetBytesPerPixel(); | 110 | const u32 dst_bpp{rhs.GetBytesPerPixel()}; |
| 111 | return std::tie(src_bpp, params.is_tiled) == std::tie(dst_bpp, rhs.is_tiled); | 111 | return std::tie(src_bpp, params.is_tiled) == std::tie(dst_bpp, rhs.is_tiled); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | MatchStructureResult MatchesStructure(const SurfaceParams& rhs) const { | 114 | MatchStructureResult MatchesStructure(const SurfaceParams& rhs) const { |
| 115 | if (params.is_tiled) { | 115 | if (!params.is_tiled) { |
| 116 | if (std::tie(params.height, params.depth, params.block_width, params.block_height, | ||
| 117 | params.block_depth, params.tile_width_spacing) == | ||
| 118 | std::tie(rhs.height, rhs.depth, rhs.block_width, rhs.block_height, rhs.block_depth, | ||
| 119 | rhs.tile_width_spacing)) { | ||
| 120 | if (params.width == rhs.width) { | ||
| 121 | return MatchStructureResult::FullMatch; | ||
| 122 | } | ||
| 123 | if (params.GetBlockAlignedWidth() == rhs.GetBlockAlignedWidth()) { | ||
| 124 | return MatchStructureResult::SemiMatch; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | return MatchStructureResult::None; | ||
| 128 | } else { | ||
| 129 | if (std::tie(params.width, params.height, params.pitch) == | 116 | if (std::tie(params.width, params.height, params.pitch) == |
| 130 | std::tie(rhs.width, rhs.height, rhs.pitch)) { | 117 | std::tie(rhs.width, rhs.height, rhs.pitch)) { |
| 131 | return MatchStructureResult::FullMatch; | 118 | return MatchStructureResult::FullMatch; |
| 132 | } | 119 | } |
| 133 | return MatchStructureResult::None; | 120 | return MatchStructureResult::None; |
| 134 | } | 121 | } |
| 122 | // Tiled surface | ||
| 123 | if (std::tie(params.height, params.depth, params.block_width, params.block_height, | ||
| 124 | params.block_depth, params.tile_width_spacing) == | ||
| 125 | std::tie(rhs.height, rhs.depth, rhs.block_width, rhs.block_height, rhs.block_depth, | ||
| 126 | rhs.tile_width_spacing)) { | ||
| 127 | if (params.width == rhs.width) { | ||
| 128 | return MatchStructureResult::FullMatch; | ||
| 129 | } | ||
| 130 | if (params.GetBlockAlignedWidth() == rhs.GetBlockAlignedWidth()) { | ||
| 131 | return MatchStructureResult::SemiMatch; | ||
| 132 | } | ||
| 133 | } | ||
| 134 | return MatchStructureResult::None; | ||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | std::optional<std::pair<u32, u32>> GetLayerMipmap(const GPUVAddr candidate_gpu_addr) const { | 137 | std::optional<std::pair<u32, u32>> GetLayerMipmap(const GPUVAddr candidate_gpu_addr) const { |
| @@ -151,35 +151,7 @@ public: | |||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | std::vector<CopyParams> BreakDown(const SurfaceParams& in_params) const { | 153 | std::vector<CopyParams> BreakDown(const SurfaceParams& in_params) const { |
| 154 | std::vector<CopyParams> result; | 154 | return params.is_layered ? BreakDownLayered(in_params) : BreakDownNonLayered(in_params); |
| 155 | const u32 layers{params.depth}; | ||
| 156 | const u32 mipmaps{params.num_levels}; | ||
| 157 | |||
| 158 | if (params.is_layered) { | ||
| 159 | result.reserve(static_cast<std::size_t>(layers) * static_cast<std::size_t>(mipmaps)); | ||
| 160 | for (u32 layer = 0; layer < layers; layer++) { | ||
| 161 | const u32 layer_offset{layer * mipmaps}; | ||
| 162 | for (u32 level = 0; level < mipmaps; level++) { | ||
| 163 | const u32 width{ | ||
| 164 | std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | ||
| 165 | const u32 height{ | ||
| 166 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | ||
| 167 | result.emplace_back(width, height, layer, level); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | return result; | ||
| 171 | |||
| 172 | } else { | ||
| 173 | result.reserve(mipmaps); | ||
| 174 | for (u32 level = 0; level < mipmaps; level++) { | ||
| 175 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | ||
| 176 | const u32 height{ | ||
| 177 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | ||
| 178 | const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))}; | ||
| 179 | result.emplace_back(width, height, depth, level); | ||
| 180 | } | ||
| 181 | return result; | ||
| 182 | } | ||
| 183 | } | 155 | } |
| 184 | 156 | ||
| 185 | protected: | 157 | protected: |
| @@ -203,6 +175,37 @@ protected: | |||
| 203 | private: | 175 | private: |
| 204 | void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params, u8* buffer, | 176 | void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params, u8* buffer, |
| 205 | u32 level); | 177 | u32 level); |
| 178 | |||
| 179 | std::vector<CopyParams> BreakDownLayered(const SurfaceParams& in_params) const { | ||
| 180 | const u32 layers{params.depth}; | ||
| 181 | const u32 mipmaps{params.num_levels}; | ||
| 182 | std::vector<CopyParams> result; | ||
| 183 | result.reserve(static_cast<std::size_t>(layers) * static_cast<std::size_t>(mipmaps)); | ||
| 184 | |||
| 185 | for (u32 layer = 0; layer < layers; layer++) { | ||
| 186 | for (u32 level = 0; level < mipmaps; level++) { | ||
| 187 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | ||
| 188 | const u32 height{ | ||
| 189 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | ||
| 190 | result.emplace_back(width, height, layer, level); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | return result; | ||
| 194 | } | ||
| 195 | |||
| 196 | std::vector<CopyParams> BreakDownNonLayered(const SurfaceParams& in_params) const { | ||
| 197 | const u32 mipmaps{params.num_levels}; | ||
| 198 | std::vector<CopyParams> result; | ||
| 199 | result.reserve(mipmaps); | ||
| 200 | |||
| 201 | for (u32 level = 0; level < mipmaps; level++) { | ||
| 202 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | ||
| 203 | const u32 height{std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | ||
| 204 | const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))}; | ||
| 205 | result.emplace_back(width, height, depth, level); | ||
| 206 | } | ||
| 207 | return result; | ||
| 208 | } | ||
| 206 | }; | 209 | }; |
| 207 | 210 | ||
| 208 | template <typename TView> | 211 | template <typename TView> |