platform/upstream/glslang.git
6 years agoSPV: Correct semantics of atomic-counter decrement.
John Kessenich [Sat, 7 Oct 2017 03:21:48 +0000 (21:21 -0600)]
SPV: Correct semantics of atomic-counter decrement.

The semantics differ between GLSL/HLSL and SPIR-V.
Translate between these.

6 years agoHLSL: Tests: Add subset of flattened opaque test to legalize results.
John Kessenich [Sat, 7 Oct 2017 03:01:07 +0000 (21:01 -0600)]
HLSL: Tests: Add subset of flattened opaque test to legalize results.

6 years agoMerge pull request #1089 from LoopDawg/split-shadow-tx
John Kessenich [Fri, 6 Oct 2017 21:33:20 +0000 (00:33 +0300)]
Merge pull request #1089 from LoopDawg/split-shadow-tx

HLSL: split textures used for both shadow and non-shadow modes

6 years agoHLSL: split textures used for both shadow and non-shadow modes
LoopDawg [Thu, 5 Oct 2017 22:25:52 +0000 (16:25 -0600)]
HLSL: split textures used for both shadow and non-shadow modes

A single texture can statically appear in code mixed with a shadow sampler
and a non-shadow sampler.  This would be create invalid SPIR-V, unless
one of them is provably dead.

The previous detection of this happened before DCE, so some shaders would
trigger the error even though they wouldn't after DCE.  To handle that
case, this PR splits the texture into two: one with each mode.  It sets
"needsLegalization" (if that happens for any texture) to warn that this shader
will need post-compilation legalization.

If the texture is only used with one of the two modes, behavior is as it
was before.

6 years agoReadme: Update with additional Windows build information for SPIRV-tools build.
John Kessenich [Fri, 6 Oct 2017 06:24:41 +0000 (00:24 -0600)]
Readme: Update with additional Windows build information for SPIRV-tools build.

6 years agoMerge pull request #1085 from KhronosGroup/flatten-assign-subset
John Kessenich [Wed, 4 Oct 2017 20:41:08 +0000 (23:41 +0300)]
Merge pull request #1085 from KhronosGroup/flatten-assign-subset

HLSL: Fix #954: Track/access subsets of flattened multi-level aggrega…

6 years agoHLSL: Fix #954: Track/access subsets of flattened multi-level aggregates.
John Kessenich [Wed, 4 Oct 2017 19:27:43 +0000 (13:27 -0600)]
HLSL: Fix #954: Track/access subsets of flattened multi-level aggregates.

Works in conjuction with d1be754 to represent and modify a partially
dereferenced multi-level flattened aggregate.

6 years agoMerge pull request #1081 from xxxbxxx/for-upstream-1
John Kessenich [Wed, 4 Oct 2017 19:01:25 +0000 (22:01 +0300)]
Merge pull request #1081 from xxxbxxx/for-upstream-1

HLSL: Fix crash when flattening both side of assignement simultaneously.

6 years agoHLSL: Fix crash when flattening both side of assignement simultaneously.
Unknown [Tue, 3 Oct 2017 07:10:26 +0000 (09:10 +0200)]
HLSL: Fix crash when flattening both side of assignement simultaneously.

6 years agoMerge pull request #1075 from LoopDawg/subpass-input
John Kessenich [Mon, 2 Oct 2017 22:47:48 +0000 (01:47 +0300)]
Merge pull request #1075 from LoopDawg/subpass-input

HLSL: add subpass input types and methods

6 years agoHLSL: add subpass input types and methods
LoopDawg [Wed, 27 Sep 2017 15:04:43 +0000 (09:04 -0600)]
HLSL: add subpass input types and methods

Add support for Subpass Input proposal of issue #1069.

Subpass input types are given as:

    layout(input_attachment_index = 1) SubpassInput<float4> subpass_f;
    layout(input_attachment_index = 2) SubpassInput<int4>   subpass_i;
    layout(input_attachment_index = 3) SubpassInput<uint4>  subpass_u;

    layout(input_attachment_index = 1) SubpassInputMS<float4> subpass_ms_f;
    layout(input_attachment_index = 2) SubpassInputMS<int4>   subpass_ms_i;
    layout(input_attachment_index = 3) SubpassInputMS<uint4>  subpass_ms_u;

The input attachment may also be specified using attribute syntax:

    [[vk::input_attachment_index(7)]] SubpassInput subpass_2;

The template type may be a shorter-than-vec4 vector, but currently user
structs are not supported.  (An unimplemented error will be issued).

The load operations are methods on objects of the above type:

    float4 result = subpass_f.SubpassLoad();
    int4   result = subpass_i.SubpassLoad();
    uint4  result = subpass_u.SubpassLoad();

    float4 result = subpass_ms_f.SubpassLoad(samp);
    int4   result = subpass_ms_i.SubpassLoad(samp);
    uint4  result = subpass_ms_u.SubpassLoad(samp);

Additionally, the AST printer could not print EOpSubpass* nodes.  Now it can.

Fixes #1069

6 years agoBuild: Fix a couple build issues.
John Kessenich [Sat, 30 Sep 2017 20:54:18 +0000 (14:54 -0600)]
Build: Fix a couple build issues.

6 years agoHLSL: Additional attribute support: [[]], namespace, parameters:
John Kessenich [Sat, 30 Sep 2017 20:34:50 +0000 (14:34 -0600)]
HLSL: Additional attribute support: [[]], namespace, parameters:

- support C++11 style brackets [[...]]
- support namespaces [[vk::...]]
- support these on parameter declarations in functions
- support location, binding/set, input attachments

6 years agoFix #1060: Could crash if using --source-entry-point with -e; fixed.
John Kessenich [Fri, 29 Sep 2017 23:51:52 +0000 (17:51 -0600)]
Fix #1060: Could crash if using --source-entry-point with -e; fixed.

6 years agoMerge pull request #1078 from greg-lunarg/addopt14
John Kessenich [Fri, 29 Sep 2017 17:57:30 +0000 (20:57 +0300)]
Merge pull request #1078 from greg-lunarg/addopt14

Remove opaque workarounds

6 years agoLegalization: Fix tests after workarounds removed
GregF [Fri, 29 Sep 2017 16:08:20 +0000 (10:08 -0600)]
Legalization: Fix tests after workarounds removed

6 years agoSPV: rationalize parameter handling for "original" and "writable" parameters.
John Kessenich [Sun, 10 Sep 2017 21:21:05 +0000 (15:21 -0600)]
SPV: rationalize parameter handling for "original" and "writable" parameters.

6 years agoHLSL: Pass opaques by local copy, instead of by interface original.
John Kessenich [Fri, 8 Sep 2017 08:38:07 +0000 (02:38 -0600)]
HLSL: Pass opaques by local copy, instead of by interface original.

Also, remove assumption that if something is opaque that it
must be in the UniformConstant storage class.

This allows function declarations to know all parameters will
be in the Function storage class.

6 years agoHLSL: Remove workarounds for assigning to opaques.
John Kessenich [Thu, 7 Sep 2017 10:33:11 +0000 (04:33 -0600)]
HLSL: Remove workarounds for assigning to opaques.

This assumes it will be combined with optimizing transforms
that eliminate assignments to opaques.

6 years agoMerge pull request #1076 from LoopDawg/shadow-tx-types
John Kessenich [Fri, 29 Sep 2017 02:07:50 +0000 (05:07 +0300)]
Merge pull request #1076 from LoopDawg/shadow-tx-types

HLSL: force textures to shadow modes from combined samplers

6 years agoHLSL: force textures to shadow modes from combined samplers
LoopDawg [Wed, 27 Sep 2017 15:12:51 +0000 (09:12 -0600)]
HLSL: force textures to shadow modes from combined samplers

Texture shadow mode must match the state of the sampler they are
combined with.  This change does that, both for the AST and the
symbol table.  Note that the texture cannot easily be *created*
the right way, because this may not be known at that time.  Instead,
the texture is subsequently patched.

This cannot work if a single texture is used with both a shadow and
non-shadow sampler, so that case is detected and generates an error.
This is permitted by the HLSL language, however.  See #1073 discussion.

Fixed one test source that was using a texture with both shadow and
non-shadow samplers.

6 years agoMerge pull request #1077 from greg-lunarg/addopt12
John Kessenich [Thu, 28 Sep 2017 19:38:29 +0000 (22:38 +0300)]
Merge pull request #1077 from greg-lunarg/addopt12

Legalization: Fix warnings and disable tests when spirv-tools not present

6 years agoLegalization: Fix warnings and disable tests when spirv-tools not present
GregF [Thu, 28 Sep 2017 16:08:32 +0000 (10:08 -0600)]
Legalization: Fix warnings and disable tests when spirv-tools not present

6 years agoMerge pull request #1070 from greg-lunarg/addopt8
John Kessenich [Thu, 28 Sep 2017 02:56:56 +0000 (05:56 +0300)]
Merge pull request #1070 from greg-lunarg/addopt8

Enable HLSL legalization

6 years agoAdvance spirv-opt known-good to hopefully fix travis multithread failure
GregF [Wed, 27 Sep 2017 21:46:59 +0000 (15:46 -0600)]
Advance spirv-opt known-good to hopefully fix travis multithread failure

6 years agoLegalization: Skip spirv-tools tests
GregF [Wed, 27 Sep 2017 17:34:48 +0000 (11:34 -0600)]
Legalization: Skip spirv-tools tests

6 years agoPick up latest spirv-tools in attempt to fix travis failures
GregF [Mon, 25 Sep 2017 19:50:32 +0000 (13:50 -0600)]
Pick up latest spirv-tools in attempt to fix travis failures

6 years agoTry Python interpreter on update_glslang_sources.py in appveyor
GregF [Fri, 22 Sep 2017 23:21:37 +0000 (17:21 -0600)]
Try Python interpreter on update_glslang_sources.py in appveyor

6 years agoFix travis and appveyor calls to update_glslang_sources.py
GregF [Fri, 22 Sep 2017 21:30:10 +0000 (15:30 -0600)]
Fix travis and appveyor calls to update_glslang_sources.py

6 years agoEnable HLSL legalization
GregF [Fri, 22 Sep 2017 00:40:22 +0000 (18:40 -0600)]
Enable HLSL legalization

Also added known-good mechanism to fetch latest validated spirv-tools.
Also added -Od and -Os to disable optimizer and optimize for size.

Fetching spirv-tools is optional for both glsl and hlsl. Legalization
of hlsl is done by default if spirv-opt is present at cmake time.
Optimization for glsl is currently done through the option -Os.

Legalization testing is currently only done on four existing shaders.
A separate baseLegalResults directory holds those results. All previous
testing is done with the optimizer disabled.

6 years agoMerge pull request #1072 from amdrexu/feature
John Kessenich [Wed, 27 Sep 2017 15:11:06 +0000 (18:11 +0300)]
Merge pull request #1072 from amdrexu/feature

Implement extension GL_NV_shader_atomic_int64

6 years agoImplement extension GL_NV_shader_atomic_int64
Rex Xu [Tue, 26 Sep 2017 07:42:56 +0000 (15:42 +0800)]
Implement extension GL_NV_shader_atomic_int64

6 years agoMerge pull request #1071 from antiagainst/ninja-make
John Kessenich [Tue, 26 Sep 2017 06:08:30 +0000 (00:08 -0600)]
Merge pull request #1071 from antiagainst/ninja-make

Travis: use make instead of ninja

6 years agoTravis: use make instead of ninja and limit concurrent jobs
Lei Zhang [Mon, 25 Sep 2017 18:04:20 +0000 (14:04 -0400)]
Travis: use make instead of ninja and limit concurrent jobs

6 years agoMerge pull request #1063 from LoopDawg/remapper-error-cleanup
John Kessenich [Sat, 23 Sep 2017 12:32:02 +0000 (06:32 -0600)]
Merge pull request #1063 from LoopDawg/remapper-error-cleanup

Remapper: make remapper robust against non-exiting error handlers

6 years agoBuild: Merge pull request #1068 from greg-lunarg/addopt4
John Kessenich [Fri, 22 Sep 2017 19:51:02 +0000 (13:51 -0600)]
Build: Merge pull request #1068 from greg-lunarg/addopt4

CMake file changes for SPIR-V legalization for HLSL

6 years agoCMake changes for HLSL legalization
GregF [Thu, 21 Sep 2017 22:50:39 +0000 (16:50 -0600)]
CMake changes for HLSL legalization

Cmake now looks for External/spirv-tools. If found, it links in
SPIRV-Tools-opt and SPVRemapper, and adds -DENABLE_OPT to build.

6 years agoRemapper: make remapper robust against non-exiting error handlers
LoopDawg [Sun, 17 Sep 2017 16:38:52 +0000 (10:38 -0600)]
Remapper: make remapper robust against non-exiting error handlers

Remapper errors are generally fatal: there has been some unexpected situation while
parsing the SPV binary, and there is no reasonable way to carry on.  The
errorHandler() function is called in this case, which by default exits, but
it is possible to submit a handler which does not.  In that case the remapper would
carry on in a bad state.

This change ensures a graceful termination of the remap() function.

While a try {} catch {} construct would be the ideal and safe way to do this,
that's off limits for certain environments, so this tries to do the same thing
with explicit code, to catch all the bailout paths.

6 years agoHLSL: Fix #1064: Don't include empty structures on OpEntryPoint
John Kessenich [Tue, 19 Sep 2017 17:09:59 +0000 (11:09 -0600)]
HLSL: Fix #1064: Don't include empty structures on OpEntryPoint

6 years agoMerge pull request #1044 from dsrbecky/image_external_essl3
John Kessenich [Sat, 16 Sep 2017 03:10:08 +0000 (21:10 -0600)]
Merge pull request #1044 from dsrbecky/image_external_essl3

Add support for GL_OES_EGL_image_external_essl3

6 years agoHLSL: fix array[1] of vec4 constant declaration.
xavier [Sun, 20 Aug 2017 08:44:21 +0000 (10:44 +0200)]
HLSL: fix array[1] of vec4 constant declaration.

6 years agoTest: Make another test legal HLSL, and rationalize GLSL vs HLSL addConstructor().
John Kessenich [Fri, 15 Sep 2017 19:15:23 +0000 (13:15 -0600)]
Test: Make another test legal HLSL, and rationalize GLSL vs HLSL addConstructor().

6 years agoHLSL: Add bounds checking, shared with GLSL. Partially address #1032.
John Kessenich [Fri, 15 Sep 2017 01:45:28 +0000 (19:45 -0600)]
HLSL: Add bounds checking, shared with GLSL. Partially address #1032.

6 years agoMerge pull request #1051 from LoopDawg/bug-1049
John Kessenich [Fri, 15 Sep 2017 00:18:19 +0000 (18:18 -0600)]
Merge pull request #1051 from LoopDawg/bug-1049

HLSL: allow split type in InputPatch template type, & HS return types.

6 years agoHLSL: handle split InputPatch templat type in patch constant functions
LoopDawg [Wed, 13 Sep 2017 14:44:39 +0000 (08:44 -0600)]
HLSL: handle split InputPatch templat type in patch constant functions

InputPatch parameters to patch constant functions were not using the
internal (temporary) variable type.  That could cause validation errors
if the input patch had a mixture of builtins and user qualified members.

This uses the entry point's internal form.

There is currently a limitation: if an InputPatch is used in a PCF,
it must also have appeared in the main entry point's parameter list.
That is not a limitation of HLSL.  Currently that situation is detected
and an "implemented" error results.  The limitation can be addressed,
but isn't yet in the current form of the PR.

6 years agoHLSL: allow mixed user & builtin members in hull shader output structure
LoopDawg [Sun, 10 Sep 2017 15:46:55 +0000 (09:46 -0600)]
HLSL: allow mixed user & builtin members in hull shader output structure

Hull shaders have an implicitly arrayed output.  This is handled by creating an arrayed form of the
provided output type, and writing to the element of it indexed by InvocationID.

The implicit indirection into that array was causing some troubles when copying to a split
structure.  handleAssign was able to handle simple symbol lvalues, but not an lvalue composed
of an indirection into an array.

6 years agoGLSL: Make gl_Layer and gl_ViewportIndex always be outside blocks.
John Kessenich [Wed, 13 Sep 2017 19:22:50 +0000 (13:22 -0600)]
GLSL: Make gl_Layer and gl_ViewportIndex always be outside blocks.

There was some ambiguity/contradiction in this behavior, and
Khronos decided glslang should always have these outside blocks,
rather than have stage/vendor/target variations.

6 years agoMerge pull request #1056 from KhronosGroup/glsl-entrypoint-rename
John Kessenich [Tue, 12 Sep 2017 16:53:05 +0000 (10:53 -0600)]
Merge pull request #1056 from KhronosGroup/glsl-entrypoint-rename

GLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.

6 years agoGLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.
John Kessenich [Tue, 12 Sep 2017 03:48:19 +0000 (21:48 -0600)]
GLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.

Fixes #1045.

6 years agoMerge pull request #1050 from amdrexu/feature
John Kessenich [Tue, 12 Sep 2017 15:09:37 +0000 (09:09 -0600)]
Merge pull request #1050 from amdrexu/feature

Implement the extension GL_AMD_shader_fragment_mask

6 years agoMerge pull request #1055 from KhronosGroup/strdup
John Kessenich [Tue, 12 Sep 2017 04:04:59 +0000 (22:04 -0600)]
Merge pull request #1055 from KhronosGroup/strdup

Build: Fix strdup -> _strdup warnings.

6 years agoBuild: Fix strdup -> _strdup warnings.
John Kessenich [Tue, 12 Sep 2017 03:27:23 +0000 (21:27 -0600)]
Build: Fix strdup -> _strdup warnings.

6 years agoBuild: Fix build warnings.
John Kessenich [Tue, 12 Sep 2017 02:39:54 +0000 (20:39 -0600)]
Build: Fix build warnings.

6 years agoFix #1043: set all scan string-locations to have bias, not just the first one.
John Kessenich [Tue, 12 Sep 2017 02:35:49 +0000 (20:35 -0600)]
Fix #1043: set all scan string-locations to have bias, not just the first one.

6 years agoNon-functional: Make usage for entry points more consistent.
John Kessenich [Tue, 12 Sep 2017 02:13:49 +0000 (20:13 -0600)]
Non-functional: Make usage for entry points more consistent.

6 years agoMerge pull request #1053 from mchock-nv/mchock-nv-fix-lambda
John Kessenich [Tue, 12 Sep 2017 01:33:11 +0000 (19:33 -0600)]
Merge pull request #1053 from mchock-nv/mchock-nv-fix-lambda

Delete unused 'this' capture

6 years agoAddress #1052: Have language-level exits of case statements.
John Kessenich [Tue, 12 Sep 2017 01:25:17 +0000 (19:25 -0600)]
Address #1052: Have language-level exits of case statements.

6 years agoDelete unused 'this' capture
mchock-nv [Mon, 11 Sep 2017 22:20:52 +0000 (15:20 -0700)]
Delete unused 'this' capture

Remove an unused 'this' entry from a lambda capture list.

This cleans up a unused-lambda-capture warning.

6 years agoImplement the extension GL_AMD_shader_fragment_mask
amhagan [Tue, 13 Jun 2017 20:53:02 +0000 (16:53 -0400)]
Implement the extension GL_AMD_shader_fragment_mask

6 years agoMerge pull request #1047 from svenstaro/add-stdin-option
John Kessenich [Fri, 8 Sep 2017 03:02:37 +0000 (20:02 -0700)]
Merge pull request #1047 from svenstaro/add-stdin-option

Add stdin option (fixes #598)

6 years agoAdd --stdin
Sven-Hendrik Haase [Sat, 2 Sep 2017 17:34:54 +0000 (19:34 +0200)]
Add --stdin

6 years agoMerge pull request #1048 from LoopDawg/opaque-type-fix
John Kessenich [Thu, 7 Sep 2017 04:50:20 +0000 (21:50 -0700)]
Merge pull request #1048 from LoopDawg/opaque-type-fix

Fix lvalue test in SPIR-V generation

6 years agoFix lvalue check in SPIR-V generation
LoopDawg [Wed, 6 Sep 2017 20:59:06 +0000 (14:59 -0600)]
Fix lvalue check in SPIR-V generation

There were several locations in TGlslangToSpvTraverser::handleUserFunctionCall testing for
whether a fn argument should be in the lvalue or rvalue array.  They must get the same
result for indexing sanity, but had slightly different logic.

They're now forced into the same test.

6 years agoAdd support for GL_OES_EGL_image_external_essl3
David Srbecký [Mon, 4 Sep 2017 16:33:04 +0000 (17:33 +0100)]
Add support for GL_OES_EGL_image_external_essl3

6 years agoMerge pull request #1042 from LoopDawg/warning-fix-2
John Kessenich [Fri, 1 Sep 2017 05:46:56 +0000 (23:46 -0600)]
Merge pull request #1042 from LoopDawg/warning-fix-2

WIP: Linux build warning fix

6 years agoMerge pull request #1039 from amdrexu/bugfix
John Kessenich [Fri, 1 Sep 2017 05:36:09 +0000 (23:36 -0600)]
Merge pull request #1039 from amdrexu/bugfix

Fix issues of GL_ARB_viewport_layer_array

6 years agoLinux build warning fix
LoopDawg [Thu, 31 Aug 2017 19:44:34 +0000 (13:44 -0600)]
Linux build warning fix

* Remove complaint about unused function parameter in resolveUniformLocation()
* Remove complaint about defined but not used variable in spvIR.h

6 years agoFix issues of GL_ARB_viewport_layer_array
Rex Xu [Thu, 31 Aug 2017 07:14:49 +0000 (15:14 +0800)]
Fix issues of GL_ARB_viewport_layer_array

6 years agoMerge pull request #1037 from LoopDawg/clip-cull-geom
John Kessenich [Thu, 31 Aug 2017 18:36:06 +0000 (12:36 -0600)]
Merge pull request #1037 from LoopDawg/clip-cull-geom

HLSL: add geometry stage support for clip/cull distance

6 years agoHLSL: add geometry stage support for clip/cull distance
LoopDawg [Mon, 28 Aug 2017 20:02:19 +0000 (14:02 -0600)]
HLSL: add geometry stage support for clip/cull distance

Changes:

(1) Allow clip/cull builtins as both input and output in the same shader stage.  Previously,
not enough data was tracked to handle this.

(2) Handle the extra array dimension in GS inputs.  The synthesized external variable can
now be created with the extra array dimension if needed, and the form conversion code is
able to handle it as well.

For example, both of these GS inputs would result in the same synthesized external type:

    triangle in float4 clip[3] : SV_ClipDistance

    triangle in float2 clip[3][2] : SV_ClipDistance

In the second case, the inner array dimension packs with the 2-vector of floats into an array[4],
which there is an array[3] of due to the triangle geometry.

6 years agoMerge pull request #1031 from xxxbxxx/for-upstream-2
John Kessenich [Tue, 29 Aug 2017 18:41:55 +0000 (12:41 -0600)]
Merge pull request #1031 from xxxbxxx/for-upstream-2

HLSL: fix preprocessor concatenation behaviour.

6 years agoBuild: Fix #1036: size_t warning.
John Kessenich [Tue, 29 Aug 2017 18:36:09 +0000 (12:36 -0600)]
Build: Fix #1036: size_t warning.

6 years agoHLSL: fix preprocessor concatenation behaviour.
xavier [Thu, 24 Aug 2017 06:28:57 +0000 (08:28 +0200)]
HLSL: fix preprocessor concatenation behaviour.

Fix #772.

6 years agoMerge pull request #1035 from LoopDawg/clip-cull-type-fix
John Kessenich [Mon, 28 Aug 2017 22:07:55 +0000 (16:07 -0600)]
Merge pull request #1035 from LoopDawg/clip-cull-type-fix

HLSL: (minor) fix type on clip/cull index result

6 years agoHLSL: fix type on clip/cull index result
LoopDawg [Mon, 28 Aug 2017 20:05:41 +0000 (14:05 -0600)]
HLSL: fix type on clip/cull index result

While adding geometry stage support for clip/cull, it transpired that the
existing clip/cull support was not setting the type of the result of indexing
into the clup/cull variable.  That's a defect independent of the geometry
support, so to simplify the geometry PR, this is addressed separately.

It doesn't appear to change the generated SPIR-V, but that's probably down to
something else tolerating a bad input.

6 years agoSPV: Add auto location mapping of non-opaque non-block uniform variables.
John Kessenich [Sat, 26 Aug 2017 21:47:25 +0000 (15:47 -0600)]
SPV: Add auto location mapping of non-opaque non-block uniform variables.

Fix #1019.

6 years agoBuild: Attempt better support for VS 2012.
John Kessenich [Sat, 26 Aug 2017 03:09:15 +0000 (21:09 -0600)]
Build: Attempt better support for VS 2012.

Fix #1020. Fix #1021. Fix #1022.

6 years agoMerge pull request #1014 from KhronosGroup/SPV_EXT_shader_viewport_index_layer
John Kessenich [Fri, 25 Aug 2017 19:33:16 +0000 (13:33 -0600)]
Merge pull request #1014 from KhronosGroup/SPV_EXT_shader_viewport_index_layer

SPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer.

6 years agoMerge pull request #1034 from KhronosGroup/module-processes
John Kessenich [Fri, 25 Aug 2017 19:05:54 +0000 (13:05 -0600)]
Merge pull request #1034 from KhronosGroup/module-processes

SPV reflection: Add OpModuleProcessed for compile options.

6 years agoSPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer.
John Kessenich [Fri, 11 Aug 2017 19:07:17 +0000 (13:07 -0600)]
SPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer.

6 years agoSPV reflection: Add OpModuleProcessed for compile options.
John Kessenich [Fri, 21 Jul 2017 02:00:36 +0000 (20:00 -0600)]
SPV reflection: Add OpModuleProcessed for compile options.

6 years agoMerge pull request #1028 from LoopDawg/clip-cull-input
John Kessenich [Thu, 24 Aug 2017 18:15:00 +0000 (12:15 -0600)]
Merge pull request #1028 from LoopDawg/clip-cull-input

HLSL: handle clip and cull distance input builtin type conversion

6 years agoHLSL: handle clip and cull distance input builtin type conversion
LoopDawg [Wed, 23 Aug 2017 18:34:42 +0000 (12:34 -0600)]
HLSL: handle clip and cull distance input builtin type conversion

HLSL allows a range of types for clip and cull distances.  There are
three dimensions, including arrayness, vectorness, and semantic ID.
SPIR-V requires clip and cull distance be a single array of floats in
all cases.

This code provides input side conversion between the SPIR-V form and
the HLSL form.  (Output conversion was added in PR #947 and #997).

This PR extends HlslParseContext::assignClipCullDistance to cope with
the input side conversion.  Not as much changed as appears: there was
also a lot of renaming to reflect the fact that the code now handles
either direction.

Currently, non-{frag,vert} stages are not handled, and are explicitly
rejected.

Fixes #1026.

6 years agoMerge pull request #1029 from amdrexu/feature2
John Kessenich [Thu, 24 Aug 2017 05:13:19 +0000 (23:13 -0600)]
Merge pull request #1029 from amdrexu/feature2

Implement extension GL_AMD_shader_image_load_store_lod

6 years agoMerge pull request #1025 from amdrexu/feature
John Kessenich [Wed, 23 Aug 2017 23:58:31 +0000 (17:58 -0600)]
Merge pull request #1025 from amdrexu/feature

SPV: Implement extension SPV_EXT_shader_stencil_export

6 years agoImplement extension GL_AMD_shader_image_load_store_lod
Rex Xu [Wed, 5 Jul 2017 09:23:28 +0000 (17:23 +0800)]
Implement extension GL_AMD_shader_image_load_store_lod

6 years agoSPV: Implement extension SPV_EXT_shader_stencil_export
Rex Xu [Wed, 23 Aug 2017 15:24:42 +0000 (23:24 +0800)]
SPV: Implement extension SPV_EXT_shader_stencil_export

6 years agoHLSL: Fix #1027.
John Kessenich [Wed, 23 Aug 2017 20:33:31 +0000 (14:33 -0600)]
HLSL: Fix #1027.

6 years agoHLSL: Fix #1018: Give an error for mismatched return type.
John Kessenich [Sat, 19 Aug 2017 23:29:44 +0000 (17:29 -0600)]
HLSL: Fix #1018: Give an error for mismatched return type.

6 years agoMerge pull request #1017 from LoopDawg/texture-struct-return.1
John Kessenich [Sat, 19 Aug 2017 22:00:26 +0000 (16:00 -0600)]
Merge pull request #1017 from LoopDawg/texture-struct-return.1

HLSL: add methods to handle user structures in texture template type.

6 years agoBuild: Fix build when NV_EXTENSIONS is not enabled.
John Kessenich [Sat, 19 Aug 2017 21:54:49 +0000 (15:54 -0600)]
Build: Fix build when NV_EXTENSIONS is not enabled.

6 years agoSPV: Fix #1016: Don't allow non-GLSL-extension protected Layer and ViewportIndex...
John Kessenich [Fri, 18 Aug 2017 05:49:39 +0000 (23:49 -0600)]
SPV: Fix #1016: Don't allow non-GLSL-extension protected Layer and ViewportIndex members.

6 years agoHLSL: add methods to track user structure in texture return type.
LoopDawg [Mon, 31 Jul 2017 19:41:42 +0000 (13:41 -0600)]
HLSL: add methods to track user structure in texture return type.

Some languages allow a restricted set of user structure types returned from texture sampling
operations.  Restrictions include the total vector size of all components may not exceed 4,
and the basic types of all members must be identical.

This adds underpinnings for that ability.  Because storing a whole TType or even a simple
TTypeList in the TSampler would be expensive, the structure definition is held in a
table outside the TType.  The TSampler contains a small bitfield index, currently 4 bits
to support up to 15 separate texture template structure types, but that can be adjusted
up or down.  Vector returns are handled as before.

There are abstraction methods accepting and returning a TType (such as may have been parsed
from a grammar).  The new methods will accept a texture template type and set the
sampler to the structure if possible, checking a range of error conditions such as whether
the total structure vector components exceed 4, or whether their basic types differe, or
whether the struct contains non-vector-or-scalar members.  Another query returns the
appropriate TType for the sampler.

High level summary of design:

In the TSampler, this holds an index into the texture structure return type table:

    unsigned int structReturnIndex : structReturnIndexBits;

These are the methods to set or get the return type from the TSampler.  They work for vector or structure returns, and potentially could be expanded to handle other things (small arrays?) if ever needed.

    bool setTextureReturnType(TSampler& sampler, const TType& retType, const TSourceLoc& loc);
    void getTextureReturnType(const TSampler& sampler, const TType& retType, const TSourceLoc& loc) const;

The ``convertReturn`` lambda in ``HlslParseContext::decomposeSampleMethods`` is greatly expanded to know how to copy a vec4 sample return to whatever the structure type should be.  This is a little awkward since it involves introducing a comma expression to return the proper aggregate value after a set of memberwise copies.

6 years agoHLSL: Add fall-back for opaque initializers to just generate long-term expected code.
John Kessenich [Tue, 15 Aug 2017 16:18:32 +0000 (10:18 -0600)]
HLSL: Add fall-back for opaque initializers to just generate long-term expected code.

This generated code needs an optimization pass to eliminate the assignments
to the opaque members.

6 years agoMerge pull request #1013 from KhronosGroup/flatten-nonarrayed
John Kessenich [Tue, 15 Aug 2017 04:16:36 +0000 (13:16 +0900)]
Merge pull request #1013 from KhronosGroup/flatten-nonarrayed

HLSL: Flatten structs for all non-arrayed I/O interfaces.

6 years agoSPV: Correct selection of storage-image capabilities. Fixes #986.
John Kessenich [Tue, 15 Aug 2017 04:10:00 +0000 (22:10 -0600)]
SPV: Correct selection of storage-image capabilities. Fixes #986.

Code was reflecting an old historical use of sampled as a SPIR-V
2-valued operand, instead of its current 3 values.

6 years agoHLSL: Flatten structs for all non-arrayed I/O interfaces.
John Kessenich [Fri, 11 Aug 2017 06:17:26 +0000 (00:17 -0600)]
HLSL: Flatten structs for all non-arrayed I/O interfaces.

6 years agoHLSL: Make fresh array sizes for TessLevelOuter and TessLevelInner arrays.
John Kessenich [Fri, 11 Aug 2017 06:14:46 +0000 (00:14 -0600)]
HLSL: Make fresh array sizes for TessLevelOuter and TessLevelInner arrays.

This prevents potentional sharing from inadvertently affecting other arrays.

6 years agoHLSL Test: Expand test, adding a user-patch-constant signature.
John Kessenich [Thu, 10 Aug 2017 17:41:11 +0000 (11:41 -0600)]
HLSL Test: Expand test, adding a user-patch-constant signature.

7 years agoHLSL: Move debug naming to a simpler, more consistent, scheme.
John Kessenich [Wed, 9 Aug 2017 20:29:29 +0000 (14:29 -0600)]
HLSL: Move debug naming to a simpler, more consistent, scheme.

This will help in expanding flattening and reducing splitting.