Use separate parameter in GLState for 3d program.

Conflicts:
	drape_frontend/frontend_renderer.cpp
	drape_frontend/render_group.cpp
This commit is contained in:
Daria Volvenkova 2015-11-06 16:03:54 +03:00
parent 2f4b8eb82a
commit b3f994948d
7 changed files with 23 additions and 11 deletions

View file

@ -46,6 +46,7 @@ bool Blending::operator == (Blending const & other) const
GLState::GLState(uint32_t gpuProgramIndex, DepthLayer depthLayer)
: m_gpuProgramIndex(gpuProgramIndex)
, m_gpuProgram3dIndex(gpuProgramIndex)
, m_depthLayer(depthLayer)
, m_depthFunction(gl_const::GLLessOrEqual)
, m_textureFilter(gl_const::GLLinear)
@ -82,6 +83,8 @@ bool GLState::operator<(GLState const & other) const
return m_blending < other.m_blending;
if (m_gpuProgramIndex != other.m_gpuProgramIndex)
return m_gpuProgramIndex < other.m_gpuProgramIndex;
if (m_gpuProgram3dIndex != other.m_gpuProgram3dIndex)
return m_gpuProgram3dIndex < other.m_gpuProgram3dIndex;
if (m_colorTexture != other.m_colorTexture)
return m_colorTexture < other.m_colorTexture;
@ -92,6 +95,7 @@ bool GLState::operator==(GLState const & other) const
{
return m_depthLayer == other.m_depthLayer &&
m_gpuProgramIndex == other.m_gpuProgramIndex &&
m_gpuProgram3dIndex == other.m_gpuProgram3dIndex &&
m_blending == other.m_blending &&
m_colorTexture == other.m_colorTexture &&
m_maskTexture == other.m_maskTexture;

View file

@ -59,6 +59,9 @@ public:
int GetProgramIndex() const { return m_gpuProgramIndex; }
void SetProgram3dIndex(uint32_t gpuProgram3dIndex) { m_gpuProgram3dIndex = gpuProgram3dIndex; }
int GetProgram3dIndex() const { return m_gpuProgram3dIndex; }
glConst GetDepthFunction() const;
void SetDepthFunction(glConst functionName);
@ -70,6 +73,7 @@ public:
private:
uint32_t m_gpuProgramIndex;
uint32_t m_gpuProgram3dIndex;
DepthLayer m_depthLayer;
Blending m_blending;
glConst m_depthFunction;

View file

@ -137,7 +137,8 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
dp::GLState const & state = msg->GetState();
TileKey const & key = msg->GetKey();
drape_ptr<dp::RenderBucket> bucket = msg->AcceptBuffer();
ref_ptr<dp::GpuProgram> program = m_gpuProgramManager->GetProgram(state.GetProgramIndex());
ref_ptr<dp::GpuProgram> program = m_gpuProgramManager->GetProgram(m_useFramebuffer ? state.GetProgram3dIndex()
: state.GetProgramIndex());
program->Bind();
bucket->GetBuffer()->Build(program);
if (!IsUserMarkLayer(key))
@ -849,10 +850,8 @@ bool FrontendRenderer::IsBillboardProgram(int programIndex) const
void FrontendRenderer::RenderSingleGroup(ScreenBase const & modelView, ref_ptr<BaseRenderGroup> group)
{
dp::GLState const & state = group->GetState();
bool const isBillboardProgram = IsBillboardProgram(state.GetProgramIndex());
if (m_useFramebuffer && (m_isBillboardRenderPass != isBillboardProgram))
if (m_useFramebuffer &&
(m_isBillboardRenderPass != IsBillboardProgram(group->GetState().GetProgram3dIndex())))
return;
group->UpdateAnimation();

View file

@ -43,7 +43,8 @@ void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManag
glsl::vec2(texRect.maxX(), texRect.minY())},
};
dp::GLState state(gpu::TEXTURING_BILLBOARD_PROGRAM, dp::GLState::OverlayLayer);
dp::GLState state(gpu::TEXTURING_PROGRAM, dp::GLState::OverlayLayer);
state.SetProgram3dIndex(gpu::TEXTURING_BILLBOARD_PROGRAM);
state.SetColorTexture(region.GetTexture());
state.SetTextureFilter(gl_const::GLNearest);

View file

@ -75,8 +75,9 @@ void RenderGroup::Render(ScreenBase const & screen)
auto const & params = df::VisualParams::Instance().GetGlyphVisualParams();
int programIndex = m_state.GetProgramIndex();
int program3dIndex = m_state.GetProgram3dIndex();
if (programIndex == gpu::TEXT_OUTLINED_PROGRAM ||
programIndex == gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM)
program3dIndex == gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM)
{
m_uniforms.SetFloatValue("u_contrastGamma", params.m_outlineContrast, params.m_outlineGamma);
m_uniforms.SetFloatValue("u_isOutlinePass", 1.0f);
@ -92,7 +93,7 @@ void RenderGroup::Render(ScreenBase const & screen)
renderBucket->Render(screen);
}
else if (programIndex == gpu::TEXT_PROGRAM ||
programIndex == gpu::TEXT_BILLBOARD_PROGRAM)
program3dIndex == gpu::TEXT_BILLBOARD_PROGRAM)
{
m_uniforms.SetFloatValue("u_contrastGamma", params.m_contrast, params.m_gamma);
dp::ApplyUniforms(m_uniforms, m_shader);

View file

@ -187,7 +187,8 @@ void TextShape::DrawSubStringPlain(StraightTextLayout const & layout, dp::FontDe
layout.Cache(glsl::vec3(glsl::ToVec2(m_basePoint), m_params.m_depth),
baseOffset, color, staticBuffer, dynamicBuffer);
dp::GLState state(gpu::TEXT_BILLBOARD_PROGRAM, dp::GLState::OverlayLayer);
dp::GLState state(gpu::TEXT_PROGRAM, dp::GLState::OverlayLayer);
state.SetProgram3dIndex(gpu::TEXT_BILLBOARD_PROGRAM);
ASSERT(color.GetTexture() == outline.GetTexture(), ());
state.SetColorTexture(color.GetTexture());
state.SetMaskTexture(layout.GetMaskTexture());
@ -230,7 +231,8 @@ void TextShape::DrawSubStringOutlined(StraightTextLayout const & layout, dp::Fon
layout.Cache(glsl::vec3(glsl::ToVec2(m_basePoint), m_params.m_depth),
baseOffset, color, outline, staticBuffer, dynamicBuffer);
dp::GLState state(gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM, dp::GLState::OverlayLayer);
dp::GLState state(gpu::TEXT_OUTLINED_PROGRAM, dp::GLState::OverlayLayer);
state.SetProgram3dIndex(gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM);
ASSERT(color.GetTexture() == outline.GetTexture(), ());
state.SetColorTexture(color.GetTexture());
state.SetMaskTexture(layout.GetMaskTexture());

View file

@ -157,7 +157,8 @@ void CacheUserPoints(UserMarksProvider const * provider,
buffer.emplace_back(pos, right + up + offset, glsl::ToVec2(texRect.RightBottom()), runAnim);
}
dp::GLState state(gpu::BOOKMARK_BILLBOARD_PROGRAM, dp::GLState::UserMarkLayer);
dp::GLState state(gpu::BOOKMARK_PROGRAM, dp::GLState::UserMarkLayer);
state.SetProgram3dIndex(gpu::BOOKMARK_BILLBOARD_PROGRAM);
state.SetColorTexture(region.GetTexture());
dp::AttributeProvider attribProvider(1, buffer.size());