textures: keep atlas data across compressed block views

This commit is contained in:
nmzik
2026-09-06 18:57:26 +04:00
parent ced73c56cc
commit 807a594c2d
3 changed files with 70 additions and 45 deletions
@@ -47,6 +47,7 @@ struct ImageSubresourceRange {
struct ImageMipInfo {
uint64_t offset = 0;
uint64_t size = 0;
// Padded dimensions in storage elements (compressed blocks for BC formats).
uint32_t pitch = 0;
uint32_t height = 0;
auto operator<=>(const ImageMipInfo&) const = default;
@@ -563,6 +563,7 @@ static void PopulateTextureMipLayout(ImageInfo& info) {
TilePaddedSize padded[16] {};
TileGetTextureSize(info.guest_format, info.extent.width, info.extent.height,
info.resources.levels, info.tile_mode, nullptr, levels, padded);
const auto texel_shift = info.IsBlock() ? 2u : 0u;
for (uint32_t level = 0; level < info.resources.levels; level++) {
const auto offset =
levels[level].src_size != 0 ? levels[level].src_offset : levels[level].offset;
@@ -576,9 +577,8 @@ static void PopulateTextureMipLayout(ImageInfo& info) {
info.mip_layout[level] = {
offset,
size,
padded[level].width != 0 ? padded[level].width : std::max(info.pitch >> level, 1u),
padded[level].height != 0 ? padded[level].height
: std::max(info.extent.height >> level, 1u),
padded[level].width >> texel_shift,
padded[level].height >> texel_shift,
};
}
}