src/compiler/translator/Compiler.cpp


Log

Author Commit Date CI Message
Olli Etuaho 8efc5ad5 2015-03-03T17:21:10 Initialize BuiltInFunctionEmulator outside Compiler This moves GLSL output specific code from the Compiler class to the GLSL/ESSL translators. BUG=angleproject:865 Change-Id: I2d552e9cdb41f7d8ddfee7b0249a99d629a6d7d7 Reviewed-on: https://chromium-review.googlesource.com/255471 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a3a5cc6a 2015-02-13T13:12:22 Expose the IntermNode tree generated in the compiler for testing This refactoring makes it possible for tests to access the IntermNode tree produced by compilation by calling compileTree(). Removing ParseContext usage from OutputHLSL has the additional benefit of better separation between parsing and output. BUG=angle:916 Change-Id: Ib40954832316328772a5c1dcbbe6b46b238e4e65 Reviewed-on: https://chromium-review.googlesource.com/249723 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
David Yen 0fbd128c 2015-02-02T14:46:09 Extension behavior is now reset between each shader translation unit. The extension behavior was being shared between translation units, this was causing states to be cached between shader compilers. This has been fixed now by adding a new ResetExtensionBehavior() function. A unit test has also been added for testing extensions when compiling shaders. A test has been included which tests that the internal state of the extension behavior is being reset properly. BUG=453543 Change-Id: Icb2a07019b5db972dc75cdbbdece4b7e9757c682 Reviewed-on: https://chromium-review.googlesource.com/245522 Tested-by: David Yen <dyen@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Austin Kinross 3ae6465f 2015-01-26T15:51:39 Fix lots of variable shadowing in ANGLE BUG=angle:877 Change-Id: I3df0fffb19f5ecbe439fbc2a8d6d239a5dc6b638 Reviewed-on: https://chromium-review.googlesource.com/243334 Tested-by: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 74cafab1 2015-01-23T23:17:32 Revert "Fix lots of variable shadowing in ANGLE" Caused WebGL CTS failures on the texture-npot test: https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/texture-npot.html This reverts commit c67e6e9fade44ef8938724e82db11db725e9c8e5. Change-Id: I089e99859231e0d657084ac3647257c650a9da92 Reviewed-on: https://chromium-review.googlesource.com/243041 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Austin Kinross c67e6e9f 2015-01-21T16:01:07 Fix lots of variable shadowing in ANGLE BUG=angle:877 Change-Id: I15168ae32605b26aee08274464ffe68adb5a7e87 Reviewed-on: https://chromium-review.googlesource.com/242351 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Austin Kinross <aukinros@microsoft.com>
Olli Etuaho 5c9cd3d1 2014-12-18T13:04:25 Implement hyperbolic function support for ESSL 3.00 Emulating arc hyperbolic functions is required on HLSL, where they do not exist natively. For this, BuiltInFunctionEmulator is split into GLSL and HLSL subclasses. The GLSL subclass handles the pre-existing built-in emulation implemented for working around OSX bugs, and the HLSL subclass handles emulating asinh, acosh and atanh on HLSL. BUG=angle:855 Change-Id: I0dfeffb862ac27ba7f9ecf5492ec31d9d952b273 Reviewed-on: https://chromium-review.googlesource.com/236861 Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 352beffc 2014-11-19T13:45:55 Remove RemoveAllTreeNodes, since it was a no-op IntermNode operator delete() or any of the IntermNode destructors don't do anything, since all the AST memory is allocated on the PoolAllocator. Because of this, RemoveAllTreeNodes was simply a no-op, and redundant with the PoolAllocator deallocation procedure, and could confuse people reading the code to think that IntermNodes should be deleted individually, when in fact this is not the case. BUG=angle:831 Change-Id: Ie1ccaa51986aabf267280d92a8e76ca9f97a19e5 Reviewed-on: https://chromium-review.googlesource.com/230730 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Erik Dahlström ea7a2121 2014-11-17T16:15:57 Add GLSL/ESSL validator/translator support for GL_EXT_shader_framebuffer_fetch. BUG=angle:834 Change-Id: I2d4e25909a8e1266b9bb7f1d4421324143157c8a Reviewed-on: https://chromium-review.googlesource.com/231032 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Erik Dahlström <ed@opera.com>
Olli Etuaho 853dc1ab 2014-11-06T17:25:48 Add mediump and lowp precision emulation support for GLSL output This implements the rounding as specified in WEBGL_debug_shader_precision extension proposal for desktop GLSL and ESSL output. The bulk of the new functionality is added in the form of a new EmulatePrecision AST traverser, which inserts calls to the rounding routines angle_frm and angle_frl in the appropriate places, and writes the rounding routines themselves to the shader. Compound assignments which are subject to emulation are transformed from "x op= y" to "angle_compound_op_frm(x, y)", a call to a function which does the appropriate rounding and places the result of the operation to x. The angle_ prefixed names should not clash with user-defined names if name hashing is on. If name hashing is not on, the precision emulation can only be used if the angle_ prefix is reserved for use by ANGLE. To support the rounding routines in output, a new operator type is added for internal helper function calls, which are not subject to name hashing. In ESSL output, all variables are forced to highp when precision emulation is on to ensure consistency with how precision emulation performs on desktop. Comprehensive tests for the added code generation are included. BUG=angle:787 Change-Id: I0d0ad9327888f803a32e79b64b08763c654c913b Reviewed-on: https://chromium-review.googlesource.com/229631 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Zhenyao Mo db9b40b0 2014-10-29T15:00:04 Reject shaders of a version that the compiler doesn't support. For example, WebGL 1.0 compiler should not compile WebGL 2.0 shaders. BUG=angle: TEST=815 Change-Id: Iaec66fa5127426778aff6e3891e2c214048d7457 Reviewed-on: https://chromium-review.googlesource.com/226380 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo 409078f1 2014-10-28T13:23:18 Remove ShGetVariableInfo() and related code. BUG=angle:775 TEST=chromium builds and runs fine Change-Id: Ic62d3a3c9a8f034880b77a96f7f1c6be2691985e Reviewed-on: https://chromium-review.googlesource.com/226004 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Zhenyao Mo 94ac7b78 2014-10-15T18:22:08 Invariant related processing. * Fix a bug in PreProcessor for STDGL pragma. * Record all invariant settings and set them in ShaderVariable. * Write #pragma STDGL invariant(all) in GL BUG=angle:776 TEST=https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shaders-with-invariance.html Change-Id: Ie28b75480deed79f0c9f26e3b98f1778d1290182 Reviewed-on: https://chromium-review.googlesource.com/223610 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho e61209af 2014-09-26T12:01:17 Add option to support EXT_draw_buffers with NV_draw_buffers After this patch, it is possible to set a flag to change EXT_draw_buffers extension directives to NV_draw_buffers in ESSL. This enables users of ANGLE to emulate EXT_draw_buffers by using NV_draw_buffers in combination with GLES3.0. Change-Id: I5dacdbd6cd0d0362424ea3791557342c42efd4bd Reviewed-on: https://chromium-review.googlesource.com/219941 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill a2fbb840 2014-09-03T09:40:47 Move CollectVariables to sh namespace. BUG=angle:466 Change-Id: I903ea840e333dfeb44f242a1759aed39974d0510 Reviewed-on: https://chromium-review.googlesource.com/213505 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo daf56572 2014-08-06T16:18:30 For SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS, assign precision to temp variables. Otherwise on Windows or other platforms with GLES backend, using this workaround will trigger shader compile failure. For the moment, to simplify the workaround, for any missing precisions in float, we always assign the highest available precion to it. BUG=angle:695 TEST=webgl conformance tests Change-Id: I810579442bc7fc61d6a52b76aff31a779046fa22 Reviewed-on: https://chromium-review.googlesource.com/211253 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Zhenyao Mo e740addb 2014-07-18T17:01:01 Add compiler option SH_REGENERATE_STRUCT_NAMES. BUG=angle:701 TEST=webgl conformance tests Change-Id: I13b35900956e7d840d5891a5bab90a400347cd6f Reviewed-on: https://chromium-review.googlesource.com/209229 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Zhenyao Mo cd68fe79 2014-07-11T10:45:44 Add a compiler option to rewrite vec/mat constructors If one of the parameters is a vec/mat, expand it into scalars. This is to work around Linux NVIDIA/AMD and Mac NVIDIA driver bugs. BUG=angle:695 TEST=webgl conformance test Change-Id: I35e1e25167d99f873dcb03bfb57a30e84b1aeed5 Reviewed-on: https://chromium-review.googlesource.com/207479 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill d5512cd4 2014-07-10T17:50:08 Collect shader outputs and interface block information. This paves the way for returning ES3-specific info from the shader translator with the new query methods. BUG=angle:466 Change-Id: Ib13cdb604854cdf11e9dc00dd94f18eadc946561 Reviewed-on: https://chromium-review.googlesource.com/206770 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 23a8a433 2014-07-09T13:27:42 Store compact and expanded shader variables. The current shader API ShGetVariableInfo relies on an expanded list of shader variables. That means that struct, or user-defined variables, are expanded into separate entries for the app to easily query struct members. The new API will preserve the struct layout, so we can store both to support both the old and new queries. BUG=angle:466 Change-Id: Id30a1d7d1bb49c7e745510e0d699f94ad3184b9c Reviewed-on: https://chromium-review.googlesource.com/206569 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill ed27c729 2014-07-02T15:31:23 Consolidate shader variable storage in Compiler. The Compiler base class now stores all the shader variables and interface block information, instead of duplicating the information in the HLSL translator. BUG=angle:466 Change-Id: Ia69079fde64fbd6b0cbfc66defd5e37d99ee3e6e Reviewed-on: https://chromium-review.googlesource.com/206020 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill a718c1e0 2014-07-02T15:31:22 Use shader variable types for variable collection. Retire the old TVariableInfoList structure, and use the new objects which we will expose more directly through the API. BUG=angle:466 Change-Id: I999a97369bfb67cf73cd659c4fe885b41429d304 Reviewed-on: https://chromium-review.googlesource.com/205839 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill aa72d782 2014-07-02T15:31:19 Remove duplicate SH and GL functions. In several places we were using variable query methods that were duplicated between the old SH enums and the corresponding GL enums. We can use the common GL enum versions now. BUG=angle:466 Change-Id: Ib8797fe6bc75828e05aed37b1f5fbd4b9ba03d22 Reviewed-on: https://chromium-review.googlesource.com/205594 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 183bde55 2014-07-02T15:31:19 Return shader variable information using GLenum values. Instead of duplicating GL header define values, explictly return GLenum for variable queries in the shader inspection API. This reduces the duplicate defines in the shader compiler header. BUG=angle:466 Change-Id: Iddaaff597b188251fa2e546f352bf77ab3ac43bc Reviewed-on: https://chromium-review.googlesource.com/205860 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill ce505553 2014-06-26T14:56:33 Revert "Return variable type queries using GLenum values." Breaks the FYI bots until we get Chromium patched. BUG=angle:466 This reverts commit 53221f5a0382887155d90f7f286e41190d4f5bfb. Change-Id: Ib28548df5c10a6f76f46e4cf8f2013dca5cf0ee2 Reviewed-on: https://chromium-review.googlesource.com/205850 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 53221f5a 2014-06-25T16:04:59 Return variable type queries using GLenum values. Instead of duplicating GL header define values, explictly return GLenum for variable queries in the shader inspection API. This reduces the duplicate defines in the shader compiler header. BUG=angle:466 Change-Id: If631b20ce68747297a946e1371def7709027a613 Reviewed-on: https://chromium-review.googlesource.com/204937 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill d4a3a317 2014-06-25T16:04:56 Rename ShHandle.h to Compiler.h. Since the above source file matches Compiler.cpp, more closely follow our standard naming convention. BUG=angle:466 Change-Id: Ib1422f87f16097f91f2bcdad550ec5bd940ce711 Reviewed-on: https://chromium-review.googlesource.com/204681 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 68fe74aa 2014-05-27T12:56:01 Add a compiler query for the translator output type. This is useful for determining if we are compiling to a D3D9 or D3D11 shader outside of the internal translator classes. BUG=angle:656 Change-Id: Ib1c1d3de569edaa2b65c24c09d05aa4dd229d3e4 Reviewed-on: https://chromium-review.googlesource.com/201564 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Shannon Woods 2d76e5f6 2014-05-16T17:46:41 Adds resource string generation to ANGLE This will avoid Chrome source having to be updated each time that ANGLE's ShBuiltInResources changes. BUG=374942 Change-Id: If54dba8351de9b261ff269e885f231547c08ff0a Reviewed-on: https://chromium-review.googlesource.com/200171 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Shannon Woods <shannonwoods@chromium.org>
Zhenyao Mo 66e5dda7 2014-04-28T11:13:25 Fix a bug in init_varyings_without_static_use workaround. The TType constrcuted is using es2 signature, which is different from the es3 signature. BUG=angle:568 TEST=webgl conformance tests with --init_varyings_without_static_use commandline switch Change-Id: I15347c7a6fe67e9214e4c96b156a50806a90c97c Reviewed-on: https://chromium-review.googlesource.com/197294 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Zhenyao Mo 7faf1a14 2014-04-25T18:03:56 Fix a mem corruption in ANGLE translator. Basically outside TCompile::compile(), the global parse context is invalid, and should never be queried. BUG=angle:568 TEST=webgl conformance tests, no crash Change-Id: I5573ce2bf3bf838ab24f59dda00948f60a0b023d Reviewed-on: https://chromium-review.googlesource.com/197178 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 6654bc93 2014-03-26T14:01:57 Fix stack overflow when parsing huge expressions. The expression limit validation check needs to be in front of other tree traversal to prevent stack overflows. Also, call depths of sufficient size (80k+) could overflow the depth check itself, necessitating an upper bound on initial tree traversal. This fixes crashes in the WebGL long-expressions bug test. BUG=angle:584 Change-Id: Ib48294bf77a5923d230f237fbd63a36a5662e317 Reviewed-on: https://chromium-review.googlesource.com/191931 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo 3cdfcce8 2014-03-07T13:00:08 Remove SH_MAP_LONG_VARIABLE_NAMES We use hashing to map all variables/strcuture field names, etc, so we no longer need this option. Checked with Firefox and WebKit, they no longer use this option either. Time to remove it. Change-Id: Ie3e79b91a05258b04af419a9c42b2fd1b00e67c4 Reviewed-on: https://chromium-review.googlesource.com/189236 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189568
Zhenyao Mo 550c600b 2014-02-26T15:40:48 Improvement on loop unrolling with loops indexing sampler arrays 1) Before this workaround is hardwired on mac, now we move it behind a compil 2) Fix the issue where "break" inside the loop isn't handled while unrolled. BUG=338474 TEST=webgl conformance test sampler-array-using-loop-index.html Change-Id: I4996a42c2dea39a8a5af772c256f8e3cb383f59a Reviewed-on: https://chromium-review.googlesource.com/188079 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org> Conflicts: include/GLSLANG/ShaderLang.h src/compiler/translator/ValidateLimitations.cpp Change-Id: I546197bd7df1634ebccdd380be14c3250cd56151 Reviewed-on: https://chromium-review.googlesource.com/189061 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 5508f39d 2014-02-20T13:31:36 Fix breaking the build with missing GetGlobalMaxTokenSize. Because the preprocessor is used independently from the compiler, we need a way to track max token size when we don't have access to the parse context with the current spec. BUG=angle:550 Change-Id: Idf5035ec2c001ee75f264151ab3c4e92f3cd44d7 Reviewed-on: https://chromium-review.googlesource.com/187140 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 88f6e946 2014-02-19T10:27:53 Proper support for token max size in WebGL+ES3. WebGL specifies a maximum token size of 256 characters, while ES3 specifies 1024 characters. We can determine the proper max size to support from the spec. BUG=angle:550 Change-Id: I6aeabe8af3b6184a27b456248ce2f84f361b76e4 Reviewed-on: https://chromium-review.googlesource.com/186973 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo 4a667fe9 2014-02-11T12:35:01 Add an option to initialize varyings without static use in vertex shaders ANGLEBUG=554 TEST=webgl conformance test on mac: shaders-with-varyings.html r=kbr@chromium.org,nicolascapens@chromium.org cc=alokp@chromium.org,shannonwoods@chromium.org Change-Id: I2e692d43fb15f1cf3ade3e398020d1fedb2b32f0 Reviewed-on: https://chromium-review.googlesource.com/185922 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org> Conflicts: src/common/version.h src/compiler/translator/Compiler.cpp Change-Id: If7db13ef345bd6199d4ea0d7786f0de20885f2f3 Reviewed-on: https://chromium-review.googlesource.com/186144 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Zhenyao Mo 7cab38b5 2013-10-15T12:59:30 Add an option to unfold short circuiting in AST. We replace "a || b" with "a ? true : b", "a && b" with "a ? b : false". This is to work around short circuiting bug in Mac drivers. ANGLEBUG=482 TEST=webgl conformance tests R=alokp@chromium.org, kbr@chromium.org Review URL: https://codereview.appspot.com/14529048 Conflicts: src/build_angle.gypi src/compiler/translator/Compiler.cpp Change-Id: Ic2384a97d58f54294efcb3a012deb2007a9fc658 Reviewed-on: https://chromium-review.googlesource.com/178996 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Tested-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill 6b9cb259 2013-10-17T10:45:47 Rename ParseHelper.cpp/h to ParseContext.cpp/h. TRAC #24002 Signed-off-by: Shannon Woods Signed-off-by: Geoff Lang
Geoff Lang 17732823 2013-08-29T13:46:49 Moved the compiler source files into directories based on their project and added a compiler.gypi to generate the compiler projects.