vulkan: only send out buffers when ready

Keep track of the buffer that is rendering and when it finishes,
move it to the ready queue.
This commit is contained in:
Wim Taymans 2019-08-19 18:16:32 +02:00
parent 38169ec5db
commit 4f31ca5383
3 changed files with 136 additions and 110 deletions

View file

@ -287,20 +287,28 @@ static int make_buffer(struct impl *this)
spa_vulkan_process(&this->state, b->id);
b->outbuf->datas[0].chunk->offset = 0;
b->outbuf->datas[0].chunk->size = n_bytes;
b->outbuf->datas[0].chunk->stride = port->stride;
if (this->state.ready_buffer_id != SPA_ID_INVALID) {
struct buffer *b = &port->buffers[this->state.ready_buffer_id];
if (b->h) {
b->h->seq = this->frame_count;
b->h->pts = this->start_time + this->elapsed_time;
b->h->dts_offset = 0;
this->state.ready_buffer_id = SPA_ID_INVALID;
spa_log_trace(this->log, NAME " %p: ready buffer %d", this, b->id);
b->outbuf->datas[0].chunk->offset = 0;
b->outbuf->datas[0].chunk->size = n_bytes;
b->outbuf->datas[0].chunk->stride = port->stride;
if (b->h) {
b->h->seq = this->frame_count;
b->h->pts = this->start_time + this->elapsed_time;
b->h->dts_offset = 0;
}
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
spa_list_append(&port->ready, &b->link);
res = SPA_STATUS_HAVE_BUFFER;
}
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
spa_list_append(&port->ready, &b->link);
res = SPA_STATUS_HAVE_BUFFER;
next:
this->frame_count++;
this->elapsed_time = FRAMES_TO_TIME(port, this->frame_count);
@ -926,6 +934,8 @@ impl_init(const struct spa_handle_factory *factory,
spa_list_init(&port->empty);
spa_list_init(&port->ready);
this->state.log = this->log;
spa_log_info(this->log, NAME " %p: initialized", this);
return 0;