mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -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,12 +2853,15 @@ namespace bgfx { namespace gl
|
||||||
void ProgramGL::create(const ShaderGL& _vsh, const ShaderGL& _fsh)
|
void ProgramGL::create(const ShaderGL& _vsh, const ShaderGL& _fsh)
|
||||||
{
|
{
|
||||||
m_id = glCreateProgram();
|
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 uint64_t id = (uint64_t(_vsh.m_hash)<<32) | _fsh.m_hash;
|
||||||
const bool cached = s_renderGL->programFetchFromCache(m_id, id);
|
const bool cached = s_renderGL->programFetchFromCache(m_id, id);
|
||||||
|
|
||||||
if (!cached)
|
if (!cached)
|
||||||
|
{
|
||||||
|
GLint linked = 0;
|
||||||
|
if (0 == _vsh.m_id)
|
||||||
{
|
{
|
||||||
GL_CHECK(glAttachShader(m_id, _vsh.m_id) );
|
GL_CHECK(glAttachShader(m_id, _vsh.m_id) );
|
||||||
|
|
||||||
|
@ -2868,8 +2871,6 @@ namespace bgfx { namespace gl
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_CHECK(glLinkProgram(m_id) );
|
GL_CHECK(glLinkProgram(m_id) );
|
||||||
|
|
||||||
GLint linked = 0;
|
|
||||||
GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked) );
|
GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked) );
|
||||||
|
|
||||||
if (0 == linked)
|
if (0 == linked)
|
||||||
|
@ -2877,8 +2878,15 @@ namespace bgfx { namespace gl
|
||||||
char log[1024];
|
char log[1024];
|
||||||
GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log) );
|
GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log) );
|
||||||
BX_TRACE("%d: %s", linked, log);
|
BX_TRACE("%d: %s", linked, log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == linked)
|
||||||
|
{
|
||||||
|
BX_WARN(0 != _vsh.m_id, "Invalid vertex/compute shader.");
|
||||||
GL_CHECK(glDeleteProgram(m_id) );
|
GL_CHECK(glDeleteProgram(m_id) );
|
||||||
|
m_used[0] = Attrib::Count;
|
||||||
|
m_id = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4188,6 +4196,7 @@ namespace bgfx { namespace gl
|
||||||
BX_TRACE("Failed to compile shader. %d: %s", compiled, log);
|
BX_TRACE("Failed to compile shader. %d: %s", compiled, log);
|
||||||
|
|
||||||
GL_CHECK(glDeleteShader(m_id) );
|
GL_CHECK(glDeleteShader(m_id) );
|
||||||
|
m_id = 0;
|
||||||
BGFX_FATAL(false, bgfx::Fatal::InvalidShader, "Failed to compile shader.");
|
BGFX_FATAL(false, bgfx::Fatal::InvalidShader, "Failed to compile shader.");
|
||||||
}
|
}
|
||||||
else if (BX_ENABLED(BGFX_CONFIG_DEBUG)
|
else if (BX_ENABLED(BGFX_CONFIG_DEBUG)
|
||||||
|
@ -5052,6 +5061,10 @@ namespace bgfx { namespace gl
|
||||||
{
|
{
|
||||||
programIdx = key.m_program;
|
programIdx = key.m_program;
|
||||||
GLuint id = invalidHandle == programIdx ? 0 : m_program[programIdx].m_id;
|
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) );
|
GL_CHECK(glUseProgram(id) );
|
||||||
programChanged =
|
programChanged =
|
||||||
constantsChanged =
|
constantsChanged =
|
||||||
|
|
Loading…
Reference in a new issue