src/compiler/translator/tree_util/SpecializationConstant.h


Log

Author Commit Date CI Message
Shahbaz Youssefi 6f80f0f0 2022-08-06T02:29:19 Translator: Clean up the compile flag passing interface Historically, compile flags were sent to the translator as a bitmask. Recently, we were getting close to running out of bits. Additionally, direct-to-metal work had started to introduce constants to be passed to the translator, which were misplaced in ShBuiltInResources and Caps. Recent work on Pixel Local Storage adds even more constants, aggravating the situation. In this change, the interface to passing compile flags is reworked. A struct is passed (instead of a bitmask) that has one bit for each flag. This can be indefinitely extended. Additionally, the constants needed by metal and PLS are also placed in this struct. In turn, the backends can set these options directly, and don't have to hack them into Caps to further get hacked into ShBuiltInResources. Bug: angleproject:7559 Change-Id: If93f1e1b8818ad3a0ac708ab04ab93b4b397d114 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3812562 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Amirali Abdolrashidi 3b988fef 2022-06-01T10:54:03 Vulkan: Remove enableLineRasterEmulation * Removed the Bresenham line raster emulation specialization constant, along with related variables and functions. Bug: angleproject:7366 Change-Id: If17c8ce9b459ad801bae8e887e5674bd9a3ff2bf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3680860 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 23f213d1 2022-05-26T23:43:44 Vulkan: Make drawable size uniform As a specialization constant, it's impossible to predict the value the drawable size may take, which in turn makes it impossible to warm up the Vulkan pipeline cache at link time. Bug: angleproject:7366 Change-Id: Ia3d1860a4fcb8e3078fdcb8d02a2e0cd173ea028 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3671976 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 98c2e169 2022-05-20T16:17:49 Vulkan: Reduce pre-rotation spec const to bool The specialization constant now only dictates whether x and y should be swapped. The complete 8 possible states of rotation and y-flip are achieved by using this swap in combination with a driver uniform for x and y flip. Swapping is still a specialization constant to avoid degrading performance of dFdx/dFdy which otherwise would need both to be evaluated instead of one. On platforms which don't support pre-rotation, the specialization constant will never change and driver uniforms entirely govern y-flip. On platforms that do support pre-rotation, only two variations of the pipeline are needed. Bug: angleproject:7366 Change-Id: I73f84e89fa9349d2098fa5b21573aee57d93a30c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3663151 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 665ddccd 2021-12-09T23:06:39 Vulkan: Emulate dithering Dithering in OpenGL is vaguely defined, to the extent that no dithering is also a valid dithering algorithm. Dithering is enabled by default, but emulating it has a non-negligible cost. Similarly to some other GLES drivers, ANGLE enables dithering only on low-bit formats where visual banding is particularly common; namely RGBA4444, RGBA5551 and RGB565. Dithering is emulated in the fragment shader and is controlled by a spec constant. Every 2 bits of the spec constant correspond to one attachment, with the value indicating: - 00: No dithering - 01: Dither for RGBA4444 - 10: Dither for RGBA5551 - 11: Dither for RGB565 The translator appends code to the shader that, based on the format specified by the specialization constant, adds dithering to each color attachment output. A 2x2 Bayer matrix is used for dithering, indexed by gl_FragCoord.xy % 2. Bug: angleproject:6755 Change-Id: Ib45da5938e299b6626bff921119d63e7357dd353 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3374261 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 095d7c0a 2022-01-06T01:20:53 Translator: Clean up spec const / driver uniform types Bug: angleproject:6755 Change-Id: I8fb1557a5e29fcc28d5cb2f3aaa2c4a14b72583d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3369125 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 31641b8e 2021-06-05T02:17:47 Declare specialization constants in the AST A new qualifier (EvqSpecConst) is added so that specialization constants can be declared in tree. This enables TVariable references to specialization constants to be validated, which were in fact invalid as every reference declared a new variable. That is fixed. Bug: angleproject:4889 Change-Id: I1711e41cbc5a1260843d2d004d3568bdae11e963 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2941451 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kyle Piddington d7aa0130 2021-04-26T16:56:15 Upstream Apple's direct-to-Metal backend: compile translator. This change is meant to merge the translator changes from Apple's direct-to-Metal backend. Taken from Kyle Piddington's CL: https://chromium-review.googlesource.com/c/angle/angle/+/2857366/ The goal of this CL is to merge the translator code in a state that compiles, but not to switch the Metal backend over to use this translator backend yet. Bug: angleproject:5505 Change-Id: I68a6354604498cd5fd1eb96c13fc56f3b38f2bd0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897536 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Shahbaz Youssefi 58eabfd7 2021-04-08T23:57:04 Translator: Validate consistent variable references Some transformations change variable declarations. This validation ensures that all references to said variables are appropriately replaced as well. Bug: angleproject:2733 Change-Id: I6c2873968eeed4cba66e70069f84eb69a1f77074 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2818140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi b1deba2f 2021-01-28T16:06:51 Vulkan: Don't emit spec const declaration in compute shaders Bug: angleproject:5070 Change-Id: I74becfeac88b4a8ff66dd36670792082d0b941cd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2658882 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi dfd9bdfd 2021-01-16T11:32:30 Reland "Vulkan: Generate gl_Position pre-rotation in SPIR-V" This reverts commit 3d39b7c5eab88c420d982155ffbb6181c678ceea. Reason for revert: Fixed interaction with the `forceDriverUniformOverSpecConst` workaround. Original change's description: > Revert "Vulkan: Generate gl_Position pre-rotation in SPIR-V" > > This reverts commit 0f86b196ffaffeeee3460e3188f20a7ac120796d. > > Reason for revert: > Breaks pre-rotation for all apps, so they are displayed in portrait instead of landscape. > > Original change's description: > > Vulkan: Generate gl_Position pre-rotation in SPIR-V > > > > Instead of having the translator output pre-rotation code in the vertex > > stage based on a specialization constant, this change makes the SPIR-V > > transformer perform pre-rotation of gl_Position on the last geometry > > stage. > > > > An alternative solution would be to generate pre-rotation code in the > > translator in every geometry stage, each controlled by a separate > > specialization constant. This change avoids unnecessary modifications > > to earlier stages. The generated shaders are also smaller, as they > > don't contain a mat2[8] pre-rotation constant matrix. The SPIR-V > > transformer knows the pre-rotation at transformation time, so it can > > simply use swizzles to achieve the same results. > > > > This also ties in with upcoming changes which move gl_Position.z > > correction to the last geometry shader stage, which is trivially done > > piggy-backing on the infrastructure in this change. > > > > Bug: angleproject:5478 > > Change-Id: I9d5d9d19f3ccda665f5504368ce5ddfa5f383faf > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2598584 > > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > > Reviewed-by: Charlie Lao <cclao@google.com> > > Reviewed-by: Jamie Madill <jmadill@chromium.org> > > TBR=syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com > > Change-Id: I81f237fa6b10c7d59831363bee8999e7ad2f09be > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: angleproject:5478 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633694 > Reviewed-by: Tim Van Patten <timvp@google.com> > Commit-Queue: Tim Van Patten <timvp@google.com> TBR=timvp@google.com,syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com Bug: angleproject:5478 Change-Id: I7c5eaeef03d9520abd36a1c4a766b6abbf4fdb45 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633709 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 3d39b7c5 2021-01-16T00:15:14 Revert "Vulkan: Generate gl_Position pre-rotation in SPIR-V" This reverts commit 0f86b196ffaffeeee3460e3188f20a7ac120796d. Reason for revert: Breaks pre-rotation for all apps, so they are displayed in portrait instead of landscape. Original change's description: > Vulkan: Generate gl_Position pre-rotation in SPIR-V > > Instead of having the translator output pre-rotation code in the vertex > stage based on a specialization constant, this change makes the SPIR-V > transformer perform pre-rotation of gl_Position on the last geometry > stage. > > An alternative solution would be to generate pre-rotation code in the > translator in every geometry stage, each controlled by a separate > specialization constant. This change avoids unnecessary modifications > to earlier stages. The generated shaders are also smaller, as they > don't contain a mat2[8] pre-rotation constant matrix. The SPIR-V > transformer knows the pre-rotation at transformation time, so it can > simply use swizzles to achieve the same results. > > This also ties in with upcoming changes which move gl_Position.z > correction to the last geometry shader stage, which is trivially done > piggy-backing on the infrastructure in this change. > > Bug: angleproject:5478 > Change-Id: I9d5d9d19f3ccda665f5504368ce5ddfa5f383faf > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2598584 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Charlie Lao <cclao@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> TBR=syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com Change-Id: I81f237fa6b10c7d59831363bee8999e7ad2f09be No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:5478 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633694 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 0f86b196 2020-12-21T22:54:05 Vulkan: Generate gl_Position pre-rotation in SPIR-V Instead of having the translator output pre-rotation code in the vertex stage based on a specialization constant, this change makes the SPIR-V transformer perform pre-rotation of gl_Position on the last geometry stage. An alternative solution would be to generate pre-rotation code in the translator in every geometry stage, each controlled by a separate specialization constant. This change avoids unnecessary modifications to earlier stages. The generated shaders are also smaller, as they don't contain a mat2[8] pre-rotation constant matrix. The SPIR-V transformer knows the pre-rotation at transformation time, so it can simply use swizzles to achieve the same results. This also ties in with upcoming changes which move gl_Position.z correction to the last geometry shader stage, which is trivially done piggy-backing on the infrastructure in this change. Bug: angleproject:5478 Change-Id: I9d5d9d19f3ccda665f5504368ce5ddfa5f383faf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2598584 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao c75473c2 2020-11-23T14:26:32 Vulkan: Generalize FlipRotationSpecConst to SpecializationConstant Specialization constant are used not just for flip/rotation. It also used for other things. This CL merges all specialization constant usage (lineRasterEmulation, flip, rotation, halfRenderArea) into one class and rename FlipRotationSpecConst to SpecConst. Bug: b/173800146 Change-Id: I8dc3354b6caedbb183cec29855fc1c301ec8872a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2555812 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>