- // XXX Allocation should be tracked per-face, but we'll run out of bits
- allocated |= 1<<level;
- if(gen_mipmap && level==0)
+ if(!allocated)
+ {
+ glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
+ apply_swizzle();
+ }
+ glTexImage2D(face, level, ifmt, s, s, 0, get_upload_format(fmt), type, data);
+
+ if(level==0)
+ {
+ allocated |= 1<<get_face_index(face);
+ if((allocated&63)==63)
+ {
+ allocated |= 64;
+ if(auto_gen_mipmap)
+ {
+ generate_mipmap();
+ allocated |= (64<<levels)-1;
+ }
+ }
+ }
+ else if(!(allocated&(64<<level)))