{
userdata.reset(new Userdata[num_queued_frames]);
for (size_t i = 0; i < num_queued_frames; ++i) {
- init_frame(i, frame_size, width, height, permissions, map_bits, generation);
+ Frame frame;
+ init_frame(frame, &userdata[i], this, pixel_format, frame_size, width, height, permissions, map_bits, buffer, generation);
+ freelist.push(frame);
}
glBindBuffer(buffer, 0);
check_error();
check_error();
}
-void PBOFrameAllocator::init_frame(size_t frame_idx, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits, int generation)
+void PBOFrameAllocator::init_frame(Frame &frame, Userdata *ud, PBOFrameAllocator *owner, bmusb::PixelFormat pixel_format, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits, GLenum buffer, int generation)
{
GLuint pbo;
glGenBuffers(1, &pbo);
glBufferStorage(buffer, frame_size, nullptr, permissions | GL_MAP_PERSISTENT_BIT);
check_error();
- Frame frame;
frame.data = (uint8_t *)glMapBufferRange(buffer, 0, frame_size, permissions | map_bits | GL_MAP_PERSISTENT_BIT);
frame.data2 = frame.data + frame_size / 2;
check_error();
frame.size = frame_size;
- Userdata *ud = &userdata[frame_idx];
frame.userdata = ud;
ud->generation = generation;
ud->pbo = pbo;
ud->pixel_format = pixel_format;
ud->data_copy_malloc = new uint8_t[frame_size];
- frame.owner = this;
+ frame.owner = owner;
// For 8-bit non-planar Y'CbCr, we ask the driver to split Y' and Cb/Cr
// into separate textures. For 10-bit, the input format (v210)
assert(false);
}
}
-
- freelist.push(frame);
}
PBOFrameAllocator::~PBOFrameAllocator()
userdata.reset(new Userdata[num_queued_frames]);
for (size_t i = 0; i < num_queued_frames; ++i) {
- init_frame(i, frame_size, width, height, permissions, map_bits, generation);
+ Frame frame;
+ init_frame(frame, &userdata[i], this, pixel_format, frame_size, width, height, permissions, map_bits, buffer, generation);
+ freelist.push(frame);
}
// There may still be frames out with the old configuration
};
private:
- void init_frame(size_t frame_idx, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits, int generation);
+ static void init_frame(Frame &frame, Userdata *ud, PBOFrameAllocator *owner, bmusb::PixelFormat pixel_format, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits, GLenum buffer, int generation);
void destroy_frame(Frame *frame);
unsigned card_index;