mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
c/swapchain: Don't only give out the zero index
This commit is contained in:
parent
5b0085f1c1
commit
753b910b5a
2
doc/changes/compositor/mr.359.1.md
Normal file
2
doc/changes/compositor/mr.359.1.md
Normal 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.
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue