mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Added ability to continue when GL shader compilation fails. Issue #327.
This commit is contained in:
parent
fa2b5068f7
commit
c15439b7cb
1 changed files with 28 additions and 15 deletions
|
@ -2853,32 +2853,40 @@ namespace bgfx { namespace gl
|
|||
void ProgramGL::create(const ShaderGL& _vsh, const ShaderGL& _fsh)
|
||||
{
|
||||
m_id = glCreateProgram();
|
||||
BX_TRACE("program create: %d: %d, %d", m_id, _vsh.m_id, _fsh.m_id);
|
||||
BX_TRACE("Program create: GL%d: GL%d, GL%d", m_id, _vsh.m_id, _fsh.m_id);
|
||||
|
||||
const uint64_t id = (uint64_t(_vsh.m_hash)<<32) | _fsh.m_hash;
|
||||
const bool cached = s_renderGL->programFetchFromCache(m_id, id);
|
||||
|
||||
if (!cached)
|
||||
{
|
||||
GL_CHECK(glAttachShader(m_id, _vsh.m_id) );
|
||||
|
||||
if (0 != _fsh.m_id)
|
||||
{
|
||||
GL_CHECK(glAttachShader(m_id, _fsh.m_id) );
|
||||
}
|
||||
|
||||
GL_CHECK(glLinkProgram(m_id) );
|
||||
|
||||
GLint linked = 0;
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked) );
|
||||
if (0 == _vsh.m_id)
|
||||
{
|
||||
GL_CHECK(glAttachShader(m_id, _vsh.m_id) );
|
||||
|
||||
if (0 != _fsh.m_id)
|
||||
{
|
||||
GL_CHECK(glAttachShader(m_id, _fsh.m_id) );
|
||||
}
|
||||
|
||||
GL_CHECK(glLinkProgram(m_id) );
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked) );
|
||||
|
||||
if (0 == linked)
|
||||
{
|
||||
char log[1024];
|
||||
GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log) );
|
||||
BX_TRACE("%d: %s", linked, log);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == linked)
|
||||
{
|
||||
char log[1024];
|
||||
GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log) );
|
||||
BX_TRACE("%d: %s", linked, log);
|
||||
|
||||
BX_WARN(0 != _vsh.m_id, "Invalid vertex/compute shader.");
|
||||
GL_CHECK(glDeleteProgram(m_id) );
|
||||
m_used[0] = Attrib::Count;
|
||||
m_id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4188,6 +4196,7 @@ namespace bgfx { namespace gl
|
|||
BX_TRACE("Failed to compile shader. %d: %s", compiled, log);
|
||||
|
||||
GL_CHECK(glDeleteShader(m_id) );
|
||||
m_id = 0;
|
||||
BGFX_FATAL(false, bgfx::Fatal::InvalidShader, "Failed to compile shader.");
|
||||
}
|
||||
else if (BX_ENABLED(BGFX_CONFIG_DEBUG)
|
||||
|
@ -5052,6 +5061,10 @@ namespace bgfx { namespace gl
|
|||
{
|
||||
programIdx = key.m_program;
|
||||
GLuint id = invalidHandle == programIdx ? 0 : m_program[programIdx].m_id;
|
||||
|
||||
// Skip rendering if program index is valid, but program is invalid.
|
||||
programIdx = 0 == id ? invalidHandle : programIdx;
|
||||
|
||||
GL_CHECK(glUseProgram(id) );
|
||||
programChanged =
|
||||
constantsChanged =
|
||||
|
|
Loading…
Reference in a new issue