Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 1 | # ANGLE Development Update - July 4, 2012 |
| 2 | |
| 3 | We haven't posted an update on the development status of ANGLE in quite some |
| 4 | time and we'd like to provide an update on some of the new features and |
| 5 | improvements that we've been working on. |
| 6 | |
| 7 | ## Conformance |
| 8 | |
| 9 | As announced in the [Chromium Blog] |
| 10 | (http://blog.chromium.org/2011/11/opengl-es-20-certification-for-angle.html), |
| 11 | ANGLE v1.0 has passed the Khronos OpenGL ES 2.0 certification process and is now |
| 12 | a [conformant](http://www.khronos.org/conformance/adopters/conformant-products/) |
| 13 | OpenGL ES 2.0 implementation. |
| 14 | |
| 15 | ## Extensions |
| 16 | |
| 17 | We have recently completed the implementation of depth texture support |
| 18 | ([ANGLE\_depth\_texture] |
| 19 | (https://code.google.com/p/angleproject/source/browse/extensions/ANGLE_depth_texture.txt?name=master)) |
| 20 | and earlier in the year we added support for instancing via attribute array |
| 21 | divisors ([ANGLE\_instanced\_arrays] |
| 22 | (https://code.google.com/p/angleproject/source/browse/extensions/ANGLE_instanced_arrays.txt?name=master)). |
| 23 | See ExtensionSupport for a complete list of extensions that are supported by |
| 24 | ANGLE. |
| 25 | |
| 26 | ## Shader Compiler |
| 27 | |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 28 | We have also made a number of improvements in the shader compiler. |
Shannon Woods | 21f76c2 | 2015-11-05 15:54:51 -0500 | [diff] [blame] | 29 | |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 30 | * We addressed a number of defects related to scoping differences between HLSL and |
Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 31 | GLSL and improved the scoping support in ANGLE's compiler front-end. We also |
| 32 | worked with The Khronos Group to get an ESSL spec bug fixed and several items |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 33 | clarified. |
| 34 | * We addressed a number of correctness issues in the GLSL to HLSL |
Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 35 | translation process. We fixed some bugs related to constant propagation and |
| 36 | comma conditional assignments. More importantly, we fully implemented support |
| 37 | for short-circuiting boolean logic operations. In GLSL, Boolean expressions do |
| 38 | short-circuit evaluation as in C, but HLSL evaluates them entirely. This only |
| 39 | has an observable effect if a short-circuited operation has side effects, such |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 40 | as a function call that modifies global variables. |
| 41 | * We implemented detection |
Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 42 | for discontinuous gradient or derivative computations inside loops and replace |
| 43 | them with explicitly defined continuous behaviour. HLSL and GLSL differ in their |
| 44 | specified behaviour for operations which compute gradients or derivatives. |
| 45 | Gradients are computed by texture sampling functions which don't specify a |
| 46 | specific mipmap LOD level, and by the OES\_standard\_derivatives built-in |
| 47 | functions. To determine the gradient, the corresponding values in neighbouring |
| 48 | pixels are differentiated. If neighbouring pixels execute different paths |
| 49 | through the shader this can cause a discontinuity in the gradient. GLSL |
| 50 | specifies that in these cases the gradient is undefined. HLSL tries to avoid the |
| 51 | discontinuity in the compiler by unrolling loops so that every pixel executes |
| 52 | all iterations. This can make the D3D HLSL compiler spend a long time generating |
| 53 | code permutations, and possibly even fail compilation due to running out of |
| 54 | instruction slots or registers. Because the GLSL specification allows undefined |
| 55 | behaviour, we can define such texture sampling functions to use mipmap LOD level |
| 56 | 0, and have the derivatives functions return 0.0. To do this we examine the GLSL |
| 57 | code's abstract syntax tree and detect whether the shader contains any loops |
| 58 | with discontinuities and gradient operations. Within such loops, we generate |
| 59 | HLSL code that uses explicitly defined texture LODs and derivative information. |
| 60 | One additional consideration is that within these loops there can be calls to |
| 61 | user-defined functions which may contain gradient operations. In this case, we |
| 62 | generate variants of user-defined functions where these operations are |
| 63 | explicitly defined. We use these new functions instead of the original ones in |
| 64 | loops with discontinuities. |
| 65 | |
| 66 | These fixes result in ANGLE being able successfully compile a number of the more |
| 67 | complex shaders. Unfortunately there are still some complex shaders which we |
| 68 | have not yet been able to obtain solutions for. Ultimately Direct3D 9 SM3 |
| 69 | shaders are more restricted than what can be expressed in GLSL. Most of the |
| 70 | problematic shaders we've encountered will also not compile successfully on |
| 71 | current ES 2.0 implementations. We would only be able to achieve parity with |
| 72 | Desktop GL implementations by using Direct3D 10 or above. |
| 73 | |
| 74 | ## Texture Origin Changes |
| 75 | |
| 76 | We have also made a major change to ANGLE in the way the origin difference |
| 77 | between D3D and OpenGL is handled. This difference is normally observable when |
| 78 | using render-to-texture techniques, and if not accounted for, it would appear |
| 79 | that images rendered to textures are upside down. In recent versions of ANGLE |
| 80 | (r536 (on Google Code)-r1161 (on Google Code)), we have been storing surfaces |
| 81 | following the D3D Y convention where (0, 0) is the top-left, rather than GL's |
| 82 | bottom-left convention. This was done by vertically flipping textures on load |
| 83 | and then adjusting the texture coordinates in the shaders to compensate. This |
| 84 | approach worked well, but it did leave the orientation of pbuffers inverted when |
| 85 | compared to native GL implementations. As of ANGLE r1162 (on Google Code), we |
| 86 | have changed this back to the original way it was implemented - textures are |
| 87 | loaded and stored in the GL orientation, and the final rendered scene is flipped |
| 88 | when it is displayed to a window by eglSwapBuffers. This should be essentially |
| 89 | transparent to applications except that orientation of pbuffers will change. In |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 90 | addition to fixing the pbuffer orientation, this change: |
Shannon Woods | 21f76c2 | 2015-11-05 15:54:51 -0500 | [diff] [blame] | 91 | |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 92 | * eliminates |
Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 93 | dependent-texture look-ups in the shaders, caused by flipping the texture |
Shannon Woods | 64b8860 | 2015-11-05 14:27:38 -0500 | [diff] [blame] | 94 | y-coordinates |
| 95 | * rounding of texture coordinates (while previously within spec) |
| 96 | will be more consistent with other implementations, and |
| 97 | * allows potential |
Andrew Bonventre | 3c7fee3 | 2015-09-22 14:14:18 -0400 | [diff] [blame] | 98 | faster paths for loading texture data to be implemented. The only potential |
| 99 | downside to this approach is that window-based rendering may be a bit slower for |
| 100 | simple scenes. The good news is that this path is not used by browser |
| 101 | implementations on most versions of Windows. |
| 102 | |
| 103 | ## Preprocessor |
| 104 | |
| 105 | Finally, Alok P. from Google has been working on implementing a new shader |
| 106 | preprocessor for the last number of months and this effort is nearly complete. |
| 107 | This new preprocessor should be more robust and much more maintainable. It also |
| 108 | includes many (~5000) unit tests and passes all WebGL conformance tests. If you |
| 109 | wish to try this out before it is enabled by default, define |
| 110 | ANGLE\_USE\_NEW\_PREPROCESSOR=1 in your project settings for the |
| 111 | translator\_common project. |
| 112 | |
| 113 | ## Contributions |
| 114 | |
| 115 | As always we welcome contributions either in the bug reports (preferably with an |
| 116 | isolated test-case) or in the form of code contributions. We have added a |
| 117 | [ContributingCode](ContributingCode.md) wiki page documenting the preferred |
| 118 | process for contributing code. We do need to ask that you sign a Contributor |
| 119 | License Agreement before we can integrate your patches. |