Detecting the (Shader) Program Binary Cache

Hi,
I’m trying to use the new program binary cache feature on Android, which is enabled by default.
At game startup, I wait for the shaders to finish compiling by checking
FShaderPipelineCache::NumPrecompilesRemaining()==0.
I was expecting this not to go through all the precompilation a second time if there was a valid ProgramBinaryCache.
But it does.

So, questions:

  1. how do I detect a missing/valid ProgramBinaryCache, so I can pop up an ‘Optimizing Content’ dialog for the first run?
  2. is it necessary to restart the game (which is by default done automatically, but can be turned off with r.ProgramBinaryCache.RestartAndroidAfterPrecompile) once the ProgramBinaryCache is created?
  3. what is the recommended sequence of events on startup?
  4. is there a way to show a progress bar for the binary cache compilation?

Thanks!

1 Like

To make this work I had to add a function to the engine like so:

// ARMATURE MOD: added this to get the state of the ProgramBinaryCache
bool FOpenGLDynamicRHI::IsProgramBinaryCacheValid() const
{
	return FOpenGLProgramBinaryCache::IsEnabled() && !FOpenGLProgramBinaryCache::IsBuildingCache();
}

Then in our initial map I check this, and if false, loop while FShaderPipelineCache::NumPrecompilesRemaining() > 0 (with a progress dialog labeled ‘optimizing content’). The game automatically restarts when done.