forked from organicmaps/organicmaps
added support for partial execution of PacketsQueue in QueuedRenderer.
This commit is contained in:
parent
0d55df6dd1
commit
a8bf5cfb16
2 changed files with 32 additions and 9 deletions
|
@ -4,6 +4,8 @@
|
|||
QueuedRenderer::QueuedRenderer(int pipelinesCount)
|
||||
{
|
||||
m_Pipelines = new PacketsPipeline[pipelinesCount];
|
||||
for (int i = 0; i < pipelinesCount; ++i)
|
||||
m_Pipelines[i].m_CouldExecutePartially = false;
|
||||
m_PipelinesCount = pipelinesCount;
|
||||
m_CurrentPipeline = 0;
|
||||
m_ProcessSinglePipelineAtFrame = false;
|
||||
|
@ -22,12 +24,21 @@ QueuedRenderer::~QueuedRenderer()
|
|||
bool QueuedRenderer::NeedRedraw() const
|
||||
{
|
||||
for (unsigned i = 0; i < m_PipelinesCount; ++i)
|
||||
{
|
||||
if (!m_Pipelines[i].m_Queue.empty())
|
||||
return true;
|
||||
if (!m_Pipelines[i].m_FrameCommands.empty())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QueuedRenderer::SetPartialExecution(int pipelineNum, bool flag)
|
||||
{
|
||||
m_Pipelines[pipelineNum].m_CouldExecutePartially = flag;
|
||||
}
|
||||
|
||||
void QueuedRenderer::BeginFrame()
|
||||
{
|
||||
m_IsDebugging = false;
|
||||
|
@ -69,20 +80,22 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum)
|
|||
|
||||
unsigned cmdProcessed = 0;
|
||||
|
||||
m_Pipelines[pipelineNum].m_Queue.processList(bind(&QueuedRenderer::PacketsPipeline::FillFrameCommands, &m_Pipelines[pipelineNum], _1, 1));
|
||||
/// FrameCommands could contain commands from the previous frame if
|
||||
/// the processed pipeline is allowed to be executed partially.
|
||||
if (m_Pipelines[pipelineNum].m_FrameCommands.empty())
|
||||
m_Pipelines[pipelineNum].m_Queue.processList(bind(&QueuedRenderer::PacketsPipeline::FillFrameCommands, &m_Pipelines[pipelineNum], _1, 1));
|
||||
|
||||
cmdProcessed = m_Pipelines[pipelineNum].m_FrameCommands.size();
|
||||
|
||||
list<yg::gl::Packet>::iterator it;
|
||||
|
||||
bool res = !m_Pipelines[pipelineNum].m_FrameCommands.empty();
|
||||
bool partialExecution = m_Pipelines[pipelineNum].m_CouldExecutePartially;
|
||||
|
||||
yg::gl::Packet::EType bucketType = m_Pipelines[pipelineNum].m_Type;
|
||||
|
||||
|
||||
for (it = m_Pipelines[pipelineNum].m_FrameCommands.begin();
|
||||
it != m_Pipelines[pipelineNum].m_FrameCommands.end();
|
||||
++it)
|
||||
while ((it = m_Pipelines[pipelineNum].m_FrameCommands.begin())
|
||||
!= m_Pipelines[pipelineNum].m_FrameCommands.end())
|
||||
{
|
||||
if (it->m_command)
|
||||
it->m_command->setIsDebugging(m_IsDebugging);
|
||||
|
@ -99,10 +112,17 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum)
|
|||
if (it->m_command)
|
||||
it->m_command->perform();
|
||||
}
|
||||
}
|
||||
|
||||
/// should clear to release resources, refered from the stored commands.
|
||||
m_Pipelines[pipelineNum].m_FrameCommands.clear();
|
||||
bool isCheckpoint = (it->m_type == yg::gl::Packet::ECheckPoint);
|
||||
|
||||
m_Pipelines[pipelineNum].m_FrameCommands.pop_front();
|
||||
|
||||
/// if we found a checkpoint instead of frameboundary and this
|
||||
/// pipeline is allowed to be partially executed we are
|
||||
/// breaking from processing cycle.
|
||||
if (isCheckpoint && partialExecution)
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_IsDebugging)
|
||||
{
|
||||
|
@ -118,7 +138,7 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum)
|
|||
|
||||
void QueuedRenderer::PacketsPipeline::FillFrameCommands(list<yg::gl::Packet> & renderQueue, int maxFrames)
|
||||
{
|
||||
m_FrameCommands.clear();
|
||||
ASSERT(m_FrameCommands.empty(), ());
|
||||
|
||||
/// searching for "delimiter" markers
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ private:
|
|||
list<yg::gl::Packet> m_FrameCommands; //< list of commands to execute on current frame
|
||||
yg::gl::Packet::EType m_Type; //< type of the actions to perform with FrameCommands
|
||||
|
||||
bool m_CouldExecutePartially;
|
||||
|
||||
/// - this function is passed to ThreadedList::ProcessQueue to fill up
|
||||
/// the FrameCommands from the QueueData, taking at maximum maxCheckPoints chunks,
|
||||
/// skipping empty frames.
|
||||
|
@ -53,6 +55,7 @@ public:
|
|||
bool RenderQueuedCommands(int pipelineNum);
|
||||
void CancelQueuedCommands(int pipelineNum);
|
||||
void PrepareQueueCancellation(int pipelineNum);
|
||||
void SetPartialExecution(int pipelineNum, bool flag);
|
||||
|
||||
void BeginFrame();
|
||||
void DrawFrame();
|
||||
|
|
Loading…
Add table
Reference in a new issue