+ assert(generation == userdata->generation);
+ if (vf.size < desired_frame_bytes || (vf.size > FRAME_SIZE && vf.size > desired_frame_bytes * 2)) {
+ // Frame is either too small or way too large, so reallocate it.
+ // Note that width and height now automatically becomes the right size
+ // (the one we just asked for, instead of the default for the allocator,
+ // which is generally the global resolution); it doesn't matter
+ // for correctness, since we'll recreate the texture on upload if needed,
+ // but it is nice to save that step.
+ destroy_frame(&vf);
+ init_frame(vf, userdata, this, pixel_format, std::max<size_t>(desired_frame_bytes, FRAME_SIZE), width, height, permissions, map_bits, buffer, generation);
+ };
+
+ vf.len = 0;
+ vf.overflow = 0;