Skip to content

Commit

Permalink
[Metal] Fix GPU-specific crashes during reflection (#251)
Browse files Browse the repository at this point in the history
Log the errors/failures instead of raising an exception, which causes a
crash if the GPU doesn't support a specific feature despite the shader
being valid.

Fixes #251
  • Loading branch information
darksylinc committed Feb 14, 2022
1 parent 0cca9ad commit bcc86cc
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions RenderSystems/Metal/src/OgreMetalProgram.mm
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,17 @@ of this software and associated documentation files (the "Software"), to deal
if( shader->hasCompileError() )
{
mCompileError = true;
OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
"Shader reflection hint '" + mShaderReflectionPairHint +
"' for pixel shader '" + mName + "' had a compiler error.",
"MetalProgram::analyzeRenderParameters" );

// Cannot be an exception because this failure can be GPU-specific;
// which will cause an app to crash only on specific devices
// Only always-repeatable errors should be exceptions in this routine
//
// See https://github.com/OGRECave/ogre-next/issues/251
LogManager::getSingleton().logMessage(
"Shader reflection hint '" + mShaderReflectionPairHint + "' for pixel shader '" +
mName + "' had a compiler error.",
LML_CRITICAL );
return;
}

assert( dynamic_cast<MetalProgram*>( shader->_getBindingDelegate() ) );
Expand Down Expand Up @@ -411,9 +418,14 @@ of this software and associated documentation files (the "Software"), to deal

mCompileError = true;

OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR,
"Failed to create pipeline state for reflection, error " +
errorDesc, "MetalProgram::analyzeRenderParameters" );
// Cannot be an exception because this failure can be GPU-specific;
// which will cause an app to crash only on specific devices.
// Only always-repeatable errors should be exceptions in this routine
//
// See https://github.com/OGRECave/ogre-next/issues/251
LogManager::getSingleton().logMessage(
"Failed to create pipeline state for reflection for " + mName + ", error " + errorDesc,
LML_CRITICAL );
}
else
{
Expand Down

0 comments on commit bcc86cc

Please sign in to comment.