mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
StreamBuffer: Use std::array for fences
This commit is contained in:
parent
7b69fec8e7
commit
1eea95a5be
@ -61,20 +61,20 @@ StreamBuffer::~StreamBuffer()
|
||||
|
||||
void StreamBuffer::CreateFences()
|
||||
{
|
||||
for (int i=0; i<SYNC_POINTS; i++)
|
||||
for (int i = 0; i < SYNC_POINTS; i++)
|
||||
{
|
||||
fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
m_fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
}
|
||||
void StreamBuffer::DeleteFences()
|
||||
{
|
||||
for (int i = SLOT(m_free_iterator) + 1; i < SYNC_POINTS; i++)
|
||||
{
|
||||
glDeleteSync(fences[i]);
|
||||
glDeleteSync(m_fences[i]);
|
||||
}
|
||||
for (int i = 0; i < SLOT(m_iterator); i++)
|
||||
{
|
||||
glDeleteSync(fences[i]);
|
||||
glDeleteSync(m_fences[i]);
|
||||
}
|
||||
}
|
||||
void StreamBuffer::AllocMemory(u32 size)
|
||||
@ -82,15 +82,15 @@ void StreamBuffer::AllocMemory(u32 size)
|
||||
// insert waiting slots for used memory
|
||||
for (int i = SLOT(m_used_iterator); i < SLOT(m_iterator); i++)
|
||||
{
|
||||
fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
m_fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
m_used_iterator = m_iterator;
|
||||
|
||||
// wait for new slots to end of buffer
|
||||
for (int i = SLOT(m_free_iterator) + 1; i <= SLOT(m_iterator + size) && i < SYNC_POINTS; i++)
|
||||
{
|
||||
glClientWaitSync(fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(fences[i]);
|
||||
glClientWaitSync(m_fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(m_fences[i]);
|
||||
}
|
||||
m_free_iterator = m_iterator + size;
|
||||
|
||||
@ -100,7 +100,7 @@ void StreamBuffer::AllocMemory(u32 size)
|
||||
// insert waiting slots in unused space at the end of the buffer
|
||||
for (int i = SLOT(m_used_iterator); i < SYNC_POINTS; i++)
|
||||
{
|
||||
fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
m_fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
|
||||
// move to the start
|
||||
@ -109,8 +109,8 @@ void StreamBuffer::AllocMemory(u32 size)
|
||||
// wait for space at the start
|
||||
for (int i = 0; i <= SLOT(m_iterator + size); i++)
|
||||
{
|
||||
glClientWaitSync(fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(fences[i]);
|
||||
glClientWaitSync(m_fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(m_fences[i]);
|
||||
}
|
||||
m_free_iterator = m_iterator + size;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/GL/GLUtil.h"
|
||||
@ -59,11 +60,11 @@ protected:
|
||||
u32 m_free_iterator;
|
||||
|
||||
private:
|
||||
static const int SYNC_POINTS = 16;
|
||||
static constexpr int SYNC_POINTS = 16;
|
||||
int SLOT(u32 x) const { return x >> m_bit_per_slot; }
|
||||
const int m_bit_per_slot;
|
||||
|
||||
GLsync fences[SYNC_POINTS];
|
||||
std::array<GLsync, SYNC_POINTS> m_fences{};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user