c/swapchain: Don't only give out the zero index

This commit is contained in:
Jakob Bornecrantz 2020-05-30 16:39:35 +01:00
parent 5b0085f1c1
commit 753b910b5a
3 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,2 @@
swapchain: Give out the oldset image index when a image is acquired. This logic
can be made better, but will work for the good case.

View file

@ -13,6 +13,7 @@
#include "xrt/xrt_gfx_vk.h"
#include "util/u_threading.h"
#include "util/u_index_fifo.h"
#include "main/comp_settings.h"
#include "main/comp_window.h"
@ -64,6 +65,12 @@ struct comp_swapchain
struct comp_compositor *c;
struct comp_swapchain_image images[XRT_MAX_SWAPCHAIN_IMAGES];
/*!
* This fifo is used to always give out the oldest image to acquire
* image, this should probably be made even smarter.
*/
struct u_index_fifo fifo;
};
enum comp_layer_type

View file

@ -31,8 +31,9 @@ swapchain_acquire_image(struct xrt_swapchain *xsc, uint32_t *index)
struct comp_swapchain *sc = comp_swapchain(xsc);
COMP_SPEW(sc->c, "ACQUIRE_IMAGE");
*index = 0;
return true;
// Returns negative on empty fifo.
return u_index_fifo_pop(&sc->fifo, index) >= 0;
}
static bool
@ -52,6 +53,9 @@ swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
struct comp_swapchain *sc = comp_swapchain(xsc);
COMP_SPEW(sc->c, "RELEASE_IMAGE");
u_index_fifo_push(&sc->fifo, index);
return true;
}
@ -273,6 +277,11 @@ comp_swapchain_create(struct xrt_compositor *xc,
}
}
// Prime the fifo
for (uint32_t i = 0; i < num_images; i++) {
u_index_fifo_push(&sc->fifo, i);
}
/*
*