[android] fixed texRtFormat selection on Samsung Galaxy Young

This commit is contained in:
rachytski 2012-02-22 14:54:04 +04:00 committed by Alex Zolotarev
parent 16e8303a4e
commit 6b29ea6c2d
10 changed files with 75 additions and 9 deletions

View file

@ -99,7 +99,6 @@ namespace android
rmParams.m_videoMemoryLimit = 30 * 1024 * 1024;
rmParams.m_rtFormat = yg::Data8Bpp;
rmParams.m_texFormat = yg::Data4Bpp;
rmParams.m_texRtFormat = yg::Data4Bpp;
try
{

View file

@ -21,6 +21,8 @@ BasicRenderPolicy::BasicRenderPolicy(VideoTimer * videoTimer,
{
yg::ResourceManager::Params rmp = rmParams;
rmp.selectTexRTFormat();
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),

View file

@ -22,6 +22,8 @@ RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
{
yg::ResourceManager::Params rmp = rmParams;
rmp.selectTexRTFormat();
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),

View file

@ -23,6 +23,8 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
{
yg::ResourceManager::Params rmp = rmParams;
rmp.selectTexRTFormat();
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),

View file

@ -22,6 +22,8 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(VideoTimer * videoTimer,
{
yg::ResourceManager::Params rmp = rmParams;
rmp.selectTexRTFormat();
rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
256,
10,

View file

@ -41,6 +41,8 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
{
yg::ResourceManager::Params rmp = rmParams;
rmp.selectTexRTFormat();
rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
256,
1,

View file

@ -178,8 +178,8 @@ namespace yg
OGLCHECK(glFinish());
}
Renderer::ReadPixels::ReadPixels(m2::RectU const & r, void * data)
: m_rect(r), m_data(data)
Renderer::ReadPixels::ReadPixels(m2::RectU const & r, void * data, yg::DataFormat rtFormat)
: m_rect(r), m_data(data), m_rtFormat(rtFormat)
{}
void Renderer::ReadPixels::perform()
@ -187,19 +187,38 @@ namespace yg
if (isDebugging())
LOG(LINFO, ("performing ReadPixels command"));
int pixelDataType = 0;
int pixelFormatType = 0;
switch (m_rtFormat)
{
case yg::Data4Bpp:
pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
pixelFormatType = GL_RGBA;
break;
case yg::Data565Bpp:
pixelDataType = GL_UNSIGNED_SHORT_5_6_5;
pixelFormatType = GL_RGB;
break;
case yg::Data8Bpp:
pixelDataType = GL_UNSIGNED_BYTE;
pixelFormatType = GL_RGBA;
break;
}
OGLCHECK(glReadPixels(m_rect.minX(),
m_rect.minY(),
m_rect.SizeX(),
m_rect.SizeY(),
RT_TRAITS::gl_pixel_format_type,
RT_TRAITS::gl_pixel_data_type,
pixelDataType,
pixelFormatType,
m_data
));
}
void Renderer::readPixels(m2::RectU const & r, void * data, bool doForce)
{
processCommand(make_shared_ptr(new ReadPixels(r, data)), Packet::ECommand, doForce);
processCommand(make_shared_ptr(new ReadPixels(r, data, m_resourceManager->params().m_texRtFormat)), Packet::ECommand, doForce);
}
void Renderer::finish(bool doForce)

View file

@ -2,6 +2,7 @@
#include "color.hpp"
#include "packets_queue.hpp"
#include "resource_manager.hpp"
#include "../base/threaded_list.hpp"
#include "../std/function.hpp"
@ -42,8 +43,9 @@ namespace yg
{
m2::RectU m_rect;
void * m_data;
yg::DataFormat m_rtFormat;
ReadPixels(m2::RectU const & r, void * data);
ReadPixels(m2::RectU const & r, void * data, yg::DataFormat rtFormat);
void perform();
};

View file

@ -355,7 +355,9 @@ namespace yg
}
ResourceManager::Params::Params()
: m_rtFormat(yg::Data8Bpp),
: m_vendorName(reinterpret_cast<char const*>(glGetString(GL_VENDOR))),
m_rendererName(reinterpret_cast<char const *>(glGetString(GL_RENDERER))),
m_rtFormat(yg::Data8Bpp),
m_texFormat(yg::Data4Bpp),
m_texRtFormat(yg::Data4Bpp),
m_useSingleThreadedOGL(false),
@ -371,7 +373,29 @@ namespace yg
m_renderTargetTexturesParams("renderTargetTexture"),
m_styleCacheTexturesParams("styleCacheTexture"),
m_guiThreadTexturesParams("guiThreadTexture")
{}
{
}
bool ResourceManager::Params::isGPU(char const * vendorName, char const * rendererName) const
{
return (m_vendorName.find(vendorName) != string::npos)
&& (m_rendererName.find(rendererName) != string::npos);
}
void ResourceManager::Params::selectTexRTFormat()
{
/// general case
m_texRtFormat = yg::Data4Bpp;
if (isGPU("Broadcom", "VideoCore IV HW"))
m_texRtFormat = yg::Data8Bpp;
if (isGPU("Imagination Technologies", "PowerVR MBX"))
{
m_rtFormat = yg::Data8Bpp;
m_texRtFormat = yg::Data8Bpp;
}
}
void ResourceManager::Params::fitIntoLimits()
{

View file

@ -207,6 +207,16 @@ namespace yg
struct Params
{
private:
string m_vendorName;
string m_rendererName;
/// check non-strict matching upon vendorName and rendererName
bool isGPU(char const * vendorName, char const * rendererName) const;
public:
DataFormat m_rtFormat;
DataFormat m_texFormat;
DataFormat m_texRtFormat;
@ -238,6 +248,7 @@ namespace yg
Params();
void distributeFreeMemory(int freeVideoMemory);
void selectTexRTFormat();
void fitIntoLimits();
int memoryUsage() const;
int fixedMemoryUsage() const;
@ -273,6 +284,7 @@ namespace yg
ResourceManager(Params const & p);
void initGlyphCaches(GlyphCacheParams const & p);
void selectTexRTFormat();
void initStoragePool(StoragePoolParams const & p, scoped_ptr<TStoragePool> & pool);