Closed ajtribick closed 2 weeks ago
At least they should not be larger then max texture size.
As an initial step, I think 16384 makes sense as an initial hard limit, since it's the largest power-of-two where the byte size of an 8-bit per channel RGBA image does not overflow a 32-bit signed integer (relevant for, e.g. ptrdiff_t
on 32-bit systems).
std::min(16384, gl::maxTextureSize);
Looks like we already implement splitting images into tiles when loading them as textures: https://github.com/CelestiaProject/Celestia/blob/97fe2c9c101d4ccba887fb9cd8d6a3de90b11344/src/celengine/texture.cpp#L352-L377
So I think we can implement the hard limit in the image loader and rely on the texture loader to implement the OpenGL-specific requirements.
It would probably make sense to impose a check on image sizes at load time to avoid trying to deal with huge images (or corrupt files whose metadata claims that the image dimensions are absurdly large). Any suggestions for an upper limit, e.g. maximum dimension 8192, 16384, 32768?
(For virtual textures this would be a per-tile limit)