src/compiler/translator/TranslatorVulkan.cpp


Log

Author Commit Date CI Message
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Austin Eng 7cf9cd24 2018-10-09T15:27:32 Add flags to shader translator to emulate gl_DrawID Adds support for translating gl_DrawID for implementation of GL_ANGLE_multi_draw. Currently the change only supports and allows emulation of the draw id using a uniform variable named `gl_DrawID`. This uniform is mapped in the translated shader to a hashed name that does not use the gl_ namespace Bug: chromium:890539 Change-Id: I08a246ca911e88e733ccdf22f1ed69dcae948e05 Reviewed-on: https://chromium-review.googlesource.com/c/1271957 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Olli Etuaho 6f591c97 2018-09-21T11:20:47 Clean up TCompiler members and style Some dead code and duplicate data are cleaned up from the compiler. Several parameters can be accessed directly from ShBuiltInResources instead of creating a copy in TCompiler. This also encapsulates some TCompiler member functions as private and changes the remaining unprefixed TCompiler member variable names to start with the m prefix. BUG=angleproject:2068 TEST=angle_unittests Change-Id: I6690aaf538b17e0f45460660272a21f82f1808a0 Reviewed-on: https://chromium-review.googlesource.com/c/1267503 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill b36a4816 2018-09-25T10:15:11 Vulkan: Add OpenGL line segment rasterization. Line rasterization rules are implemented using a shader patch. The patch does a small test and discards pixels that are outside of the OpenGL line region. The feature is disabled on Android until we can determine the root cause of the test failures. Bug: angleproject:2598 Change-Id: Ic76c5e40fa3ceff7643e735e66f5a9050240c80b Reviewed-on: https://chromium-review.googlesource.com/1120153 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 74c179bb 2018-09-24T10:53:23 Vulkan: Refresh descriptor sets on driver uniform change. In some state change scenarios the driver uniforms would be updated but not reapplied to the current state. Fix this by setting the descriptor sets dirty when we dirty the driver uniforms. Includes a test using gl_DepthRange. Also fixes a bug with the upcoming line segment rasterization emulation. Bug: angleproject:2598 Bug: angleproject:2845 Change-Id: Ia66f3c86f9770ceb145069eec879fd8725111a76 Reviewed-on: https://chromium-review.googlesource.com/1240413 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 8e9d2340 2018-09-10T13:29:37 Vulkan: Fix FragCoord scaling when a viewport is applied. We were using the pivot based on the viewport dimensions which is only valid if the viewport is the size of the framebuffer. The more correct pivot size is actually based on the Framebuffer height. Also updates the driver uniforms block to be a bit simpler. Bug: angleproject:2598 Change-Id: I1cb500cded7141d10e8db6862b6ed29758cc7fb4 Reviewed-on: https://chromium-review.googlesource.com/1214205 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Jamie Madill fb19e084 2018-09-06T15:39:09 Vulkan: Correct gl_FragCoord with default FBO. The viewport flipping we use would give incorrect values. Correct them using the same logic we do for gl_PointCoord. Also corrects the viewport scale driver uniform. It was not being updated after the draw framebuffer setting was adjusted. Also corrects the naming of the replaced builtin variables so it can't possibly conflict with a user variable. This was affecting the OpenGL line raster emulation. Bug: angleproject:2598 Change-Id: I843b5ac7b02160a5ec81a6f8ed2d937b0937198b Reviewed-on: https://chromium-review.googlesource.com/1208515 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 70a4ef10 2018-08-30T15:55:41 Vulkan: Fix depth range scaling. We were using a formula that didn't work for some of the clipping tests. Bug: angleproject:2601 Change-Id: I60d965c2701656ad590c3b250c2cc777fb432421 Reviewed-on: https://chromium-review.googlesource.com/1194919 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 1e1b731a 2018-08-28T13:27:23 Vulkan: Clean up point coord translation. Use - 0.5 instead of + -0.5 in FlipGLPointCoord. Bug: angleproject:2673 Change-Id: I819dcc45f9098ea64085eb71af8920fe99b67c62 Reviewed-on: https://chromium-review.googlesource.com/1194454 Reviewed-by: Tobin Ehlis <tobine@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Luc Ferron e835609c 2018-07-12T12:36:47 Vulkan: Implement gl_DepthRange support using driver uniform Bug: angleproject:2592 Change-Id: Iec3d111df4d8e5cef205c8afb177f0514ffac5c8 Reviewed-on: https://chromium-review.googlesource.com/1135448 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Luc Ferron 9ff9c773 2018-07-11T13:08:18 Vulkan: Add driver uniforms for point coords flipping This new driver uniform allows us to dynamically decide if we flip the y coordinate of the gl_PointCoord variable. We only flip the coordinate if we render downside-up, and otherwise we cancel the flipping since the y coordinate doesn't need modification anymore. This completes all end2end and deqp gles2 tests success when viewport flipping is enabled on Windows Nvidia. Bug: angleproject: 2673 Change-Id: I570e01ef4965933428375f6ebd8eac83ef16fbff Reviewed-on: https://chromium-review.googlesource.com/1133584 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill c0bb36cb 2018-07-10T11:10:31 Vulkan: Add driver uniforms to shader. Bug: angleproject:2717 Change-Id: I542f3b0f2de21857d7fea0267f07d2d0eec78a8c Reviewed-on: https://chromium-review.googlesource.com/1131567 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Luc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill ac1a377d 2018-06-26T15:05:38 Vulkan: Split tree ops into separate files. This makes the design consistent. Added new files for NameEmbeddedStructs and RewriteStructSamplers. Bug: angleproject:2665 Bug: angleproject:2494 Change-Id: If7d22a6ce9a86d51d38f68787006b7a28957861e Reviewed-on: https://chromium-review.googlesource.com/1108086 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill b779b12c 2018-06-20T11:46:43 Add kEmptyImmutableString. We can use this instead of ImmutableString(""). Bug: angleproject:2665 Change-Id: I8b3d5d3075838b9f2caa1627071202e48a5fdc83 Reviewed-on: https://chromium-review.googlesource.com/1108085 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Luc Ferron <lucferron@chromium.org>
Jamie Madill f54e93d6 2018-06-20T11:46:42 Vulkan: Implement nested sampler structs. Nested structs are handled similarly as to non-nested samplers in structs. They are extracted and named according to the same pattern. Also enables functional.shaders.random.all_features.fragment* The remaining work in the samplers-in-structs implementation is to translate function arguments. Bug: angleproject:2494 Bug: angleproject:2595 Change-Id: If8170feb71137d4036d352b2b0078518647d48a1 Reviewed-on: https://chromium-review.googlesource.com/1101569 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 10887984 2018-06-20T11:46:41 Vulkan: Sampler structs in arrays. Samplers are extracted from arrays of struct uniforms similarly as with non-arrays. They are named according to the variable name, array element and sampler field name. Nested structs to come later. Bug: angleproject:2494 Change-Id: Ie2f5f7bd1f747e73b3c6b505b2b1043cfe1073b5 Reviewed-on: https://chromium-review.googlesource.com/1101568 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill e033999e 2018-06-20T11:46:40 Vulkan: Add struct sampler parsing. Vulkan requires all uniforms to be declared in a block. Uniform blocks can't have store samplers. Thus we can't use structs in samplers with Vulkan GLSL. To work around this limitation we extract samplers from structs and move them into standalone types. The samplers are named according to the variable and struct fields. Arrays of structs and nested structs to come later. Bug: angleproject:2494 Change-Id: I83a94ab082c6ce7ee68ec1290751ecee18820683 Reviewed-on: https://chromium-review.googlesource.com/1101567 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 4da0d315 2018-06-20T11:46:38 Vulkan: Handle embedded struct uniforms. Also known as nameless structs. Uniform structs without a struct name would not be parsed correctly. This fixes the bug by adding a tree transformation. The transformation gives an internally scoped name to the embedded struct. Bug: angleproject:2665 Change-Id: I43e4dad7d9ad64a40e382066bb136e4f8f719797 Reviewed-on: https://chromium-review.googlesource.com/1101566 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 50cf2be0 2018-06-15T09:46:57 Reformat some style in touched files. This was triggered by running the code generation script. Bug: angleproject:2665 Change-Id: Id639c78eb618182ee1859678590cf0f559b572c2 Reviewed-on: https://chromium-review.googlesource.com/1101564 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Luc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Luc Ferron ad2ae93e 2018-06-11T15:31:17 Vulkan: Clamp the point size range to have a min value of 1.0 Bug: angleproject:2658 Change-Id: I32ff9aa27b064d9977eea0b83b18c52c4e42e38d Reviewed-on: https://chromium-review.googlesource.com/1096054 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Luc Ferron e18b8147 2018-06-07T11:53:19 Vulkan: Fix point coord management The gl_PointCoord.y coordinate needs to be flipped around the X axis in Vulkan to have correct results. Bug: angleproject:2457 Change-Id: I0d87ad28366623c2be0867c610cc35678a4af43f Reviewed-on: https://chromium-review.googlesource.com/1090824 Reviewed-by: Luc Ferron <lucferron@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Commit-Queue: Luc Ferron <lucferron@chromium.org>
Luc Ferron 3ec304db 2018-04-18T14:14:25 Vulkan: Support struct initializers in shaders Also adds a new test in GLSLTest to validate the initialization of a struct on the same line as its declaration. Bug: angleproject:2459 Change-Id: Ib37e20378f8ec76541db26392663bcba03390756 Reviewed-on: https://chromium-review.googlesource.com/1017340 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Luc Ferron d91c3793 2018-04-06T09:36:36 Vulkan: Implement support for structs in uniforms - Also enables 174 additional dEQP tests. Bug: angleproject:2446 Change-Id: I07cce46815d2f7a80fd48e7fd9407f7d528b397f Reviewed-on: https://chromium-review.googlesource.com/998406 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Luc Ferron <lucferron@chromium.org>
Luc Ferron 2371acad 2018-03-27T16:03:03 Vulkan: Support for uniform arrays - Enable dEQP tests for uniform arrays - Fix the shader translator to support arrays - Fix for finding the uniforms location - Support get/set of uniform array values Bug: angleproject:2416 Change-Id: I7d0e9c602840ffb915f8ea3ba5d832d03bd74985 Reviewed-on: https://chromium-review.googlesource.com/984599 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho c26214de 2018-03-16T10:43:11 Move AST utilities to a subdirectory Move AST related utilities to compiler/translator/tree_util. BUG=angleproject:2409 TEST=angle_unittests Change-Id: I7567c2f6f2710292029263257c7ac26e2a144ac8 Reviewed-on: https://chromium-review.googlesource.com/966032 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 0e82ae9c 2018-03-16T16:46:52 Vulkan: Implement depth range correction. This is done via inserting a statement at the end of the "main" of the vertex shader which scales and offsets gl_Position.z. Relevant sections of the Vulkan spec are 23.4. Coordinate Transformations and OpenGL spec "2.12.1 Controlling the Viewport". Bug: angleproject:2406 Change-Id: Ibf5403b3ad06a5114a7de3be0a406d696cbb7dea Reviewed-on: https://chromium-review.googlesource.com/964733 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho fbb1c792 2018-01-19T16:26:59 Store symbol names as a ImmutableString This will enable compile-time initialization of built-in symbols as well as reducing copying strings. Most of the code that deals with names is changed to use ImmutableString where it makes sense to avoid conversions. The lexer/parser now allocate const char pointers into pool memory instead of allocating TStrings. These are then converted to ImmutableString upon entering TParseContext. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: I244d6271ea1ecf7150d4f89dfa388a7745a1150c Reviewed-on: https://chromium-review.googlesource.com/881561 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 8b5e8fdb 2017-12-15T14:59:15 Replace remaining usage of TName with TSymbol TName used to contain just a subset of the information stored in TSymbol. It makes more sense to use TSymbol directly instead of converting it to TName. This also improves type safety a bit by making some functions only take in TVariable or TFunction instead of the more generic TName. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Icb46923c25d33ebbbbc06ddc487da25957dda771 Reviewed-on: https://chromium-review.googlesource.com/829143 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill de03e003 2017-10-21T14:04:20 Vulkan: Add shader handling for textures. BUG=angleproject:2167 Change-Id: I33940288331a23b940753795e5e43b8cabcb87f5 Reviewed-on: https://chromium-review.googlesource.com/732189 Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 89a69a03 2017-10-23T12:20:45 Generate performance warnings in HLSL translation Generate performance warnings for some code that undergoes heavy emulation when translated to HLSL: 1. Dynamic indexing of vectors and matrices. 2. Non-empty fall-through cases in switch/case. The warnings are generated only when code is translated to HLSL. Generating them in the parsing stage would add too much maintenance burden. Improves switch statement fall-through handling in cases where an empty fall-through case follows a non-empty one so that extra performance warnings are not generated. BUG=angleproject:1116 Change-Id: I7c85d78fe7c4f8e6042bda72ceaaf6e37dadfe6c Reviewed-on: https://chromium-review.googlesource.com/732986 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 76e471e9 2017-10-21T09:56:01 Vulkan: Implement basic uniforms. This implementation adds one descriptor set with two bindings: one for default vertex uniforms and the other for fragment. It adds two corresponding uniform buffers, and the logic for updating the descriptor sets bound to Vulkan. It doesn't handle much in the way of synchronization and dependency management, or uniform update. If there are only vertex or fragment uniforms the empty uniform buffer is omitted from the descriptor set. If both are missing, there is no descriptor set bound. Note that as our implementation progresses we might not be able to initialize our descriptor sets at link time, due to streaming in uniform data. BUG=angleproject:2167 Change-Id: I4ce4c3879ab454114df43bfac8d87ddf817fc045 Reviewed-on: https://chromium-review.googlesource.com/706340 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 6276b922 2017-09-25T02:35:57 Vulkan: Implement basic uniform shader parsing. This is a first step at implementing uniforms with descriptor sets. It does not actually bind uniforms and upload data, but it does implement uniform shader parsing. Uniforms are gathered into a single uniform block which is bound to set 0, with binding 0 for vertex uniforms and binding 1 for fragment uniforms. Also adds a ReplaceSubstring helper to string_utils. Also removes the precision writing from OutputVulkanGLSL since this was generating warnings with glslang. BUG=angleproject:2167 Change-Id: I9ec8351ec1973e583100f99292b0080ee968067b Reviewed-on: https://chromium-review.googlesource.com/699938 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Olli Etuaho a5e693af 2017-07-13T16:07:26 Make unique id counter a member of TSymbolTable This makes unique id counting thread-safe. BUG=angleproject:624 TEST=angle_unittests Change-Id: Ie0f2c7e574470b39750d37d2181c790bc874b275 Reviewed-on: https://chromium-review.googlesource.com/570419 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 5df2b9d2 2017-05-18T12:15:28 Clean up AddDefaultReturnStatements It doesn't need to use a traverser, since all function definitions can be found simply by iterating over the children of the root node. BUG=angleproject:2040 TEST=angle_end2end_tests Change-Id: I380942f90a0e73152f296b98d1fb027762d913b0 Reviewed-on: https://chromium-review.googlesource.com/508689 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill e794cd86 2017-01-13T17:29:51 Vulkan: Implement new GLSL translator back-end. The Vulkan GLSL translator back-end will handle validating and translating our WebGL/ESSL shaders into Vulkan-specific GLSL. glslang (the Vulkan one) accepts both GLSL and GLSL ES shaders as inputs, and both the desktop and ESSL back-ends give incompleteness warnings when used. For now, use the desktop GL 450 as a target for Vulkan GLSL. The Vulkan-specific changes are currently only to add locations to every vertex input and fragment output. BUG=angleproject:1575 Change-Id: I7c3f32f522e9d18e5f8618eb7927336bf4fbdcf2 Reviewed-on: https://chromium-review.googlesource.com/412266 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>