Engine design Tracking (nine. 14.2i) Android GLES 3.0 Perfect

Source: Internet
Author: User

Recently filled out the Gles API corresponding to the rendering device. There are mainly irenderdevice/ishader/itexture/igraphicsresourcemanager/iindexbuffer/ivertexbuffer.
It's all about physical activity, and it's up to the documentation (HTTPS://WWW.KHRONOS.ORG/OPENGLES/SDK/DOCS/MAN3/) to fill in the corresponding API.
The following questions are recorded:

  1. Stick to the standard
    • C++standard does not require char to be unsigned
      typedef char UINT8; found this on GCC. The uint8 is signed, so the typedef usigned Char uint8 is changed;
    • Use standard library functions. msvc on the ABS (float) function, when running on Android found a problem with mathematical calculations, and finally catch up with this function
      Originally GCC did not have abs (float), checked the standard (
      http://www.cplusplus.com/reference/cstdlib/abs/?kw=abs), the standard does not, only fabs ().
  2. Vertex Shader Compilation Error:
    • Error:uniform variables in vertex shader don't fit in vectors.
      GLES3.0 's vertex shader uniform is also at least 256. This is strange. Because Blade's skeletal animation is written according to the minimum requirements of VS3.0 (registers), shader float2x4[120] uses 240 registers, and 2 matrix44, which is 8 registers. Total 248 should be no super. Currently, the number of bones has been changed to 110.
    • In addition to the DQ animation, the HLSL float2x4 turned into GLSL, HLSL2GLSL did transpose it, so it was float4x2, so that 4 registers were used. The workaround is to use the FLOAT4 array directly, which is applicable on both D3D and Gles.
  3. GLES Adaptation:
    The Sampler property of GL is bound to the map by default. (Gltexparameter), this is different from D3d9 's sampler state, fortunately GLES3.0 has sampler object glgensamplers/glbindsampler/ Glsamplerparameter can be set up in the same way as D3D.
    Overall gles.30 did not encounter big problems, mainly because of the accumulation of work last year, so to achieve faster.

Currently blade terrain and DQ animations can be run on the Android real machine, about these two modules, the animation did not do any adaptation, in addition to some device bug on the special workaround.

Simply record the terrain problem:

    • Compressed maps cannot update part of the area, or some updates have a limit (glcompressedtexsubimage), and D3D can directly lock the map to update the local area. This will be composite Altas when the error. The solution is not difficult, with the image interface (soft buffer) first merged well, the last one-time upload, this way for gl/es and D3D are applicable. The runtime on Android does not have edit mode, so there is no dynamic update.
    • The batch merge of the terrain on the tested Android device slows down and the extra bandwidth is estimated to be too large. So the batch was turned off on Android. This only needs to change the configuration file, because the batch merge would have been configured on Windows and saved to the configuration file.
    • The terrain texture on Android is changed from 512x512 to 256x256, and for a 4x4 atlas, the map size on Windows is 2048x2048, and Android is 1024x1024. Added the scale parameter to the Bladetexcompressor, adding additional configuration parameters to the Terrain module: Texture size for dynamic adaptation.
    • In addition, for the sake of efficiency, the topography of the detail normal also temporarily closed, because detail normal with the Atlas normal map, will be more than 4 samples.

Some other updates:

    • Joined the arm of the neon SIMD, this is to take the Directxmath code, before doing SSE has joined the time, but did not open neon, this time to tune it, do some modification and adaptation.
    • Added the message box. Because the message box is Iplatformmanager's feature, calling the API directly on Windows requires JNI calling Java to fit on Android. It is important to note that this Java file is also placed at the platform level, not related to the specific project, but only when the final build apk is copied to the Java src.
    • Shader precompile: As mentioned before, add an event handler to the app level, load all the shader within the package, save it in binary format, store it in a local folder, and switch the "shader:/" path to a local path. Pay attention to a lot of details. For example, compiling shader needs to be done after gles initialization, which fortunately blade has a render device ready event. The problem is that all shader preloading is also the event that is handled, and shader loading must be done correctly at the end of the shader-precompiling. So these two handler have sequential conflicts. This problem can be abstracted as an event handler call order problem, because the order of handler in the internal store/call is indeterminate, resulting in a sequence of calls to multiple handler of the same event undefined. Remember that when working, the first project also encountered similar problems, which were called according to the order of registration. But now it feels like this is the equivalent of two of modules that do not want to do have weak coupling in the registration order, and the registration order is difficult to control, not very good. The current practice is to add priority, the same priority of the handler call order is indeterminate, but the priority is different, the invocation is sequential. Because the sequence of collisions is relatively small, a few priorities are available. Set shader Pre-complie to the highest priority This can be gles initialization after the first time to compile shader, how to determine whether shader need to recompile also a bit cumbersome, need to compare the number of files, time stamp and so on, here is not recorded.

Currently on the Adreno 330 release build, a 512x512 terrain, can run 30-50fps, some devices are 30, some 50. There is no time to Profille, guess the efficiency bottleneck can be two, one is the number of vertices/triangles, and the other is that Atlas is in the fragment shader to dynamically calculate the UV, and requires multiple texture sampling.

Personally feel that if the architecture itself supports multi-platform abstraction, then the workload of the Platform porting is small, the main workload should be in the optimization. A really usable engine is not just a run-up.

Below a terrain demo apk and Obb Bar, can be run on the real machine, need GLES3.0 support, just a simple brush a terrain, not carefully to edit:

Https://drive.google.com/folderview?id= 0b-jwaxcrpttafk9jwezgaklldk5gskfsshhdwknwx2vuvuv1x1y4tjk4mel0tkzvyklfmhc&usp=sharing

The recent progress of Android has been largely due to the build-up of Android on the job, and has been designed to target cross-platform, so the changes are not very large.

suddenly have the impulse to do indie game, even with some mobile small 3D action the idea of the game, but now accumulation is not enough. If there is a chance, then do indiegame. And now with the children, there are many factors to consider. The back will slow down, because the work is very busy, the amateur also does not have too much time.

Engine design Tracking (nine. 14.2i) Android GLES 3.0 Perfect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.