diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.cpp b/app/src/main/cpp/skyline/gpu/texture/texture.cpp index ac442107..ec9db2a6 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture/texture.cpp @@ -16,15 +16,20 @@ namespace skyline::gpu { if (layerStride) return layerStride; + layerStride = CalculateLayerSize(); + return layerStride; + } + + u32 GuestTexture::CalculateLayerSize() { switch (tileConfig.mode) { case texture::TileMode::Linear: - return layerStride = static_cast(format->GetSize(dimensions)); + return static_cast(format->GetSize(dimensions)); case texture::TileMode::Pitch: - return layerStride = dimensions.height * tileConfig.pitch; + return dimensions.height * tileConfig.pitch; case texture::TileMode::Block: - return layerStride = static_cast(texture::GetBlockLinearLayerSize(dimensions, format->blockHeight, format->blockWidth, format->bpb, tileConfig.blockHeight, tileConfig.blockDepth, mipLevelCount, layerCount > 1)); + return static_cast(texture::GetBlockLinearLayerSize(dimensions, format->blockHeight, format->blockWidth, format->bpb, tileConfig.blockHeight, tileConfig.blockDepth, mipLevelCount, layerCount > 1)); } } diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.h b/app/src/main/cpp/skyline/gpu/texture/texture.h index f1e8da30..b6ee8a8d 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.h +++ b/app/src/main/cpp/skyline/gpu/texture/texture.h @@ -276,6 +276,11 @@ namespace skyline::gpu { */ u32 GetLayerStride(); + /** + * @brief Calculates the size of a single layer in bytes, unlike `GetLayerStride` the returned layer size is always calculated and may not be equal to the actual layer stride + */ + u32 CalculateLayerSize(); + /** * @return The most appropriate backing image type for this texture */