src/compiler/translator/OutputHLSL.cpp


Log

Author Commit Date CI Message
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>
Olli Etuaho e79904c3 2015-03-18T16:56:42 Accept equality and assignment for arrays in parsing This is enough to support the operations in GLSL output. HLSL output will likely require additional work to support this. BUG=angleproject:941 Change-Id: I728d511ab07af94bc3382dc2796c1e9ac79d1442 Reviewed-on: https://chromium-review.googlesource.com/260801 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Arun Patole 6341939f 2015-03-13T11:51:07 Fix code duplication in OutputHLSL While debugging, I came across the piece of code in OutputHLSL::OutputHLSL which is unnecessarily duplicated, this change just fixes it. Change-Id: I0549d58696417ccf651bacfa19f489b290d4ba6e Reviewed-on: https://chromium-review.googlesource.com/259960 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Arun Patole 44efa0b8 2015-03-04T17:11:05 Conditionally enable IEEE strictness for isnan() ANGLE's ESSL3 built-in function isnan() implementation just uses HLSL intrinsic function isnan(). For HLSL intrinsic function isnan() to work properly, IEEE strictness needs to be enabled for D3D compiler. This change detects use of isnan() in shaders and passes compiler flag D3DCOMPILE_IEEE_STRICTNESS whenever isnan is used in shaders. This change also moves existing workarounds in D3DWorkaroundType to D3DCompilerWorkarounds. BUG=angle:927 TEST= dEQP tests dEQP-GLES3.functional.shaders.builtin_functions.common.isnan.* Change-Id: I1ce5b1a7a825fdd720a37dc9aeb71320e55162d9 Reviewed-on: https://chromium-review.googlesource.com/255834 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho fc7fab72 2015-03-06T12:03:18 Fix matrix compound multiplication Matrix compound multiplication was lacking transposes. Add them so that results match normal multiplication. BUG=angleproject:938 TEST=dEQP-GLES3.functional.shaders.matrix.mul_assign.* Change-Id: I4c5159de0727afb4ee2831586f04fa817619de7a Reviewed-on: https://chromium-review.googlesource.com/256366 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 8efc5ad5 2015-03-03T17:21:10 Initialize BuiltInFunctionEmulator outside Compiler This moves GLSL output specific code from the Compiler class to the GLSL/ESSL translators. BUG=angleproject:865 Change-Id: I2d552e9cdb41f7d8ddfee7b0249a99d629a6d7d7 Reviewed-on: https://chromium-review.googlesource.com/255471 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 95cd3c68 2015-03-03T16:45:32 Move some output out of BuiltInFunctionEmulator subclasses This paves the way for getting rid of the BuiltInFunctionEmulator subclasses in favor of initializing the BuiltInFunctionEmulator dynamically in Compiler subclasses. The eventual goal is getting rid of GLSL output specific functionality in Compiler, which should be language-agnostic. BUG=angle:865 Change-Id: Ibb114b905785c7343b2726c97699268c982536a0 Reviewed-on: https://chromium-review.googlesource.com/255470 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Qingqing Deng 5dbece59 2015-02-27T20:35:38 Implement trunc, round, roundEven (Emulated roundEven) BUG=angle:934 Change-Id: If33256bf3707f3f0202147276c71f08c65518205 Reviewed-on: https://chromium-review.googlesource.com/254842 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 2cd7a0ed 2015-02-27T13:57:32 Remove switch fall-through on HLSL Remove fall-through from non-empty labels in switch statements. Tested with dEQP-GLES3.functional.shaders.*switch*. All pass except for tests that require dFdx/dFdy, which fail for an unrelated reason. Additional test coverage could still be useful for cases where a label is terminated by a continue or return statement. BUG=angle:921 Change-Id: I4741867789a9308d66d0adeabdaf83907106e2d2 Reviewed-on: https://chromium-review.googlesource.com/254550 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 05ae50dc 2015-02-20T10:16:47 Add basic support for HLSL output of switch and case This patch outputs switch and case statements in HLSL, but ignores fall-through. Switch statements that include fall-through cause the platform HLSL compiler to generate errors. BUG=angle:921 Change-Id: I10efbfb45076cf4fd79840698abafd8111e597d4 Reviewed-on: https://chromium-review.googlesource.com/251527 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Gregoire Payen de La Garanderie 5cc9ac85 2015-02-20T11:27:56 Fix shadow samplers with textureProj and vertex shaders. Fixes: dEQP-GLES3.functional.shaders.texture_functions.textureproj.sampler2dshadow_fragment dEQP-GLES3.functional.shaders.texture_functions.textureproj.sampler2dshadow_bias_fragment dEQP-GLES3.functional.shaders.texture_functions.textureprojoffset.sampler2dshadow_fragment dEQP-GLES3.functional.shaders.texture_functions.textureprojoffset.sampler2dshadow_bias_fragment and some of: dEQP-GLES3.functional.shaders.texture_functions.texture*.sampler2dshadow_vertex BUG=angle:925 Change-Id: I080e379ded95469f0486ae9c8bb1756842118a2d Reviewed-on: https://chromium-review.googlesource.com/251530 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 3c1dfb5a 2015-02-20T11:34:03 Add stubs for switch and case output BUG=angle:921 Change-Id: I58bd645a8d53ef5bad9b680e54c8948d50932fca Reviewed-on: https://chromium-review.googlesource.com/251525 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Daniel Bratell 29190088 2015-02-20T16:42:54 Make Angle code 40 KB smaller by using string literals directly. The implicit conversion of hundreds of string literals to TString generated a lot of machine code. By keeping them as string literals all the way the code will be smaller and faster. This is the change with clang for x64 (note VisitUnary in particular): Total change: -41392 bytes ========================== 2 added, totalling +469 bytes across 1 sources 2 removed, totalling -472 bytes across 1 sources 5 shrunk, for a net change of -41389 bytes (54126 bytes before, 12737 bytes after) across 1 sources 279692 unchanged, totalling 51433327 bytes ------------------------------------------------------------------------------------------------------------------------------------ -41392 - Source: /home/bratell/src/chromium/src/third_party/angle/src/compiler/translator/OutputHLSL.cpp - (gained 469, lost 41861) ------------------------------------------------------------------------------------------------------------------------------------ New symbols: +328: sh::OutputHLSL::outputConstructor(Visit, TType const&, char const*, TVector<TIntermNode*> const*) type=t, size=328 bytes +141: sh::OutputHLSL::outputTriplet(Visit, char const*, char const*, char const*) type=t, size=141 bytes Removed symbols: -133: sh::OutputHLSL::outputTriplet(Visit, std::basic_string<char, std::char_traits<char>, pool_allocator<char> > const&, std::basic_string<char, std::char_traits<char>, pool_allocator<char> > const&, std::basic_string<char, std::char_traits<char>, pool_allocator<char> > const&) type=t, size=133 bytes -339: sh::OutputHLSL::outputConstructor(Visit, TType const&, std::basic_string<char, std::char_traits<char>, pool_allocator<char> > const&, TVector<TIntermNode*> const*) type=t, size=339 bytes Shrunk symbols: -388: sh::OutputHLSL::writeEmulatedFunctionTriplet(Visit, char const*) type=t, (was 628 bytes, now 240 bytes) -714: sh::OutputHLSL::visitBranch(Visit, TIntermBranch*) type=t, (was 1017 bytes, now 303 bytes) -9738: sh::OutputHLSL::visitAggregate(Visit, TIntermAggregate*) type=t, (was 17609 bytes, now 7871 bytes) -14132: sh::OutputHLSL::visitBinary(Visit, TIntermBinary*) type=t, (was 17627 bytes, now 3495 bytes) -16417: sh::OutputHLSL::visitUnary(Visit, TIntermUnary*) type=t, (was 17245 bytes, now 828 bytes) Change-Id: Id0f87d72f6d7f1ab7b543f0d28d5a8b7c7db9ec7 Reviewed-on: https://chromium-review.googlesource.com/251090 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: bratell at Opera <bratell@opera.com>
Olli Etuaho b6e07a6a 2015-02-16T12:22:10 Implement ESSL3 modf This is the first built-in function that has an out parameter, so l-value checks are added for built-ins. BUG=angle:918 Change-Id: Ifd5befe955224f706f864e25107879c9cdce9e9f Reviewed-on: https://chromium-review.googlesource.com/250780 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Arun Patole 0c1726e6 2015-02-18T14:35:02 Implement isnan/isinf This change adds ANGLE support for isnan/isinf. BUG=angle:922 TEST=dEQP tests: dEQP-GLES3.functional.shaders.builtin_functions.common.isnan.* (high precision tests still fail) Tests passing 100% because of this change: dEQP-GLES3.functional.shaders.builtin_functions.common.isinf.* Reduced number of errors in tests: EQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.isnan.* dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.isinf_* Change-Id: I52bf18b59365ea7031746ae840550162d7e6b96e Reviewed-on: https://chromium-review.googlesource.com/250761 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Nicolas Capens <capn@chromium.org>
Olli Etuaho a3a5cc6a 2015-02-13T13:12:22 Expose the IntermNode tree generated in the compiler for testing This refactoring makes it possible for tests to access the IntermNode tree produced by compilation by calling compileTree(). Removing ParseContext usage from OutputHLSL has the additional benefit of better separation between parsing and output. BUG=angle:916 Change-Id: Ib40954832316328772a5c1dcbbe6b46b238e4e65 Reviewed-on: https://chromium-review.googlesource.com/249723 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ff805cc3 2015-02-13T10:59:34 Separate integer and float modulus Integer and float modulus are separated into Mod and IMod operator types to make the code clearer and to make GetOperatorString return the correct value for both. Change-Id: Ibfbca2c558bf919b0eab6404d7349f87fe47a18c Reviewed-on: https://chromium-review.googlesource.com/249692 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 55e79e09 2015-02-09T15:35:00 Implement equality ops for nested structs. This fixes the WebGL test glsl_misc_struct_equals as well as several dEQP tests in functional.shaders.struct. BUG=391957 BUG=angle:910 Change-Id: I09f3cd3f51bbc3541b64dbcfddfe01884ddba6f5 Reviewed-on: https://chromium-review.googlesource.com/247083 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Gregoire Payen de La Garanderie b3dced29 2015-01-12T14:54:55 Implementing gl_InstanceID in the HLSL compiler. Fixes: dEQP-GLES3.functional.instanced.draw_arrays_instanced.instance_id dEQP-GLES3.functional.instanced.draw_arrays_instanced.mixed dEQP-GLES3.functional.instanced.draw_elements_instanced.instance_id dEQP-GLES3.functional.instanced.draw_elements_instanced.mixed BUG=angle:601 Change-Id: I6e120eebc90d00e025fc58f096064e6ed1da826b Reviewed-on: https://chromium-review.googlesource.com/246911 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 37997145 2015-01-28T10:06:34 Defer dependent HLSL global var inits. Some global initializers depend on other globals, for instance a varying or attribute value. Since we use a static proxy variable for these varyings, we need to initialize the global static after we initialize the proxy in the shader preamble. This fixes a long- standing compiler bug. We should also add a WebGL test for this. BUG=angle:878 Change-Id: I71db103a6b8c24fb862e0d8b32293da9bc2e8103 Reviewed-on: https://chromium-review.googlesource.com/243581 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 32aab01d 2015-01-27T14:12:26 Use a stack for OutputHLSL info log output. Previously we would always reference mBody in several intermediate output methods. This made using these traversals from within the header, or for utility methods, very difficult. Instead, use a stack where we write to the top InfoLog, and can push/pop from the stack. This gives us more flexibility. BUG=angle:878 Change-Id: I8a6c0382bad18b44d75158274c701db13d4d4e65 Reviewed-on: https://chromium-review.googlesource.com/243580 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cooper Partin e6664f06 2015-01-09T16:22:24 Added PointSprites Support for renderers that do not support Geometry Shaders Change-Id: Iae9ac5f8fbba68dba5e49ccda7bb7eebb05c8e9a Reviewed-on: https://chromium-review.googlesource.com/240450 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 31b5fc62 2015-01-16T12:13:36 Add support for bitwise operations in ESSL3 Add support for <<, >>, &, |, ^, and their compound assignment variants <<=, >>=, &=, |=, ^=. Also add support for bitwise not (~). BUG=angle:870 Change-Id: I5e6a835409589556d5d58d58078fdf505cfd8da5 Reviewed-on: https://chromium-review.googlesource.com/241850 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 7700ff65 2015-01-15T12:16:29 Add basic support for ESSL3 vec2 (un)pack functions The functions are emulated on HLSL, and use the native functions on OpenGL 4.2+ and GLES3.0. Emulation for OpenGL versions <= 4.1 is not yet implemented. BUG=angle:865 Change-Id: I6803a1767dacdb3dca12f13924651fd38fcacb75 Reviewed-on: https://chromium-review.googlesource.com/240961 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho abf6dadd 2015-01-14T14:45:16 Implement matrix inverse built-in Inverse is emulated in HLSL by calculating the cofactor matrix and dividing that with the determinant. This results in the transpose of the inverse as is required. Better performing options might exist especially for 4x4 matrices, but this is enough for a working implementation. BUG=angle:859 Change-Id: I5185797cc1ed86865f5f4342707abdc2977a186b Reviewed-on: https://chromium-review.googlesource.com/240331 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 80a5a6c6 2015-01-12T15:35:27 Clean up BuiltInFunctionEmulator public interface This removes all language-specific bits from BuiltInFunctionEmulator parent class, and makes the public interface of BuiltInFunctionEmulator minimal. Writing comments around emulated function definitions is removed from OutputHLSL, they are not necessary as the emulated function definitions are just another part of the shader header. Change-Id: I9abf57d86f4e37b0674d7dfafe653298f205dd27 Reviewed-on: https://chromium-review.googlesource.com/240230 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho e39706d0 2014-12-30T16:40:36 Implement simple ESSL3 matrix functions Add support for built-in functions outerProduct, determinant, transpose and the variations of matrixCompMult that were previously unsupported. BUG=angle:859 Change-Id: Ie2b9cf83cd80c5a886c6d4eb190c7ce25a32d0a4 Reviewed-on: https://chromium-review.googlesource.com/239873 Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho e17e3197 2015-01-02T12:47:59 Use BuiltInFunctionEmulatorHLSL for all emulated functions Implementation of missing built-in functions is a separate concern from outputting the intermediate tree itself as HLSL, so it makes sense to have all of the built-in emulation in a class that is separate from OutputHLSL. Being able to reuse the same logic for different emulated functions also makes the code more compact. Change-Id: Id503dc3a5c5e743ec65722add56d6ba216a03a7f Reviewed-on: https://chromium-review.googlesource.com/239872 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 9e0478f6 2015-01-13T11:13:54 Move the block layout code to translator. This code is easily accessible from the translator, with the proper export calls. This facilitates adding a common static library, since this code calls some methods in translator. BUG=angle:773 Change-Id: I0c50098ec3f67c2df7749b3c2518be0a9fd939e2 Reviewed-on: https://chromium-review.googlesource.com/240093 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 5c9cd3d1 2014-12-18T13:04:25 Implement hyperbolic function support for ESSL 3.00 Emulating arc hyperbolic functions is required on HLSL, where they do not exist natively. For this, BuiltInFunctionEmulator is split into GLSL and HLSL subclasses. The GLSL subclass handles the pre-existing built-in emulation implemented for working around OSX bugs, and the HLSL subclass handles emulating asinh, acosh and atanh on HLSL. BUG=angle:855 Change-Id: I0dfeffb862ac27ba7f9ecf5492ec31d9d952b273 Reviewed-on: https://chromium-review.googlesource.com/236861 Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho e8d2c072 2015-01-08T16:33:54 Implement float-integer conversions for ESSL 3.00 The implementation uses asint, asuint and asfloat in the HLSL output. BUG=angle:865 Change-Id: I6b48298e18c7b3b0bdeac522b375ebc4eab7cf4e Reviewed-on: https://chromium-review.googlesource.com/239520 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Austin Kinross 4fd18b1b 2014-12-22T12:32:05 Emulate large and negative viewports on D3D11 Feature Level 9_3 Like D3D9, D3D11 Feature Level 9_3 doesn't support large or negative viewports. We have to emulate these in the vertex shader. BUG=angle:858 Change-Id: I2bd53e3921dc3590cc7193164d73596deafca9ea Reviewed-on: https://chromium-review.googlesource.com/236040 Tested-by: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Gregoire Payen de La Garanderie be954a23 2014-12-23T00:05:28 Implement support for the binary operator '%' in the translator. BUG=angle:854 Change-Id: If116de132dc83d93255749b54c1919a75abcb65c Reviewed-on: https://chromium-review.googlesource.com/236330 Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez 80bacde5 2014-11-10T12:07:37 Use the [[flatten]] attribute only when a loop is present. Flattening branch-heavy shaders that contained no loops caused regressions. As a temporary workaround we only flatten ifs when there exists a loop. BUG=395048 Change-Id: I95c40f0249643b98c62304a0f2a4563561d1fbbc Reviewed-on: https://chromium-review.googlesource.com/228722 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 76acee83 2014-11-04T13:44:03 Name mangle function prototypes and print them in interm output This patch changes function prototype handling so that they get assigned the same kind of a mangled name as function definitions and function calls. This name is now also printed in interm output so that function prototypes can be accurately identified in the interm output. BUG=angle:821 TEST=compiler_tests Change-Id: Ia150b8ac5b816b8096c964767cd8666bdee28539 Reviewed-on: https://chromium-review.googlesource.com/227390 Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Nicolas Capens 5e0c80ad 2014-10-10T10:11:54 Use attributes to avoid unrolling and flatten conditionals. [loop] and [flatten] help avoid unrolling make more shaders compile successfully. When unrolling has to happen, an error X3531 is generated so we have to try compiling again without these attributes. BUG=395048,395286 Change-Id: I91ea8ac3a822ab1f1ac24907d42326e3c6c9d9af Reviewed-on: https://chromium-review.googlesource.com/222810 Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Zhenyao Mo de1e00e1 2014-10-09T16:55:32 Implement support of unary operator "+" in translator. BUG=angle:779 TEST=conformance/glsl/misc/struct-unary-operators.html Change-Id: Ia827e07dcfc8ad3bbbc078e54336815be9027945 Reviewed-on: https://chromium-review.googlesource.com/222720 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Nicolas Capens fa41aa08 2014-10-06T17:40:13 Perform short-circuit unfolding on separate declarations. BUG=415694 Change-Id: I812abb21d2ab4af0b63631a23026d5860df61672 Reviewed-on: https://chromium-review.googlesource.com/221945 Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Nicolas Capens d974db43 2014-10-07T10:50:19 Split combined declarations into separate statements. BUG=415694 Change-Id: I7afb08a8a5ed10bbc6f7d23638daca6982f7c88b Reviewed-on: https://chromium-review.googlesource.com/221455 Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill 54ad4f81 2014-09-03T09:40:46 Use the CollectVariables path on the HLSL translator. This approach consolidates our two methods, and lets us reuse the same code for both methods of variable collection. BUG=angle:466 Change-Id: Ie92f76ff0b6d0d0dbfd211a234d0ab86290fa798 Reviewed-on: https://chromium-review.googlesource.com/213504 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 42bcf32e 2014-08-25T16:20:46 Refactor ShaderVariables to store fields in the base. Instead of only storing structure information in Varyings, Uniforms and Interface Block Fields, store it in the base class. Also only store base variable information for struct fields, instead of fully typed information. This works because stuff like interpolation type, invariance, and other properties are for the entire variable, not individual fields. Also add new fields for interface block instance name, varying invariance and structure name for all struct types. BUG=angle:466 Change-Id: If03fc071e6becb7aad6dea5093989bba7daee69e Reviewed-on: https://chromium-review.googlesource.com/213501 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 3b5c2dae 2014-08-19T15:23:32 Add a new invariant declaration operator. BUG=angle:711 Change-Id: I54a48b636a68c317b8d44ee2d578847b80095289 Reviewed-on: https://chromium-review.googlesource.com/213500 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 1c28e1f0 2014-08-04T11:37:54 Fix shaders with invariant keyword. We would trigger assertion failures in Debug mode, and fail to parse and translate correctly in Release. BUG=angle:711 Change-Id: Ibb7f33b288376617598578f48c7bbdbdec044279 Reviewed-on: https://chromium-review.googlesource.com/210822 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill a3fe2b4e 2014-07-18T10:33:13 Update non-default constructors in shadervars.h. Most of these constructors are unused. Remove the unused ones, and change the usage of existing constructors to be consistent. BUG=angle:466,697 Change-Id: I455dd314036e1dfcb8c4690bab577b81dd0e060c Reviewed-on: https://chromium-review.googlesource.com/208355 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 9fe25e9e 2014-07-18T10:33:08 Add a uniform register query to the translator. This returns the uniform index that we assigned for default uniforms. All the dependent structure offsets can be determined from the base register, so we won't have to store uniform information in the shader variable. BUG=angle:466 Change-Id: I0dd05251e8dba00c20d09fd865dfb150de56738e Reviewed-on: https://chromium-review.googlesource.com/207254 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Zhenyao Mo e40d1e9c 2014-07-16T17:40:36 Fix style violations. BUG=angle:650 TEST=no behavior change Change-Id: I3096615a181b1ec2c18ce60566c3d6249975b84e Reviewed-on: https://chromium-review.googlesource.com/208569 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 4e1fd412 2014-07-10T17:50:10 Store a map of interface block registers. The shader translator can return the assigned register for a block via a new API. This will let us delete the member variable in interface blocks for the register -- a nice thing for GLSL. BUG=angle:466 Change-Id: I9bc38e0cd031e32f90787be42c2324fc7c79dbf9 Reviewed-on: https://chromium-review.googlesource.com/206828 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 77f74853 2014-07-08T15:02:34 Add a GetVariableInfo helper method. This method replaces the similar logic in storing uniforms, varyings, and interface blocks when collecting variable info. We can also re-use this method for both GLSL and HLSL programs. BUG=angle:466 Change-Id: Ie6c13abe0f09f38b2f9b36e117caae4833eaccbf Reviewed-on: https://chromium-review.googlesource.com/206566 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 4cfb1e89 2014-07-07T12:49:23 Add a new TIntermRaw node type to translator. This raw node stores text strings that we directly copy to the output. This allows for more tricky substitutions that don't fit in to the HLSL/GLSL shared parsing model. BUG=346463 BUG=391697 Change-Id: Ibbde6db4fc98ef6d892f219631ca1a258a902a86 Reviewed-on: https://chromium-review.googlesource.com/206823 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill 183bde55 2014-07-02T15:31:19 Return shader variable information using GLenum values. Instead of duplicating GL header define values, explictly return GLenum for variable queries in the shader inspection API. This reduces the duplicate defines in the shader compiler header. BUG=angle:466 Change-Id: Iddaaff597b188251fa2e546f352bf77ab3ac43bc Reviewed-on: https://chromium-review.googlesource.com/205860 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill ce505553 2014-06-26T14:56:33 Revert "Return variable type queries using GLenum values." Breaks the FYI bots until we get Chromium patched. BUG=angle:466 This reverts commit 53221f5a0382887155d90f7f286e41190d4f5bfb. Change-Id: Ib28548df5c10a6f76f46e4cf8f2013dca5cf0ee2 Reviewed-on: https://chromium-review.googlesource.com/205850 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 53221f5a 2014-06-25T16:04:59 Return variable type queries using GLenum values. Instead of duplicating GL header define values, explictly return GLenum for variable queries in the shader inspection API. This reduces the duplicate defines in the shader compiler header. BUG=angle:466 Change-Id: If631b20ce68747297a946e1371def7709027a613 Reviewed-on: https://chromium-review.googlesource.com/204937 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill f2575989 2014-06-25T16:04:54 Use the sh namespace for shader variables. Since these types originate from the translator, use an appropriate namespace. Also rename some of the gl helper functions to be more specific to their functionality. BUG=angle:466 Change-Id: Idc29987b2053b3c40748dd46b581f3dbd8a6fd61 Reviewed-on: https://chromium-review.googlesource.com/204680 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill f91ce811 2014-06-13T10:04:34 Split OutputHLSL uniform code into new module. Refactoring patch only, should have no externally visible changes. BUG=angle:466 Change-Id: I01088a3b2979b96702d0a3c424d26928eb72b5b2 Reviewed-on: https://chromium-review.googlesource.com/203731 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 8daaba15 2014-06-13T10:04:33 Split OutputHLSL structure code into new module. Refactoring patch only. BUG=angle:466 Change-Id: I2c57096e1e24574e7de3d35d608645fde3b0c681 Reviewed-on: https://chromium-review.googlesource.com/203730 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Jamie Madill 033dae67 2014-06-18T12:56:28 Move OutputHLSL utility methods to other files. OutputHLSL was become a large, unweildy file. Some were also useful to other classes, even on the GL back-end, but were inacessible. Refactoring patch only. BUG=angle:466 Change-Id: Id216147122ca105c6ccdf0ba0c5f6c5038726965 Reviewed-on: https://chromium-review.googlesource.com/203459 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2bf8b372 2014-06-16T17:18:51 Fix link error when using varyings with "dx_". Varyings beginning with "dx_" would not get decorated properly, or at all, which could cause potential internal variables and certainly caused link errors. Fix this by no longer treating the "dx_" prefix differently. Also fix our naming of "dx_Position" to be consistent with our other internal types. BUG=angle:678 Change-Id: I03da0494a3d934d82ae7b3f8f12a576ff9bc3869 Reviewed-on: https://chromium-review.googlesource.com/203777 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens 2a59292d 2014-06-11T16:22:57 Implement support for constructing a 2x2 matrix from a vector. BUG=380353 Change-Id: Ica0b94104e39f87b4a3439df40221b1f682fd678 Reviewed-on: https://chromium-review.googlesource.com/203293 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>