- unsigned width = static_cast<const Texture1D *>(this)->width;
- return id ? width*get_pixel_size(storage_fmt) : 0;
+ if(!id)
+ return 0;
+
+ const Texture1D &self = *static_cast<const Texture1D *>(this);
+
+ size_t level_size = self.width*get_pixel_size(storage_fmt);
+ size_t total_size = level_size;
+ for(unsigned i=0; i<n_levels; ++i, level_size>>=2)
+ total_size += level_size;
+ return total_size;