Skip to content

Commit

Permalink
correct M-tiled surface size calculation when mip is less than a tile
Browse files Browse the repository at this point in the history
  • Loading branch information
psucien committed Nov 17, 2024
1 parent 430eec4 commit df5e56a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/video_core/texture_cache/image_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,21 @@ static constexpr std::pair<u32, size_t> ImageSizeMicroTiled(u32 pitch, u32 heigh
}

static constexpr std::pair<u32, size_t> ImageSizeMacroTiled(u32 pitch, u32 height, u32 bpp,
u32 num_samples, u32 tiling_idx) {
u32 num_samples, u32 tiling_idx,
u32 mip_n) {
const auto& [pitch_align, height_align] = GetMacroTileExtents(tiling_idx, bpp, num_samples);
ASSERT(pitch_align != 0 && height_align != 0);
bool downgrade_to_micro = false;
if (mip_n > 0) {
const bool is_less_than_tile = pitch < pitch_align || height < height_align;
// TODO: threshold check
downgrade_to_micro = is_less_than_tile;
}

if (downgrade_to_micro) {
return ImageSizeMicroTiled(pitch, height, bpp, num_samples);
}

const auto pitch_aligned = (pitch + pitch_align - 1) & ~(pitch_align - 1);
const auto height_aligned = (height + height_align - 1) & ~(height_align - 1);
const auto log_sz = pitch_aligned * height_aligned * num_samples;
Expand Down Expand Up @@ -366,7 +378,7 @@ void ImageInfo::UpdateSize() {
case AmdGpu::TilingMode::Depth_MacroTiled: {
ASSERT(!props.is_block);
std::tie(mip_info.pitch, mip_info.size) =
ImageSizeMacroTiled(mip_w, mip_h, bpp, num_samples, tiling_idx);
ImageSizeMacroTiled(mip_w, mip_h, bpp, num_samples, tiling_idx, mip);
break;
}
default: {
Expand Down

0 comments on commit df5e56a

Please sign in to comment.