8 #ifndef hifi_gpu_ResourceSwapChain_h
9 #define hifi_gpu_ResourceSwapChain_h
18 SwapChain(uint8_t size = 2U) : _size{ size } {}
19 virtual ~SwapChain() {}
22 _frontIndex = (_frontIndex + 1) % _size;
25 uint8_t getSize()
const {
return _size; }
29 uint8_t _frontIndex{ 0U };
32 typedef std::shared_ptr<SwapChain> SwapChainPointer;
35 class ResourceSwapChain :
public SwapChain {
43 using TypePointer = std::shared_ptr<R>;
44 using TypeConstPointer = std::shared_ptr<const R>;
46 ResourceSwapChain(
const std::vector<TypePointer>& v) : SwapChain{ std::min<uint8_t>((uint8_t)v.size(), MAX_SIZE) } {
47 for (
size_t i = 0; i < _size; ++i) {
51 const TypePointer& get(
unsigned int index)
const {
return _resources[(index + _frontIndex) % _size]; }
55 std::array<TypePointer, MAX_SIZE> _resources;