src/compiler/translator/Compiler.cpp


Log

Author Commit Date CI Message
Qiankun Miao 7ebb97fc 2016-09-08T18:01:50 Use 64-bits compile options BUG=chromium:645071 Change-Id: I31825123bf4cb45fb37a93f538e8936487beb5ff Reviewed-on: https://chromium-review.googlesource.com/382712 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 966456de 2016-09-12T11:42:44 Remove SH_TIMING_RESTRICTIONS compiler flag The timing restrictions code is not in use and not updated for ESSL3, so it is better to remove it to make refactoring the AST easier. It can also be argued that perfect prevention of shader timing attacks is not feasible due to factors that are not under control of ANGLE, such as fixed function color compression in GPUs. Such color compression may make the use of texture bandwidth and thus performance dependent on the content of a texture regardless of whether a compressed format is chosen through the API. SH_DEPENDENCY_GRAPH flag that could only be active together with the timing restrictions flag is also removed, along with all the code that was supporting it. The newer CallDAG code is used for different purposes and is kept. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I2cd10e18df366e8e43f7c3af1ca12d2a4bfb2007 Reviewed-on: https://chromium-review.googlesource.com/384511 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho f119a263 2016-08-19T15:54:22 Clean up unary and aggregate math folding Prefer asserts instead of adding internal errors to the compiler log when types of arguments are not as expected or the folding function runs into an operation it can't handle. Neither of these cases should be possible, the checks for correct argument types are solid at this point. In the future, when new built-in functions are added, constant folding support for them should be added as well. foldUnaryWithDifferentReturnType and foldUnaryWithSameReturnType are renamed to foldUnaryNonComponentWise and foldUnaryComponentWise respectively. These names better reflect what these functions are doing. The info sink member is removed from TIntermediate, since TDiagnostics is now passed into the functions that may generate warnings instead. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I6a08abbe29cf23f3a318032fdc46dd3dbaf4410e Reviewed-on: https://chromium-review.googlesource.com/377959 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Martin Radev 4a9cd800 2016-09-01T16:51:51 Refactor type_specifier_nonarray parsing to reduce code repetition When type_specifier_nonarray gets parsed the scope gets saved into TType and the code becomes repetitive. Setting of the scope is moved to type_specifier_no_prec as it occurs less times. BUG=angleproject:911 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I6da5fe7bc2d60ba2996221af71b719b818f5e9b1 Reviewed-on: https://chromium-review.googlesource.com/380535 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Qiankun Miao c2c5fc48 2016-08-31T15:24:22 Remove CSS Shader related code CSS shader has been removed from spec and chrome code base. Remove the code in ANGLE. BUG=chromium:233383 Change-Id: I93a35437f540e51ce7af9d49f21ca60d7c0b156a Reviewed-on: https://chromium-review.googlesource.com/378739 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Qiankun Miao f69682be 2016-08-16T14:50:42 Add unittests to verify invariant doesn't leak This is a followup CL of https://chromium-review.googlesource.com/366720. Unittests is added to check invariant status does not leak across shaders. This CL also moves mInvariantVaryings and mGlobalInvariant from TSymbolTable to TSymbolTableLevel. So at the end of a compilation, the levels pop, and the settings will be cleared and will not affect the next compilation. Change-Id: I1199fade7a637276ab149ab9a599621b9977298b Reviewed-on: https://chromium-review.googlesource.com/370844 Commit-Queue: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Kenneth Russell bccc65d3 2016-07-19T16:48:43 Flatten "#pragma STDGL invariant(all)" into varying variables. This is implemented as a compiler option which is enabled by default when outputting to desktop GLSL version 130 and greater, which does not support this #pragma in fragment shaders. As a workaround, and for better compatibility on desktop OpenGL drivers, this pragma is also flattened into the outputs of vertex shaders, and the inputs of ESSL 1.00 fragment shaders. TEST=conformance/glsl/misc/shaders-with-invariance.html with --enable-unsafe-es3-apis BUG=629622, angleproject:1293 Change-Id: Ib040230915e639971505ed496d26e804c9d64e68 Reviewed-on: https://chromium-review.googlesource.com/361792 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Qiankun Miao 583c4d2a 2016-08-05T17:58:40 Invariant qualifier should not leak across shaders Change-Id: I2a35899bffd28767b8bc638f415857636d4ad8ef Reviewed-on: https://chromium-review.googlesource.com/366720 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Zhenyao Mo 4e94fea8 2016-08-09T14:31:37 Emulate gl_FragColor broadcasting behavior when GL_EXT_draw_buffers is enabled. BUG=angleproject:1467,635433 TEST=WebGL conformance, angle_unittests Change-Id: I9eb4ce715732087a3786da886f42243716f2b9b2 Reviewed-on: https://chromium-review.googlesource.com/367532 Commit-Queue: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Martin Radev 802abe01 2016-08-04T17:48:32 Add compute shader compilation support in the glsl compiler Support is added for compute shader compilation. There is a small extension to the parser so that 'local_size_x = ', 'local_size_y = ' and 'local_size_z = ' are supported as layout qualifiers. A few shader compilation tests are added and one which checks the AST whether the layout qualifiers are properly parsed. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I67283797d1cf13fa4ac47faa2a6e66d93a2db867 Reviewed-on: https://chromium-review.googlesource.com/362300 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Martin Radev e93d24ef 2016-07-28T12:06:05 Add es3.1 shader constants The patch adds all shader built-in constants. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I81cae479d6506a8faa2dce023d5fcc2c1291d521 Reviewed-on: https://chromium-review.googlesource.com/364460 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Zhenyao Mo f178d0bd 2016-07-23T06:59:00 Fix output variable gl_FragData array size issue. If the GL_EXT_draw_buffers extension isn't explicitly enabled in the shader, then gl_FragData is an array of size 1, not of size max_draw_buffers. BUG=angleproject:1441 TEST=webgl2_conformance with --use-gl=angle Change-Id: I2ead1457462bf1f396fda1f47022df6b54612e17 Reviewed-on: https://chromium-review.googlesource.com/362781 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Zhenyao Mo f931268f 2016-07-22T12:51:31 Handle initializing of struct typed output variable correctly. BUG=angleproject:1441 TEST=webgl2 conformance Change-Id: Idb27036347e1e814ba4603969cc2065e425ac4aa Reviewed-on: https://chromium-review.googlesource.com/362641 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 27776e33 2016-07-22T14:00:56 Fix member variable masking warning in standalone MSVS build The patch for initializing output variables introduced a warning that broke MSVS 2015 standalone build. The "shaderType" variable passed to TCompiler::initializeOutputVariables was unnecessary and had the same name as a member variable of TCompiler that stores the shader type. TEST=MSVS 2015 build Change-Id: I9e01f5eae77a88babde21d4864a02c8731a220de Reviewed-on: https://chromium-review.googlesource.com/362550 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Zhenyao Mo 72111915 2016-07-20T17:45:56 Initialize all output variables. BUG=angleproject:1441 TEST=bots Change-Id: Ia4cf415d8346c3234bf0f548a178ee3ea8cd35c4 Reviewed-on: https://chromium-review.googlesource.com/362110 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Martin Radev 1be913cf 2016-07-11T17:59:16 Add support for ES31 context creation The dEQP test for context creation passes. SH_WEBGL3_SPEC has been added, but it should be considered whether we should keep it, remove it or rename it. It was added so that there is a webgl mapping to es 310 shaders. Check Compiler.cpp. The bison file has been modified so that some tokens from es3 can be also used in es31 as well. A separate macro ES3_1_ONLY is added so that some tokens are limited only for es 310 shaders. BUG=angleproject:1442 TEST=angle_unittests Change-Id: I2e5ca227c96046c30dc796ab934f3fda9c533eba Reviewed-on: https://chromium-review.googlesource.com/360300 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Kenneth Russell 8bad46d4 2016-07-01T19:52:52 The global invariant pragma must not leak across compilations. BUG=chromium:625363 TEST=conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html Change-Id: I66389352b92211f4d7967772f68470c8e93405bd Reviewed-on: https://chromium-review.googlesource.com/358515 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Zhenyao Mo 7e1200b4 2016-07-05T02:25:13 Revert "The global invariant pragma must not leak across compilations." This reverts commit ae2e19188cf0a9b035a27143f585df10e72ffabd. Change-Id: I017ba4ba9baa633793d7bdd9691c580ed7016cde Reviewed-on: https://chromium-review.googlesource.com/358410 Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Kenneth Russell ae2e1918 2016-07-01T19:52:52 The global invariant pragma must not leak across compilations. BUG=chromium:625363 TEST=conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html Change-Id: Ie8d38e44837fc87bb4c94e76e779ad41e8b79957 Reviewed-on: https://chromium-review.googlesource.com/358203 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 438dbcf1 2016-06-17T14:20:05 translator: Fix builtin function emulator use-after-free. We were calling the global pool allocator in the builtin function emulator, which would lead to us freeing TTypes that were still referenced. Fix this by using the TCache which was designed for such a purpose, and locking the allocator around the builtin function emulator to try and prevent similar bugs from creeping in. Eventually we would like to get rid of the global allocator and replace it with different pools in different contexts, which are managed more safely. BUG=620937 Change-Id: If501ff6ea4d9bf8a2b8f89f2c94a01386f79ee3a Reviewed-on: https://chromium-review.googlesource.com/353671 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Geoff Lang b66a9097 2016-05-16T15:59:14 Add support for OES_EGL_image_external and OES_EGL_image_external_essl3. BUG=angleproject:1372 Change-Id: I8489e7fd0ab409b0775041ad5e9fbf0aab53886d Reviewed-on: https://chromium-review.googlesource.com/344734 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 3d932d83 2016-04-12T11:10:30 Defer global initializers when necessary Move global variable initializers that are not constant expressions to a function that gets called at the start of main(). This is done with an AST transformation. This needs to be done because global variable initializers must be constant in native GL, but ANGLE is more lenient with what can be put into ESSL 1.00 global initializers to remain compatible with legacy WebGL content. Non-constant global variable initializers also caused issues in HLSL output, since in HLSL output some types of expressions get unfolded into multiple statements. These include short-circuiting operators and array initialization. To make sure that these cases are covered, any initializers that can't be constant folded are deferred, even if they have the const qualifier. The old deferring mechanism in OutputHLSL is removed in favor of this new AST transformation based approach. BUG=angleproject:819 BUG=angleproject:1205 BUG=angleproject:1350 BUG=596616 TEST=WebGL conformance test conformance/glsl/misc/global-variable-init.html Change-Id: I039cc05d6b8c284baeefbdf7f10062cae4bc5716 Reviewed-on: https://chromium-review.googlesource.com/338291 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 19d1dc99 2016-03-08T17:18:46 Add option to limit the number of function parameters Trying to compile user-defined functions that have thousands of parameters introduces some instability in native compilers, so it is better to reject shaders with large numbers of function parameters in ANGLE. The check is only enabled if the SH_LIMIT_EXPRESSION_COMPLEXITY flag is turned on. The default limit for the number of parameters is 1024, but it can also be configured. BUG=angleproject:1338 TEST=angle_unittests Change-Id: I5c9b7a4e97e67f36e77f969368336fa8fffba1c3 Reviewed-on: https://chromium-review.googlesource.com/331970 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Ian Ewell 924b7de2 2016-01-21T13:54:28 Always write to gl_Position when compiling shaders with SH_GLSL_COMPATIBILITY_OUTPUT. BUG=angleproject:1277 Change-Id: Ib820a46151637e8c61e94b966b970de46ccca6b9 Reviewed-on: https://chromium-review.googlesource.com/323160 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: Ian Ewell <ewell@google.com>
Olli Etuaho 792a41d1 2015-12-15T12:39:16 Fix missing newline from "Missing main()" error message Change-Id: Id28e20097fc2c66117c688425c73df731afecbe3 Reviewed-on: https://chromium-review.googlesource.com/318431 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez 0469479f 2015-12-07T15:52:05 Compiler: remove dead code in limitExpressionComplexity TGraphTraverser is a class that does nothing by itself so the for loop was a noop statement and has been for at least two years (since 17732823f9c2, didn't check earlier). BUG=angleproject:591 Change-Id: I1919059fcb8987c2f043a71fed6223e16bc014d8 Reviewed-on: https://chromium-review.googlesource.com/316600 Tryjob-Request: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 8a76dcc7 2015-12-10T20:25:12 Don't try to apply ForLoopUnroll to loops it can't handle ForLoopUnroll should only mark loops that fit the limitations in ESSL 1.00 Appendix A. BUG=angleproject:1253 TEST=angle_unittests, WebGL conformance tests Change-Id: I00b0a7d29cd42efea9611d020aa1f873ac04773f Reviewed-on: https://chromium-review.googlesource.com/317551 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 183d7e24 2015-11-20T15:59:09 Remove predefined precision qualifiers from ESSL3 samplers New sampler types in ESSL3 should not have default precision qualifiers. This is specified in ESSL 3.00.4 section 4.5.4. BUG=angleproject:1222 TEST=angle_unittests Change-Id: I9c8e7a5fbb4278db80de79bcaeebaf23e64242a0 Reviewed-on: https://chromium-review.googlesource.com/312048 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho e1a94c67 2015-11-16T17:35:25 Check that texture offset is constant and valid Offset passed to textureOffset and similar functions must be constant. See ESSL 3.00 spec section 8.8. It must also be in the valid range between MIN_PROGRAM_TEXEL_OFFSET and MAX_PROGRAM_TEXEL_OFFSET. Using values outside the valid range makes the results of the texture lookup undefined, as specified in GLES 3.0.4 section 3.8.10. We generate a compiler error if an offset is outside the valid range. BUG=angleproject:1215 TEST=angle_unittests Change-Id: Ida28361444d2f4050d516160f1491674c31868a1 Reviewed-on: https://chromium-review.googlesource.com/312223 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 5d91dda9 2015-06-18T15:47:46 Remove dynamic indexing of matrices and vectors in HLSL Re-re-relanding after clang warning fix. Re-re-landing with fix to setting qualifiers on generated nodes. The previous version failed when a uniform was indexed, because it would set the uniform qualifier on some of the generated nodes and that interfered with the operation of UniformsHLSL. Re-landing after fixing D3D9 specific issues. HLSL doesn't support dynamic indexing of matrices and vectors, so replace that with helper functions that unroll dynamic indexing into switch/case and static indexing. Both the indexed vector/matrix expression and the index may have side effects, and these will be evaluated correctly. If necessary, index expressions that have side effects will be written to a temporary variable that will replace the index. Besides dEQP tests, this change is tested by a WebGL 2 conformance test. In the case that a dynamic index is out-of-range, the base ESSL 3.00 spec allows undefined behavior. KHR_robust_buffer_access_behavior adds the requirement that program termination should not occur and that out-of-range reads must return either a value from the active program's memory or zero, and out-of-range writes should only affect the active program's memory or do nothing. This patch clamps out-of-range indices so that either the first or last item of the matrix/vector is accessed. The code is not transformed in case the it fits within the limited subset of ESSL 1.00 given in Appendix A of the spec. If the code isn't within the restricted subset, even ESSL 1.00 shaders may require this workaround. BUG=angleproject:1116 TEST=dEQP-GLES3.functional.shaders.indexing.* (all pass after change) WebGL 2 conformance tests (glsl3/vector-dynamic-indexing.html) Change-Id: I9f6d7c7ecda8ac4dc3c30b39e15a9a0b5381c5a8 Reviewed-on: https://chromium-review.googlesource.com/310010 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill a5f64de7 2015-10-30T12:31:00 Revert "Remove dynamic indexing of matrices and vectors in HLSL" Failing build on Clang-win: ..\..\third_party\angle\src\compiler\translator\RemoveDynamicIndexing.cpp(128,43) : error: expected '(' for function-style cast or type construction fieldType.setPrimarySize(unsigned char(indexedType.getRows())); ~~~~~~~~ ^ BUG=angleproject:1116 This reverts commit 7535b761dd4740c8e76b888d7c58c7cbeefd2083. Change-Id: I7b502e3dcd45e17b7ed88fec18be702614d9ac65 Reviewed-on: https://chromium-review.googlesource.com/309772 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 7535b761 2015-06-18T15:47:46 Remove dynamic indexing of matrices and vectors in HLSL Re-re-landing with fix to setting qualifiers on generated nodes. The previous version failed when a uniform was indexed, because it would set the uniform qualifier on some of the generated nodes and that interfered with the operation of UniformsHLSL. Re-landing after fixing D3D9 specific issues. HLSL doesn't support dynamic indexing of matrices and vectors, so replace that with helper functions that unroll dynamic indexing into switch/case and static indexing. Both the indexed vector/matrix expression and the index may have side effects, and these will be evaluated correctly. If necessary, index expressions that have side effects will be written to a temporary variable that will replace the index. Besides dEQP tests, this change is tested by a WebGL 2 conformance test. In the case that a dynamic index is out-of-range, the base ESSL 3.00 spec allows undefined behavior. KHR_robust_buffer_access_behavior adds the requirement that program termination should not occur and that out-of-range reads must return either a value from the active program's memory or zero, and out-of-range writes should only affect the active program's memory or do nothing. This patch clamps out-of-range indices so that either the first or last item of the matrix/vector is accessed. The code is not transformed in case the it fits within the limited subset of ESSL 1.00 given in Appendix A of the spec. If the code isn't within the restricted subset, even ESSL 1.00 shaders may require this workaround. BUG=angleproject:1116 TEST=dEQP-GLES3.functional.shaders.indexing.* (all pass after change) WebGL 2 conformance tests (glsl3/vector-dynamic-indexing.html) Change-Id: I16119f9092360fb72798f9550a6f4d3cfffdc92f Reviewed-on: https://chromium-review.googlesource.com/308790 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill b066669d 2015-10-26T10:38:18 Revert "Remove dynamic indexing of matrices and vectors in HLSL" This reverts commit 3766a40d6fda7e7190514ab7838a3f37169d863f. This CL was causing crashes in UniformHLSL.cpp, where an internal uniform "base" was attempted to be declared in HLSL. Was crashing on an external WebGL 3D canvas page (http://www.taccgl.org/?dbg=t). BUG=546686 Original commit message: Re-landing after fixing D3D9 specific issues. HLSL doesn't support dynamic indexing of matrices and vectors, so replace that with helper functions that unroll dynamic indexing into switch/case and static indexing. Both the indexed vector/matrix expression and the index may have side effects, and these will be evaluated correctly. If necessary, index expressions that have side effects will be written to a temporary variable that will replace the index. Besides dEQP tests, this change is tested by a WebGL 2 conformance test. In the case that a dynamic index is out-of-range, the base ESSL 3.00 spec allows undefined behavior. KHR_robust_buffer_access_behavior adds the requirement that program termination should not occur and that out-of-range reads must return either a value from the active program's memory or zero, and out-of-range writes should only affect the active program's memory or do nothing. This patch clamps out-of-range indices so that either the first or last item of the matrix/vector is accessed. The code is not transformed in case the it fits within the limited subset of ESSL 1.00 given in Appendix A of the spec. If the code isn't within the restricted subset, even ESSL 1.00 shaders may require this workaround. BUG=angleproject:1116 TEST=dEQP-GLES3.functional.shaders.indexing.* (all pass after change) WebGL 2 conformance tests (glsl3/vector-dynamic-indexing.html) Change-Id: I1d4b2e3888e91af7d5eebf743d12778698b6b903 Reviewed-on: https://chromium-review.googlesource.com/308770 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho a6996685 2015-10-12T14:32:30 Automatically enable highp in fragment shaders on ESSL3 Most code using the translator already enables highp with the resources flag when a shader spec that accepts ESSL3 is used, but for example the shader_translator utility doesn't. This fix makes sure that highp is always enabled when a fragment shader written in ESSL3 or newer is being compiled. This will make shader_translator easier to use for testing ESSL3 shaders. BUG=541550 TEST=angle_unittests Change-Id: Ia1911677c55f3c5d921829a8cbb808847ac8b636 Reviewed-on: https://chromium-review.googlesource.com/305190 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez d4b5054d 2015-09-28T12:19:26 compiler: Rewrite do-while loops as while loops This works around a Mac driver shader compiler bug that makes many do-while loops cause GPU-hangs when ran. BUG=angleproject:891 Change-Id: I29828d6ea9e887ad0ed0c577f1deb41fb632a900 Reviewed-on: https://chromium-review.googlesource.com/302465 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 3766a40d 2015-06-18T15:47:46 Remove dynamic indexing of matrices and vectors in HLSL Re-landing after fixing D3D9 specific issues. HLSL doesn't support dynamic indexing of matrices and vectors, so replace that with helper functions that unroll dynamic indexing into switch/case and static indexing. Both the indexed vector/matrix expression and the index may have side effects, and these will be evaluated correctly. If necessary, index expressions that have side effects will be written to a temporary variable that will replace the index. Besides dEQP tests, this change is tested by a WebGL 2 conformance test. In the case that a dynamic index is out-of-range, the base ESSL 3.00 spec allows undefined behavior. KHR_robust_buffer_access_behavior adds the requirement that program termination should not occur and that out-of-range reads must return either a value from the active program's memory or zero, and out-of-range writes should only affect the active program's memory or do nothing. This patch clamps out-of-range indices so that either the first or last item of the matrix/vector is accessed. The code is not transformed in case the it fits within the limited subset of ESSL 1.00 given in Appendix A of the spec. If the code isn't within the restricted subset, even ESSL 1.00 shaders may require this workaround. BUG=angleproject:1116 TEST=dEQP-GLES3.functional.shaders.indexing.* (all pass after change) WebGL 2 conformance tests (glsl3/vector-dynamic-indexing.html) Change-Id: I66a5e5a8d7f4267da0045f1cc2ba6b0dc7eb3f5d Reviewed-on: https://chromium-review.googlesource.com/296671 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 3c192a78 2015-08-26T20:32:53 Revert "Remove dynamic indexing of matrices and vectors in HLSL" Seems to be failing a WebGL/ES2 CTS test in D3D9: conformance/ogles/GL/mat3/mat3_001_to_006 BUG=angleproject:1116 BUG=525188 This reverts commit 83f3411da456faac8570892e3dd7d76edf4095e5. Change-Id: Ic186f51240dbdd96ccab3f5470329cdc9727c618 Reviewed-on: https://chromium-review.googlesource.com/295730 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 83f3411d 2015-06-18T15:47:46 Remove dynamic indexing of matrices and vectors in HLSL HLSL doesn't support dynamic indexing of matrices and vectors, so replace that with helper functions that unroll dynamic indexing into switch/case and static indexing. Both the indexed vector/matrix expression and the index may have side effects, and these will be evaluated correctly. If necessary, index expressions that have side effects will be written to a temporary variable that will replace the index. Besides dEQP tests, this change is tested by a WebGL 2 conformance test. In the case that a dynamic index is out-of-range, the base ESSL 3.00 spec allows undefined behavior. KHR_robust_buffer_access_behavior adds the requirement that program termination should not occur and that out-of-range reads must return either a value from the active program's memory or zero, and out-of-range writes should only affect the active program's memory or do nothing. This patch clamps out-of-range indices so that either the first or last item of the matrix/vector is accessed. The code is not transformed in case the it fits within the limited subset of ESSL 1.00 given in Appendix A of the spec. If the code isn't within the restricted subset, even ESSL 1.00 shaders may require this workaround. BUG=angleproject:1116 TEST=dEQP-GLES3.functional.shaders.indexing.* (all pass after change) WebGL 2 conformance tests (glsl3/vector-dynamic-indexing.html) Change-Id: I024722ef4ca1e14d5ad47fdc540397e18858bed6 Reviewed-on: https://chromium-review.googlesource.com/290515 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 4dfe8094 2015-08-21T17:44:35 Always collect variables when generating HLSL HLSL output needs uniform information generated by the collectVariables() step to be able to write uniform registers. Tested manually by compiling a shader with a uniform with shader_translator. BUG=angleproject:1132 Change-Id: I91d19b5fa789b7b33cf76a654ffbbd17d279db01 Reviewed-on: https://chromium-review.googlesource.com/294962 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho a7b6db7f 2015-08-19T14:26:30 Only apply Appendix A limitations to ESSL 1.00 shaders ESSL 1.00 specifies a set of minimum functionality, and ANGLE automatically checks that WebGL shaders stay within this minimum functionality. However, this should only apply to ESSL 1.00. ESSL 3.00 shaders compiled for WebGL 2.0 should not be subject to these restrictions, since there is no similar spec for minimum functionality for ESSL 3.00. In case a non-WebGL based shader spec is used, the restrictions can be toggled from outside by specifying the SH_VALIDATE_LOOP_INDEXING flag, same as before this patch. BUG=angleproject:1116 TEST=WebGL 2 conformance tests Change-Id: Idaec0fb4c7c85cd72020d0b23112fddb1b020571 Reviewed-on: https://chromium-review.googlesource.com/293933 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Cooper Partin 4d61f7ed 2015-08-12T10:56:50 Reland Fixed compiler warning C4267 'conversion from 'size_t' to 'type', possible loss of data' Additional warnings found with more testing and added C4267 warning disable only for angle_libpng BUG=angleproject:1120 Change-Id: Ic403dcff5a8018056fa51a8c408e64207f3362eb Reviewed-on: https://chromium-review.googlesource.com/293028 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill b195643c 2015-08-12T17:35:20 Revert "Fixed compiler warning C4267 'conversion from 'size_t' to 'type', possible loss of data'" Seems to have quite a few warnings in 64-bit on my machine. BUG=angleproject:1120 This reverts commit c5cf9bc47d0ee028adbbf9e9f94ca567eec601dc. Change-Id: I86768b900aeba52e7a2242d9ae8949f93f1a5ba9 Reviewed-on: https://chromium-review.googlesource.com/293280 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Cooper Partin c5cf9bc4 2015-08-06T10:46:48 Fixed compiler warning C4267 'conversion from 'size_t' to 'type', possible loss of data' BUG=angleproject:1120 Change-Id: I01ef10bea7f487c2b394d030c76628f38d2ea645 Reviewed-on: https://chromium-review.googlesource.com/292780 Tested-by: Cooper Partin <coopp@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Kimmo Kinnunen b18609b9 2015-07-16T14:13:11 Implement ES 2,3 parts of EXT_blend_func_extended for shader translation Exposes gl_SecondaryFragColor, glSecondaryFragData[] and gl_MaxDualSourceDrawBuffers to GLES SL 1.0. Relaxes rules for undefined output locations for GLES SL 3.0 and exposes gl_MaxDualSourceDrawBuffers. If the output GL context is GL ES 2.0 or 3.0: The emulation layer is expected to turn on EXT_blend_func_extended if the output GL context supports it. If the output GL context is GL: The emulation layer is expected to turn on EXT_blend_func_extended if the output GL context supports ARB_blend_func_extended or if GL context is 3.2 or later. If the source shader spec is GLES SL 2.0: The emulation layer is expected to inspect the shader compilation output variables upon linking. If output target is GL SL, the emulation layer should bind color location 0, index 1 to "angle_SecondaryFragColor" if variable "gl_SecondaryFragColorEXT" is used. Alternatively, emulation layer should bind "angle_SecondaryFragData" to locations 0,1,2,3,..., all color index 1, if "gl_SecondaryFragData" array is used. (The caller can not bind the locations or specify output variables.) If the source shader spec is GLES SL 3.0: The emulation layer is expected to do location auto-resolve of the the output variables that have undefined output locations that have not been bound by the caller. (The caller can not use gl_ built-ins, so nothing to do with those.) BUG=angleproject:1085 TEST=angle_unittest Change-Id: I5cafe205b0c29478b0dcd24aa89a7b0000f5d046 Reviewed-on: https://chromium-review.googlesource.com/287580 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Kimmo Kinnunen <kkinnunen@nvidia.com>
Olli Etuaho 43613b03 2015-08-04T11:02:21 Make sure that the AST root is always a sequence node This enables inserting helper functions as an AST transformation. BUG=angleproject:1116 TEST=angle_unittests Change-Id: I169d4d3a726d0e389cb3444fe9dfb4c6c5d80155 Reviewed-on: https://chromium-review.googlesource.com/290513 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Corentin Wallez b081e78b 2015-07-20T05:40:04 Compiler: avoid an undefined behavior when using erase-remove Using that idiom on an empty vector results in an undefined behavior that I have seen cause a vector to get length -1 with clang 3.6 on Linux. BUG= Change-Id: I3bb8d8884efa29a17672b458263067644dbf0fec Reviewed-on: https://chromium-review.googlesource.com/286740 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Dmitry Skiba 01971113 2015-07-10T14:54:00 Cache TTypes. *re-land with build fix for Win/Release* This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I4382c55b2480f70b00c5d117fcb7e0c51d0dfbb4 Reviewed-on: https://chromium-review.googlesource.com/284735 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Dmitry Skiba <dskiba@google.com> Reviewed-by: Alexis Hétu <sugoi@chromium.org>
Jamie Madill 53b76107 2015-07-10T18:52:58 Revert "Cache TTypes." Unused variable warning in Release: warning C4189: 'MaxEnumValue' : local variable is initialized but not referenced I'll handle fixing this. BUG=492725 This reverts commit b25d14e4b39ee273fad3bb585c3a3a929b3f794c. Change-Id: I502fc5288d5d3c48ecd43f84acdf66b7e300ad22 Reviewed-on: https://chromium-review.googlesource.com/284863 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba b25d14e4 2015-06-23T17:43:14 Cache TTypes. This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I7b8053c032c9c68f646162baf61abf6db3afe52e Reviewed-on: https://chromium-review.googlesource.com/284003 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2f232370 2015-07-07T21:57:55 Revert "Cache TTypes." Lots of compile errors. BUG=492725 This reverts commit 5377720aae042c5bfae0e8a37032c90dc3ab78cf. Change-Id: I64889b99b1f1f48d39b87ebb668f6a32a3abac45 Reviewed-on: https://chromium-review.googlesource.com/283945 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba 5377720a 2015-06-23T17:43:14 Cache TTypes. This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I2ee748f7271b1afe0834083cbff6f0b84104aa53 Reviewed-on: https://chromium-review.googlesource.com/281411 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Dmitry Skiba <dskiba@google.com>
Geoff Lang 8273e006 2015-06-15T13:40:19 Add new GLSL target versions. Test the emulated GLSL functions against multiple GL versions. BUG=angleproject:1044 Change-Id: I1e12523301042f0d541ab2f4e73f02319d1584ef Reviewed-on: https://chromium-review.googlesource.com/277702 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 5c407bb7 2015-06-01T12:20:39 Work around pow() issue in NVIDIA 331.x drivers pow(x, y) when y is a certain kind of a constant vector can cause issues on NVIDIA 331 series drivers. Add an option to replace pow(x, y) with exp2(y * log2(x)) when y is a constant to work around this issue. This is done with an AST traverser instead of BuiltInFunctionEmulator, since there's no mechanism in BuiltInFunctionEmulator to apply the replacements only to calls where the second parameter is constant. TEST=WebGL conformance tests BUG=chromium:477306 Change-Id: Ifb327d72659fca36868439f24705203014b3ce53 Reviewed-on: https://chromium-review.googlesource.com/274279 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 6e06b1f4 2015-05-14T10:01:17 Make TParseContext a class, with private data. *re-land with build fix* BUG=angleproject:995 Change-Id: I67d3ded8f6c705b54fb372857e07ce1a86b58475 Reviewed-on: https://chromium-review.googlesource.com/271162 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 749fe340 2015-05-13T21:07:55 Revert "Make TParseContext a class, with private data." Causing build errors on Linux: FAILED: ninja -t msvc -e environment.x86 -- C:\b\build\goma/gomacc "C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\angle\src\compiler\translator\translator_lib.ParseContext.obj.rsp /c ..\..\third_party\angle\src\compiler\translator\ParseContext.cpp /Foobj\third_party\angle\src\compiler\translator\translator_lib.ParseContext.obj /Fdobj\third_party\angle\src\translator_lib.cc.pdb c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\validateglobalinitializer.h(11) : error C2220: warning treated as error - no 'object' file generated c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\validateglobalinitializer.h(11) : warning C4099: 'TParseContext' : type name first seen using 'class' now seen using 'struct' c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\parsecontext.h(28) : see declaration of 'TParseContext' BUG=angleproject:995 This reverts commit 6c0c2987fba9dcf2a8d432534c9548092281bfa4. Change-Id: I49a8b7df9bc8b7c4892bf3af5e2c7a6444fba890 Reviewed-on: https://chromium-review.googlesource.com/270767 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 6c0c2987 2015-05-13T13:50:04 Make TParseContext a class, with private data. BUG=angleproject:995 Change-Id: Ie077e3a4f0fd5ef840aa35edeb41d15a98b7c0ff Reviewed-on: https://chromium-review.googlesource.com/270628 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Qingqing Deng ad0d0799 2015-04-08T14:25:06 Expand ShShaderOutput for different GLSL versions BUG=angleproject:968 Change-Id: I2d4c0a8e9a91a940922da4501c22124da0c0399c Reviewed-on: https://chromium-review.googlesource.com/264840 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho c6833115 2015-04-22T15:15:54 Prune empty declarations from the AST Empty declarations in ESSL shaders currently result in errors on several platforms. Prune empty declarations that are not struct or interface block declarations from the AST. TEST=WebGL conformance tests, angle_unittests, angle_end2end_tests BUG=angleproject:980 Change-Id: I9e3abf8134e6dfed0253cc83f69ce0ee92b0e0e7 Reviewed-on: https://chromium-review.googlesource.com/266841 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez a094a8a9 2015-04-07T11:53:06 Add a compiler option to prune unused function and prototypes Also adds a simple unit test checking the pruning BUG=angleproject:937 BUG=395048 Change-Id: I88440378f66178dcebebcd596f8f80235903f20e Reviewed-on: https://chromium-review.googlesource.com/264568 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 78b3a8b9 2015-04-08T16:04:24 Revert "Add a compiler option to prune unused function and prototypes" Compile error on Mac: http://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Mac%20Builder/builds/29051 This reverts commit e423d9ca6e1b340ae06d543419b8a515de5ac3f2. Change-Id: Ie08d7f2bf86089a006f3177480aa7491a9405257 Reviewed-on: https://chromium-review.googlesource.com/264585 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez e423d9ca 2015-04-07T11:53:06 Add a compiler option to prune unused function and prototypes Also adds a simple unit test checking the pruning BUG=angleproject:937 BUG=395048 Change-Id: I49904c34d1a72949cdc579569967d99c736c7237 Reviewed-on: https://chromium-review.googlesource.com/264415 Reviewed-by: Kenneth Russell <kbr@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 71d147f6 2015-02-11T11:15:24 Implemented a CallDAG to allow for more AST analysis The CallDAG preprocesses the AST to construct a DAG of functions that can be used for several analyses. Use it to implement check for recursion and max call depth. It will also be used to limit the usage of [[flatten]] and [[unroll]]. BUG=angleproject:937 BUG=395048 Change-Id: I8578703f2d49513f315aecccbcff34914562e4ff Reviewed-on: https://chromium-review.googlesource.com/263774 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Geoff Lang 186160b2 2015-04-02T19:34:38 Revert "Implemented a CallDAG to allow for more AST analysis" failures in angle_unittests and compilation failure on clang (see: https://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Mac%20Builder%20%28dbg%29/builds/30016/steps/compile/logs/stdio) . This reverts commit b34d1d12969496b1b0fb53934b8ce3200304f900. Change-Id: Ia995fb2db0e891294f3461de01617cb13e5ae381 Reviewed-on: https://chromium-review.googlesource.com/263727 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Corentin Wallez b34d1d12 2015-02-11T11:15:24 Implemented a CallDAG to allow for more AST analysis The CallDAG preprocesses the AST to construct a DAG of functions that can be used for several analysis. Use it to implement check for recursion and max call depth. It will also be used to limit the usage of [[flatten]] and [[unroll]]. BUG=angleproject:937 BUG=395048 Change-Id: I643e0ed605ad095e4fd7da4977d842be5e6a12e0 Reviewed-on: https://chromium-review.googlesource.com/229352 Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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>