src/compiler/translator/OutputHLSL.cpp


Log

Author Commit Date CI Message
Olli Etuaho 74da73fe 2017-02-01T15:37:48 Add ESSL 3.10 ldexp/frexp builtins This adds new built-ins found in ESSL 3.10 section 8.3 Common Functions. This includes constant folding support for ldexp and support for both GLSL and HLSL output. In HLSL these functions need to be emulated. BUG=angleproject:1730 TEST=angle_unittests Change-Id: I1330e69978b0cf53efbc3416150194764414e96c Reviewed-on: https://chromium-review.googlesource.com/435342 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 25aef453 2017-01-29T16:15:44 Add new ESSL 3.10 pack/unpack builtins This adds new built-ins found in ESSL 3.10 section 8.4 Floating-Point Pack and Unpack Functions. This includes constant folding support and support for both GLSL and HLSL output. In HLSL all of these functions need to be emulated. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.*pack*norm4x8* Change-Id: Ibed60286a366cd35c4faafd405e79af562a02a06 Reviewed-on: https://chromium-review.googlesource.com/434170 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 1ecd14b8 2017-01-26T13:54:15 Fold user-definedness of function nodes into TOperator Whether a function call is user-defined is not orthogonal to TOperator associated with the call node - other ops than function calls can't be user-defined. Because of this it makes sense to store the user- definedness by having different TOperator enums for different types of calls. This patch also tags internal helper functions that have a raw definition outside the AST with a separate TOperator enum. This way they can be handled with logic that is easy to understand. Before this, function calls like this left the user-defined bit unset, despite not really being built-ins either. The EmulatePrecision traverser uses this. This is also something that could be used to clean up built-in emulation in the future. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I597fcd9789d0cc22b689ef3ce5a0cc3f621d4859 Reviewed-on: https://chromium-review.googlesource.com/433443 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 9250cb24 2017-01-21T10:51:27 Add ESSL 3.10 integer math built-ins This adds built-ins found in ESSL 3.10 section 8.8 Integer functions. This includes constant folding support for functions that may be constant folded, and support for both GLSL and HLSL output. In HLSL several of the functions need to be emulated. The precision qualification for the return value of some of these functions is determined by special rules, that are now part of type promotion for TIntermUnary nodes and determining the type of TIntermAggregate nodes. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.builtin_functions.integer.* Change-Id: Ib0056c17671c42b6496c2f0ef059b99f8f25c122 Reviewed-on: https://chromium-review.googlesource.com/431310 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho dfa75e87 2017-01-23T09:43:06 Add support for 4-parameter functions to BuiltInFunctionEmulator New entry points are needed to support built-ins with more parameters. Also, now that ops that are not function calls don't use the TIntermAggregate class any more, it's easier to exclude nodes that are not candidates for built-in emulation using a simple blacklist rather than to use a whitelist. Also includes function name style cleanup in BuiltInFunctionEmulator. This will make it possible to add necessary emulation for built-ins from ESSL 3.10. BUG=angleproject:1730 TEST=angle_unittests Change-Id: If267fc68f5cb9b2ee6703cbcbbe4d157da44a7e0 Reviewed-on: https://chromium-review.googlesource.com/431297 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 1d9dcc24 2017-01-19T11:25:32 Make AST path always include the current node being traversed AST traversers tend to sometimes call traverse() functions manually during PreVisit. Change TIntermTraverser so that even if this happens, all the nodes are automatically added to the traversal path, instead of having to add them manually in each individual AST traverser. This also makes calling getParentNode() return the correct node during InVisit. This does cause the same node being added to the traversal path twice in some cases, where nodes are repeatedly traversed, like in OutputHLSL, but this should not have adverse side effects. The more common case is that the traverse() function is called on the children of the node being currently traversed. This fixes a bug in OVR_multiview validation, which did not previously call incrementDepth and decrementDepth when it should have. BUG=angleproject:1725 TEST=angle_unittests, angle_end2end_tests Change-Id: I6ae762eef760509ebe853eefa37dac28c16e7a9b Reviewed-on: https://chromium-review.googlesource.com/430732 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Xinghua Cao b123938d 2016-12-13T15:07:05 D3D11: Add support to compile and link compute shaders This is a reland of 2cd9d7e032fb412b539a907c58342060340387a1. BUG=angleproject:1442 TEST=angle_end2end_tests Change-Id: I5be0032b97617c31cdd4c66a823e8eb3b518867a Reviewed-on: https://chromium-review.googlesource.com/430199 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 8ad9e757 2017-01-16T19:55:20 Always store function headers in TIntermFunctionPrototype nodes TIntermFunctionDefinition nodes now have a TIntermFunctionPrototype child that stores the function signature, instead of having a separate type and an aggregate child that stores the parameters. This makes parsing functions simpler, and paves the way for further simplifications of function parsing, like reducing conversions between symbol table structures and AST structures. TIntermAggregate is now only used for function calls. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: Ib56a77b5ef5123b142963a18499690bf37fed987 Reviewed-on: https://chromium-review.googlesource.com/427945 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 16c745a3 2017-01-16T17:02:27 Split TIntermFunctionPrototype from TIntermAggregate Function prototypes now have their own class TIntermFunctionPrototype. It's only used for prototypes, not function parameter lists. TIntermAggregate is still used for parameter lists and function calls. BUGS=angleproject:1490 TEST=angle_unittests Change-Id: I6e246ad00a29c2335bd2ab7f61cf73fe463b74bb Reviewed-on: https://chromium-review.googlesource.com/427944 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 417df92f 2017-01-12T09:23:07 Revert "D3D11: Add support to compile and link compute shaders." Fails https://build.chromium.org/p/chromium.gpu.fyi/builders/Linux%20Debug%20%28New%20Intel%29/builds/5769 BUG=angleproject:1442 This reverts commit 2cd9d7e032fb412b539a907c58342060340387a1. Change-Id: Ic1610d20ba0449b423528fa9840aa951c012cf84 Reviewed-on: https://chromium-review.googlesource.com/427229 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Xinghua Cao 2cd9d7e0 2016-12-13T15:07:05 D3D11: Add support to compile and link compute shaders. BUG=angleproject:1442 Change-Id: I13240e931e6f121d175d2cd6b41324d38bb39a5c Reviewed-on: https://chromium-review.googlesource.com/405831 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho d68924e5 2017-01-02T17:34:40 Use GetOperatorString when writing GLSL unary built-in calls GetOperatorString is now used when writing GLSL for built-in calls that fall under TIntermUnary. Component-wise not TOperator enum is renamed for consistency. This also cleans up some unnecessary creation of string objects when writing built-in functions. BUG=angleproject:1682 TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests Change-Id: I89b2ef222bf5af479d4977417f320789b58ace85 Reviewed-on: https://chromium-review.googlesource.com/424552 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho e180559f 2017-01-02T16:41:20 Use GetOperatorString when writing GLSL built-in function calls GetOperatorString is now used when writing GLSL for built-in calls that fall under TIntermAggregate. Component wise and not component wise TOperator enums are disambiguated from each other. BUG=angleproject:1682 TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests Change-Id: I861f1e94eb695eb712592df99705848b442ef07b Reviewed-on: https://chromium-review.googlesource.com/424532 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 77ba408a 2016-12-16T12:01:18 Unify Diagnostics interface Use the same kind of interface for reporting preprocessor errors as for reporting regular compiler errors, and make global errors like having too many uniforms also go through Diagnostics. Also don't create std::string objects unnecessarily. Includes cleanups of some dead code related to reporting errors. BUG=angleproject:1670 TEST=angle_unittests Change-Id: I3ee794d32ddeec1826bdf1b76b558f35259f82c0 Reviewed-on: https://chromium-review.googlesource.com/421527 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho bf4e1b73 2016-12-09T11:30:15 Split TIntermInvariantDeclaration from TIntermAggregate This change is pure refactoring and doesn't fix bugs related to invariant declarations. Invariant declarations are supposed to accept a list of identifiers, but this refactoring keeps the current behavior of only accepting a single identifier in an invariant declaration. When the bug will be fixed, the new TIntermInvariantDeclaration class that now has only a single child node can be changed so that it may have multiple children. TIntermAggregate is still used for function calls, function prototypes and function parameter lists. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I3e22092c87e1c06445fd7e123d9922c2fcb59428 Reviewed-on: https://chromium-review.googlesource.com/419415 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill d7b1ab58 2016-12-12T14:42:19 Fix up translator style. Using git cl format. BUG=angleproject:650 Change-Id: I7d3f98d2b0dcfb0a8de6c35327db74e55c28d761 Reviewed-on: https://chromium-review.googlesource.com/419059 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 56a2f95f 2016-12-08T12:16:27 Output infinity and NaN literals correctly in shaders Previously infinity and NaN resulting from constant folding would be clamped to finite 32-bit float range when they were written in shader output. Now they are written as a bit pattern in case the shader version allows it. This does not guarantee that NaNs work, but this is fine, since ESSL 3.00.6 spec has very loose requirements when it comes to NaNs. BUG=angleproject:1654 TEST=angle_end2end_tests Change-Id: I9997000beeaa8ed22523c22d5cf6929cdfc93f60 Reviewed-on: https://chromium-review.googlesource.com/417301 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 45bcc784 2016-11-07T13:58:48 translator: Scope all classes with "sh". I was seeing an odd problem with our PoolAlloc conflicting with the glslang/Vulkan TIntermNode, so the fix was to move everything to a separate namespace. The bison grammars are also regenerated. No functional changes. BUG=angleproject:1576 Change-Id: I959c7afe4c092f0d458432c07b4dcee4d39513f3 Reviewed-on: https://chromium-review.googlesource.com/408267 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 60e6edfa 2016-10-31T12:17:19 Make ASSERT reference the conditional expression. This should prevent further unexpected bot breakage due to unreferenced variables in the ASSERT expression. Also remove the no longer needed variable referencing macro. BUG=angleproject:1586 Change-Id: I127695165bdfe39c51fe8d17e00daf6bf2fa8252 Reviewed-on: https://chromium-review.googlesource.com/404948 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 13389b66 2016-10-16T11:48:18 Split TIntermDeclaration from TIntermAggregate The new class TIntermDeclaration is now used for struct, interface block and variable declarations. TIntermDeclaration nodes do not have a type - rather the type is stored in each child node. The types may differ in case the declaration is a series of array declarators with mismatching sizes. TIntermAggregate is still used for function calls, function prototypes, function parameter lists and invariant declarations. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I0457188f354481470855f61ac1c878fc2579b1d1 Reviewed-on: https://chromium-review.googlesource.com/400023 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 4db7ded5 2016-10-13T12:23:11 Change comma nodes to TIntermBinary Comma nodes always have just two parameters. If there's an expression with several commas in the middle, it's parsed as a tree of comma operations. It makes more sense to represent it as a binary node rather than an aggregate node. After this patch, TIntermAggregate is still used for function prototypes, function parameter lists, function calls, and variable and invariant declarations. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: I66be10624bf27bcf25987b4d93958d4a07600771 Reviewed-on: https://chromium-review.googlesource.com/397320 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 336b1470 2016-10-05T16:37:55 Split TIntermFunctionDefinition from TIntermAggregate This makes the code easier to understand. Function definition nodes always have just two children, the parameters node and the function body node, so there was no proper reason why they should be aggregate nodes. As a part of this change, intermediate output is modified to print symbol table ids of functions so that debugging function id related functionality will be easier in the future. After this patch, TIntermAggregate is still used for function prototypes, function parameter lists, function calls, variable and invariant declarations and the comma (sequence) operator. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: Ib88b4ca5d21abd5f126836ca5900d0baecabd19e Reviewed-on: https://chromium-review.googlesource.com/394707 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho bd674557 2016-10-06T13:28:42 Separate function info from TIntermAggregate This change will make it easier to split types of TIntermAggregate nodes representing functions and function calls into different node classes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I730aa7858fe31fda86218fc685980c6ad486f5e0 Reviewed-on: https://chromium-review.googlesource.com/394706 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 6d40bbdd 2016-09-30T13:49:38 Split TIntermBlock from TIntermAggregate The new TIntermBlock node class replaces TIntermAggregate nodes with the EOpSequence op. It represents the root node of the tree which is a list of declarations and function definitions, and any code blocks that can be denoted by curly braces. These include function and loop bodies, and if-else branches. This change enables a bunch of more compile-time type checking, and makes the AST code easier to understand and less error-prone. The PostProcess step that used to be done to ensure that the root node is TIntermAggregate is removed in favor of making sure that the root node is a TIntermBlock in the glslang.y parsing code. Intermediate output formatting is improved to print the EOpNull error in a clearer way. After this patch, TIntermAggregate is still used for function definitions, function prototypes, function parameter lists, function calls, variable and invariant declarations and the comma (sequence) operator. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: I04044affff979a11577bc1fe75d747e538b799c8 Reviewed-on: https://chromium-review.googlesource.com/393726 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 5878f832 2016-10-07T10:14:58 Fix formatting of OutputHLSL::visitAggregate Subsequent refactoring of this code will be easier to review if there won't be unrelated style changes that git cl format insists on doing. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I102fd73bd92317ab438e1676422212f644d2859b Reviewed-on: https://chromium-review.googlesource.com/394649 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 32db19b7 2016-10-04T14:43:16 Ensure that if-else branches are always sequence nodes This mainly affects RewriteElseBlocks, which was the only piece of code still adding TIntermIfElse nodes directly as children of other TIntermIfElse nodes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I5b25c2fb9c642424417cd6c29e37c20482c6ffaf Reviewed-on: https://chromium-review.googlesource.com/392847 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f51fdd2e 2016-10-03T10:03:40 Ensure that all functions have a body node in the AST Some traversers that insert code to main() assume that the main() function has a non-null body node in place. This assumption was previously wrong, since functions could be missing the body node in case the function body was empty. Fix possible invalid dereferencing of missing function body nodes by always adding an empty sequence node to represent the body of functions that have an empty body in the ESSL source. This also enables simplifying some tree traversers that used to take the possibility of missing function body nodes into account. Also fix AddDefaultReturnStatements to check the last statement inside the function body for a return statement, instead of checking the first statement. BUG=angleproject:1539 TEST=angle_unittests, angle_end2end_tests Change-Id: I2fbd18c78653fa2f1a96dbd9a619accc4874030d Reviewed-on: https://chromium-review.googlesource.com/392046 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b6fa043d 2016-09-28T16:28:05 Split vector swizzle AST nodes into a different node class This avoids creating a weird aggregate node with a sequence of constant union nodes to store the offsets. They're stored neatly inside a vector instead. This makes code that needs to iterate over the swizzle offsets much simpler. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I156b95723529ee05a94d30295ffb6d0952a98564 Reviewed-on: https://chromium-review.googlesource.com/390832 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Shao 6f0a0dca 2016-09-27T13:51:29 Workaround isnan() on Intel drivers On some Intel drivers, calling function isnan() on highp float will get wrong answer. This patch work arounds this bug by using an expression to emulate this function. BUG=chromium:650547 Change-Id: I5bc5e0352c434f42cd2c55103a74f9f7ba51a72c Reviewed-on: https://chromium-review.googlesource.com/389834 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 5796127e 2016-09-14T13:57:46 Rename TIntermSelection to TIntermIfElse Now that ternary nodes are not represented by TIntermSelection any more, TIntermIfElse is an easier name to understand for newcomers to the code. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ia1e04e356ab93409400245092a84533d7dfd129d Reviewed-on: https://chromium-review.googlesource.com/385416 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 d0bad2c7 2016-09-09T18:01:16 Split ternary node class from TIntermSelection Ternary operator nodes are typed parts of expressions, they always have two children and the children are also guaranteed to be TIntermTyped. "If" selection nodes can't be a part of an expression, they can have either one or two children and the children are code blocks. Due to all of these differences it makes sense to store these using two different AST node classes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I913ab1d806e3cdb5c21106f078cc9c0b6c72ac54 Reviewed-on: https://chromium-review.googlesource.com/384512 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Geoff Lang 1fe74c7e 2016-08-25T13:23:01 Manually compute the mipmap size for the textureSize builtin. There were two issues with the current implementation: * The GetDimensions function already takes into account the base level of the SRV. * The GetDimensions function returns doesn't return valid sizes for levels that don't exist in the SRV. Instead, manually do the lod offset. BUG=angleproject:931 BUG=angleproject:1316 TEST=dEQP-GLES3.functional.shaders.texture_functions.texturesize.sampler2d_fixed_vertex Change-Id: I63259b563a42b93b73949e0ef7ac412099a42f13 Reviewed-on: https://chromium-review.googlesource.com/376099 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 856c497e 2016-08-08T11:38:39 Clarify error checking function names in the GLSL parser Most error checking functions in ParseContext used to follow a format like <property>ErrorCheck. Sometimes this function would check that the node/value would have <property>, sometimes it would check that the node/value would not have it, which was confusing. Change most of these functions to use a lot more descriptive names, which clearly communicate what they are checking for. Also includes a bit of refactoring in constructorErrorCheck(), so that the function only checks for errors rather than also setting the type of the constructor node. Also make TType::arraySize unsigned, and return a sanitized size from checkIsValidArraySize() instead of using an output parameter. BUG=angleproject:911 TEST=angle_unittests Change-Id: Id9767b8c79594ad3f782f801ea68eb96df721a31 Reviewed-on: https://chromium-review.googlesource.com/367070 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b741c761 2016-06-29T15:49:22 Support precision emulation on HLSL Re-submit with missing virtual destructor and angle::NonCopyable added. Add precision emulation support to HLSL 4.1 output. This makes it possible for developers to test their shaders for precision issues easily on Chrome on Windows without having to use the GL backend. The patch has been verified with Chrome on Windows to reproduce some precision bugs in real-world WebGL content, including old versions of the babylon.js library. The EmulatePrecision AST transformation still relies on writing out raw shader code for the rounding functions, with raw HLSL code added alongside pre-existing GLSL and ESSL code. In some ways it would be nicer to do the EmulatePrecision step as a pure AST transformation, but on the other hand the raw code is much more readable and easier to optimize. To better support multiple output languages in EmulatePrecision, add a RoundingHelperWriter class that has different subclasses for writing the rounding functions in different languages. The unit tests are expanded to cover the HLSL output of precision emulation. The parts of the tests that require the HLSL output are only active on Windows where ANGLE_ENABLE_HLSL define is added to the unit tests. Putting the HLSL tests in an entirely separate file is a worse alternative, since it would require either a lot of code duplication or add a lot of boilerplate to the individual tests. BUG=angleproject:1437 TEST=angle_unittests Change-Id: I47d501037c206f4bd8b976d3acab9b21c717084c Reviewed-on: https://chromium-review.googlesource.com/360152 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3fdaf6f2 2016-07-13T15:07:41 Revert "Support precision emulation on HLSL" Forgot to add virtual destructors. BUG=angleproject:1437 This reverts commit a42e8b2cb9d0857f53c0490b5be3bf25b4e1f827. Change-Id: If33fecfeca9947deedf4668c64dbadf25a5dc5eb Reviewed-on: https://chromium-review.googlesource.com/360122 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a42e8b2c 2016-06-29T15:49:22 Support precision emulation on HLSL Add precision emulation support to HLSL 4.1 output. This makes it possible for developers to test their shaders for precision issues easily on Chrome on Windows without having to use the GL backend. The patch has been verified with Chrome on Windows to reproduce some precision bugs in real-world WebGL content, including old versions of the babylon.js library. The EmulatePrecision AST transformation still relies on writing out raw shader code for the rounding functions, with raw HLSL code added alongside pre-existing GLSL and ESSL code. In some ways it would be nicer to do the EmulatePrecision step as a pure AST transformation, but on the other hand the raw code is much more readable and easier to optimize. To better support multiple output languages in EmulatePrecision, add a RoundingHelperWriter class that has different subclasses for writing the rounding functions in different languages. The unit tests are expanded to cover the HLSL output of precision emulation. The parts of the tests that require the HLSL output are only active on Windows where ANGLE_ENABLE_HLSL define is added to the unit tests. Putting the HLSL tests in an entirely separate file is a worse alternative, since it would require either a lot of code duplication or add a lot of boilerplate to the individual tests. BUG=angleproject:1437 TEST=angle_unittests Change-Id: Ia4ba0374cd415908f16f34752321af1cb93525a5 Reviewed-on: https://chromium-review.googlesource.com/358473 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d4f4c11b 2016-04-15T15:11:24 Fix deferring global array initialization The initial implementation of DeferGlobalInitializers did not take HLSL corner cases into account. In particular, in case there was a const-qualified array variable with an initializer that contained elements that weren't constant folded, initialization would not be deferred and the global scope of HLSL output would contain a call to angle_construct_into_*(). On the other hand, deferring global initializers was also done in cases where it wasn't necessary. Initializers of non-const qualified array variables that could be written as HLSL literals by HLSL output were unnecessarily deferred. This patch fixes both of these issues: Now all global initializers are potential candidates for deferral instead of just those where the symbol has the EvqGlobal qualifier, and initializers that are constructors taking only constant unions as parameters are not unnecessarily deferred. BUG=angleproject:1205 BUG=541551 TEST=angle_end2end_tests Change-Id: I4027059e0e5f39c8a5a48b5c97a3fceaac6b6f8a Reviewed-on: https://chromium-review.googlesource.com/339201 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 5858f7e3 2016-04-08T13:08:46 Re-land "Refactor texture function handling in OutputHLSL" This change is pure refactoring, it does not introduce any functional changes. Separate texture function output into a helper class and further into different helper functions to make the code more maintainable. Some of the logic is simplified slightly by eliminating duplicate cases and limiting the scope of variables where possible, but care has been taken to preserve the exact same functionality as before. Re-land with a fix to typo in include guard. BUG=angleproject:1349 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (no regression) dEQP-GLES3.texture.* (no regression) Change-Id: I57c1ec1950fa05bd16275ca578eb5ee99b34a5ae Reviewed-on: https://chromium-review.googlesource.com/339180 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez c2ed9380 2016-04-15T13:29:25 Revert "Refactor texture function handling in OutputHLSL" It triggered an include guard warning on Windows Clang This reverts commit 6f6c5580553d1f3c584df692823c2f5640e23d88. Change-Id: Ibd4f2851f311a494f16376d8eed38f3119594761 Reviewed-on: https://chromium-review.googlesource.com/338933 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 6f6c5580 2016-04-08T13:08:46 Refactor texture function handling in OutputHLSL This change is pure refactoring, it does not introduce any functional changes. Separate texture function output into a helper class and further into different helper functions to make the code more maintainable. Some of the logic is simplified slightly by eliminating duplicate cases and limiting the scope of variables where possible, but care has been taken to preserve the exact same functionality as before. BUG=angleproject:1349 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (no regression) dEQP-GLES3.texture.* (no regression) Change-Id: I5d81b842d693c0055890d5724eae6c105e454cd8 Reviewed-on: https://chromium-review.googlesource.com/337931 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 b079c7af 2016-04-01T12:32:52 Wrap integer textures with correct wrap mode in HLSL The wrap mode information for all three dimensions is packed to a single integer in order to conserve sampler metadata space. Only one int4 vector is used for the metadata for a single sampler. The sampler metadata is now packed into a struct instead of an array of integers in order to make the code more readable and maintainable. The internalFormatBits field is not removed in this patch. It's better to remove it in a separate patch, so restoring it is easier in case it will be used for optimizing some of the texture sampling functions. The wrap mode passed in sampler metadata is used to wrap the texture coordinates in the code generated to implement ESSL 3.00 integer texture sampling built-ins. Those dEQP-GLES3.functional.texture.units.* tests that sample from integer cube maps still fail on Intel D3D after this change, presumably due to driver issues. BUG=angleproject:1244 BUG=angleproject:1095 BUG=angleproject:1092 TEST=dEQP-GLES3.functional.texture.units.* (all pass on NVIDIA), dEQP-GLES3.functional.shaders.texture_functions.* (no regressions) Change-Id: I4e31e5796086f9cc290c6f1f8c4380a768758d71 Reviewed-on: https://chromium-review.googlesource.com/336638 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ced87057 2016-04-04T16:34:27 Fix integer texture sampling with explicit gradients The lod level should be selected according to the explicit gradients, and the gradients are relative to the normalized texture coordinates, so they need to be multiplied by the base level dimensions to get the correct gradients to use in the lod level formula. In the case of sampling integer cube maps, the derivatives of the texture coordinates on the cube map face need to be calculated based on the derivatives of the cube map direction vector components. Also includes fix for sampling integer cube maps with explicit LOD. BUG=angleproject:1092 TEST=dEQP-GLES3.functional.shaders.texture_functions.*grad* Change-Id: Iadd358e713fa9695e755e98db8f368e8c512ac45 Reviewed-on: https://chromium-review.googlesource.com/337100 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d4102f09 2016-01-22T14:54:04 Refactor HLSL texture coordinate output to prepare for wrap modes Wrap modes for integer textures need to be implemented in shaders in HLSL. This requires more complex transformations on the texture coordinates, so store the texture coordinate code for each texture coordinate in a string variable. BUG=angleproject:1244 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (no regression), dEQP-GLES3.functional.texture.units.* (no regression) Change-Id: Iadd9617a7f906aa1d56dabfba6639f932152e6f1 Reviewed-on: https://chromium-review.googlesource.com/336637 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 9696316d 2016-03-21T11:54:33 Support ESSL structs containing samplers on D3D Since HLSL can't natively handle samplers in structs, samplers need to be extracted out of structs into separate variables in the translated shader code. In HLSL 4.1, samplers that were in structs go into the normal sampler arrays and are identified by index constants. In other HLSL versions, samplers that were in structs are translated as uniform variables. These transformations are done inside the HLSL output classes, not as tree transformations. This helps to keep the uniform API provided by the shader translator intact. Wherever a struct containing samplers is passed into a user-defined function, the translated HLSL code passes the separate sampler variables alongside a struct where the samplers have been removed. The D3D backend in libANGLE queries the uniform registers of any samplers that were in uniform structs, and adds them to the register maps, so that correct sampler state gets assigned to them. The extracted sampler variables are prefixed with "angle_" instead of the usual "_" to prevent any name conflicts between them and regular variables. BUG=angleproject:504 TEST=angle_end2end_tests, dEQP-GLES*.functional.shaders.struct.uniform.* (all pass), dEQP-GLES*.functional.uniform_api.* (most now pass) Change-Id: Ib79cba2fa0ff8257a973d70dfd917a64f0ca1efb Reviewed-on: https://chromium-review.googlesource.com/333743 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez b076adde 2016-01-11T16:45:46 Implement gl_VertexID BUG=angleproject:1217 Change-Id: Ibb9423d7de4966bce231734925a804b6340b5059 Reviewed-on: https://chromium-review.googlesource.com/321420 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho be59c2fb 2016-03-07T11:32:34 Fix ambiguous function call issues in HLSL output D3D compiler can't resolve between these overloaded functions: float4 vec4(float2x2 x0); float4 vec4(float4 x0); Include the parameter types in the function name to disambiguate between overloaded user-defined functions and constructors, like this: float4 vec4_float2x2(float2x2 x0); float4 vec4_float4(float4 x0); This is only done for float2x2 and float4 parameters, other parameter types like float2x3 vs. float3x2 don't need this. BUG=angleproject:1099 BUG=angleproject:1030 TEST=angle_end2end_tests, dEQP-GLES3.functional.attribute_location.* (10 more tests pass), dEQP-GLES2.functional.attribute_location.* Change-Id: Ief047d41b0adbc238393c3c13cb29771cbb83d58 Reviewed-on: https://chromium-review.googlesource.com/329882 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f8bf583b 2016-02-11T16:21:49 Pass integer texture format bit count to shaders on D3D11 This will be needed in the future when integer texture wrap mode support will be added by sampling integer textures through FLOAT/UNORM/SNORM SRVs. The bit count needs to be passed for 8-, 10- and 16-bit textures. 32-bit integer textures are the ones left over. Only passing the bit counts for the absolute minimum number of formats avoids unnecessary driver constant buffer updates. BUG=angleproject:1244 BUG=angleproject:1095 TEST=angle_end2end_tests Change-Id: I28a84588842b2eb9a1661454437d21c22ce794b7 Reviewed-on: https://chromium-review.googlesource.com/326944 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho bce743ab 2016-01-15T17:18:28 Use texture base level to implement textureSize on D3D11 HLSL HLSL GetDimensions call doesn't take the texture base level into account, so ANGLE needs to use the texture base level passed in uniforms to emulate ESSL textureSize() which does take it into account. After this change the relevant dEQP tests pass on NVIDIA, Intel is still suffering from an issue where a wrong value is returned when the lod is > 0 (tested on Intel HD Graphics 4600). AMD is also suffering from an unknown issue. BUG=angleproject:596 TEST=dEQP-GLES3.functional.shaders.texture_functions.texturesize.* (all pass on NVIDIA now), angle_end2end_tests Change-Id: I13e33d126008ecdf2b89461a3fb5040949cf19e2 Reviewed-on: https://chromium-review.googlesource.com/322123 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 618bebcd 2016-01-15T16:40:00 Pass texture base level to shaders on D3D11 The base level is passed to shaders in an array included in the driver uniform block. This is done on feature levels above 9_3, which treat samplers as indices to sampler arrays in shaders. A separate uniform block couldn't be used for the sampler metadata, since that would bring the number of available uniform blocks down to below minimum level defined by GLES 3.0. BUG=angleproject:596 TEST=angle_end2end_tests Change-Id: Ie040521402f9996d51a978aeeba9222e9dd761ce Reviewed-on: https://chromium-review.googlesource.com/326290 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Austin Kinross 2a63b3f8 2016-02-08T12:29:08 Re-land "Implement EGL_experimental_present_path_angle" - Re-land with clang fix. This allows ANGLE to render directly onto a D3D swapchain in the correct orientation when using the D3D11 renderer. The trick is to add an extra uniform to each shader which takes either the value +1.0 or -1.0. When rendering to a texture, ANGLE sets this value to -1.0. When rendering to the default framebuffer, ANGLE sets this value to +1.0. ANGLE multiplies vertex positions by this value in the VS to invert rendering when appropriate. It also corrects other state (e.g. viewport/scissor rect) and shader built-in values (e.g. gl_FragCoord). This saves a substantial amount of GPU time and lowers power consumption. For example, the old method (where ANGLE renders all content onto an offscreen texture, and then copies/inverts this onto the swapchain at eglSwapBuffers() time) uses about 20% of the GPU each frame on a Lumia 630. Verification: + dEQP GL ES2 tests pass when "present path fast" is enabled + all ANGLE_end2end_tests pass when "present path fast" is enabled BUG=angleproject:1219 Change-Id: I56b339897828753a616d7bae837a2f354dba9c63 Reviewed-on: https://chromium-review.googlesource.com/326730 Tryjob-Request: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill d1c46228 2016-02-08T14:51:18 Revert "Implement EGL_experimental_present_path_angle" Compile failure on Clang/Win: The reason for reverting is: FAILED: ninja -t msvc -e environment.x86 -- "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m32 /nologo /showIncludes /FC @obj\third_party\angle\src\tests\egl_tests\angle_end2end_tests.EGLPresentPathD3D11Test.obj.rsp /c ..\..\third_party\angle\src\tests\egl_tests\EGLPresentPathD3D11Test.cpp /Foobj\third_party\angle\src\tests\egl_tests\angle_end2end_tests.EGLPresentPathD3D11Test.obj /Fdobj\gpu\angle_end2end_tests.cc.pdb In file included from ..\..\third_party\angle\src\tests\egl_tests\EGLPresentPathD3D11Test.cpp:7: In file included from ..\..\third_party\angle\src\tests\test_utils/ANGLETest.h:13: ..\..\testing\gtest\include\gtest/gtest.h(1392,16) : error: comparison of integers of different signs: 'const int' and 'const unsigned int' [-Werror,-Wsign-compare] if (expected == actual) { ~~~~~~~~ ^ ~~~~~~ ..\..\testing\gtest\include\gtest/gtest.h(1422,12) : note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<int, unsigned int>' requested here return CmpHelperEQ(expected_expression, actual_expression, expected, ^ ..\..\third_party\angle\src\tests\egl_tests\EGLPresentPathD3D11Test.cpp(281,9) : note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<int, unsigned int>' requested here ASSERT_EQ(mWindowWidth * 4, mappedSubresource.RowPitch); ^ ..\..\testing\gtest\include\gtest/gtest.h(1960,32) : note: expanded from macro 'ASSERT_EQ' # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) ^ ..\..\testing\gtest\include\gtest/gtest.h(1943,67) : note: expanded from macro 'GTEST_ASSERT_EQ' EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \ ^ BUG=angleproject:1219 This reverts commit 6b3c1db5170450bbc4946d8f18ba0d8619da43a0. Change-Id: Ia67ab82dd13295dc03235d57fa417c73f20a49e6 Reviewed-on: https://chromium-review.googlesource.com/326680 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Austin Kinross 6b3c1db5 2015-12-18T14:01:46 Implement EGL_experimental_present_path_angle This allows ANGLE to render directly onto a D3D swapchain in the correct orientation when using the D3D11 renderer. The trick is to add an extra uniform to each shader which takes either the value +1.0 or -1.0. When rendering to a texture, ANGLE sets this value to -1.0. When rendering to the default framebuffer, ANGLE sets this value to +1.0. ANGLE multiplies vertex positions by this value in the VS to invert rendering when appropriate. It also corrects other state (e.g. viewport/scissor rect) and shader built-in values (e.g. gl_FragCoord). This saves a substantial amount of GPU time and lowers power consumption. For example, the old method (where ANGLE renders all content onto an offscreen texture, and then copies/inverts this onto the swapchain at eglSwapBuffers() time) uses about 20% of the GPU each frame on a Lumia 630. Verification: + dEQP GL ES2 tests pass when "present path fast" is enabled + all ANGLE_end2end_tests pass when "present path fast" is enabled BUG=angleproject:1219 Change-Id: Ib6eeea46bafa6ebce4adada0ae9db3a433b8fc4c Reviewed-on: https://chromium-review.googlesource.com/321360 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tryjob-Request: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Geoff Lang 00140f4a 2016-02-03T18:47:33 Revert "Pass texture base level to shaders on D3D11" This reverts commit 3026829e155bd89b5ca5b7b7c5267699b9192557. Change-Id: I0b4c3f5b1453b993b149423bb1ce407f4918cf54 Reviewed-on: https://chromium-review.googlesource.com/325435 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 3026829e 2016-01-15T16:40:00 Pass texture base level to shaders on D3D11 The base level is passed to shaders in a uniform block created specifically for passing sampler metadata. This is done on feature levels above 9_3, which treat samplers as indices to sampler arrays in shaders. BUG=angleproject:596 TEST=angle_end2end_tests Change-Id: I846f2fc195ab1fd884052824ffd3c1d65083c0fb Reviewed-on: https://chromium-review.googlesource.com/322122 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 9b4e8626 2015-12-22T15:53:22 Redesign samplers in shaders on D3D11 Translation of samplers to HLSL on D3D11 is changed as follows: Instead of passing around HLSL sampler and HLSL texture references in shaders, all references to ESSL samplers are converted to constant indices within the shader body. Each ESSL sampler is identified by an unique index. In the code generated to implement ESSL texture functions, these indices are used to index arrays of HLSL samplers and HLSL textures to get the sampler and texture to use. HLSL textures and samplers are grouped into arrays by their types. Each unique combination of a HLSL texture type + HLSL sampler type gets its own array. To convert a unique sampler index to an index to one of these arrays, a constant offset is applied. In the most common case of a 2D texture and a regular (non-comparison) sampler, the index offset is always zero and is omitted. The end goal of this refactoring is to make adding extra metadata for samplers easier. The unique sampler index can be used in follow-up changes to index an array of metadata passed in uniforms, which can contain such things as the base level of the texture. This does not solve the issues with samplers in structs. The interface from the point of view of libANGLE is still exactly the same, the only thing that changes is how samplers are handled inside the shader. On feature level 9_3, the D3D compiler has a bug where it can report that the maximum sampler index is exceeded when in fact it is not. This can happen when an array of samplers is declared in the shader. Because of this the new approach can't be used on D3D11 feature level 9_3, but it will continue using the old approach instead. BUG=angleproject:1261 TEST=angle_end2end_tests, dEQP-GLES3.functional.shaders.texture_functions.* (no regressions) dEQP-GLES3.functional.texture.units.* (no regressions) Change-Id: I5fbb0c4280000202dc2795a628b56bd8194ef96f Reviewed-on: https://chromium-review.googlesource.com/320571 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 6c9b2ae9 2015-12-08T13:43:11 Revert "D3D11: Use clamp wrap mode for Integer textures." dEQP-GLES3 texture failures: http://build.chromium.org/p/chromium.gpu.fyi/builders/Win7%20Release%20dEQP%20%28NVIDIA%29/builds/4510/steps/angle_deqp_gles3_tests/logs/stdio dEQP-GLES3.functional.shaders.texture_functions.texture.isampler* dEQP-GLES3.functional.shaders.texture_functions.texture.usampler* BUG=angleproject:1244 This reverts commit 7a6a1ffeb275a8b565701305c8b42857ff2bf0b0. Change-Id: I0e25e7aed0e0d78015d5b8f5a7b9a81e0a5fca4e Reviewed-on: https://chromium-review.googlesource.com/316641 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 8c46ab11 2015-12-07T16:39:19 OutputHLSL: Avoid using info sink stack as much as possible. Due to how the traversers work, it might not be trivial to avoid the info sink stack entirely, but minimize its use to keep the code as functional as possible. BUG=angleproject:958 Change-Id: I354313f10f496feea7c6a6f167b0617aeadbe5b0 Reviewed-on: https://chromium-review.googlesource.com/316412 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 7a6a1ffe 2015-12-07T16:32:58 D3D11: Use clamp wrap mode for Integer textures. Until we can support all wrap modes for int textures, use a correct clamping scheme. This fixes several dEQP GLES3 FBO tests. This shuffles some of the tests in functional.texture.units since it hard-codes a different behaviour for all wrap modes, ignoring the sampler setting. BUG=angleproject:1244 TEST=dEQP-GLES3.functional.texture.* Change-Id: Ic7e89a111728dfb18821534996bf5b9a5ad172b6 Reviewed-on: https://chromium-review.googlesource.com/313997 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 8d9f35f1 2015-11-24T16:10:20 Re-land "D3D11: Fix Integer Texture Cube mip mapping." We were missing both the correct SRV parameter, as well as the full computation of the mip level in the HLSL. Re-land makes the mip computation only happen with implicit sampling. Before it would confuse the LOD0 computation. BUG=angleproject:1208 TEST=dEQP-GLES3.functional.texture.* Change-Id: I4b579033afe5cd1aca1f2d017e48a74c7fc324cc Reviewed-on: https://chromium-review.googlesource.com/314330 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill ee322723 2015-11-24T20:42:48 Revert "D3D11: Fix Integer Texture Cube mip mapping." 2 tests failed: dEQP_GLES3.Default/functional_shaders_texture_functions_texture_isamplercube_vertex (c:\b\build\slave\gpu_win_builder\build\src\third_party\angle\src\tests\deqp_support\angle_deqp_gtest.cpp:234) dEQP_GLES3.Default/functional_shaders_texture_functions_texture_usamplercube_vertex (c:\b\build\slave\gpu_win_builder\build\src\third_party\angle\src\tests\deqp_support\angle_deqp_gtest.cpp:234) BUG=angleproject:1208 This reverts commit 5778557fe99e300f245a7bfc2200f6b0179e3fbf. Change-Id: I6f7441bdbfbf937680b0d572645edee8ece649a1 Reviewed-on: https://chromium-review.googlesource.com/314301 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 5778557f 2015-11-23T09:37:44 D3D11: Fix Integer Texture Cube mip mapping. We were missing both the correct SRV parameter, as well as the full computation of the mip level in the HLSL. BUG=angleproject:1208 Change-Id: I345b1e0895495654de3863c4ebcc395d9b7371b9 Reviewed-on: https://chromium-review.googlesource.com/312060 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho e8e4debc 2015-11-18T17:15:38 Fix invalid generated sampling functions in HLSL output In some generated shaders, "levels" would be read before it is assigned by GetDimensions when clamping mip level to valid range. Fix these cases. BUG=angleproject:1092 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (12 tests start passing) Change-Id: I9fce8d378606738e5172673d222bce7968e26789 Reviewed-on: https://chromium-review.googlesource.com/312022 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 18b9deb4 2015-11-05T12:14:50 Support writing initializers using HLSL literal syntax Instead of using constructor functions to initialize variables, it is better to use literal initializer syntax provided by HLSL when it is possible. This way shader complexity is reduced and constant array initialization doesn't have to go through as many AST transformations. Before this patch, vec4 initialization would result in the following kind of HLSL: float4 f = float4(1.0, 2.0, 3.0, 4.0); After this patch, it will be: float4 f = {1.0, 2.0, 3.0, 4.0}; Before this patch, vec2 array initialization would result in the following kind of HLSL: float2 f[2] = {0, 0, 0, 0}; angle_construct_into_2_float2(f, float2(1.0, 2.0), float2(3.0, 4.0)); After this patch, it will be: float2 f[2] = {1.0, 2.0, 3.0, 4.0}; BUG=angleproject:1094 BUG=541551 TEST=WebGL conformance tests Change-Id: I9816a8d95a2cba3964922f6b561862d478da6145 Reviewed-on: https://chromium-review.googlesource.com/311160 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b1edc4f5 2015-11-02T17:20:03 Accept const array initialization in shader parsing Array constructors are not folded, unlike all other constant expressions. Change initializer parsing path so that it accepts constant initializers whether they are folded or not. Some parts need to be adapted to work with expressions that are qualified as constant but that are not necessarily folded: 1. Identifier parsing 2. Indexing parsing 3. Field selection parsing 4. HLSL output for variable declarations 5. Determining unary operator result type 6. Determining binary operator result type 7. Determining built-in function call result type 8. Determining ternary operator result type Corner cases that are not supported yet: 1. Using array constructors inside case labels 2. Using array constructors inside array size expressions 3. Detecting when a negative constant expression containing an array constructor is used to index an array In these cases being able to constant fold the expression is essential to validating that the code is correct, so they require a more sophisticated solution. For now we keep the old code that rejects the shader if ANGLE hasn't been able to constant fold the case label or array size. In case of indexing an array with a negative constant expression containing an array constructor, ANGLE will simply treat it as a non-constant expression. BUG=541551 BUG=angleproject:1094 TEST=dEQP-GLES3.functional.shaders.constant_expressions.* (all pass), angle_unittests Change-Id: I0cbc47afd1651a4dece3d68acf7ec72a01fdf047 Reviewed-on: https://chromium-review.googlesource.com/310231 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Kimmo Kinnunen 5f0246ca 2015-07-22T10:30:35 Implement gl_FragDepth for GLES SL 3.0 Makes it an error to access gl_FragDepthEXT in #version 300 es shader. TODO: Lacks the feature to make "#extension GL_EXT_frag_depth : require" an error for #version 300 es. Reland of: https://chromium-review.googlesource.com/#/c/287570 BUG=angleproject:1102 TEST=angle_unittest Change-Id: I064d918d65f37539cb1e14f12173ca5591a4ea3f Reviewed-on: https://chromium-review.googlesource.com/301711 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Corentin Wallez 477b243b 2015-08-31T10:41:16 Change the FLATTEN heuristic to "ifs with a loop with a gradient" This heuristic makes more sense than the previous "ifs with a discontinuous loop" as the reason we need to flatten is that we need gradients to be in branchless code. Change the UnrollFlatten test accordingly. Tested with: - the WebGL CTS - dev.miaumiau.cat/rayTracer "Skull Demo" - THe turbulenz engine GPU particle demo - Lots of ShaderToy Samples (inc. Volcanic, Metropolis and Hierarchical Voronoi) - Google Maps Earth mode - Lots of Chrome experiments - madebyevan.com/webgl-water BUG=524297 Change-Id: Iaa727036fffcfde3952716a1ef33b6ee0546b69d Reviewed-on: https://chromium-review.googlesource.com/296442 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 59f9a641 2015-08-06T20:38:26 Remove EOpInternalFunctionCall It's cleaner to mark internal functions by using the TName class, similarly to TIntermSymbol. TEST=angle_unittests BUG=angleproject:1116 Change-Id: I12a03a3dea42b3fc571fa25a1b11d0161f24de72 Reviewed-on: https://chromium-review.googlesource.com/291621 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f5cfc8df 2015-08-06T16:36:39 Track whether a name is internal to ANGLE in a separate class The AST contains identifiers in a few different places: besides symbols, there are also function names, which show up in function signatures and function calls. Any of these can be coming either from the original shader or from inside ANGLE. A class that encapsulates a string and its internalness will be useful for implementing a unified way of handling all names in shader translation. Start implementing this by splitting the functionality out of TSymbol. TEST=angle_unittests BUG=angleproject:1116 Change-Id: I0a1b5936dcccd0d5fc1c0c13c712102fbfff2a79 Reviewed-on: https://chromium-review.googlesource.com/291280 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Geoff Lang e2bfe2cd 2015-07-23T21:25:45 Revert "Implement gl_FragDepth for GLES SL 3.0" assertion failures in WebGL2 CTS. This reverts commit 544809610a131fe7040f2212789c62e212bbaf24. Change-Id: I2e0c7045c5b6ef9031a6e6c5916504fe68f51077 Reviewed-on: https://chromium-review.googlesource.com/287910 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 54480961 2015-07-22T10:30:35 Implement gl_FragDepth for GLES SL 3.0 Makes it an error to access gl_FragDepthEXT in #version 300 es shader. TODO: Lacks the feature to make "#extension GL_EXT_frag_depth : require" an error for #version 300 es. BUG=angleproject:1102 TEST=angle_unittest Change-Id: Ic313a0e1ed6369550d53885290f300fab1aaf304 Reviewed-on: https://chromium-review.googlesource.com/287570 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Alexis Hetu 07e57df7 2015-06-16T16:55:52 Added non square matrix construction Added new construction operations for non square matrices, along with the required changes to the related translation functions. Change-Id: I04ae7d4b2d1bb363b35d088cea45c0e7c4bc8a13 Reviewed-on: https://chromium-review.googlesource.com/277729 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Sam McNally 5a0edc62 2015-06-30T12:36:07 Change intializer list order to match field order. BUG=505304 Change-Id: I38149e72732f0b4eb7d398f90b5d11660e2a7fbc Reviewed-on: https://chromium-review.googlesource.com/282465 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 4785fec9 2015-05-18T16:09:37 Clean up most common extra semicolons and braces in HLSL output Clean up extra semicolons and braces from loops and conditional statements and extra braces from function definitions. This makes the HLSL output considerably easier to read. TEST=angle_unittests, angle_end2end_tests, dEQP-GLES3.functional.shaders.*, WebGL conformance tests BUG=angleproject:1013 Change-Id: I8180bab7b3d4bda1cdb8e4fb51cf9d8e384dd797 Reviewed-on: https://chromium-review.googlesource.com/273607 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 4d59f3c6 2015-05-28T17:33:53 Make false blocks produced by RewriteElseBlocks sequence nodes All child nodes of selection should be sequence nodes, so that they will output braces and extra braces can be removed from HLSL output. Also make RewriteElseBlocks to reuse common IntermTraverser functionality to simplify the code. TEST=WebGL conformance tests on D3D9 BUG=angleproject:1013 Change-Id: Iafdc05468b22d110abcd020cf52c646dd98fb4a0 Reviewed-on: https://chromium-review.googlesource.com/273608 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Arun Patole d94f6647 2015-05-18T16:25:12 Add ANGLE support for ESSL3 variant of mix() This change adds support for ESSL3 variant of built-in function mix() that takes last argument as a boolean vector. lerp() - HLSL equivalent of mix() doesn't look to be supporting a variant that takes last argument as a boolean vector so emulated it for HLSL. BUG=angleproject:1006 TESTS=dEQP tests Fixes "no matching overloaded function found " errors in below tests: dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.mix_*_b* (Note: These tests still fail because of constant expression issues) Change-Id: I79b353933cb450516b8678b1fdaeabe60417e9a7 Reviewed-on: https://chromium-review.googlesource.com/271751 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho fd3b9be6 2015-05-18T17:07:36 Set mUsesDiscardRewriting more conservatively This fixes a regression from recent refactoring of unfolding short-circuiting operators. mUsesDiscardRewriting used to be set based on detecting patterns that the AST traverser now overwrites before the code reaches OutputHLSL. With this patch mUsesDiscardRewriting is set more conservatively, which ensures that using discard works correctly also in case the input shader contains the same kind of pattern as the short-circuiting operator unfolding creates. TEST=WebGL conformance tests on D3D9 BUG=chromium:488552 Change-Id: Iea0103822a268079593b0913f0b6fc54c745c6e3 Reviewed-on: https://chromium-review.googlesource.com/271761 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d81ed841 2015-05-12T12:46:35 Defer executing if statements in the global scope Unfolding of short-circuiting operators (ternary and logical operators) may create if statements in the global scope, which is not valid HLSL. Use existing deferred global initialization function to defer execution of if statements in the global scope. TEST=WebGL conformance tests BUG=angleproject:819 Change-Id: I2b0afcc6824dab6bb87eb6abed609e75b1384dab Reviewed-on: https://chromium-review.googlesource.com/270461 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a6f22096 2015-05-08T18:31:10 Make UnfoldShortCircuit to change AST instead of writing output This is needed to make way for further AST transformations to handle array expressions that need to work correctly together with unfolding short- circuiting operators. This also improves the maintainability of HLSL output by isolating the unfolding into a separate compilation step. The new version of UnfoldShortCircuit traverser will traverse the tree until an expression that needs to be unfolded is encountered. It then unfolds it and gets reset. The traverser will be run repeatedly until no more operations to unfold are found. This helps with keeping the traverser's design relatively simple. All declarations are separated to single declarations before short-circuit unfolding is run. Previously OutputHLSL already output every declaration separately. BUG=angleproject:960 TEST=WebGL conformance tests, angle_unittests, angle_end2end_tests Change-Id: Id769be396adbd4c0223e418980dc464dd855f019 Reviewed-on: https://chromium-review.googlesource.com/270460 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 6ba6eadc 2015-05-04T14:21:21 Rename ConstantUnion to TConstantUnion. This clarified that we're using the Pool allocator/deallocator for this type. BUG=angleproject:993 Change-Id: If8c95f6054d07291e7014be0d4e35766ba2e943b Reviewed-on: https://chromium-review.googlesource.com/269131 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 2e295e23 2015-04-29T10:41:33 hlsl: Fix struct specifiers in uniforms. We would miss the definition for structs specfied in uniforms. Fix this by always checking to add the constructor. Fixes the WebGL test 'glsl/misc/struct-specifiers-in-uniforms'. BUG=angleproject:818 BUG=433412 Change-Id: I411e4a4477f7ef34fceb9faa77489f77d8efdce8 Reviewed-on: https://chromium-review.googlesource.com/267797 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez a1884f2b 2015-04-29T10:15:16 Fixes for the tagging of discontinuous loops The first fix was for all loops being considered discontinuous in OutputHLSL because of a typo that produced a tautology. The error was not detected by the unit tests because as an optimization we do not generate Lod0 calls when they are not needed for the callee function (which was correctly detected by the analysis in this case). Fixed the unit tests by adding a call to a builtin gradient operation. The second fix was for discard not being taken into account in the analyses of the AST, which caused a WebGL test regression after the first fix for conformance/glsl/bugs/conditional-discard-in-loop BUG=angleproject:982 Change-Id: I1315eac1ad36f726be52d7fda5facf3104341b1f Reviewed-on: https://chromium-review.googlesource.com/267814 Tested-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho d57e0db3 2015-04-24T15:05:08 Remove separate compilerdebug.h in favor of debug.h This unifies the behavior across the compiler and rest of ANGLE - for example, one can use #define ANGLE_TEST_CONFIG to disable UNIMPLEMENTED asserts in both the compiler and the rest of ANGLE. Compiler traces from asserts also go to the same TRACE_OUTPUT_FILE as other traces instead of being directed through ParseContext. The compiler build already includes the common sources, so no changes to build config are needed. The original version of this change was reverted due to release mode build issues. This version adds UNUSED_ASSERTION_VARIABLE where needed. TEST=angle_unittests, angle_end2end_tests, dEQP-GLES3.functional.shaders.* BUG=angleproject:983 Change-Id: I36929020a04251b8bc834fbb3c069e10128c3082 Reviewed-on: https://chromium-review.googlesource.com/267411 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill a656490d 2015-04-27T14:30:32 Revert "Remove separate compilerdebug.h in favor of debug.h" Causing compile warnings in Release: 1>compiler\translator\CallDAG.cpp(238): error C2220: warning treated as error - no 'object' file generated 1>compiler\translator\CallDAG.cpp(238): warning C4189: 'op' : local variable is initialized but not referenced 1>compiler\translator\IntermNode.cpp(1495): error C2220: warning treated as error - no 'object' file generated 1>compiler\translator\IntermNode.cpp(1495): warning C4189: 'replaced' : local variable is initialized but not referenced 1>compiler\translator\IntermNode.cpp(1517): warning C4189: 'replaced' : local variable is initialized but not referenced This reverts commit 5271025865b34685da71d0309131c5aff2e32f71. Change-Id: Icdf1c37eef22a13d083767609ab0b0285d3dc517 Reviewed-on: https://chromium-review.googlesource.com/267359 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 52710258 2015-04-24T15:05:08 Remove separate compilerdebug.h in favor of debug.h This unifies the behavior across the compiler and rest of ANGLE - for example, one can use #define ANGLE_TEST_CONFIG to disable UNIMPLEMENTED asserts in both the compiler and the rest of ANGLE. Compiler traces from asserts also go to the same TRACE_OUTPUT_FILE as other traces instead of being directed through ParseContext. The compiler build already includes the common sources, so no changes to build config are needed. TEST=angle_unittests, angle_end2end_tests, dEQP-GLES3.functional.shaders.* BUG=angleproject:983 Change-Id: Ifca4d16f667b1e5cf9c2e7cc4139940091917a1c Reviewed-on: https://chromium-review.googlesource.com/266993 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a8c414ba 2015-04-16T15:51:03 Add basic support for arrays as return values in HLSL output In HLSL output, user-defined functions that have an array as their return value get changed so that they have the array as an out parameter instead. Still missing: support for calling a function that has array as a return value without assigning the array. Also support for assignments inside complex expressions. TEST=dEQP-GLES3.functional.shaders.arrays.return.* BUG=angleproject:941 Change-Id: I79f5170139116a3dcfb2be2df5f0f79a3d955ca8 Reviewed-on: https://chromium-review.googlesource.com/266003 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 78174db7 2015-04-21T16:14:00 Replace EvqInternal with a separate flag to make it more flexible The internal flag disables decorating a given symbol in output, effectively placing it to a different namespace than user-defined symbols. This enables the compiler to insert symbols to the tree when transforming it to be suitable for HLSL output without running into name conflicts. In this patch the flag is separated from the qualifiers since sometimes different qualifiers need to be used with these internal symbols. TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests BUG=angleproject:941 Change-Id: I7036bed98fdb1478a383bb959ca03b42c3cb8100 Reviewed-on: https://chromium-review.googlesource.com/266690 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez 1239ee94 2015-03-19T14:38:02 Use the AST analyses to narrow the usage of [[loop]] and [[unroll]] These attributes are now used exactly in the loops and ifs that require them, limiting the number of failed compilations due to excessive unrolling and flattening. Also output Lod0 functions only when needed. Adds unit tests for LOOP, FLATTEN and Lod0 generation. The patch was tested against the WebGL CTS 1.0.4 for which all the failures existed prior to this patch and seem to be unrelated to this change. It also works correctly on the following sites that had trouble with [[loop]] and [[unroll]]: * dev.miaumiau.cat/rayTracer "Skull Demo" * The turbulenz engine particle demo * Lots of ShaderToy samples (including "Volcanic" and "Metropolis") * Google Maps Earth mode * Lots of Chrome Experiments * Lagoa * madebyevan.com/webgl-water * SketchFab * Unit Tests BUG=angleproject:937 BUG=395048 Change-Id: I856de9025f10b79781929ec212dbffc2064a940e Reviewed-on: https://chromium-review.googlesource.com/264791 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 938f0029 2015-04-08T19:35:40 Revert "Use the AST analyses to narrow the usage of [[loop]] and [[unroll]]" Caused linking failures on mac because the unit test asks for TranslatorHLSL which is not compiled. This reverts commit 3342e01f2a29343ea95961f0194f9d4f422cb840. Change-Id: I02b2f54ca5b90611f11b7a549e75bf2e8310639d Reviewed-on: https://chromium-review.googlesource.com/264790 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 3342e01f 2015-03-19T14:38:02 Use the AST analyses to narrow the usage of [[loop]] and [[unroll]] These attributes are now used exactly in the loops and ifs that require them, limiting the number of failed compilations due to excessive unrolling and flattening. Also output Lod0 functions only when needed. Adds unit tests for LOOP, FLATTEN and Lod0 generation. The patch was tested against the WebGL CTS 1.0.4 for which all the failures existed prior to this patch and seem to be unrelated to this change. It also works correctly on the following sites that had trouble with [[loop]] and [[unroll]]: * dev.miaumiau.cat/rayTracer "Skull Demo" * The turbulenz engine particle demo * Lots of ShaderToy samples (including "Volcanic" and "Metropolis") * Google Maps Earth mode * Lots of Chrome Experiments * Lagoa * madebyevan.com/webgl-water * SketchFab * Unit Tests BUG=angleproject:937 BUG=395048 Change-Id: If7baddae1cdae0b3a414aa49e5a4c4babedbfe50 Reviewed-on: https://chromium-review.googlesource.com/261263 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez f4eab3b9 2015-03-18T12:55:45 Implement gradient operation AST analysis This will allow narrowing down which usages of [[flatten]] and [[unroll]] are actually useful. BUG=angleproject:937 BUG=395048 Change-Id: Ib8d7b98431b8cd3563e1eff8ecc9ed5df1a9b7d6 Reviewed-on: https://chromium-review.googlesource.com/263775 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 9638c352 2015-04-01T14:34:52 Support assigning array constructors in HLSL output This adds support to the following type of shader code, where an array constructor is used as a source of assignment: float a[3]; a = float[3](0.0, 1.0, 2.0); The assignment gets replaced in the HLSL code by a function call where the array is an out parameter and the constructor parameters are regular parameters. Constructors cannot yet be used in initializers. With this change in place, some of the relevant dEQP tests start passing. TEST=dEQP-GLES3.functional.shaders.arrays.constructor.* BUG=angleproject:941 Change-Id: I13ed603c02a30d9f9950a61c4d562ae9fac058ec Reviewed-on: https://chromium-review.googlesource.com/263403 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f40319e9 2015-03-10T14:33:00 Add basic support for array constructors Add limited support for parsing array constructors and writing them out as GLSL code. Still missing from this version: HLSL output, array support in initializer lists, arrays with implicit size. BUG=angleproject:941 Change-Id: I7febf80923c4cd0b730399f1f49f9456cf3668e9 Reviewed-on: https://chromium-review.googlesource.com/260572 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez 711d8663 2015-04-02T19:43:57 Revert "Implement gradient operation AST analysis" This reverts commit 2fc57a2ace58b7ae3106344c56be94948f761b2a. Change-Id: I619297090c8441c1b90099437f8764263cdd68cc Reviewed-on: https://chromium-review.googlesource.com/263728 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 2fc57a2a 2015-03-18T12:55:45 Implement gradient operation AST analysis This will allow narrowing down which usages of [[flatten]] and [[unroll]] are actually useful. BUG=angleproject:937 BUG=395048 Change-Id: Ic31e434c7b5bb6c32eff2336e5949391bfee25a5 Reviewed-on: https://chromium-review.googlesource.com/260930 Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 1269076c 2015-03-31T12:55:28 Add basic support for assigning arrays in HLSL output Implement support for assignments where the return value of the assignment is not used in another part of the expression. TEST=WebGL conformance tests BUG=angleproject:960 Change-Id: Ibf9d71a75d27d139d2aabb5162ab04a0974321d3 Reviewed-on: https://chromium-review.googlesource.com/263222 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho fc7cfd1c 2015-03-31T14:46:18 Fix array function parameter syntax in HLSL equality function The fact that passing shaders to the platform compiler is deferred until linking is performed allowed this bug to pass undetected in earlier manual testing. TEST=WebGL conformance tests BUG=angleproject:941 Change-Id: Ic12b5d0c5547057551df90086453e897a161d559 Reviewed-on: https://chromium-review.googlesource.com/263221 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Nicolas Capens <capn@chromium.org>
Olli Etuaho ae37a5c8 2015-03-20T16:50:15 Support equality between structs containing arrays in HLSL output This requires sorting all equality functions together so that struct equality functions can have dependencies on array equality functions, but support for array equality functions that have dependencies on struct equality functions is also maintained. There's no automated test coverage for this specifically. The change was tested by manually inspecting shader output and ensuring that there were no test regressions in tests listed below. TEST=dEQP-GLES3.functional.shaders.* BUG=angleproject:954 Change-Id: If7199ab2446804afae50f103bb625101172882b9 Reviewed-on: https://chromium-review.googlesource.com/261550 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 7fb4955d 2015-03-18T17:27:44 Support array equality operator in HLSL output This requires adding functions to the shader source that can do the comparison for a specific array size. There's no automated test coverage specifically for this functionality, since all deqp tests that cover this also require array constructors to be supported. The change has been tested by manually inspecting shader output. No regressions were seen in automated tests listed below. TEST=dEQP-GLES3.functional.shaders.*, angle_unittests BUG=angleproject:941 Change-Id: Ie2ca7c016a3f0bcb3392a96d6d20d6f803d28bf0 Reviewed-on: https://chromium-review.googlesource.com/261530 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>