Performance and compatibility issues with FSR-Unity-URP 1.0

1) Performance and compatibility issues of FSR-Unity-URP 1.0
​2) Time-consuming problem of calculating MD5 of large files
3) How to monitor Unity’s upcoming Reload Script
4) How to symbolically analyze Android crashes and ANR problems in Unity games


This is the push of the 315th UWA technical knowledge sharing. Today we continue to select a number of issues related to development and optimization for you. It is recommended to read for 10 minutes, and you will gain something after reading carefully.

Rendering

Q: Regarding the performance and compatibility issues of FSR-Unity-URP 1.0:

Test environment:
Unity version: 2020.3.3
URP version: 10.4.0
Graphics API: Vulkan
Device: OPPO K1

1. Compatibility issues
The scene camera has enabled HDR, the default format of the rendering target RT under URP is B10G11R11_UFloatPack32, and an error will be reported on the device: Format unsupported for random writes - RG11B10. The texture format does not support random writing, and then the format is forced to be set to R16G16B16A16_SFloat, the problem is solved, but I want to find a more formal approach.

2. Performance issues:
On OPPO K1, the GPU time-consuming is about 20ms in the normal rendering state of the scene. After turning on the FSR Performance Level, the GPU time-consuming soars to about 100ms. At the same time, when testing on the HUAWEI P30 Pro, the FPS dropped by 3FPS about.

Use RenderDoc to capture frames in the Editor, and the performance hotspots are concentrated in the Compute Shader of FSR:

The number of samples for a single Thread of Compute Shader is 12 times.

In addition, after using the integrated post-processing method, I tested it on OPPO K1 and found that the cost of post-processing is much greater than the cost saved after changing RenderScale to 0.5, and the overall frame rate dropped instead.

I don’t know if you students have experience in implementing FSR into the project, I hope you can share it.

A1: Do not use the implementation of the Compute Shader version, refer to the implementation of the post-processing method in URP12.

I tried it some time ago, and Xiaolong 660 is not very good at this level. The consumption and saving on 670 are almost the same, and it is better to open FSR on 670 and above.

Thanks to Jin Zhe@UWA Q&A Community for providing answers

A2: The following answers are for reference:

  1. Compatibility issues
    I asked a friend from Unity. For the format B10G11R11_UFloatPack32, there is a default requirement for the OpenGL standard of the desktop system in the implementation. OGLES cannot be enabled by default, so for the time being, your approach is a correct operation. Or you can only wait for Unity to update Code to support B10G11R11_UFloatPack32 under OGLES.

  2. Performance problem:
    I am not very familiar with the post-processing method on URP12 and the specific content of the Compute Shader implementation. The answer given by Mr. Jin Zhe above should be more reliable. Looking at the implementation of Compute from the currently posted content, only from the perspective of Driver and HW, there may be two places that may cause certain performance problems: vkCmdBeginRenderPass(C=Load, DS=load) and vkCmdEndRenderPass(C=store, DS =store), are these two places Load Store necessary? Especially the DS part?

    Store and Load will consume GPU bandwidth to synchronize Mem reading and writing vkCmdDispatch(188,94,1) and vkCmdDispatch(1,1,1). These two WorkItems are not an ideal setting. The GPU configuration of the general mobile phone platform, Both hope that these two are a certain power of 2, typically a multiple of 32 or a multiple of 64/128/256/512, if it is too large (for example, more than 2048, just for example) or too small (such as Less than 32) will affect the parallelism of the GPU when performing calculations.

    These two may be part of the reason why the Compute execution time is very long on the Snapdragon 660 K1. As for HUAWEI's Core, technologies such as Turbo will consider some optimizations at the bottom layer and change the APP request, resulting in inconsistent performance fluctuations.

Thanks to the Seague@UWA Q&A community for providing answers


Scripting

Q: When calculating the MD5 of a large file, there is a serious time-consuming problem. It takes about 2 minutes, and it cannot be accepted on the mobile phone. Does anyone have a solution?

The test found that: changing the buffer size to 1MB, from 2200 milliseconds to 1980 milliseconds, the optimization effect is not obvious.
C# – the fastest way to create a checksum for large files in C# – iTecNote

A: You can try to use the xxHash algorithm and compare the performance data, which is much faster than the MD5 algorithm.
https://github.com/uranium62/xxHashhttps://github.com/Cyan4973/xxHash
_

Thanks to the Ma San guy @UWA question and answer community for providing an answer


Scripting

Q: How to monitor Unity's upcoming Reload Script?

I found the method [UnityEditor.Callbacks.DidReloadScripts(0)], which is the callback after Reload Script, but I didn’t find the monitoring method before Reload. Is there a way to monitor it?

A: The following two events are used in conjunction with InitializeOnLoadMethod or InitializeOnLoad at the beginning:
AssemblyReloadEvents.beforeAssemblyReload
AssemblyReloadEvents.afterAssemblyReload

Another mode switching event: EditorApplication.playModeStateChanged, I wrote a manual Reload Script, as follows:
https://github. com/ZeroUltra/UnityManualReload/blob/main/ScriptCompileReloadTools.cs

Thanks to zerolj@UWA Q&A community for providing answers


Scripting

Q: How to symbolically analyze Android crashes and ANR problems in Unity games?

A1: Google Play supports uploading debug symbol files for each app version in the Play Console. This makes it easier to analyze and fix crashes and ANR issues.

Starting with Unity 2020.3 and later, you can follow Unity's guide to generate Android symbols, then upload the symbolication analysis file to the Google Play Console to view human-readable stack traces in the Android vitals dashboard.

Otherwise, you can manually parse stack traces or generate symbol files for lower versions of Unity by following the article Symbolicizing Android Crashes in Unity.

Thanks to the I'm@UWA Q&A community for providing answers

A2: Crash and ANR issues on Android generate stack traces, which are snapshots of the sequence of nested functions your game called before it crashed. These snapshots help you find and fix any problems in your source code.

However, when you build a game with Unity in release mode, symbols are not packaged with the APK. If your game crashes or has ANR issues, the call stack will only show memory addresses.

05-26 18:06:51.311: A/libc(26986): Fatal signal 11 (SIGSEGV) at 0x000004e4 (code=1), thread 27024 (Worker Thread)
05-26 18:06:51.411: I/DEBUG(242): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-26 18:06:51.411: I/DEBUG(242): Build fingerprint: 'Xiaomi/cancro_wc_lte/cancro:4.4.4/KTU84P/V6.7.1.0.KXDCNCH:user/release-keys’
05-26 18:06:51.411: I/DEBUG(242): Revision: '0’
05-26 18:06:51.411: I/DEBUG(242): pid: 26986, tid: 27024, name: Worker Thread >>> com.u.demo <<<
05-26 18:06:51.411: I/DEBUG(242): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 000004e4
I/DEBUG(242): backtrace:
I/DEBUG(242): #00 pc 006d4960 /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #01 pc 006d4c0c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #02 pc 006d4c0c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #03 pc 006d4c0c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #04 pc 006d4c0c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #05 pc 001c5510 /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #06 pc 001c595c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #07 pc 001c4ec0 /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #08 pc 0043a05c /data/app-lib/com.u.demo-1/libunity.so
I/DEBUG(242): #09 pc 0000d248 /system/lib/libc.so (__thread_entry+72)
I/DEBUG(242): #10 pc 0000d3e0 /system/lib/libc.so (pthread_create+240)

Thanks to anan@UWA Q&A community for providing answers

The cover image comes from the Internet


That's all for today's sharing. Of course, there is no limit to life but no limit to knowledge. In the long development cycle, these questions you see may be just the tip of the iceberg. We have already prepared more technical topics on the UWA Q&A website, waiting for you to explore and share together. You who love progress are welcome to join, maybe your method can solve the urgent needs of others; and the "stone" of other mountains can also attack your "jade".

Official website: www.uwa4d.com
Q&A community: answer.uwa4d.com

 

 

Guess you like

Origin blog.csdn.net/UWA4D/article/details/128110433