|   | c6390143 | 2022-10-12T09:57:55 |  | Vulkan: Make compatible with GCC
Resolves below warnings occurred with GCC build.
1) deperecated-copy
Overriding an assignment operator without a copy constructor
caused the deprecated-copy warnings.
2) unused-function
3) parenthesis
Warnings occurred due to missing parenthesis around
some logical expressions, add them to quiet the warnings.
4) unused variable
5) 'maybe-unused' attribute ignored
Introduces 'ANGLE_MAYBE_UNUSED_PRIVATE_FIELD' macro to avoid
'attribute ignored' warning which is only occurred
with GCC because GCC doesn't warn about 'unused non
static data member' whereas Clang has Wno-unused-private-field.
Signed-off-by: Sungyong Choi <sywow.choi@samsung.com>
Bug: angleproject:7764
Change-Id: I8e7410a5ed8cb9b8f8b3202073d779fea63d6b75
Reviewed-by: Jeff Vigil <j.vigil@samsung.com>
Reviewed-by: Mohan Maiya <m.maiya@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3963830
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | fa3d7d5c | 2022-08-05T00:57:40 |  | Make PLS coherent on Vulkan
Uses the VK_EXT_fragment_shader_interlock extension to make the shader
image implementation of PLS coherent on Vulkan.
This extension is supported on AMD, Apple, NVIDIA, and Intel.
Bug: angleproject:7279
Change-Id: Ic0253eb20932eb6be0b1f433ba454e48b57be2f5
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3813816
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Chris Dalton <chris@rive.app>
Reviewed-by: Geoff Lang <geofflang@chromium.org> | 
            
              |   | 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> | 
            
              |   | 7fe0694c | 2022-07-14T16:42:30 |  | Vulkan: Use push constants for driver uniforms
* Updated the driver uniforms so they would be defined as push
  constants in SPIR-V. Their data would be updated via
  pushConstants() when handling the driver uniform dirty bits.
* Updated TOutputVulkanGLSL to be able to generate the push
  constants as required.
* When handling the driver uniform dirty bits, we no longer
  allocate a buffer.
* Removed the driver uniform descriptor set from the pipeline
  layout.
* Removed the binding-related functions and flags for the driver
  uniforms.
  * In invalidateGraphicsDescriptorSet(), DIRTY_BIT_DESCRIPTOR_SETS
  is used instead of DIRTY_BIT_DRIVER_UNIFORMS_BINDING. (Same for
  invalidateComputeDescriptorSet())
  * DIRTY_BIT_DRIVER_UNIFORMS_BINDING is replaced with
  DIRTY_BIT_DRIVER_UNIFORMS in other places.
* Removed mDriverUniform and DriverUniformsDescriptorSet from
  ContextVk.
* Added mSupportedVulkanShaderStageMask to RendererVk, which is used
  in creating the pipeline layout and updating the push constants.
* Added a TODO note for driverUniformsDescriptorSetIndex.
Bug: angleproject:6858
Change-Id: I91037d378528962a816b12ff3f21249ee17b7652
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3782570
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | c554b92b | 2022-08-08T10:08:33 |  | Apply memory qualifier decorations in SPIR-V
Bug: angleproject:7279
Change-Id: I9390261aa572fe4b39152a6f7bdd2b100b34f616
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3818162
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 4f7d2d02 | 2022-07-12T11:55:19 |  | Vulkan: SPIR-V Gen: Apply Flat to gl_ViewID_OVR in FS
Follow up to
https://chromium-review.googlesource.com/c/angle/angle/+/3756612
Bug: angleproject:7491
Change-Id: I0a5fdfba6474cf22b3cfcd56f02d7418f4928981
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3758703
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | c525ccf7 | 2022-07-11T17:07:09 |  | Vulkan: SPIR-V Gen: Apply Flat to int inputs in FS
Not directly specified by the spec itself, but required according to
this more generic statement:
> Fragment shader inputs that are, or contain, integral types must be
> qualified with the interpolation qualifier flat.
This was previously fixed for gl_Layer in
https://chromium-review.googlesource.com/c/angle/angle/+/3652746, but
applies to gl_SampleID and gl_PrimitiveID as well.
Bug: angleproject:7491
Change-Id: Ideae78ba57fe927ad0aa39460a5940dd5313ce9d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3756612
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 91976352 | 2022-06-21T15:41:02 |  | Use C++17 attributes instead of custom macros
Bug: angleproject:6747
Change-Id: Iad6c7cd8a18d028e01da49b647c5d01af11e0522
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3718999
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 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> | 
            
              |   | 87ea0c7d | 2022-05-17T22:33:57 |  | Vulkan: SPIR-V Gen: Apply Flat to gl_Layer in FS
Not directly specified by the spec on gl_Layer itself, but required
according to this more generic statement:
> Fragment shader inputs that are, or contain, integral types must be
> qualified with the interpolation qualifier flat.
Bug: angleproject:7332
Change-Id: Ieaa389e9b1318d3f13147cba7949cff6491c4b61
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3652746
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Brandon Schade <b.schade@samsung.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 62fe36d3 | 2022-05-04T22:46:52 |  | Vulkan: Emulate YUV built-ins
In this change, the rgb_2_yuv and yuv_2_rgb built-ins are emulated with
normal functions that perform matrix multiplication based on the given
conversion function.
Bug: angleproject:6818
Change-Id: I67adb029109aaf6a674b1ee75105c1b352325eb2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3630599
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | cd3c74af | 2022-03-30T11:48:41 |  | SPIR-V Gen: Fix aliasing out parameters
In ANGLE, when an unindexed lvalue was passed as an out parameter to a
function, SPIR-V was generated such that the lvalue is passed in
directly.  A Skia test revealed a difference in SPIR-V and GLSL
semantics where aliasing out parameters are expected to work on local
copies until the end of the function.
Bug: b/226904235
Change-Id: I476af01eb7d065272825967111cd208faf88c275
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3561278
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 0f00fbae | 2022-01-21T00:28:48 |  | Translator: Make vec/matrix size getters unsigned
TType stored type's primary and secondary sizes as `unsigned char`, but
the getters returned `int`.  This caused unnecessary casts when the size
was passed from one TType to another, as well as comparisons with other
unsigned numbers.
This change specifies the type of these members as `uint8_t` and makes
the getters return the same type.  The call sites are accordingly
adjusted to remove unnecessary casts, use the correct type in local
variables, and add casts when passed to ostream::operator<<.
Bug: angleproject:6755
Change-Id: Ia4d86bd4ccb5c1a2ae1e10a0085a5166c3a6bcf7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3402850
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 7d33e71a | 2021-11-15T11:20:25 |  | Vulkan: SPIR-V Gen: Don't generate names for constants
Multiple constant variables can have the same value, and they are
coalesced to the same SPIR-V id.  It's not useful to attempt to generate
multiple constants with different names, especially as those names don't
make it into the SPIR-V-Cross-generated GLSL.  Additionally, most
constants in the translator don't retain their name, only the ones that
are not folded do (and which are folded is a rather arbitrary decision).
By generating names for these constants, the SPIR-V gen code was
introducing a bug where multiple OpNames could be generated for the
same OpConstant* id.  This change removes OpNames generated for
constants in the first place.
Bug: angleproject:6644
Change-Id: Ife2f4bee8e2eb095dc0b22994420ee1dfc6023c6
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3282425
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Cody Northrop <cnorthrop@google.com> | 
            
              |   | 5c914b57 | 2021-10-28T13:27:04 |  | Vulkan: SPIR-V Gen: Fix float+matrix
Found by a fuzzer, float+matrix was not handled correctly by the SPIR-V
output.
Bug: chromium:1264212
Change-Id: I09b13c3e48374621228f5fab4de68c33973ddfd4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3251585
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 066fb91b | 2021-10-18T15:31:27 |  | Vulkan: SPIR-V Gen: Handle scalar(const) produced by index clamp
Normally scalar(const) is folded into a constant.  The index clamp
transformation may produce such a code where the index looks dynamic at
first (for example `false ? uniform_value : constant`), but becomes
constant after folding.
This change makes SPIR-V generation robust in that case.  A potential
future change could avoid the clamp entirely by making FoldExpressions
adjust the op of the EOpIndexIndirect node whose index is being replaced
with a constant with EOpIndexDirect (and apply the clamp on the
argument).
Bug: chromium:1260651
Change-Id: I552b7527d821d1cb52e0e53212cc481285674861
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3226311
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 7f87a326 | 2021-10-18T13:06:29 |  | Vulkan: SPIR-V Gen: Fix crash in array of struct constant
Bug: chromium:1260690
Change-Id: I51fe85a2ebc23c3fcaa3c961c4ebf84688bbed31
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3226309
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 57b73c07 | 2021-10-14T15:51:18 |  | Vulkan: SPIR-V Gen: TODO clean up
This change removes a number of stale TODOs.
Bug: angleproject:4889
Change-Id: If21d55717e61383ffdd58a7f88da5961988e035f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223643
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | b3d77208 | 2021-10-14T15:38:51 |  | Vulkan: SPIR-V Gen: Make unfolded constants SPIR-V constants
If a constant is not folded by the translator, for example because it's
an array, this change makes sure that it becomes a constant in SPIR-V
anyway.  This is particularly important to support cases where a
constant is required, for example as argument to textureGatherOffsets().
Bug: angleproject:4889
Bug: angleproject:5362
Change-Id: Ic43e4be13a8917bb100ea64902ba90048cfbb9ee
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223642
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 9112b1a9 | 2021-09-13T15:39:53 |  | Vulkan: SPIR-V Gen: Fix precision of findMsb
In GLSL, findMsb operates on a highp operand, while returning a lowp
result.  In SPIR-V, RelaxedPrecision cannot be applied on the FindSMsb
instruction as that affects the operand as well.  This change makes sure
RelaxedPrecision is not applied to a FindSMsb instruction.
Bug: angleproject:4889
Bug: angleproject:6132
Change-Id: I6a0defbbd53ec703c7ecbad5cd5c79d215b11c32
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3158506
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | f3aea744 | 2021-08-25T22:09:58 |  | Vulkan: SPIR-V Gen: Fix precision of constructors
According to the spec, constructors don't have a precision (and thus
their precision is derived from the operands they are used in.
Bug: angleproject:4889
Bug: angleproject:6132
Change-Id: I557386764abf5493fbe59803dc8e260312c04b48
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3119352
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 798c5200 | 2021-07-31T22:17:48 |  | Translator: Make precise-ness a property of AST nodes
Instead of creating a "set of precise nodes", the nodes themselves are
marked precise.  This change is preparation for another change that
overhauls precision propagation through the nodes, and which would also
be storing the promoted precision in the nodes.
Bug: angleproject:4889
Change-Id: Ieec8864be5cd2e95ed6fb4d90b367946d9f33fa1
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3065569
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 1ce78397 | 2021-07-30T16:51:45 |  | Remove support for WEBGL_debug_shader_precision
This extension was rejected, and the implementation was hacky.  This
clean up is part of an ongoing work to improve precision handling.
Bug: angleproject:6059
Change-Id: If08581ec6f19cf1698ffa3dd6d248dc5e68a1d31
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3064303
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | aca9f2e2 | 2021-07-29T17:49:26 |  | Vulkan: SPIR-V Gen: Fix constructors with uniform parameters
When the constructor contains parameters from interface blocks, they may
have SPIR-V type specializations that was not previously accounted for.
The code is made more robust by retrieving the column/component types
when generating constructors through TTypes instead of modifying
SpirvTypes directly.
Bug was caught by the WebGL CTS.
Bug: angleproject:4889
Change-Id: I6c9df17a97fac8622dea55ed67c7bae1ce16d1bd
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061640
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 8fb5c2f2 | 2021-07-29T23:41:08 |  | Vulkan: SPIR-V Gen: Fix OpImage* on multisampled images
Lod should not be implicitly specified on multisampled images per spec.
This change fixes a crash on Intel/Mesa with the
TextureSampleShadingTest.Basic/ES3_1_Vulkan test.
Old spirv-val catches this bug, but ToT has regressed this:
    https://github.com/KhronosGroup/SPIRV-Tools/issues/4424
Bug: angleproject:4889
Change-Id: Ic2a661ce5264beb1f47f4e52706fe6556176628d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3062203
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | ebe943e2 | 2021-07-29T11:19:33 |  | Vulkan: SPIR-V Gen: Fix gl_Clip/CullDistance
These built-ins can be redeclared in the shader.  The translator took
these redeclarations (and gl_LastFragData) as UserDefined symbols.
There were a number of hacks such as in name generation and
CollectVariables, to special-case these redeclarations.
This change instead makes sure that these variables continue to be
considered built-ins with the appropriate qualifiers.  A number of fixes
are made accordingly:
- Hacks are removed.
- In fragment shaders, ANGLEClipDistance was initialized with
  gl_ClipDistance for further use by the shader.  The code generation
  however mistakenly produced `gl_ClipDistance[0] =
  ANGLEClipDistance[0];`, which caused compilation failures by glslang,
  but passed the tests accidentally because they expected link failures
  (see next item).
- CollectVariables is fixed to correctly collect gl_Clip/CullDistance
  in fragment shaders; previously they were collected as output
  varyings, and therefore the aforementioned link error was not produced
  in the tests after the compilation error was fixed.
Additional fixes:
- The transformation of gl_Clip/CullDistance was always ever done on one
  of them due to misplaced breaks in the loop that detected their
  presence.
- The transformation of gl_CullDistance was skipped when it was not
  redeclared.
Validation is added to make sure these built-ins always have the correct
qualifier even when redeclared.  SPIR-V gen support for these variables
have been fixed as well.
Bug: angleproject:4889
Change-Id: Ic8bf2c508357035cb937ef41a28ae22ffc533ebe
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3059921
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | a83c9108 | 2021-07-29T17:13:41 |  | Vulkan: SPIR-V Gen: Fix nested ternary operators
The OpPhi instruction used to implement ternaries referenced to the
blocks pregenerated for the true and false cases.  However, if there
were other code nested inside that could generate blocks (other
ternary expressions or short-circuits), that would be wrong.
Instead, the last block id is taken every time the true or false case is
entirely visited (similar to how it's done in the short-circuit
implementation).
Bug was caught by the WebGL CTS.
Bug: angleproject:4899
Change-Id: I71be86989dfe9596a13940ce657a7e67849e86bf
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061639
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 2b23aae4 | 2021-07-29T16:39:28 |  | Vulkan: SPIR-V Gen: Support vec(..., mat)
Matrices specified in vector constructor arguments were not correctly
handled w.r.t to casting (caught by the WebGL CTS).
Bug: angleproject:4889
Change-Id: I70253f049a651fc5f439b56d1e4d8f785813b605
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061638
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 3036e090 | 2021-07-29T15:55:39 |  | Vulkan: Direct SPIR-V Gen: Support the precise keyword
The precise keyword is different in GLSL in that it defines what
arithmetic operations _that have led to the value being assigned to a
variable_ should be done precisely (i.e. not "contracted").
A tree traverser is implemented that detects precise access chains and
applies precise-ness to the right hand side of assignment expressions to
said access chains.  This is only done if the shader uses the precise
keyword in the first place.  The algorithm for this is inspired by the
implementation in glslang.
This change additionally:
- Fixes parser to allow precise on function parameters
- Fixes GLSL code generation to output precise on struct members and
  function parameters.
Bug: angleproject:4889
Change-Id: Ie3808c3c8c08da308e88af20f5f90379d9d14d47
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3056369
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | dbe986d7 | 2021-07-26T01:43:44 |  | Vulkan: SPIR-V Gen: Fixes to tessellation shader support
- TCS barrier() built-in is correctly looked up
- Patch decorations are fixed
Bug: angleproject:4889
Change-Id: I1befcaca85a965c9d46b1b41ec74597de44bf2b2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052687
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 63fa7080 | 2021-07-25T23:19:02 |  | Vulkan: SPIR-V Gen: Fix bugs with ES3.1 texture* builtins
- Add missing ImageCubeArray capability for image cube arrays
- Remove extra Lod image operand for sampler/image buffers
Bug: angleproject:4889
Change-Id: I96545092528b7dcecf902561e194b17636217ef4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052683
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 715bab1f | 2021-07-25T23:35:17 |  | Vulkan: SPIR-V Gen: Fixes to geometry shader support
- max_vertices=0 is invalid in SPIR-V and is fixed (similarly to
  anglebug.com/5411)
- gl_PrimitiveID used in fragment shaders requires the Geometry
  capability.
Bug: angleproject:4889
Change-Id: If8c6a9d455d0582d61c3c52b5f773bcb5ca64b53
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052684
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | ff7eafb5 | 2021-07-25T23:05:26 |  | Vulkan: SPIR-V Gen: Fix .length() vs ssbo arrays
Bug: angleproject:4889
Change-Id: Ib490a46fabf058064fc1b18d2c084a4bc5f9277d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052682
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | b19fbbda | 2021-07-25T21:57:12 |  | Vulkan: SPIR-V Gen: Support multiview
Bug: angleproject:4889
Change-Id: Ibe66f53357473dbb4435af58775b524d83ed250b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052675
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 939ea5f4 | 2021-07-23T15:53:17 |  | Vulkan: SPIR-V Gen: Fixes to tessellation builtins
On TCS, TES and FS, gl_PrimitiveID is actually an input.  Additionally,
`patch` variables (including gl_TessLevel* built-ins) need to be
decorated with Patch.
Bug: angleproject:4889
Change-Id: I326ec4b0c011fe8eaafbad4f8bcb0f537005f96f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048320
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 9416e84e | 2021-07-23T14:53:43 |  | Vulkan: SPIR-V Gen: Add missing DepthReplacing execution mode
Shaders writing to gl_FragDepth need this execution mode specified.
Bug: angleproject:4889
Change-Id: I315c90f9161f4d3d51b1c856f1364fb26a4bd404
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048317
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | de8dc2c9 | 2021-07-23T15:45:28 |  | Vulkan: SPIR-V Gen: Support OES_sample_variables
Built-ins from this extension are now decorated.
Bug: angleproject:4889
Change-Id: I12f80d67e3595f94fc64bdc8cb3031d36b98c279
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048319
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 8bf2e5ec | 2021-07-23T16:54:16 |  | Vulkan: SPIR-V Gen: Fix switch with default at the end
A minor bug was making a switch with default at the end to jump to the
merge block instead of the default block.
Bug: angleproject:4889
Change-Id: Ied434fab949b10d45a0db1242c1b8535a5f4f773
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048321
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 82d7d888 | 2021-07-22T21:46:21 |  | Vulkan: SPIR-V Gen: Fix bugs with texture* builtins
With this change, deqp ES3 tests pass.
Bug: angleproject:4889
Change-Id: Ica158d4e9012c7bb3e458da62b4a7f92aee5c6de
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3047380
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 31bc9226 | 2021-07-23T15:16:27 |  | Vulkan: SPIR-V Gen: Fix unpack* built-ins
The parameter to these built-ins was getting extended to a vector.
Bug: angleproject:4889
Change-Id: Idddce008c9b4f6bf9205b1e20f6e89ef657ea3a1
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048318
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 6b5cec15 | 2021-07-22T17:01:41 |  | Vulkan: SPIR-V Gen: Fixes to scalar->vector promotion
With the ternary operator, the condition may be a bool-in-interface
block that needs to be cast.  This cast is now part of
createConstructorVectorFromScalar so it can't be missed.
Bug: angleproject:4889
Change-Id: I0e24cd4127301d33a3ac677ccaf560c4468e0799
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3047379
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | d0c03ff4 | 2021-07-22T14:55:51 |  | Vulkan: SPIR-V Gen: Fix lvalues passed to in/inout parameters
In GLSL, these values are semantically copied when passed to a function
as an in or inout parameter.  For example in:
    bool f(inout vec4 a, inout vec4 b)
    {
        a = vec4(0);
        return all(equal(a, b));
    }
    var = vec4(1);
    bool result = f(var, var);
result is expected to be false.  In SPIR-V, every parameter is
semantically passed by "reference".
glslang conservatively uses temporaries to pass to functions.  An
optimization in ANGLE didn't create temporaries for unindexed lvalues,
which did not take into account the above fact.  This optimization is
limited to out parameters now.
Bug: angleproject:4889
Change-Id: Ie1b4b1cecba847ba63d5810d01d0856823b89ddc
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046103
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | cc69d861 | 2021-07-22T12:49:39 |  | Vulkan: SPIR-V Gen: Fix textureProj's coordinate adjustment
The OpCompositeInsert's parameters were given in the wrong order.
Additionally, some instructions were not having RelaxedPrecision applied
correctly; this is fixed by deriving the decorations from the type of
the argument that's passed in a function instead of the type of the
parameter itself.
Bug: angleproject:4889
Change-Id: I34a54fcc0ef1699e554f9e1abb94c93a5b34b6d3
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046102
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 9d23ae62 | 2021-07-22T12:32:44 |  | Vulkan: SPIR-V Gen: Fix conditionals with pruned blocks
Rewored the visitIfElse function to simplify the logic and correctly
handle if-else constructs where the true block is pruned.
Bug: angleproject:4889
Change-Id: Ib968a2fe65f4b6463158fd76e7d67757115ee832
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046101
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 9f7a86a8 | 2021-07-21T14:54:03 |  | Vulkan: SPIR-V Gen: Fix bugs with matrix ops
A number of matrix operations are fixed in this change, such as
matrix/scalar, ++matrix etc.
This change fixes most of the failing dEQP-GLES2.* tests.  The test
suite will be enabled once the remaining 32 failures are fixed.
Bug: angleproject:4889
Change-Id: I0905dfaeabe50716432ce354b890be35f2a16e59
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3042555
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 951b04bb | 2021-07-21T12:20:13 |  | Vulkan: SPIR-V Gen: Support scalar constructors
In GLSL, the scalar constructor can be given a vector and matrix, in
which case the first element is selected.  This case was not previously
handled.
Bug: angleproject:4889
Change-Id: Ibf276883fc7396b750981a4e469ff9b152c6e700
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3042554
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 45d4641a | 2021-07-21T10:58:29 |  | Vulkan: SPIR-V Gen: Support tessellation shaders
Bug: angleproject:4889
Change-Id: I7370e037a82689260e27bfd5e72c5c8c982efa58
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041624
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 7f199d75 | 2021-07-20T00:11:23 |  | Vulkan: SPIR-V Gen: Support geometry shaders
Geometry shader built-ins are implemented.  A bug in
DeclarePerVertexBlocks is fixed w.r.t to gl_PerVertex arrays and a new
AST validation option is added to catch that sort of error.
Bug: angleproject:4889
Change-Id: I40b2929e450eac8ae840bbf1a1583e6c4c047c88
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041623
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 0e1c90cf | 2021-07-21T10:24:26 |  | Translator: Validate function parameter qualifiers
This change cleans up a confusion in EvqConst and EvqConstReadOnly,
where the former was frequently used instead of the latter for function
parameters.
The change makes the following renames to make the intent of the
relevant qualifiers clearer:
    EvqIn            -> EvqParamIn
    EvqOut           -> EvqParamOut
    EvqInOut         -> EvqParamInOut
    EvqConstReadOnly -> EvqParamConst
Bug: angleproject:4889
Change-Id: Idedd32c08a91de069b91b1657d6b783dddece04a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041622
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | e9decf0c | 2021-07-19T14:29:21 |  | Vulkan: SPIR-V Gen: Support framebuffer fetch
Bug: angleproject:4889
Change-Id: Ia75b45b5d0f6cb3b6ca8a8f8a987bb857e45ad33
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3040120
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | a8807cbf | 2021-07-17T00:00:27 |  | Vulkan: SPIR-V Gen: Support interpolateAt*
The interpolateAt* builtins take their first argument as a pointer, so
only the OpAccessChain result should be given to the corresponding
SPIR-V instruction.
A test is written in this change to handle interpolateAt* when given a
swizzled lvalue, which is not representable in SPIR-V.  This can be
supported by having the AST transform:
    interpolateAtX(value.zy)
to:
    interpolateAtX(value).zy
which can be done right when the function is parsed and the AST node for
it is created (by taking the swizzle out of the parameter and applying
it to the node).  However, swizzled lvalues as parameter to
interpolateAt* is only allowed in desktop GLSL, and so the test is
disabled.  From the GLSL ES3.2 spec:
> Component selection operators (e.g. .xy) may not be used when
> specifying interpolant.
Bug: angleproject:4889
Change-Id: I043969f22011e6171c7ae225ded3a5013e8cfa4e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3035588
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 32196d8f | 2021-07-16T14:49:08 |  | Vulkan: SPIR-V Gen: Support built-ins with out parameters
Some built-ins have out parameters; modf, frexp, uaddCarry, usubBorrow,
umulExtended and imulExtended.  In SPIR-V, they are translated as such:
- modf and frexp: Returns the same result as GLSL, with a pointer to
  store the output parameter.  Since SPIR-V cannot create pointers to
  swizzles, a temp variable is used in that case.
- uaddCarry, usubBorrow, umulExtended and imulExtended: These return a
  struct in SPIR-V, which contains the two output parameters; with lsb
  in field 0 and msb in field 1.
Bug: angleproject:4889
Change-Id: Ic5114f74b9c1013093007e91939f78d5218f2a07
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3036088
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | f4ce6d00 | 2021-07-15T11:07:25 |  | Vulkan: SPIR-V Gen: Support bool in interface blocks
SPIR-V doesn't allow bool in interface blocks.  Another type
specialization is added for this purpose, turning those bools to uint.
Bug: angleproject:4889
Change-Id: I803bffcf5ea58c913d4df6e7aae3386c67901b25
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3032021
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 9c6fb52c | 2021-07-13T14:10:41 |  | Vulkan: SPIR-V Gen: Assignment between mismatching SPIR-V types
In general, GLSL qualifiers translate to SPIR-V decorations on SPIR-V
variables.  In the case of blocks (struct or interface block),
OpMemberDecorate is used, which due to its specification in SPIR-V, can
only apply decorations to direct members of a block.  This makes it
impossible for example to decorate a nested member of a block through
its variable id.
As such, some decorations such as RowMajor and Invariant apply to
members of a block given its _type_ id.  Unfortunately SPIR-V requires
ArrayStride to also be applied to a type directly, rather than a member
of a block.  This implies that some types, such as structs used in
uniform/buffer interface block, or decorated with invariant or
row_major, as well as arrays (of any type) used inside and outside
interface blocks to produce different SPIR-V types from the same GLSL
type.  The SpirvTypeSpec data previously introduced specialize these
types.
It's necessary to "cast" between these types when needed.  The
translator handles casts at load/store boundary:
- Upon load, the value is cast to the type with the default
  SpirvTypeSpec.
- Upon store, the value is cast from the default to the store target
  SpirvTypeSpec.
- All intermediate results use the default SpirvTypeSpec.
Bug: angleproject:4889
Change-Id: I6fa28e518ec6b517ff163f44b6892859eb4b10fd
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3026145
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 5e579a18 | 2021-07-13T01:22:48 |  | Vulkan: SPIR-V Gen: Support row-major blocks
The SPIR-V type generation is refactored to contain all
type-differentiating properties in a specific struct that is passed
around.  The following can lead to different SPIR-V types generated from
the same GLSL type:
- Block storage for blocks
- Invariant for blocks
- Row-major for blocks with matrices
- Row-major for matrix arrays in blocks
- Bool when used inside an interface block (not yet implemented)
Previously, block storage and invariant were passed around.  Instead,
with this change the aggregate of all the above is passed around.  The
row-major specialization is added in this change.
This change also refactors the uniform/buffer block encoding to use the
existing encoders in blocklayout.h.
Bug: angleproject:4889
Change-Id: I3cfa8bd96bb380a1f1f05fbbd6b3eebd702c9e24
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3021670
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 07c39616 | 2021-07-08T17:01:31 |  | Vulkan: SPIR-V Gen: Enable GLSLTest*
This change includes an assortment of small fixes to enable most of
GLSLTest* end2end tests.
- User-defined std140 storage buffers were mistakenly turned to std430.
- External and WEBGL samplers were redundantly redeclaring the sampler2D
  type.
- `invariant` specified on a field of struct type didn't apply it to
  said struct's members.
- Arrays of struct as a member of an interface block didn't have their
  size aligned, producing incorrect stride
- Interpolation and auxiliary qualifiers are now generated
- Arrays of opaque uniforms are now correctly passed to functions when
  indexed.
- atan(x, y)'s built-in Op is fixed
- early_fragment_tests is now generated
Additionally, the SPIR-V transformer didn't handle the Invariant
decoration applied to gl_PerVertex built-ins, which is possible as a
result of:
    #pragma STDGL invariant(all)
This bug existed in the transformer due to two bugs:
- ANGLE didn't generate this line when generating GLSL to feed to
  glslang.  This is fixed by this change.
- glslang itself ignores this line:
  https://github.com/KhronosGroup/glslang/issues/2689
Bug: angleproject:4889
Change-Id: I15ad9fcc178abc1eae944e7a58f4e6153fa5dfd9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3016762
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | e2710f59 | 2021-07-06T17:29:08 |  | Vulkan: SPIR-V Gen: Fix image atomic built-ins
The `imageAtomic*` built-ins additionally include coordinate and
sample parameters that need to be fed to OpImageTexelPointer before the
atomic operation can be generated.
This change passes all *image*atomic* GLES31 deqp tests as well as:
    GLSLTest_ES31.ArraysOfArraysOfR32fImages/ES3_1_Vulkan_DirectSPIRVGen
Bug: angleproject:4889
Change-Id: I9ed729d09914cb01467d4de504de38c931a9196e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3011419
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 8d0eb08c | 2021-07-05T23:22:24 |  | Vulkan: SPIR-V Gen: Take advantage of OpConstantNull
As part of fixing GLSLTest*.MissingReturn* tests, refactoring is done
such that complex null values are declared concisely with
OpConstantNull.  The tests are fixed by making the SPIR-V generator
implicitly add a `return <null-value-of-correct-type>;` if the return
statement is missing from GLSL.
Bug: angleproject:4889
Change-Id: Iffd80c5e6ce66afcdbf3813bffade6928f292007
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3010578
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 81ed8d40 | 2021-07-02T00:54:25 |  | Vulkan: SPIR-V Gen: Support barrier* built-ins
This change enables the ComputeShaderTest suite and additionally
includes the following fixes:
- OpArrayLength was given the array type instead of variable.
- Struct arrays inside interface blocks were not decorated with
  ArrayStride.
Bug: angleproject:4889
Change-Id: Ibae95371bcea10e58c86b8fe1d1e172a18d56a09
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3001908
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | afdf378f | 2021-07-01T21:55:58 |  | Vulkan: SPIR-V Gen: Support == and != on complex types
In GLSL, == and != produce a bool.  In SPIR-V, there are only
component-wise comparison operations.  For ==, OpAll should be used to
reduce it to a single bool, and for !=, OpAny.  For matrices, the
comparison is done column by column with a similar reduction for each
column, and one for the final result.  For structs and arrays, the
comparison is similarly done field by field or element by element
respectively.
Bug: angleproject:4889
Change-Id: I8157c1931b7d1dedd74a3825967f5e212d346900
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3001905
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | cfaaf2ab | 2021-06-30T17:23:55 |  | Vulkan: SPIR-V Gen: Fixes to std430 block definition
Bug: angleproject:4889
Change-Id: I18feff0916f348c8514cc97ba438d42fc00d0cba
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2999023
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 3b0fcf6a | 2021-06-30T15:14:48 |  | Vulkan: SPIR-V Gen: Support type casts in constructors
GLSL basic, vector and matrix constructors can convert between types.
This was already done for constants used in constructors.  This change
implements the cast for non-constant expressions.
Bug: angleproject:4889
Change-Id: I0a8c1a6e97ffced0d1652032a41fb87c70be16ca
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2999022
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | 0461d8d4 | 2021-06-23T23:20:33 |  | Vulkan: SPIR-V Gen: texture and image built-ins
GLSL contains a large number of built-in texture* and image* functions,
but these map to only a handful of SPIR-V instructions.  The bulk of the
work to map these is to extract the arguments from the built-ins based
on their ordinal position.
Bug: angleproject:4889
Change-Id: I760d986bd9171ddde35f9f046c549ca53252df17
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2992980
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | dc59772e | 2021-06-22T22:37:26 |  | Vulkan: SPIR-V Gen: Support switch
With the infrastructure to support this in place, switch is simply
implemented as a conditional with multiple blocks.  Each block either
ends with a branch to the merge block or the next block, implementing
fallthrough.
Bug: angleproject:4889
Change-Id: I5831531d918ac06648cced7707d1d48ffeb6b1b0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2983559
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | a8c9cecf | 2021-06-12T00:12:34 |  | Vulkan: SPIR-V Gen: Support break and continue
This is simply done by issuing a branch to the merge or continue blocks
respectively.
Bug: angleproject:4889
Change-Id: I3e96a3b0f1a0533aa4eac519ab64a87600c0983b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2957810
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 153240b2 | 2021-06-11T16:36:32 |  | Vulkan: SPIR-V Gen: Support loops
Loops are similar to if-else in that they generate a number of blocks
where the first block specifies divergence (OpLoopMerge) and the merge
block.  Differently from if-else, there is a block where the condition
is evaluated and a block which `continue;` leads to (this last block is
the only one allowed to back-jump to the beginning of the loop).
Bug: angleproject:4889
Change-Id: Ic59f4bf3e05fbf93cb5af85acd3bc4b0da8412af
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2957809
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | c75a1d6f | 2021-06-11T23:27:33 |  | Vulkan: SPIR-V Gen: Support the ternary operator
Bug: angleproject:4889
Change-Id: I3ac193e08fc74cc784b688cc049fb786ab68657d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2957808
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 7d023dac | 2021-06-10T00:13:41 |  | Vulkan: SPIR-V Gen: Basic support for fragment shaders
Fragment shader built-ins are implemented in this change and direct
SPIR-V generation for fragment shaders is enabled.
Bug: angleproject:4889
Change-Id: I6f92a5585f242122a81c97a9b1aa2763009161a0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2951625
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 64ce506d | 2021-06-18T14:48:29 |  | Vulkan: SPIR-V Gen: Support most non-texture/image built-ins
Most GLSL built-ins map directly to some SPIR-V operation.  texture*()
and image*() built-ins are not implemented as well as a handful of other
built-ins that require special-handling.
Bug: angleproject:4889
Change-Id: I72abfb4692c3d66a3c8be43ce44ba6808efe6255
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2971646
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 99a98963 | 2021-06-10T16:11:13 |  | Vulkan: SPIR-V Gen: Support discard
This is simply done with OpKill.  If-else blocks now check if the block
is already terminated (through return, discard, continue or break)
before adding the branch to merge block.
Bug: angleproject:4889
Change-Id: I713286cf38e40f9048486d2914a4355ddbc686ac
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953369
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 9c500951 | 2021-06-10T15:48:57 |  | Vulkan: SPIR-V Gen: Fix user-defined blocks
The _u prefix was missing from blocks and their fields.
Bug: angleproject:4889
Change-Id: I31f3b393bc81352c8cf7a433dd652692833fc3f7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953368
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | e48f2210 | 2021-06-10T13:23:34 |  | Vulkan: SPIR-V Gen: Support short-circuiting && and ||
When short-circuiting is necessary (because the right-hand side has side
effects), the following code is generated in SPIR-V:
    // For left && right:
    result = left
    if (left)
        result = right
    // For left || right:
    result = left
    if (!left)
        result = right
Bug: angleproject:4889
Change-Id: Id87b56dc4a1463ed781852a23d2ba6eb2015d700
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953366
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | a76f224f | 2021-06-16T00:43:55 |  | Fix build
Two CLs went in at the same time, causing a build breakage.
Bug: angleproject:4889
Change-Id: I0dacda7263959014fb4ad9bd83733f58a5e98fe6
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2965319
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: John Plate <jplate@google.com> | 
            
              |   | 64ca25f1 | 2021-06-08T17:15:49 |  | Vulkan: SPIR-V Gen: Unary operators
The line raster emulation coded uses round() which was previously not
translated.  This change implements all operations supported by
TIntermUnary nodes.  Bresenham line emulation is now allowed.
Bug: angleproject:4889
Change-Id: I1ffbe3f9bf0299f7efa2c6d1e8f011fefdbb2ddb
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2951624
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 0297779c | 2021-06-08T01:06:21 |  | Vulkan: SPIR-V Gen: Handle invariant variables
The Invariant decoration is applied to variable declarations and block
members as necessary.  When invariant is applied to a gl_PerVertex
built-in, it's applied to the appropriate member in
DeclarePerVertexBlocks.
Bug: angleproject:4889
Change-Id: Idaa8d4ab92f975381a0237d372f0a4044ff983e0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2946116
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 18ddd131 | 2021-06-07T14:59:43 |  | Vulkan: SPIR-V Gen: Support mediump/lowp
The mediump and lowp precisions translate to a RelaxedPrecision
decoration in SPIR-V.  This change implements this decoration and
enables SPIR-V generation when emulating Bresenham lines.  Prior to this
change, Bresenham line emulation resulted in a validation error due to
the vertex shader output being without RelaxedPrecision but the fragment
shader input (translated by glslang) with it.
The function that produces a new id is given a list of decorations to
apply, which itself is automatically deriven from the TType where
applicable, to minimize the risk of any id missing this decoration.
Bug: angleproject:4889
Change-Id: I30cc5a278634c5d83d63cd65b057336f9f573baa
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2946113
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | 29227eef | 2021-06-05T22:25:01 |  | Vulkan: SPIR-V Gen: Specialization constants
With specialization constant qualifier and ids set in the node types,
the SPIR-V generation for these variables are trivially handled.
This is in preparation for enabling line raster emulation as well as
fragment shaders in general.
Bug: angleproject:4889
Change-Id: Ie4d4e47b222ac66d1e0eee29f55ac09990313580
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939337
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | d769742c | 2021-06-03T19:43:58 |  | Vulkan: SPIR-V Gen: Default uniforms
Default uniforms are gathered in a uniform block, so treat them like
other nameless uniform block fields.
Bug: angleproject:4889
Change-Id: If340040ab4c59f3243c40de7daba530b2289e147
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939333
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | ac2fc259 | 2021-06-03T17:11:14 |  | Vulkan: SPIR-V Gen: Support function forward declaration
The generation of function-related ids is moved to
visitFunctionPrototype to support forward declarations.  The
DeferGlobalInitializers AST transformation produces such code.
Bug: angleproject:4889
Change-Id: Iefee534575092ca25ff86e416e35703d7022bc07
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939332
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 0c26ff11 | 2021-06-03T17:09:22 |  | Vulkan: SPIR-V Gen: Support initializers in declarations
If the initializer is a constant, it's specified directly in the
OpVariable instruction.  Otherwise an OpStore is generated where the
declaration is visited.
Bug: angleproject:4889
Change-Id: I79291552ecc50c0878f921aff9f6d8618be34116
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939331
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 6746e5dd | 2021-06-01T22:48:14 |  | Vulkan: SPIR-V Gen: Basic support for compute shaders
This change enables direct SPIR-V generation for compute shaders and
enables a few tests.  A handful of built-in functions are translated to
support said tests.
Bug: angleproject:4889
Change-Id: I8fd6dc50ff31559a738ba680a993fb197e29fcf9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939330
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | ee4a5266 | 2021-06-01T14:57:24 |  | Vulkan: SPIR-V Gen: Function calls
This change implements function calls.  As a result, transform feedback
tests are enabled as well as support for transform feedback emulation
(which contains functions and if blocks).
`const` and opaque uniform function arguments take intermediate values,
while the rest take memory objects.  If the argument being passed is an
unindexed lvalue, it can be directly given to the function.  Otherwise a
temporary variable is made which is initialized by the parameter if
necessary (in and inout parameters) and later overwrites the parameter
if necessary (out and inout parameters).
Bug: angleproject:4889
Change-Id: I8976cdd17870c35d5a2daeed3c38de57ada931d9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2930363
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 77831a6d | 2021-05-31T22:41:58 |  | Vulkan: SPIR-V Gen: If-else blocks
This change implements if-else blocks as well as a few simple binary
operations (equality, less-than etc).  It builds on prior work to
generate the function in separate blocks and introduces a "conditionals"
stack to support nesting of if-else blocks, switches and loops.
Bug: angleproject:4889
Change-Id: If7694000487811837ed5946753568b41d67199f0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2929660
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | c2ad5824 | 2021-05-31T12:20:27 |  | Vulkan: SPIR-V Gen: Code blocks
This change lays the foundation for implementing branches and loops.  In
SPIR-V, every block starts with an OpLabel (which identifies the block
and serves as the branch target to that block), and ends in a branch.
An `if` for example implies the existence of four blocks, the header
including code leading up to the if, the true and false blocks and the
"merge" block, including the code following the if-else blocks.
This change includes support code for generating function code split in
blocks, even though only one block is currently used.
Bug: angleproject:4889
Change-Id: I10f96b78b6f00c20bc7f9c81e854ab5543bf8fde
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2929659
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> | 
            
              |   | be873929 | 2021-05-26T21:55:50 |  | Vulkan: SPIR-V Gen: Handle constants and constructors
This change translates constants and constructors (minus type
casting).  With this change, shaders such as
    gl_Position = vec4(aposition, 0, 1);
are translated correctly.
Bug: angleproject:4889
Change-Id: I4463717cf880c6d05db179b98691d5cabc1a2d7c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2920192
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | aa2626f9 | 2021-05-21T15:24:55 |  | Vulkan: SPIR-V Gen: Handle load/store access chain
This change implements a key instruction of SPIR-V, OpAccessChain.
Inspired by glslang's implementation, a class is added (AccessChain)
that tracks "indices" into a base value.  These indices could select a
field of a block, an element of an array, a column of a matrix, or a
component of a vector.  Nuances (such as multi-component swizzle as an
lvalue not representable in SPIR-V) and optimizations (such as
all-literal indices to an rvalue) that are implemented in glslang have
also been implemented in this change.  As a result, this change
implements all manners of loads and stores (with the exception of this
gotcha: https://github.com/KhronosGroup/glslang/issues/2637).
The change uses this feature to translate the basic shader which does
`gl_Position = positionAttr;` (by implementing EOpAssign), and enables a
test that uses this shader.
Bug: angleproject:4889
Change-Id: I22dbe5b169ce499eaac657902164aca3b0ebc193
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2911880
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com> | 
            
              |   | c229ccfe | 2021-05-18T15:51:12 |  | Vulkan: SPIR-V Gen: Handle gl_PerVertex
If not declared by the shader, default gl_PerVertex is now explicitly
declared in AST prior to SPIR-V generation.  The SPIR-V generation code
then doesn't need to declare them magically.
Bug: angleproject:4889
Change-Id: Icc593bc1ccc3162487bdbae7f66bc775d098778d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2905952
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> | 
            
              |   | 9bc837f6 | 2021-04-07T15:24:12 |  | Vulkan: Generate SPIR-V directly from the translator; Part 1
This is the first change in a series to generate SPIR-V directly from
the translator's AST, instead of the generating text GLSL and feeding it
to glslang.
This change implements the majority of the work needed to map AST types
to SPIR-V types, and declare types and interface variables in SPIR-V.
Additionally, it lays the infrastructure to conditionally enabling this
path in end2end tests.
No tests are currently enabled as the change doesn't actually generate
code for function bodies yet.
Bug: angleproject:4889
Change-Id: Iacb28b6907fd48c50e4cc5a0e7ad72f6eed241d4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2889603
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org> |