src/compiler/translator/RemoveDynamicIndexing.cpp


Log

Author Commit Date CI Message
Olli Etuaho 3272a6d3 2016-08-29T17:54:50 Promote and fold indexing nodes similarly to other binary ops Indexing nodes now get their type set in TIntermBinary::promote, same as math and logic ops. They are also constant folded through TIntermBinary::fold() instead of having special functions for constant folding them in ParseContext. Index nodes for struct and interface block member access now always have integer type, instead of sometimes having the type of the field they were used to access. Usage of TIntermBinary constructor is cleaned up so only the constructor that takes in left and right operands is used. The type of TIntermBinary nodes is always determined automatically. Together these changes make the code considerably cleaner. Note that the code for constant folding for array indexing is actually never hit because constant folding array constructors is still intentionally disabled in the code. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ifcec45257476cdb0d495c7d72e3cf2f83388e8c5 Reviewed-on: https://chromium-review.googlesource.com/377961 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 666f65a1 2016-08-26T01:34:37 Revert "Revert "Cover vector dynamic indexing case in SplitSequenceOperator"" This reverts commit d2f59bb6dda4f3548e158a09540829f9ff56bba4. Change-Id: If2842bce17a0c085e2bc913ff120083fbe90497c Reviewed-on: https://chromium-review.googlesource.com/376189 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill d2f59bb6 2016-08-17T11:50:52 Revert "Cover vector dynamic indexing case in SplitSequenceOperator" This CL was causing inverted rendering in a WebGL application. This reverts commit 7da9850643f55335a13a4663d226c73d0ac4d3b1. Vectors or matrices that are dynamically indexed as a part of an l-value generate new statements in the RemoveDynamicIndexing AST transformation step. SplitSequenceOperator needs to detect this case and split the sequence operator before statements are generated from its operands to ensure the correct order of execution. BUG=angleproject:1341 TEST=angle_end2end_tests Change-Id: I854f8cce2d46107afa62f48edf3d32c6d5c97eda Reviewed-on: https://chromium-review.googlesource.com/371643 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 03d863c8 2016-07-27T18:15:53 translator: Refactor node replacement APIs. BUG=angleproject:851 Change-Id: I50c3b3a4f00b27fed85f09509738513a441c7b5b Reviewed-on: https://chromium-review.googlesource.com/363990 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 1048e43f 2016-07-23T18:51:28 D3D: Work around HLSL integer pow folding bug. BUG=angleproject:851 Change-Id: I68a47b8343a29e42c0a69ca3f2a6cb5054d03782 Reviewed-on: https://chromium-review.googlesource.com/362775 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 7da98506 2016-07-20T18:45:09 Cover vector dynamic indexing case in SplitSequenceOperator Vectors or matrices that are dynamically indexed as a part of an l-value generate new statements in the RemoveDynamicIndexing AST transformation step. SplitSequenceOperator needs to detect this case and split the sequence operator before statements are generated from its operands to ensure the correct order of execution. BUG=angleproject:1341 TEST=angle_end2end_tests Change-Id: I84e41a59c88fb5d0111669cab60312b930531a22 Reviewed-on: https://chromium-review.googlesource.com/361695 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: 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>
Zhenyao Mo 54c311fc 2015-09-09T15:37:31 win clang build fix BUG= TEST=win clang bots build Change-Id: I802be2e72a884e50cf13120d3cd9c76a8f8eb86f Reviewed-on: https://chromium-review.googlesource.com/298253 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Geoff Lang <geofflang@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>