cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

webgl2.0 UBO bufferSubData performance loss

Open W-MTZing opened this issue 3 years ago • 4 comments

Cocos Creator version

3.4.2

System information

webgl2.0 iOS 14.3, iOS15.1

Issue description

This problem is caused by the difference in the use of buffersubdata, please refer to the following paragraph: "Consider using multiple buffer objects to avoid stalling the rendering pipeline during data store updates. If any rendering in the pipeline makes reference to data in the buffer object being updated by glBufferSubData, especially from the specific region being updated, that rendering must drain from the pipeline before the data store can be updated."

After the following modification, the frame rate of the demo test case reached 60 from 40.

1651060793(1)

Relevant error log output

No response

Steps to reproduce

3.4.2 demo: test342.zip

turn on the shadows。

Minimal reproduction project

No response

W-MTZing avatar Apr 27 '22 12:04 W-MTZing

The problem occurs on runtime platform using GLES 3.0 backend and Wechat WebGL 2.0 backend. If update the same Uniform Buffer multiple times using glBufferSubData, the performance will drop drastically, but if changing to glBufferData, the performance will return to normal.

@star-e please help provide insights and possible solution

pandamicro avatar Apr 27 '22 14:04 pandamicro

When the buffer is in device memory, we need to use triple-buffer if it is updated frequently (PerFrame). Or we can use dynamic buffer, which supports fast cpu write.

star-e avatar Apr 27 '22 15:04 star-e

Tried both on mac and ios, can't reproduce. If there's any extra step please let me known. Besides: could you have a try if does it make any difference on portrait mode and landscape mode? and phone settings->safari->advanced->WebGL via Metal, try turn it off.

for reference here: https://bugs.webkit.org/show_bug.cgi?id=228012

hana-alice avatar Sep 21 '22 07:09 hana-alice

To my current understanding of creator ide, the native side wants to simulate may not be good simulation, need GLSE 3.0 back-end but currently in the iOS platform does not seem to support the export, you can try to package into webgl2.0 WeChat mini game will be reproduced.

W-MTZing avatar Sep 21 '22 07:09 W-MTZing

same https://github.com/cocos/3d-tasks/issues/13603

yiwenxue avatar Dec 05 '22 11:12 yiwenxue