mirror of https://github.com/AxioDL/boo.git
More graceful OpenGL uniform block binding
This commit is contained in:
parent
af188afc81
commit
54ae8c2b1a
|
@ -599,27 +599,33 @@ struct GLShaderDataBinding : IShaderDataBinding
|
||||||
m_vtxFormat->bind(b);
|
m_vtxFormat->bind(b);
|
||||||
if (m_ubufOffs.size())
|
if (m_ubufOffs.size())
|
||||||
{
|
{
|
||||||
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
for (size_t i=0 ; i<m_ubufCount && i<m_pipeline->m_uniLocs.size() ; ++i)
|
||||||
{
|
{
|
||||||
|
GLint loc = m_pipeline->m_uniLocs[i];
|
||||||
|
if (loc < 0)
|
||||||
|
continue;
|
||||||
IGraphicsBuffer* ubuf = m_ubufs[i];
|
IGraphicsBuffer* ubuf = m_ubufs[i];
|
||||||
const std::pair<size_t,size_t>& offset = m_ubufOffs[i];
|
const std::pair<size_t,size_t>& offset = m_ubufOffs[i];
|
||||||
if (ubuf->dynamic())
|
if (ubuf->dynamic())
|
||||||
static_cast<GLGraphicsBufferD*>(ubuf)->bindUniformRange(i, offset.first, offset.second, b);
|
static_cast<GLGraphicsBufferD*>(ubuf)->bindUniformRange(i, offset.first, offset.second, b);
|
||||||
else
|
else
|
||||||
static_cast<GLGraphicsBufferS*>(ubuf)->bindUniformRange(i, offset.first, offset.second);
|
static_cast<GLGraphicsBufferS*>(ubuf)->bindUniformRange(i, offset.first, offset.second);
|
||||||
glUniformBlockBinding(prog, m_pipeline->m_uniLocs.at(i), i);
|
glUniformBlockBinding(prog, loc, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
for (size_t i=0 ; i<m_ubufCount && i<m_pipeline->m_uniLocs.size() ; ++i)
|
||||||
{
|
{
|
||||||
|
GLint loc = m_pipeline->m_uniLocs[i];
|
||||||
|
if (loc < 0)
|
||||||
|
continue;
|
||||||
IGraphicsBuffer* ubuf = m_ubufs[i];
|
IGraphicsBuffer* ubuf = m_ubufs[i];
|
||||||
if (ubuf->dynamic())
|
if (ubuf->dynamic())
|
||||||
static_cast<GLGraphicsBufferD*>(ubuf)->bindUniform(i, b);
|
static_cast<GLGraphicsBufferD*>(ubuf)->bindUniform(i, b);
|
||||||
else
|
else
|
||||||
static_cast<GLGraphicsBufferS*>(ubuf)->bindUniform(i);
|
static_cast<GLGraphicsBufferS*>(ubuf)->bindUniform(i);
|
||||||
glUniformBlockBinding(prog, m_pipeline->m_uniLocs.at(i), i);
|
glUniformBlockBinding(prog, loc, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i=0 ; i<m_texCount ; ++i)
|
for (size_t i=0 ; i<m_texCount ; ++i)
|
||||||
|
|
Loading…
Reference in New Issue