diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 23 |
2 files changed, 5 insertions, 32 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 249b0061a..ce967c4d6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -1058,9 +1058,6 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, | |||
| 1058 | } | 1058 | } |
| 1059 | break; | 1059 | break; |
| 1060 | case SurfaceParams::SurfaceTarget::TextureCubemap: { | 1060 | case SurfaceParams::SurfaceTarget::TextureCubemap: { |
| 1061 | const u32 byte_stride{old_params.rt.layer_stride * | ||
| 1062 | (SurfaceParams::GetFormatBpp(old_params.pixel_format) / CHAR_BIT)}; | ||
| 1063 | |||
| 1064 | if (old_params.rt.array_mode != 1) { | 1061 | if (old_params.rt.array_mode != 1) { |
| 1065 | // TODO(bunnei): This is used by Breath of the Wild, I'm not sure how to implement this | 1062 | // TODO(bunnei): This is used by Breath of the Wild, I'm not sure how to implement this |
| 1066 | // yet (array rendering used as a cubemap texture). | 1063 | // yet (array rendering used as a cubemap texture). |
| @@ -1070,15 +1067,14 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, | |||
| 1070 | } | 1067 | } |
| 1071 | 1068 | ||
| 1072 | // This seems to be used for render-to-cubemap texture | 1069 | // This seems to be used for render-to-cubemap texture |
| 1073 | const std::size_t size_with_mipmaps{new_params.SizeInBytes2DWithMipmap()}; | ||
| 1074 | ASSERT_MSG(size_with_mipmaps == byte_stride, "Unexpected"); | ||
| 1075 | ASSERT_MSG(old_params.target == SurfaceParams::SurfaceTarget::Texture2D, "Unexpected"); | 1070 | ASSERT_MSG(old_params.target == SurfaceParams::SurfaceTarget::Texture2D, "Unexpected"); |
| 1076 | ASSERT_MSG(old_params.pixel_format == new_params.pixel_format, "Unexpected"); | 1071 | ASSERT_MSG(old_params.pixel_format == new_params.pixel_format, "Unexpected"); |
| 1077 | ASSERT_MSG(old_params.width == new_params.width, "Unexpected"); | ||
| 1078 | ASSERT_MSG(old_params.height == new_params.height, "Unexpected"); | ||
| 1079 | ASSERT_MSG(old_params.rt.array_mode == 1, "Unexpected"); | ||
| 1080 | ASSERT_MSG(old_params.rt.base_layer == 0, "Unimplemented"); | 1072 | ASSERT_MSG(old_params.rt.base_layer == 0, "Unimplemented"); |
| 1081 | 1073 | ||
| 1074 | // TODO(bunnei): Verify the below - this stride seems to be in 32-bit words, not pixels. | ||
| 1075 | // Tested with Splatoon 2, Super Mario Odyssey, and Breath of the Wild. | ||
| 1076 | const std::size_t byte_stride{old_params.rt.layer_stride * sizeof(u32)}; | ||
| 1077 | |||
| 1082 | for (std::size_t index = 0; index < new_params.depth; ++index) { | 1078 | for (std::size_t index = 0; index < new_params.depth; ++index) { |
| 1083 | Surface face_surface{TryGetReservedSurface(old_params)}; | 1079 | Surface face_surface{TryGetReservedSurface(old_params)}; |
| 1084 | ASSERT_MSG(face_surface, "Unexpected"); | 1080 | ASSERT_MSG(face_surface, "Unexpected"); |
| @@ -1092,7 +1088,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, | |||
| 1092 | face_surface->GetSurfaceParams().rt.index, new_params.rt.index, index); | 1088 | face_surface->GetSurfaceParams().rt.index, new_params.rt.index, index); |
| 1093 | } | 1089 | } |
| 1094 | 1090 | ||
| 1095 | old_params.addr += size_with_mipmaps; | 1091 | old_params.addr += byte_stride; |
| 1096 | } | 1092 | } |
| 1097 | break; | 1093 | break; |
| 1098 | } | 1094 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 51eb9b6dd..49025a3fe 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -707,29 +707,6 @@ struct SurfaceParams { | |||
| 707 | return SizeInBytes2D() * depth; | 707 | return SizeInBytes2D() * depth; |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | /** | ||
| 711 | * Returns the size in bytes of the 2D surface with mipmaps. Each mipmap level proceeds the | ||
| 712 | * previous with half the width and half the height. Once the size of the next mip reaches 0, we | ||
| 713 | * are done. | ||
| 714 | */ | ||
| 715 | std::size_t SizeInBytes2DWithMipmap() const { | ||
| 716 | std::size_t size_in_bytes{}; | ||
| 717 | auto mip_params{*this}; | ||
| 718 | for (std::size_t level = 0; level < max_mip_level; level++) { | ||
| 719 | size_in_bytes += mip_params.SizeInBytes2D(); | ||
| 720 | |||
| 721 | mip_params.width /= 2; | ||
| 722 | mip_params.height /= 2; | ||
| 723 | |||
| 724 | if (!mip_params.width || !mip_params.height) { | ||
| 725 | break; | ||
| 726 | } | ||
| 727 | } | ||
| 728 | |||
| 729 | // TODO(bunnei): This alignup is unverified, but necessary in games tested (e.g. in SMO) | ||
| 730 | return Common::AlignUp(size_in_bytes, 0x1000); | ||
| 731 | } | ||
| 732 | |||
| 733 | /// Creates SurfaceParams from a texture configuration | 710 | /// Creates SurfaceParams from a texture configuration |
| 734 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, | 711 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, |
| 735 | const GLShader::SamplerEntry& entry); | 712 | const GLShader::SamplerEntry& entry); |