force alignment of mip levels for block compressible imported textures by reducing mipcount if necessary
This commit is contained in:
@@ -1729,7 +1729,7 @@ namespace wi::graphics
|
||||
{
|
||||
return ((value + alignment - 1) / alignment) * alignment;
|
||||
}
|
||||
constexpr uint32_t GetMipCount(uint32_t width, uint32_t height, uint32_t depth = 1u, uint32_t min_dimension = 1u)
|
||||
constexpr uint32_t GetMipCount(uint32_t width, uint32_t height, uint32_t depth = 1u, uint32_t min_dimension = 1u, uint32_t required_alignment = 1u)
|
||||
{
|
||||
uint32_t mips = 1;
|
||||
while (width > min_dimension || height > min_dimension || depth > min_dimension)
|
||||
@@ -1737,6 +1737,12 @@ namespace wi::graphics
|
||||
width = std::max(min_dimension, width >> 1u);
|
||||
height = std::max(min_dimension, height >> 1u);
|
||||
depth = std::max(min_dimension, depth >> 1u);
|
||||
if (
|
||||
AlignTo(width, required_alignment) != width ||
|
||||
AlignTo(height, required_alignment) != height ||
|
||||
AlignTo(depth, required_alignment) != depth
|
||||
)
|
||||
break;
|
||||
mips++;
|
||||
}
|
||||
return mips;
|
||||
|
||||
@@ -934,7 +934,7 @@ namespace wi
|
||||
const uint32_t block_size = GetFormatBlockSize(desc.format);
|
||||
desc.width = AlignTo(desc.width, block_size);
|
||||
desc.height = AlignTo(desc.height, block_size);
|
||||
desc.mip_levels = GetMipCount(desc.width, desc.height, desc.depth, block_size);
|
||||
desc.mip_levels = GetMipCount(desc.width, desc.height, desc.depth, block_size, block_size);
|
||||
|
||||
success = device->CreateTexture(&desc, nullptr, &resource->texture);
|
||||
device->SetName(&resource->texture, name.c_str());
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 238;
|
||||
const int revision = 239;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user