mirror of
https://github.com/mpv-player/mpv
synced 2025-04-07 10:02:50 +00:00
vo_opengl: make the number of PBOs tunable
Also set the number of PBOs from 2 to 3, which should be better for pipelining. This makes it easier to add more in the future.
This commit is contained in:
parent
9b6c93e904
commit
8f1a889f75
@ -1156,15 +1156,15 @@ void gl_pbo_upload_tex(struct gl_pbo_upload *pbo, GL *gl, bool use_pbo,
|
|||||||
if (!pbo->buffers[0]) {
|
if (!pbo->buffers[0]) {
|
||||||
pbo->gl = gl;
|
pbo->gl = gl;
|
||||||
pbo->buffer_size = buffer_size;
|
pbo->buffer_size = buffer_size;
|
||||||
gl->GenBuffers(2, &pbo->buffers[0]);
|
gl->GenBuffers(NUM_PBO_BUFFERS, &pbo->buffers[0]);
|
||||||
for (int n = 0; n < 2; n++) {
|
for (int n = 0; n < NUM_PBO_BUFFERS; n++) {
|
||||||
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[n]);
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[n]);
|
||||||
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL,
|
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL,
|
||||||
GL_DYNAMIC_COPY);
|
GL_DYNAMIC_COPY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pbo->index = (pbo->index + 1) % 2;
|
pbo->index = (pbo->index + 1) % NUM_PBO_BUFFERS;
|
||||||
|
|
||||||
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[pbo->index]);
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[pbo->index]);
|
||||||
void *data = gl->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, needed_size,
|
void *data = gl->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, needed_size,
|
||||||
@ -1192,6 +1192,6 @@ no_pbo:
|
|||||||
void gl_pbo_upload_uninit(struct gl_pbo_upload *pbo)
|
void gl_pbo_upload_uninit(struct gl_pbo_upload *pbo)
|
||||||
{
|
{
|
||||||
if (pbo->gl)
|
if (pbo->gl)
|
||||||
pbo->gl->DeleteBuffers(2, &pbo->buffers[0]);
|
pbo->gl->DeleteBuffers(NUM_PBO_BUFFERS, &pbo->buffers[0]);
|
||||||
*pbo = (struct gl_pbo_upload){0};
|
*pbo = (struct gl_pbo_upload){0};
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,12 @@ uint64_t gl_timer_last_us(struct gl_timer *timer);
|
|||||||
uint64_t gl_timer_avg_us(struct gl_timer *timer);
|
uint64_t gl_timer_avg_us(struct gl_timer *timer);
|
||||||
uint64_t gl_timer_peak_us(struct gl_timer *timer);
|
uint64_t gl_timer_peak_us(struct gl_timer *timer);
|
||||||
|
|
||||||
|
#define NUM_PBO_BUFFERS 3
|
||||||
|
|
||||||
struct gl_pbo_upload {
|
struct gl_pbo_upload {
|
||||||
GL *gl;
|
GL *gl;
|
||||||
int index;
|
int index;
|
||||||
GLuint buffers[2];
|
GLuint buffers[NUM_PBO_BUFFERS];
|
||||||
size_t buffer_size;
|
size_t buffer_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user