effekseer / Effekseer

MIT License
1.44k stars 219 forks source link

performance bottlenecks in iOS and android #110

Open huachangmiao opened 6 years ago

huachangmiao commented 6 years ago

Is there a better way to optimize?

durswd commented 6 years ago

Does this change get enough performance? I think mapbuffer and bufferrange are not good for current Android (error and performance)

huachangmiao commented 6 years ago

No improvement at all. Still 10-12fps/s. I try to disable the NEON tomorrow.

durswd commented 6 years ago

OK.

huachangmiao commented 6 years ago

Finally, I found the reason.

void Renderer::setupVBO() { glGenBuffers(2, &_buffersVBO[0]); // Issue #15652 // Should not initialize VBO with a large size (VBO_SIZE=65536), // it may cause low FPS on some Android devices like LG G4 & Nexus 5X. // It's probably because some implementations of OpenGLES driver will // copy the whole memory of VBO which initialized at the first time // once glBufferData/glBufferSubData is invoked. // For more discussion, please refer to https://github.com/cocos2d/cocos2d-x/issues/15652 // mapBuffers(); } I set the maximum vertex count to 100.

It's running OK. 30fps/s

How to fix it?

durswd commented 6 years ago

Thank you !!!!!!!!! I try to think how to fix. (perhaps divide two draw call)

By the way, may I remove division count parameter in ring and track? I think it is already not needed.

-So I have a new idea. -Can the Track and the Ribbon set the count of vertices? just like the Ring.

huachangmiao commented 6 years ago

I think it can be removed. : )

durswd commented 6 years ago

OK!! Please wait for few days. Until I fix it, you set the maximum vertex count to 100

durswd commented 6 years ago

https://github.com/effekseer/EffekseerForCocos2d-x

I updated. Is it OK?

// large buffer make application slow on Android
int32_t spriteSize = 600;

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
renderer2d = ::EffekseerRendererGL::Renderer::Create(spriteSize, EffekseerRendererGL::OpenGLDeviceType::OpenGLES2);
#else
renderer2d = ::EffekseerRendererGL::Renderer::Create(spriteSize, EffekseerRendererGL::OpenGLDeviceType::OpenGL2);
#endif

where spriteSize is larger than 100, but VBO size is lower than 65536.

huachangmiao commented 6 years ago

I'm sorry my reply was late. I spent some time trying.

I refer to the cocos rendering. Because some implementations of OpenGLES driver will copy the whole memory of VBO which initialized at the first time. I think glBufferData should be called before draw every time. I comment the glBufferData's call in VertexBuffer's creator function. and add this function into VertexBuffer::Unlock(). I built it in huawei honor v10. It 's working well. I think at least in the android platform should be modified like this. What do you think? default

durswd commented 6 years ago

I think it is OK. But it should be included with #ifdef __ANDROID__ It seem that this implementation decrease a performance on iOS and PC.

durswd commented 6 years ago

And another question, Is nBufferingMode true? If this option makes no sense, I want to remove this.

huachangmiao commented 6 years ago

OK. This is just a temporary code. I will include #ifdef ANDROID later.

nBufferingMode is true in android opengles2.0? image

nBufferingMode = !GLExt::IsSupportedBufferRange() && GLExt::IsSupportedMapBuffer();

durswd commented 6 years ago

I think it is true. If you have a time, please would you check a performance inserting nBufferingMode = false?

huachangmiao commented 6 years ago

OK, I will check it.

huachangmiao commented 6 years ago

I tested in huawei CUN-AL00: nBufferingMode = false; 38/fps nBufferingMode = true; 41/fps

ZTE C880U: nBufferingMode = false; 41/fps nBufferingMode = true; 42/fps

I think you can remove Triple buffering. It 's using with mutiThread render. But cocos is simpleThread render. mapBuffer shouldn 't be removed, because it can improve performance on android.

I optimize the code.

image

durswd commented 6 years ago

I fixed it. (Removed nBuffering and add ANDORID)

https://github.com/effekseer/EffekseerForCocos2d-x

Is it OK?

huachangmiao commented 6 years ago

Thank you. This is a little different.

image

image

durswd commented 6 years ago

Thank you, I will try to fix

durswd commented 6 years ago

I updated. https://github.com/effekseer/EffekseerForCocos2d-x

huachangmiao commented 6 years ago

It's OK

durswd commented 6 years ago

Thank you for your help.