handy debug assert

This commit is contained in:
Jack Andersen 2015-12-17 11:29:47 -10:00
parent 916002f9da
commit bb35ded399
1 changed files with 14 additions and 0 deletions

View File

@ -499,6 +499,12 @@ struct GLShaderDataBinding : IShaderDataBinding
std::unique_ptr<IGraphicsBuffer*[]> m_ubufs; std::unique_ptr<IGraphicsBuffer*[]> m_ubufs;
size_t m_texCount; size_t m_texCount;
std::unique_ptr<ITexture*[]> m_texs; std::unique_ptr<ITexture*[]> m_texs;
#ifndef NDEBUG
/* Debugging aids */
bool m_committed = false;
#endif
GLShaderDataBinding(IShaderPipeline* pipeline, GLShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat, IVertexFormat* vtxFormat,
size_t ubufCount, IGraphicsBuffer** ubufs, size_t ubufCount, IGraphicsBuffer** ubufs,
@ -517,6 +523,12 @@ struct GLShaderDataBinding : IShaderDataBinding
} }
void bind(int b) const void bind(int b) const
{ {
#ifndef NDEBUG
if (!m_committed)
Log.report(LogVisor::FatalError,
"attempted to use uncommitted GLShaderDataBinding");
#endif
GLuint prog = m_pipeline->bind(); GLuint prog = m_pipeline->bind();
m_vtxFormat->bind(b); m_vtxFormat->bind(b);
for (size_t i=0 ; i<m_ubufCount ; ++i) for (size_t i=0 ; i<m_ubufCount ; ++i)
@ -578,6 +590,8 @@ IGraphicsDataToken GLDataFactory::commit()
return IGraphicsDataToken(this, nullptr); return IGraphicsDataToken(this, nullptr);
std::unique_lock<std::mutex> lk(m_committedMutex); std::unique_lock<std::mutex> lk(m_committedMutex);
GLData* retval = m_deferredData; GLData* retval = m_deferredData;
for (std::unique_ptr<GLShaderDataBinding>& b : retval->m_SBinds)
b->m_committed = true;
m_deferredData = nullptr; m_deferredData = nullptr;
m_committedData.insert(retval); m_committedData.insert(retval);
/* Let's go ahead and flush to ensure our data gets to the GPU /* Let's go ahead and flush to ensure our data gets to the GPU