From 414a87a4f4570344140d77a7985b4d118b754341 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Dec 2020 04:51:14 -0500 Subject: video_core: Resolve more variable shadowing scenarios pt.2 Migrates the video core code closer to enabling variable shadowing warnings as errors. This primarily sorts out shadowing occurrences within the Vulkan code. --- src/video_core/texture_cache/surface_base.cpp | 27 +++++++++++++------------ src/video_core/texture_cache/surface_base.h | 4 ++-- src/video_core/texture_cache/surface_params.cpp | 14 ++++++------- 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src/video_core/texture_cache') diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp index b44c09d71..42a1c0c6f 100644 --- a/src/video_core/texture_cache/surface_base.cpp +++ b/src/video_core/texture_cache/surface_base.cpp @@ -167,27 +167,28 @@ std::vector SurfaceBaseImpl::BreakDownNonLayered(const SurfaceParams return result; } -void SurfaceBaseImpl::SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params, - u8* buffer, u32 level) { - const u32 width{params.GetMipWidth(level)}; - const u32 height{params.GetMipHeight(level)}; - const u32 block_height{params.GetMipBlockHeight(level)}; - const u32 block_depth{params.GetMipBlockDepth(level)}; +void SurfaceBaseImpl::SwizzleFunc(MortonSwizzleMode mode, u8* memory, + const SurfaceParams& surface_params, u8* buffer, u32 level) { + const u32 width{surface_params.GetMipWidth(level)}; + const u32 height{surface_params.GetMipHeight(level)}; + const u32 block_height{surface_params.GetMipBlockHeight(level)}; + const u32 block_depth{surface_params.GetMipBlockDepth(level)}; std::size_t guest_offset{mipmap_offsets[level]}; - if (params.is_layered) { + if (surface_params.is_layered) { std::size_t host_offset = 0; const std::size_t guest_stride = layer_size; - const std::size_t host_stride = params.GetHostLayerSize(level); - for (u32 layer = 0; layer < params.depth; ++layer) { - MortonSwizzle(mode, params.pixel_format, width, block_height, height, block_depth, 1, - params.tile_width_spacing, buffer + host_offset, memory + guest_offset); + const std::size_t host_stride = surface_params.GetHostLayerSize(level); + for (u32 layer = 0; layer < surface_params.depth; ++layer) { + MortonSwizzle(mode, surface_params.pixel_format, width, block_height, height, + block_depth, 1, surface_params.tile_width_spacing, buffer + host_offset, + memory + guest_offset); guest_offset += guest_stride; host_offset += host_stride; } } else { - MortonSwizzle(mode, params.pixel_format, width, block_height, height, block_depth, - params.GetMipDepth(level), params.tile_width_spacing, buffer, + MortonSwizzle(mode, surface_params.pixel_format, width, block_height, height, block_depth, + surface_params.GetMipDepth(level), surface_params.tile_width_spacing, buffer, memory + guest_offset); } } diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 173f2edba..cfcfa5b3a 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h @@ -167,8 +167,8 @@ protected: std::vector mipmap_offsets; private: - void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params, u8* buffer, - u32 level); + void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& surface_params, + u8* buffer, u32 level); std::vector BreakDownLayered(const SurfaceParams& in_params) const; diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp index 13dd16356..305297719 100644 --- a/src/video_core/texture_cache/surface_params.cpp +++ b/src/video_core/texture_cache/surface_params.cpp @@ -356,18 +356,18 @@ std::size_t SurfaceParams::GetLayerSize(bool as_host_size, bool uncompressed) co std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size, bool uncompressed) const { - const u32 width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())}; - const u32 height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())}; - const u32 depth{is_layered ? 1U : GetMipDepth(level)}; + const u32 mip_width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())}; + const u32 mip_height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())}; + const u32 mip_depth{is_layered ? 1U : GetMipDepth(level)}; if (is_tiled) { - return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), width, height, - depth, GetMipBlockHeight(level), + return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), mip_width, + mip_height, mip_depth, GetMipBlockHeight(level), GetMipBlockDepth(level)); } else if (as_host_size || IsBuffer()) { - return GetBytesPerPixel() * width * height * depth; + return GetBytesPerPixel() * mip_width * mip_height * mip_depth; } else { // Linear Texture Case - return pitch * height * depth; + return pitch * mip_height * mip_depth; } } -- cgit v1.2.3