diff options
| author | 2018-10-26 19:18:03 -0400 | |
|---|---|---|
| committer | 2018-10-28 19:00:05 -0400 | |
| commit | f0e902a7d6df72531fbd01d27756f9875dc3c65d (patch) | |
| tree | f56941ce6cdddf4815ff2d5c6ae7588d513690d1 | |
| parent | Fixed Invalid Image size and Mipmap calculation (diff) | |
| download | yuzu-f0e902a7d6df72531fbd01d27756f9875dc3c65d.tar.gz yuzu-f0e902a7d6df72531fbd01d27756f9875dc3c65d.tar.xz yuzu-f0e902a7d6df72531fbd01d27756f9875dc3c65d.zip | |
Fixed mipmap block autosizing algorithm
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 24 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.h | 6 |
3 files changed, 25 insertions, 13 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 4d89d0f67..b2250e6be 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -103,7 +103,7 @@ std::size_t SurfaceParams::InnerMipmapMemorySize(u32 mip_level, bool force_gl, b | |||
| 103 | ? m_height | 103 | ? m_height |
| 104 | : std::max(1U, (m_height + compression_factor - 1) / compression_factor); | 104 | : std::max(1U, (m_height + compression_factor - 1) / compression_factor); |
| 105 | m_depth = std::max(1U, m_depth >> mip_level); | 105 | m_depth = std::max(1U, m_depth >> mip_level); |
| 106 | u32 m_block_height = MipBlockHeight(mip_level, m_height); | 106 | u32 m_block_height = MipBlockHeight(mip_level); |
| 107 | u32 m_block_depth = MipBlockDepth(mip_level); | 107 | u32 m_block_depth = MipBlockDepth(mip_level); |
| 108 | return Tegra::Texture::CalculateSize(force_gl ? false : is_tiled, bytes_per_pixel, m_width, | 108 | return Tegra::Texture::CalculateSize(force_gl ? false : is_tiled, bytes_per_pixel, m_width, |
| 109 | m_height, m_depth, m_block_height, m_block_depth); | 109 | m_height, m_depth, m_block_height, m_block_depth); |
| @@ -111,7 +111,7 @@ std::size_t SurfaceParams::InnerMipmapMemorySize(u32 mip_level, bool force_gl, b | |||
| 111 | 111 | ||
| 112 | std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only, | 112 | std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only, |
| 113 | bool uncompressed) const { | 113 | bool uncompressed) const { |
| 114 | std::size_t block_size_bytes = 512 * block_height * block_depth; // 512 is GOB size | 114 | std::size_t block_size_bytes = Tegra::Texture::GetGOBSize() * block_height * block_depth; |
| 115 | std::size_t size = 0; | 115 | std::size_t size = 0; |
| 116 | for (u32 i = 0; i < max_mip_level; i++) { | 116 | for (u32 i = 0; i < max_mip_level; i++) { |
| 117 | size += InnerMipmapMemorySize(i, force_gl, layer_only, uncompressed); | 117 | size += InnerMipmapMemorySize(i, force_gl, layer_only, uncompressed); |
| @@ -1043,8 +1043,8 @@ void CachedSurface::FlushGLBuffer() { | |||
| 1043 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); | 1043 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); |
| 1044 | ASSERT(!tuple.compressed); | 1044 | ASSERT(!tuple.compressed); |
| 1045 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 1045 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |
| 1046 | glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, static_cast<GLsizei>(gl_buffer[0].size()), | 1046 | glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, |
| 1047 | gl_buffer[0].data()); | 1047 | static_cast<GLsizei>(gl_buffer[0].size()), gl_buffer[0].data()); |
| 1048 | glPixelStorei(GL_PACK_ROW_LENGTH, 0); | 1048 | glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
| 1049 | ConvertFormatAsNeeded_FlushGLBuffer(gl_buffer[0], params.pixel_format, params.width, | 1049 | ConvertFormatAsNeeded_FlushGLBuffer(gl_buffer[0], params.pixel_format, params.width, |
| 1050 | params.height); | 1050 | params.height); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 951e03ba6..15ac4a1b1 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -917,14 +917,14 @@ struct SurfaceParams { | |||
| 917 | 917 | ||
| 918 | // Auto block resizing algorithm from: | 918 | // Auto block resizing algorithm from: |
| 919 | // https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 919 | // https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nv50/nv50_miptree.c |
| 920 | u32 MipBlockHeight(u32 mip_level, u32 alt_height = 0) const { | 920 | u32 MipBlockHeight(u32 mip_level) const { |
| 921 | if (mip_level == 0) | 921 | if (mip_level == 0) |
| 922 | return block_height; | 922 | return block_height; |
| 923 | if (alt_height == 0) | 923 | u32 alt_height = MipHeight(mip_level); |
| 924 | alt_height = MipHeight(mip_level); | 924 | u32 h = GetDefaultBlockHeight(pixel_format); |
| 925 | u32 blocks_in_y = (alt_height + 7) / 8; | 925 | u32 blocks_in_y = (alt_height + h - 1) / h; |
| 926 | u32 bh = 32; | 926 | u32 bh = 16; |
| 927 | while (bh > 1 && blocks_in_y <= bh * 2) { | 927 | while (bh > 1 && blocks_in_y <= bh * 4) { |
| 928 | bh >>= 1; | 928 | bh >>= 1; |
| 929 | } | 929 | } |
| 930 | return bh; | 930 | return bh; |
| @@ -933,11 +933,17 @@ struct SurfaceParams { | |||
| 933 | u32 MipBlockDepth(u32 mip_level) const { | 933 | u32 MipBlockDepth(u32 mip_level) const { |
| 934 | if (mip_level == 0) | 934 | if (mip_level == 0) |
| 935 | return block_depth; | 935 | return block_depth; |
| 936 | if (is_layered) | ||
| 937 | return 1; | ||
| 936 | u32 depth = MipDepth(mip_level); | 938 | u32 depth = MipDepth(mip_level); |
| 937 | u32 bd = 32; | 939 | u32 bd = 32; |
| 938 | // Magical block resizing algorithm, needs more testing. | 940 | while (bd > 1 && depth * 2 <= bd) { |
| 939 | while (bd > 1 && depth / depth <= bd) { | 941 | bd >>= 1; |
| 940 | bd = bd >> 1; | 942 | } |
| 943 | if (bd == 32) { | ||
| 944 | u32 bh = MipBlockHeight(mip_level); | ||
| 945 | if (bh >= 4) | ||
| 946 | return 16; | ||
| 941 | } | 947 | } |
| 942 | return bd; | 948 | return bd; |
| 943 | } | 949 | } |
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index 4726f54a5..b390219e4 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h | |||
| @@ -10,6 +10,12 @@ | |||
| 10 | 10 | ||
| 11 | namespace Tegra::Texture { | 11 | namespace Tegra::Texture { |
| 12 | 12 | ||
| 13 | // GOBSize constant. Calculated by 64 bytes in x multiplied by 8 y coords, represents | ||
| 14 | // an small rect of (64/bytes_per_pixel)X8. | ||
| 15 | inline std::size_t GetGOBSize() { | ||
| 16 | return 512; | ||
| 17 | } | ||
| 18 | |||
| 13 | /** | 19 | /** |
| 14 | * Unswizzles a swizzled texture without changing its format. | 20 | * Unswizzles a swizzled texture without changing its format. |
| 15 | */ | 21 | */ |