diff options
| author | 2019-05-24 11:59:23 -0400 | |
|---|---|---|
| committer | 2019-06-20 21:38:33 -0300 | |
| commit | 92513541529e90f4f79a1f2c3f8ccf5a199e4c20 (patch) | |
| tree | d686a78d8af4e41bf6a7c3fc2136e146b98f42e4 /src/video_core/texture_cache | |
| parent | texture_cache: Only load on recycle with accurate GPU. (diff) | |
| download | yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.gz yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.xz yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.zip | |
texture_cache: Correct copying between compressed and uncompressed formats
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/surface_base.h | 9 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_params.h | 20 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 8 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index dacbc97c7..77c2d6758 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h | |||
| @@ -235,9 +235,8 @@ private: | |||
| 235 | 235 | ||
| 236 | for (u32 layer = 0; layer < layers; layer++) { | 236 | for (u32 layer = 0; layer < layers; layer++) { |
| 237 | for (u32 level = 0; level < mipmaps; level++) { | 237 | for (u32 level = 0; level < mipmaps; level++) { |
| 238 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | 238 | const u32 width = SurfaceParams::IntersectWidth(params, in_params, level, level); |
| 239 | const u32 height{ | 239 | const u32 height = SurfaceParams::IntersectHeight(params, in_params, level, level); |
| 240 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | ||
| 241 | result.emplace_back(width, height, layer, level); | 240 | result.emplace_back(width, height, layer, level); |
| 242 | } | 241 | } |
| 243 | } | 242 | } |
| @@ -250,8 +249,8 @@ private: | |||
| 250 | result.reserve(mipmaps); | 249 | result.reserve(mipmaps); |
| 251 | 250 | ||
| 252 | for (u32 level = 0; level < mipmaps; level++) { | 251 | for (u32 level = 0; level < mipmaps; level++) { |
| 253 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; | 252 | const u32 width = SurfaceParams::IntersectWidth(params, in_params, level, level); |
| 254 | const u32 height{std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; | 253 | const u32 height = SurfaceParams::IntersectHeight(params, in_params, level, level); |
| 255 | const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))}; | 254 | const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))}; |
| 256 | result.emplace_back(width, height, depth, level); | 255 | result.emplace_back(width, height, depth, level); |
| 257 | } | 256 | } |
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h index d9aa0b521..c3affd621 100644 --- a/src/video_core/texture_cache/surface_params.h +++ b/src/video_core/texture_cache/surface_params.h | |||
| @@ -140,6 +140,26 @@ public: | |||
| 140 | return (height * bh2 + bh1 - 1) / bh1; | 140 | return (height * bh2 + bh1 - 1) / bh1; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | // this finds the maximun possible width between 2 2D layers of different formats | ||
| 144 | static u32 IntersectWidth(const SurfaceParams& src_params, const SurfaceParams& dst_params, | ||
| 145 | const u32 src_level, const u32 dst_level) { | ||
| 146 | const u32 bw1 = src_params.GetDefaultBlockWidth(); | ||
| 147 | const u32 bw2 = dst_params.GetDefaultBlockWidth(); | ||
| 148 | const u32 t_src_width = (src_params.GetMipWidth(src_level) * bw2 + bw1 - 1) / bw1; | ||
| 149 | const u32 t_dst_width = (dst_params.GetMipWidth(dst_level) * bw1 + bw2 - 1) / bw2; | ||
| 150 | return std::min(t_src_width, t_dst_width); | ||
| 151 | } | ||
| 152 | |||
| 153 | // this finds the maximun possible height between 2 2D layers of different formats | ||
| 154 | static u32 IntersectHeight(const SurfaceParams& src_params, const SurfaceParams& dst_params, | ||
| 155 | const u32 src_level, const u32 dst_level) { | ||
| 156 | const u32 bh1 = src_params.GetDefaultBlockHeight(); | ||
| 157 | const u32 bh2 = dst_params.GetDefaultBlockHeight(); | ||
| 158 | const u32 t_src_height = (src_params.GetMipHeight(src_level) * bh2 + bh1 - 1) / bh1; | ||
| 159 | const u32 t_dst_height = (dst_params.GetMipHeight(dst_level) * bh1 + bh2 - 1) / bh2; | ||
| 160 | return std::min(t_src_height, t_dst_height); | ||
| 161 | } | ||
| 162 | |||
| 143 | /// Returns the default block width. | 163 | /// Returns the default block width. |
| 144 | u32 GetDefaultBlockWidth() const { | 164 | u32 GetDefaultBlockWidth() const { |
| 145 | return VideoCore::Surface::GetDefaultBlockWidth(pixel_format); | 165 | return VideoCore::Surface::GetDefaultBlockWidth(pixel_format); |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 685bd28f4..d2093e581 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -444,11 +444,9 @@ private: | |||
| 444 | } | 444 | } |
| 445 | modified |= surface->IsModified(); | 445 | modified |= surface->IsModified(); |
| 446 | // Now we got all the data set up | 446 | // Now we got all the data set up |
| 447 | const u32 dst_width{params.GetMipWidth(mipmap)}; | 447 | const u32 width = SurfaceParams::IntersectWidth(src_params, params, 0, mipmap); |
| 448 | const u32 dst_height{params.GetMipHeight(mipmap)}; | 448 | const u32 height = SurfaceParams::IntersectHeight(src_params, params, 0, mipmap); |
| 449 | const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap, | 449 | const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap, width, height, 1); |
| 450 | std::min(src_params.width, dst_width), | ||
| 451 | std::min(src_params.height, dst_height), 1); | ||
| 452 | passed_tests++; | 450 | passed_tests++; |
| 453 | ImageCopy(surface, new_surface, copy_params); | 451 | ImageCopy(surface, new_surface, copy_params); |
| 454 | } | 452 | } |