hello! why does loading a big texture (16384x16384) takes so much more time than loading 16 textures of 4096x4096 (if the sum of the texture sizes is the same in the end)?
in this code:
#include <SFML/Graphics.hpp>
#include <iostream>
int main(){
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML");
sf::Clock clock;
sf::Image big_img, small_img;
sf::Texture big_tex, small_tex[16];
big_img.create(16384, 16384);
small_img.create(4096, 4096);
clock.restart();
big_tex.loadFromImage(big_img);
std::cout << "big_tex loading time: " << clock.restart().asMilliseconds() << " ms" << std::endl;
for (int n=0; n<16; n++){
small_tex[n].loadFromImage(small_img);
std::cout << "small_tex[" << n << "] loading time: " << clock.restart().asMilliseconds() << " ms" << std::endl;
}
return 0;
}
in my computer (not a high-end) it took more than two minutes to load the big texture, and about 15 seconds to load all the small ones. I suspect it could be something related to the video board needing a contiguous block of memory, but I'm not sure.
anyway, can we somehow take advantage of that to make loading times faster? i tried drawing all the small ones in a RenderTexture, but loading it to a sf::Texture ended up taking much more time (about 5min) ::)
The values I get:
big_tex loading time: 395 ms
small_tex[0] loading time: 25 ms
small_tex[1] loading time: 25 ms
small_tex[2] loading time: 25 ms
small_tex[3] loading time: 25 ms
small_tex[4] loading time: 25 ms
small_tex[5] loading time: 25 ms
small_tex[6] loading time: 26 ms
small_tex[7] loading time: 25 ms
small_tex[8] loading time: 25 ms
small_tex[9] loading time: 25 ms
small_tex[10] loading time: 25 ms
small_tex[11] loading time: 25 ms
small_tex[12] loading time: 25 ms
small_tex[13] loading time: 25 ms
small_tex[14] loading time: 25 ms
small_tex[15] loading time: 25 ms
Same thing on my side (in debug mode)
big_tex loading time: 451 ms
small_tex[0] loading time: 27 ms
small_tex[1] loading time: 25 ms
small_tex[2] loading time: 27 ms
small_tex[3] loading time: 27 ms
small_tex[4] loading time: 28 ms
small_tex[5] loading time: 27 ms
small_tex[6] loading time: 29 ms
small_tex[7] loading time: 27 ms
small_tex[8] loading time: 28 ms
small_tex[9] loading time: 33 ms
small_tex[10] loading time: 34 ms
small_tex[11] loading time: 42 ms
small_tex[12] loading time: 52 ms
small_tex[13] loading time: 35 ms
small_tex[14] loading time: 36 ms
small_tex[15] loading time: 38 ms
I'd have guessed some odd AV interference, but since this code isn't even accessing the file system, that's not really possible.
As such I can only guess that your GPU might not be happy with the size of the textures.
What does sf::Texture::getMaximumSize() return and what GPU do you have?