Skip to content

Commit

Permalink
[Metal] Do not crash if a shader failed when reflection (#251)
Browse files Browse the repository at this point in the history
Log it and mark it as "compile error" instead
Fixes #251
  • Loading branch information
darksylinc committed Nov 23, 2021
1 parent 52e38ea commit 2cec404
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions RenderSystems/Metal/src/OgreMetalProgram.mm
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ of this software and associated documentation files (the "Software"), to deal
if( error )
errorDesc = [error localizedDescription].UTF8String;

mCompileError = true;

OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR,
"Failed to create pipeline state for reflection, error " +
errorDesc, "MetalProgram::analyzeComputeParameters" );
Expand Down Expand Up @@ -394,6 +396,8 @@ of this software and associated documentation files (the "Software"), to deal
if( error )
errorDesc = [error localizedDescription].UTF8String;

mCompileError = true;

OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR,
"Failed to create pipeline state for reflection, error " +
errorDesc, "MetalProgram::analyzeRenderParameters" );
Expand Down Expand Up @@ -608,15 +612,22 @@ of this software and associated documentation files (the "Software"), to deal
if( !mLibrary )
return;

if( mType != GPT_COMPUTE_PROGRAM )
try
{
//You think this is a code smell? How about making BUILDconstantDefinitions const???
//It's an oxymoron.
const_cast<MetalProgram*>(this)->analyzeRenderParameters();
if( mType != GPT_COMPUTE_PROGRAM )
{
//You think this is a code smell? How about making BUILDconstantDefinitions const???
//It's an oxymoron.
const_cast<MetalProgram*>(this)->analyzeRenderParameters();
}
else
{
const_cast<MetalProgram*>(this)->analyzeComputeParameters();
}
}
else
catch( RenderingAPIException &e )
{
const_cast<MetalProgram*>(this)->analyzeComputeParameters();
LogManager::getSingleton().logMessage( e.getFullDescription() );
}
}
//-----------------------------------------------------------------------
Expand Down

0 comments on commit 2cec404

Please sign in to comment.