forked from organicmaps/organicmaps
Rebuild vertex array buffers after switch between 2d and 3d mode.
This commit is contained in:
parent
b3f994948d
commit
5082c0f0aa
4 changed files with 39 additions and 19 deletions
|
@ -94,7 +94,9 @@ void VertexArrayBuffer::Build(ref_ptr<GpuProgram> program)
|
|||
if (m_moveToGpuOnBuild && !m_isPreflushed)
|
||||
PreflushImpl();
|
||||
|
||||
ASSERT(m_VAO == 0 && m_program == nullptr, ("No-no-no! You can't rebuild VertexArrayBuffer"));
|
||||
if (m_VAO != 0 && m_program == program)
|
||||
return;
|
||||
|
||||
m_program = program;
|
||||
/// if OES_vertex_array_object not supported, than buffers will be bind on each Render call
|
||||
if (!GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
|
@ -103,6 +105,8 @@ void VertexArrayBuffer::Build(ref_ptr<GpuProgram> program)
|
|||
if (m_staticBuffers.empty())
|
||||
return;
|
||||
|
||||
if (m_VAO != 0)
|
||||
GLFunctions::glDeleteVertexArray(m_VAO);
|
||||
m_VAO = GLFunctions::glGenVertexArray();
|
||||
Bind();
|
||||
BindStaticBuffers();
|
||||
|
|
|
@ -137,10 +137,10 @@ 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(m_useFramebuffer ? state.GetProgram3dIndex()
|
||||
: state.GetProgramIndex());
|
||||
ref_ptr<dp::GpuProgram> program = m_gpuProgramManager->GetProgram(state.GetProgramIndex());
|
||||
ref_ptr<dp::GpuProgram> program3d = m_gpuProgramManager->GetProgram(state.GetProgram3dIndex());
|
||||
program->Bind();
|
||||
bucket->GetBuffer()->Build(program);
|
||||
bucket->GetBuffer()->Build(m_useFramebuffer ? program3d : program);
|
||||
if (!IsUserMarkLayer(key))
|
||||
{
|
||||
if (CheckTileGenerations(key))
|
||||
|
@ -149,7 +149,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
else
|
||||
{
|
||||
m_userMarkRenderGroups.emplace_back(make_unique_dp<UserMarkRenderGroup>(state, key, move(bucket)));
|
||||
m_userMarkRenderGroups.back()->SetRenderParams(program, make_ref(&m_generalUniforms));
|
||||
m_userMarkRenderGroups.back()->SetRenderParams(program, program3d, make_ref(&m_generalUniforms));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -546,7 +546,9 @@ void FrontendRenderer::AddToRenderGroup(vector<drape_ptr<RenderGroup>> & groups,
|
|||
{
|
||||
drape_ptr<RenderGroup> group = make_unique_dp<RenderGroup>(state, newTile);
|
||||
ref_ptr<dp::GpuProgram> program = m_gpuProgramManager->GetProgram(state.GetProgramIndex());
|
||||
group->SetRenderParams(program, make_ref(&m_generalUniforms));
|
||||
ref_ptr<dp::GpuProgram> program3d = m_gpuProgramManager->GetProgram(state.GetProgram3dIndex());
|
||||
|
||||
group->SetRenderParams(program, program3d, make_ref(&m_generalUniforms));
|
||||
group->AddBucket(move(renderBucket));
|
||||
groups.push_back(move(group));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "drape/debug_rect_renderer.hpp"
|
||||
#include "drape/shader_def.hpp"
|
||||
#include "drape/vertex_array_buffer.hpp"
|
||||
|
||||
#include "geometry/screenbase.hpp"
|
||||
|
||||
|
@ -13,9 +14,11 @@
|
|||
namespace df
|
||||
{
|
||||
|
||||
void BaseRenderGroup::SetRenderParams(ref_ptr<dp::GpuProgram> shader, ref_ptr<dp::UniformValuesStorage> generalUniforms)
|
||||
void BaseRenderGroup::SetRenderParams(ref_ptr<dp::GpuProgram> shader, ref_ptr<dp::GpuProgram> shader3d,
|
||||
ref_ptr<dp::UniformValuesStorage> generalUniforms)
|
||||
{
|
||||
m_shader = shader;
|
||||
m_shader3d = shader3d;
|
||||
m_generalUniforms = generalUniforms;
|
||||
}
|
||||
|
||||
|
@ -24,14 +27,15 @@ void BaseRenderGroup::UpdateAnimation()
|
|||
m_uniforms.SetFloatValue("u_opacity", 1.0);
|
||||
}
|
||||
|
||||
void BaseRenderGroup::Render(const ScreenBase &)
|
||||
void BaseRenderGroup::Render(const ScreenBase & screen)
|
||||
{
|
||||
ASSERT(m_shader != nullptr, ());
|
||||
ref_ptr<dp::GpuProgram> shader = screen.isPerspective() ? m_shader3d : m_shader;
|
||||
ASSERT(shader != nullptr, ());
|
||||
ASSERT(m_generalUniforms != nullptr, ());
|
||||
|
||||
m_shader->Bind();
|
||||
dp::ApplyState(m_state, m_shader);
|
||||
dp::ApplyUniforms(*(m_generalUniforms.get()), m_shader);
|
||||
shader->Bind();
|
||||
dp::ApplyState(m_state, shader);
|
||||
dp::ApplyUniforms(*(m_generalUniforms.get()), shader);
|
||||
}
|
||||
|
||||
bool BaseRenderGroup::IsOverlay() const
|
||||
|
@ -73,6 +77,10 @@ void RenderGroup::Render(ScreenBase const & screen)
|
|||
{
|
||||
BaseRenderGroup::Render(screen);
|
||||
|
||||
ref_ptr<dp::GpuProgram> shader = screen.isPerspective() ? m_shader3d : m_shader;
|
||||
for(auto & renderBucket : m_renderBuckets)
|
||||
renderBucket->GetBuffer()->Build(shader);
|
||||
|
||||
auto const & params = df::VisualParams::Instance().GetGlyphVisualParams();
|
||||
int programIndex = m_state.GetProgramIndex();
|
||||
int program3dIndex = m_state.GetProgram3dIndex();
|
||||
|
@ -81,14 +89,14 @@ void RenderGroup::Render(ScreenBase const & screen)
|
|||
{
|
||||
m_uniforms.SetFloatValue("u_contrastGamma", params.m_outlineContrast, params.m_outlineGamma);
|
||||
m_uniforms.SetFloatValue("u_isOutlinePass", 1.0f);
|
||||
dp::ApplyUniforms(m_uniforms, m_shader);
|
||||
dp::ApplyUniforms(m_uniforms, shader);
|
||||
|
||||
for(auto & renderBucket : m_renderBuckets)
|
||||
renderBucket->Render(screen);
|
||||
|
||||
m_uniforms.SetFloatValue("u_contrastGamma", params.m_contrast, params.m_gamma);
|
||||
m_uniforms.SetFloatValue("u_isOutlinePass", 0.0f);
|
||||
dp::ApplyUniforms(m_uniforms, m_shader);
|
||||
dp::ApplyUniforms(m_uniforms, shader);
|
||||
for(auto & renderBucket : m_renderBuckets)
|
||||
renderBucket->Render(screen);
|
||||
}
|
||||
|
@ -96,13 +104,13 @@ void RenderGroup::Render(ScreenBase const & screen)
|
|||
program3dIndex == gpu::TEXT_BILLBOARD_PROGRAM)
|
||||
{
|
||||
m_uniforms.SetFloatValue("u_contrastGamma", params.m_contrast, params.m_gamma);
|
||||
dp::ApplyUniforms(m_uniforms, m_shader);
|
||||
dp::ApplyUniforms(m_uniforms, shader);
|
||||
for(auto & renderBucket : m_renderBuckets)
|
||||
renderBucket->Render(screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
dp::ApplyUniforms(m_uniforms, m_shader);
|
||||
dp::ApplyUniforms(m_uniforms, shader);
|
||||
|
||||
for(drape_ptr<dp::RenderBucket> & renderBucket : m_renderBuckets)
|
||||
renderBucket->Render(screen);
|
||||
|
@ -241,9 +249,13 @@ void UserMarkRenderGroup::UpdateAnimation()
|
|||
void UserMarkRenderGroup::Render(ScreenBase const & screen)
|
||||
{
|
||||
BaseRenderGroup::Render(screen);
|
||||
dp::ApplyUniforms(m_uniforms, m_shader);
|
||||
ref_ptr<dp::GpuProgram> shader = screen.isPerspective() ? m_shader3d : m_shader;
|
||||
dp::ApplyUniforms(m_uniforms, shader);
|
||||
if (m_renderBucket != nullptr)
|
||||
{
|
||||
m_renderBucket->GetBuffer()->Build(shader);
|
||||
m_renderBucket->Render(screen);
|
||||
}
|
||||
}
|
||||
|
||||
string DebugPrint(RenderGroup const & group)
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
: m_state(state)
|
||||
, m_tileKey(tileKey) {}
|
||||
|
||||
void SetRenderParams(ref_ptr<dp::GpuProgram> shader, ref_ptr<dp::UniformValuesStorage> generalUniforms);
|
||||
void SetRenderParams(ref_ptr<dp::GpuProgram> shader, ref_ptr<dp::GpuProgram> shader3d,
|
||||
ref_ptr<dp::UniformValuesStorage> generalUniforms);
|
||||
|
||||
dp::GLState const & GetState() const { return m_state; }
|
||||
TileKey const & GetTileKey() const { return m_tileKey; }
|
||||
|
@ -33,11 +34,12 @@ public:
|
|||
bool IsOverlay() const;
|
||||
|
||||
virtual void UpdateAnimation();
|
||||
virtual void Render(ScreenBase const & /*screen*/);
|
||||
virtual void Render(ScreenBase const & screen);
|
||||
|
||||
protected:
|
||||
dp::GLState m_state;
|
||||
ref_ptr<dp::GpuProgram> m_shader;
|
||||
ref_ptr<dp::GpuProgram> m_shader3d;
|
||||
dp::UniformValuesStorage m_uniforms;
|
||||
ref_ptr<dp::UniformValuesStorage> m_generalUniforms;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue