using glReadPixels only on PowerVR devices on Android.

This commit is contained in:
rachytski 2012-07-25 20:35:05 -07:00 committed by Alex Zolotarev
parent ad65d6a01e
commit ee3f59fcd1
7 changed files with 38 additions and 4 deletions

View file

@ -6,6 +6,7 @@ QueuedRenderer::QueuedRenderer(int pipelinesCount)
m_Pipelines = new PacketsPipeline[pipelinesCount];
m_PipelinesCount = pipelinesCount;
m_CurrentPipeline = 0;
m_ProcessSinglePipelineAtFrame = false;
}
QueuedRenderer::~QueuedRenderer()
@ -51,7 +52,8 @@ void QueuedRenderer::DrawFrame()
{
/// next DrawFrame should start from another pipeline
m_CurrentPipeline = (num + 1) % m_PipelinesCount;
break;
if (m_ProcessSinglePipelineAtFrame)
break;
}
}
}
@ -202,3 +204,8 @@ void QueuedRenderer::PrepareQueueCancellation(int pipelineNum)
{
m_Pipelines[pipelineNum].m_Queue.cancelFences();
}
void QueuedRenderer::SetSinglePipelineProcessing(bool flag)
{
m_ProcessSinglePipelineAtFrame = flag;
}

View file

@ -36,6 +36,11 @@ private:
/// pipeline starvation we should select them in a cyclic manner
int m_CurrentPipeline;
/// This flag controls whether we should process only one pipeline at a frame.
/// This is necessary to improve the GUI responsiveness if we have a lot of
/// "heavy" commands in the pipeline.
bool m_ProcessSinglePipelineAtFrame;
bool m_IsDebugging;
public:
@ -54,6 +59,7 @@ public:
void EndFrame();
bool NeedRedraw() const;
void SetSinglePipelineProcessing(bool flag);
yg::gl::PacketsQueue * GetPacketsQueue(int pipelineNum);
};

View file

@ -111,8 +111,8 @@ RenderPolicyST::RenderPolicyST(Params const & p)
rmp.fitIntoLimits();
m_resourceManager.reset();
m_resourceManager.reset(new yg::ResourceManager(rmp));
m_QueuedRenderer->SetSinglePipelineProcessing(m_resourceManager->useReadPixelsToSynchronize());
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);

View file

@ -134,7 +134,6 @@ void TileRenderer::ReadPixels(yg::gl::PacketsQueue * glQueue, core::CommandsQueu
unsigned tileHeight = m_resourceManager->params().m_renderTargetTexturesParams.m_texHeight;
shared_ptr<vector<unsigned char> > buf = SharedBufferManager::instance().reserveSharedBuffer(tileWidth * tileHeight * 4);
drawer->screen()->finish(true);
drawer->screen()->readPixels(m2::RectU(0, 0, tileWidth, tileHeight), &(buf->at(0)), true);
SharedBufferManager::instance().freeSharedBuffer(tileWidth * tileHeight * 4, buf);
}
@ -231,9 +230,11 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
if (!env.isCancelled())
tileOverlay->clip(renderRect);
ReadPixels(glQueue, env);
drawer->screen()->finish();
if (m_resourceManager->useReadPixelsToSynchronize())
ReadPixels(glQueue, env);
drawer->screen()->unbindRenderTarget();
if (!env.isCancelled())

View file

@ -140,6 +140,8 @@ TilingRenderPolicyST::TilingRenderPolicyST(Params const & p)
m_resourceManager.reset(new yg::ResourceManager(rmp));
m_QueuedRenderer->SetSinglePipelineProcessing(m_resourceManager->useReadPixelsToSynchronize());
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);
m_resourceManager->addFonts(fonts);

View file

@ -404,6 +404,7 @@ namespace
{
/// general case
m_texRtFormat = yg::Data4Bpp;
m_useReadPixelsToSynchronize = false;
if (isGPU("Qualcomm", "Adreno", false))
m_texRtFormat = yg::Data8Bpp;
@ -417,6 +418,13 @@ namespace
m_texRtFormat = yg::Data8Bpp;
}
bool isAndroidDevice = GetPlatform().DeviceName() == "Android";
/// on PowerVR chips in Android glFinish doesn't work, so we should use
/// glReadPixels instead of glFinish to synchronize.
if (isGPU("Imagination Technologies", "PowerVR", false) && isAndroidDevice)
m_useReadPixelsToSynchronize = true;
/* /// filtering all devices from Vivante Corporation
/// to use vertex arrays
if (isGPU("Vivante Corporation", "", false))
@ -439,6 +447,8 @@ namespace
};
LOG(LINFO, ("selected", name, "format for tile textures"));
if (m_useReadPixelsToSynchronize)
LOG(LINFO, ("using ReadPixels instead of glFinish to synchronize"));
}
void ResourceManager::Params::fitIntoLimits()
@ -891,4 +901,9 @@ namespace
if (m_guiThreadStorages.get())
m_guiThreadStorages->Cancel();
}
bool ResourceManager::useReadPixelsToSynchronize() const
{
return m_params.m_useReadPixelsToSynchronize;
}
}

View file

@ -220,6 +220,7 @@ namespace yg
DataFormat m_texFormat;
DataFormat m_texRtFormat;
bool m_useSingleThreadedOGL;
bool m_useReadPixelsToSynchronize;
size_t m_videoMemoryLimit;
@ -321,6 +322,8 @@ namespace yg
void cancel();
bool useReadPixelsToSynchronize() const;
shared_ptr<yg::gl::BaseTexture> createRenderTarget(unsigned w, unsigned h);
};