KhronosGroup / KTX-Specification

KTX file format source
Other
69 stars 12 forks source link

Definition of 'num_blocks_x' lacks max(1, ...) ? #198

Closed JulienVernay-AsoboStudio closed 1 year ago

JulienVernay-AsoboStudio commented 1 year ago

Hello,

In the 2. File Structure section, the following definitions are given for the number of blocks for a given mip level p.

num\_blocks\_z = \max\left(1, \left\lceil{\frac{\left\lfloor{{pixelDepth}*{2^{-p}}}\right\rfloor}{block\_depth}}\right\rceil\right)$
num\_blocks\_y = \max\left(1, \left\lceil{\frac{\left\lfloor{{pixelHeight}*{2^{-p}}}\right\rfloor}{block\_height}}\right\rceil\right)
num\_blocks\_x = \left\lceil{\frac{\left\lfloor{{pixelWidth}*{2^{-p}}}\right\rfloor}{block\_width}}\right\rceil

num_blocks_y and num_blocks_z are required to be at least 1 block, which is useful for non-square textures. Shouldn't num_blocks_x be at least 1 block too ?

For instance, given the texture dimension (pixelWidth, pixelHeight, pixelDepth) = (256, 512, 1) : The maximum level p can be log2(512) = 9. At this level, there should be num_blocks_(x, y, z) = (1, 1, 1). Yet, the definitions give num_blocks_(x, y, z) = (0, 1, 1).

MarkCallow commented 1 year ago

Shouldn't num_blocks_x be at least 1 block too ?

Yes. That's a bug. I don't know how we failed to spot it for so long. Thanks for the report.