Shader compilation for multiple platforms

Source: Internet
Author: User
Recently, due to cross-platform issues, we have considered the shader issue.

I have changed from HLSL to CG for a long time, and CG also has good support for PC and Mac, But it is said that CG Runtime is not running well on ATI and rumtime is bloated.

From this point of view, writing the native glsl to parse the display driver/runtime should be the best method, but it is unwilling to maintain two at the same time.

Looking back, CG was rejected by OpenGL and used glsl of 3dlab, coupled with HLSL created by MS and NV, this natural obstacle was a tragedy of our generation.

In addition, the core staff of CG jumped to Ms one after another, and it seems that NV is always a bit of the shadows of 3dfx. Most of the time, it is ahead of the industry to launch its own technology, such as CG, such as cuda, however, it is always unable to reach the leadership position like ms, and its own set is always unable to meet industry standards, such as CG in HLSL/glsl, and Cuda in opencl.

 

Back to the HLSL-> glsl issue, ATI previously launched a project called hlsl2glsl. Later, it was extended to hlsl2glslfork by unity3d and existed as Lib, in addition, you can easily perform translate using several interfaces.

The following problem is that only sm3.0 is supported, which is just right for me currently.

Just as the unity3d people said below, on opengles, the driver is not doing well in glsl optimization (my judgment is that the runtim of opengles is not doing well, in addition, unlike the strong competition between NV and ATI on the PC, many optimizations have been completed in the driver), so a glsl-optimizer is introduced to be responsible for optimization.

 

In my previous experience in ATI, taking HLSL as an example, d3d runtime will be responsible for an optimization. The Byte Code passed into the driver is already like glsl-optimizer, removing the bloatedCodeThis inline removes useless variables/functions, and so on. However, Runtime is only an upper-layer middleware, only the driver of the driver knows how to perform "more specific optimization", so the driver will perform further optimization based on different video cards using different paths. At present, the mobile platform is still messy, resulting in the app being responsible for optimization and then passing in.

 

Fortunately, ogre still uses CG on PC/Mac, and uses hlsl2glslfork + glsl-optimizer in ogles to complete CG-> glsl, this part has been implemented in ES 2.x Render system, but in my opinion, considering the backward compatibility issue, it is better to directly implement all shader with HLSL in 1.8, then does OGL and ogles use translator to complete native tasks? More efficient?

 

The following are some related materials:

------------------------------------------------------------------------------

 

Shader compilation for multiple platforms

Http://blogs.unity3d.com/2010/10/20/shader-compilation-for-multiple-platforms/

 

Glsl Optimizer

Http://aras-p.info/blog/2010/09/29/glsl-optimizer/

 

 

Ogre

Http://www.ogre3d.org/forums/viewtopic.php? F = 21 & amp; T = 62256

 

4 New changesets in ogre: Drawing r2617: f38dbc3f6dd6user: assaframandate: 2011-01-03 20: 24: 46 Summary: Es 2.x Render system: Added basic CG support. ogre_cg_support_for_gles2 flag was added to control if this option is on. http://code.google.com/p/hlsl2glslfork/ is used to convert the CG code to glsl. hlsl2glslfork code is required to compile for the CG support to compile and link. not all CG programs compile or link. hlsl2glslfork cmake find script is not provided with this commit. affected #: 10 files (27.4 KB)

 

Export r2697: 0b40d4b9ece4user: masterfalcondate: 2011-03-12 03: 23: 32 Summary: gles2: add support for the glsl optimiser. see here for more info about it: https://github.com/aras-p/glsl-optimizerIt is enabled by default but you can opt out by adding "use_optimiser false" to a program definitionaffected #: 14 files (13.1 KB) --- A/cmake/dependencies. cmakefri Mar 11 20:16:36 2011-0600 ++ B/cmake/dependencies. cmakefri Mar 11 20:23:32 2011-0600 @-173,6 + 173,13 @ find_package (TBB) macro_log_feature (tbb_found "TBB" "threading building blocks" "http://www.threadingbuildingblocks.org/" false """") + # glsl-optimizer + find_package (glsloptimizer) + GAUGE (gauge "glsl optimizer" "glsl optimizer" "http://github.com/aras-p/glsl-optimizer/" false ") ++ # hlsl2glsl + find_package (hlsl2glsl) + macro_log_feature (hlsl2glsl_found "hlsl2glsl" "hlsl2glsl" "http://hlsl2glslfork.googlecode.com/" false """")

 

 

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.