diff options
| author | 2018-10-25 12:24:10 -0400 | |
|---|---|---|
| committer | 2018-10-28 19:00:03 -0400 | |
| commit | f4432b5d0cb0cb89ff4af8172720f7457514d981 (patch) | |
| tree | 7f78dd3c548c4165e2dd094bd0cc594d0bbcc456 | |
| parent | Implement Mip Filter (diff) | |
| download | yuzu-f4432b5d0cb0cb89ff4af8172720f7457514d981.tar.gz yuzu-f4432b5d0cb0cb89ff4af8172720f7457514d981.tar.xz yuzu-f4432b5d0cb0cb89ff4af8172720f7457514d981.zip | |
Fixed Block Resizing algorithm and Clang Format
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 23 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/maxwell_to_gl.h | 1 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 28f17bc75..cbe5bf664 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -100,7 +100,7 @@ std::size_t SurfaceParams::InnerMipmapMemorySize(u32 mip_level, bool force_gl, b | |||
| 100 | m_width = std::max(1U, m_width >> mip_level); | 100 | m_width = std::max(1U, m_width >> mip_level); |
| 101 | m_height = std::max(1U, m_height >> mip_level); | 101 | m_height = std::max(1U, m_height >> mip_level); |
| 102 | m_depth = std::max(1U, m_depth >> mip_level); | 102 | m_depth = std::max(1U, m_depth >> mip_level); |
| 103 | u32 m_block_height = MipBlockHeight(mip_level); | 103 | u32 m_block_height = MipBlockHeight(mip_level, m_height); |
| 104 | u32 m_block_depth = MipBlockDepth(mip_level); | 104 | u32 m_block_depth = MipBlockDepth(mip_level); |
| 105 | return Tegra::Texture::CalculateSize(force_gl ? false : is_tiled, bytes_per_pixel, m_width, | 105 | return Tegra::Texture::CalculateSize(force_gl ? false : is_tiled, bytes_per_pixel, m_width, |
| 106 | m_height, m_depth, m_block_height, m_block_depth); | 106 | m_height, m_depth, m_block_height, m_block_depth); |
| @@ -875,6 +875,9 @@ CachedSurface::CachedSurface(const SurfaceParams& params) | |||
| 875 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 875 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 876 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 876 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 877 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 877 | glTexParameteri(SurfaceTargetToGL(params.target), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 878 | if (params.max_mip_level == 1) { | ||
| 879 | glTexParameterf(SurfaceTargetToGL(params.target), GL_TEXTURE_LOD_BIAS, 1000.0); | ||
| 880 | } | ||
| 878 | 881 | ||
| 879 | VideoCore::LabelGLObject(GL_TEXTURE, texture.handle, params.addr, | 882 | VideoCore::LabelGLObject(GL_TEXTURE, texture.handle, params.addr, |
| 880 | SurfaceParams::SurfaceTargetName(params.target)); | 883 | SurfaceParams::SurfaceTargetName(params.target)); |
| @@ -1325,8 +1328,6 @@ void RasterizerCacheOpenGL::AccurateCopySurface(const Surface& src_surface, | |||
| 1325 | const Surface& dst_surface) { | 1328 | const Surface& dst_surface) { |
| 1326 | const auto& src_params{src_surface->GetSurfaceParams()}; | 1329 | const auto& src_params{src_surface->GetSurfaceParams()}; |
| 1327 | const auto& dst_params{dst_surface->GetSurfaceParams()}; | 1330 | const auto& dst_params{dst_surface->GetSurfaceParams()}; |
| 1328 | auto* start = Memory::GetPointer(src_params.addr); | ||
| 1329 | std::fill(start, start + dst_params.MemorySize(), 0); | ||
| 1330 | FlushRegion(src_params.addr, dst_params.MemorySize()); | 1331 | FlushRegion(src_params.addr, dst_params.MemorySize()); |
| 1331 | LoadSurface(dst_surface); | 1332 | LoadSurface(dst_surface); |
| 1332 | } | 1333 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 68479d55a..951e03ba6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -915,21 +915,28 @@ struct SurfaceParams { | |||
| 915 | return std::max(1U, depth >> mip_level); | 915 | return std::max(1U, depth >> mip_level); |
| 916 | } | 916 | } |
| 917 | 917 | ||
| 918 | u32 MipBlockHeight(u32 mip_level) const { | 918 | // Auto block resizing algorithm from: |
| 919 | u32 height = MipHeight(mip_level); | 919 | // https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nv50/nv50_miptree.c |
| 920 | u32 bh = block_height; | 920 | u32 MipBlockHeight(u32 mip_level, u32 alt_height = 0) const { |
| 921 | // Magical block resizing algorithm, needs more testing. | 921 | if (mip_level == 0) |
| 922 | while (bh > 1 && (height + bh - 1) / bh <= 16) { | 922 | return block_height; |
| 923 | bh = bh >> 1; | 923 | if (alt_height == 0) |
| 924 | alt_height = MipHeight(mip_level); | ||
| 925 | u32 blocks_in_y = (alt_height + 7) / 8; | ||
| 926 | u32 bh = 32; | ||
| 927 | while (bh > 1 && blocks_in_y <= bh * 2) { | ||
| 928 | bh >>= 1; | ||
| 924 | } | 929 | } |
| 925 | return bh; | 930 | return bh; |
| 926 | } | 931 | } |
| 927 | 932 | ||
| 928 | u32 MipBlockDepth(u32 mip_level) const { | 933 | u32 MipBlockDepth(u32 mip_level) const { |
| 934 | if (mip_level == 0) | ||
| 935 | return block_depth; | ||
| 929 | u32 depth = MipDepth(mip_level); | 936 | u32 depth = MipDepth(mip_level); |
| 930 | u32 bd = block_depth; | 937 | u32 bd = 32; |
| 931 | // Magical block resizing algorithm, needs more testing. | 938 | // Magical block resizing algorithm, needs more testing. |
| 932 | while (bd > 1 && depth / bd <= 16) { | 939 | while (bd > 1 && depth / depth <= bd) { |
| 933 | bd = bd >> 1; | 940 | bd = bd >> 1; |
| 934 | } | 941 | } |
| 935 | return bd; | 942 | return bd; |
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index 76c3b65bd..87d511c38 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h | |||
| @@ -165,7 +165,6 @@ inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode, | |||
| 165 | return {}; | 165 | return {}; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | |||
| 169 | inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) { | 168 | inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) { |
| 170 | switch (wrap_mode) { | 169 | switch (wrap_mode) { |
| 171 | case Tegra::Texture::WrapMode::Wrap: | 170 | case Tegra::Texture::WrapMode::Wrap: |