diff options
author | bunnei <bunneidev@gmail.com> | 2018-09-21 05:41:25 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-09-30 20:31:58 +0200 |
commit | f543b43fd054ae9ec1e4d693a9bd1540e408ddac (patch) | |
tree | 25ad751cf70c87c7e7ef7f9345bb680365eb8929 /src/video_core/renderer_opengl/gl_rasterizer_cache.h | |
parent | gl_shader_decompiler: TEXS: Implement TextureType::TextureCube. (diff) | |
download | yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar.gz yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar.bz2 yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar.lz yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar.xz yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.tar.zst yuzu-f543b43fd054ae9ec1e4d693a9bd1540e408ddac.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.h')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index e2fd0009e..51eb9b6dd 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -9,6 +9,7 @@ #include <memory> #include <vector> +#include "common/alignment.h" #include "common/common_types.h" #include "common/hash.h" #include "common/math_util.h" @@ -706,6 +707,29 @@ struct SurfaceParams { return SizeInBytes2D() * depth; } + /** + * Returns the size in bytes of the 2D surface with mipmaps. Each mipmap level proceeds the + * previous with half the width and half the height. Once the size of the next mip reaches 0, we + * are done. + */ + std::size_t SizeInBytes2DWithMipmap() const { + std::size_t size_in_bytes{}; + auto mip_params{*this}; + for (std::size_t level = 0; level < max_mip_level; level++) { + size_in_bytes += mip_params.SizeInBytes2D(); + + mip_params.width /= 2; + mip_params.height /= 2; + + if (!mip_params.width || !mip_params.height) { + break; + } + } + + // TODO(bunnei): This alignup is unverified, but necessary in games tested (e.g. in SMO) + return Common::AlignUp(size_in_bytes, 0x1000); + } + /// Creates SurfaceParams from a texture configuration static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, const GLShader::SamplerEntry& entry); @@ -738,6 +762,15 @@ struct SurfaceParams { std::size_t size_in_bytes_total; std::size_t size_in_bytes_2d; SurfaceTarget target; + u32 max_mip_level; + + // Render target specific parameters, not used in caching + struct { + u32 index; + u32 array_mode; + u32 layer_stride; + u32 base_layer; + } rt; }; }; // namespace OpenGL @@ -747,6 +780,7 @@ struct SurfaceReserveKey : Common::HashableStruct<OpenGL::SurfaceParams> { static SurfaceReserveKey Create(const OpenGL::SurfaceParams& params) { SurfaceReserveKey res; res.state = params; + res.state.rt = {}; // Ignore rt config in caching return res; } }; |