x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Android (OpenGL) compiles shaders at runtime first spawn actor?

I am trying to some optimization to the gameplay in my project. So I was never quiet sure what is the suggested way of spawning gameplay relevant things.

So when I first spawn an Actor with a StaticMesh or SplineMeshComponent on Android I get some FPS spikes caused by the render thread as seen in the FrontEnd stats picture below taken from a GalaxyS5:

alt text

ShaderLinkTime and ShaderCompileTime take enough time to stop the flow of the gameplay.

Considering that this only happens at the first spawn of the actor, I so far spawned gameplay relevant things once before gameplay begins to keep this FPS Spike from happening. After that I destroy them and spawn them again when needed. Even tough those actors get garbage collected the SharderLinkTime and ShaderCompileTime don't seem to be influenced by this.

The Actor I spawn here has following CD0 and the FishMesh is the SplineMeshComponent example mesh from the content example project.

https://forums.unrealengine.com/showthread.php?95911-First-Spawn-of-Actor-with-SplineMeshComponent-is-slow-%28especially-on-Android%29

Is there any other workaround for avoiding the FPS spike on first spawn on mobile? Or what is the suggested way to spawn actors with PrimitiveComponents to avoid FPS spike?

Product Version: UE 4.10
Tags:
more ▼

asked Jan 19 '16 at 11:56 PM in Rendering

avatar image

spaceharry
402 22 30 139

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

AFAIK this is mostly an OpenGL problem. OpenGL doesn't support precompiled shaders so the driver has to actually compile the high level GLSL file the first time it's loaded. Since the compiler is implemented in the device's OpenGL driver, compilation time can vary from device to device or even between different driver versions. The GPU driver will (usually) re-use the compiled result when the same shader is loaded again by the same application while it's running, that's why you don't see the lag spike even after UE4 performs garbage collection.

My suggestion to avoid such spikes is to create a preload actor that contains one instance of each mesh you intend to load in your level and spawn one of those at a moment where the spike won't be noticed, like during the level loading screen.

more ▼

answered Jan 21 '16 at 01:54 PM

avatar image

manoelneto
358 8 12 26

avatar image spaceharry Jan 21 '16 at 06:10 PM

Thanks for indepth answer!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question