Split out guest texture layer size calcs into a seperate func

This commit is contained in:
Billy Laws 2022-10-09 16:42:51 +01:00
parent 8fa83fdf13
commit ad3195e06f
2 changed files with 13 additions and 3 deletions

View File

@ -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<u32>(format->GetSize(dimensions));
return static_cast<u32>(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<u32>(texture::GetBlockLinearLayerSize(dimensions, format->blockHeight, format->blockWidth, format->bpb, tileConfig.blockHeight, tileConfig.blockDepth, mipLevelCount, layerCount > 1));
return static_cast<u32>(texture::GetBlockLinearLayerSize(dimensions, format->blockHeight, format->blockWidth, format->bpb, tileConfig.blockHeight, tileConfig.blockDepth, mipLevelCount, layerCount > 1));
}
}

View File

@ -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
*/