Commit Graph

343 Commits

Author SHA1 Message Date
St0fF
a1184ddd48 fix further MSVC 2012 build issues
MSVC 2012 does not allow initializer lists - replaced with corrresponding CTor calls.
2018-04-09 21:08:14 +02:00
John Kessenich
f52b63812a Fix #1331: Emit SPV_GOOGLE_hlsl_functionality1 for counters.
It was missing when there were no semantics.
2018-04-05 19:35:38 -06:00
John Kessenich
5611c6d27b GLSL/SPV: Implement SPV_EXT_descriptor_indexing and GL_EXT_nonuniform_qualifier 2018-04-05 11:25:02 -06:00
Jeff Bolz
2abe9a4d34 Implement GL_NV_shader_subgroup_partitioned 2018-03-29 22:52:17 -05:00
GregF
fb03a55e0f Only print legalization warning if optimizer disabled 2018-03-29 13:17:54 -06:00
John Kessenich
7be36647fc
Merge pull request #1319 from KhronosGroup/array-rationalization
Array rationalization
2018-03-28 23:26:27 -06:00
John Kessenich
ead8622484 Non-functional. Rationalizations enabling future generalizations:
- Use much simpler method to update implicit array sizes.
  The previous overly complicated method was error prone.
- Rationalize all use of unsized arrays.
- Combine decorations when generating SPIR-V, to simplify
  adding extensions.
2018-03-28 18:01:20 -06:00
GregF
4bede9eb00 Disable DCE by Remapper through glslangValidator...
...now that spirv-opt is capable enough.
2018-03-27 10:15:51 -06:00
John Kessenich
643e57cddf
Merge pull request #1313 from greg-lunarg/kg15
Update SPIRV-Tools known good.
2018-03-27 00:46:18 -06:00
greg-lunarg
0b46c1edbf
Merge branch 'master' into kg15 2018-03-26 12:20:43 -06:00
GregF
eecb874c35 Update SPIRV-Tools known good.
Also update spirv-opt recipes.
2018-03-26 12:11:55 -06:00
John Kessenich
859b0342b8 Types: Fix #1290: Rationalize and correct "mixed" style array dimensioning.
There a couple functional problems, which when reduced down also led to
some good simplifications and rationalization.  So, this commit:
 - corrects "mixed" functionality: int[A] f[B] -> f[B][A]
 - correct multi-identifier decls: int[A] f[B], g[C] -> f and g are independently sized.
 - increases symmetry between different places in the code that do this
 - makes fewer ways to do the same thing; several methods are just gone now
 - makes more clear when something is copied or shared
2018-03-26 00:38:53 -06:00
John Kessenich
5d610ee1dc Implement SPV_GOOGLE_hlsl_functionality1.
Enabled via -fhlsl_functionality1
2018-03-16 20:21:44 -06:00
Neil Roberts
eddb1318ae Use the correct type for the constant for matrix/scalar division
When a matrix is divided by a scalar it tries to take the reciprocal
of the scalar to convert the operation into a multiply. However it was
always doing this by making a 32-bit constant. If the scalar is a
double then this would end up making an FDiv instruction with
different types in the operands.

This patch adds a helper method called makeFpConstant which makes a
floating-point constant of the given type. The code to take the
reciprocal now uses it to make the same type as the result.

Fixes https://github.com/KhronosGroup/glslang/issues/1278
2018-03-13 13:50:56 +01:00
John Kessenich
ac3707921e Revert the commits that change OpArrayLength type and bumped the version number.
Now, version 5.* is all connected to making the uint type, which doesn't quite work.
Generator versions 4 and 6 do not do this.
2018-03-07 11:48:25 -07:00
John Kessenich
66011cb2c2 SPV: Implement Vulkan 1.1 features and extensions. 2018-03-06 16:12:04 -07:00
John Kessenich
c6c80a6e48 Versioning: Address #1255: Move to semantic versioning.
Still missing is automation and final decisions on mechanisms in general.
2018-03-05 22:23:17 -07:00
John Kessenich
0216f24f0e SPV: Bump up the generator number. 2018-03-03 11:47:07 -07:00
Rex Xu
1e5d7b0b27 Implement the extension GL_AMD_gpu_shader_half_float_fetch
- Support new opaque types: f16sampler*, f16image*, f16subpassInput*.
- Add new built-in GLSL texture/image functions.
2018-03-02 16:48:03 +08:00
John Kessenich
c5215791f5 IO mapper: Fix #1261: Supply location mapper with size computer.
This factored computeTypeLocationSize() out of needing the TIntermediate contents,
and uses it to show how to know how many locations an object needs.
However, it still does not do cross stage, or mixed location/no-location
analysis.
2018-02-27 13:31:48 -07:00
John Kessenich
4bee531fc1 HLSL: Fix #1249: Always execute both sides of ternary "?:".
This is semantically required by HLSL, and frequently results in using
OpSelect instead of control flow.
2018-02-20 21:32:33 -07:00
LoopDawg
4425f245a5 HLSL: Add conversions for image ops during SPV construction
HLSL allows image and texture types to be templatized on sub-vec4 types,
or even structures.  This was mostly handled already during creation of
sampling operations.  However, for operator[] which can generate image
loads, this wasn't happening.

It also isn't very easy to do at that point in time, because operator[]
does not know where the results it produces will end up.  They may be
an lvalue or an rvalue, and there's a post-process to convert loads to
stores.  They may end up in atomic ops.

To bypass that difficulty, GlslangToSpv now looks for this case and
adds the appropriate conversion.  LIMITATION: this only works for
cases for which a simple conversion opcode suffices.  That is to say,
it will not work if the type is templatized on a struct.
2018-02-18 13:13:36 -07:00
GregF
8a4848f5b2 Add DeadInsertElim to legalization and RedundancyElim to -Os. 2018-02-07 16:04:42 -07:00
John Kessenich
71b5da60d0 SPV: Bump up generator number, because previous commit changes code gen slightly. 2018-02-06 08:06:36 -07:00
John Kessenich
a2858d9bdd GLSL: Implement GL_EXT_control_flow_attributes.
See https://github.com/KhronosGroup/GLSL/pull/11.
2018-02-01 00:55:08 -07:00
John Kessenich
e18fd20d5c HLSL: Refactor attribute implementation.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
2018-02-01 00:30:34 -07:00
John Kessenich
2b5ea9f851 SPV Version: Emit the requested SPIR-V version, not the header version.
Fixes #1236.
2018-01-31 18:41:59 -07:00
Frank Henigman
541f7bbd50 Fix unused function warning.
TGlslangToSpvTraverser::getExtBuiltins is only used when AMD_EXTENSIONS
is defined, so only define it in that case to avoid an unused function
warning.
2018-01-16 00:18:26 -05:00
GregF
e0639287df HLSL Legalization: Add scalar replacement
This allow for propagation through structs with dynamically indexed
arrays. This supports recent removal of non-io struct flattening.
2017-12-21 11:30:13 -07:00
John Kessenich
3f0d4bcd6a SPV: Document history of the generator version number. 2017-12-16 23:46:37 -07:00
John Kessenich
838d7afc61 SPV: HLSL: Move to correct HLSL barrier semantics, per Khronos recommendation. 2017-12-16 00:34:08 -07:00
John Kessenich
c72e5937dd SPV: Bump the generator number to account for barrier changes. 2017-12-16 00:34:08 -07:00
John Kessenich
8297936dd6 SPV: Change barrier emission to conform to Khronos decisions.
The memory model group agreed to these definitions for how
to map GLSL barrier, memoryBarrier, etc. With HLSL following suit.
2017-12-16 00:30:10 -07:00
John Kessenich
edaf556778 SPV: Plumb through XFB buffer and stride information.
Also, only emit this XFB information where the SPIR-V spec says
it should be emitted: essentially, on objects.

This and the previous commit together fix #1185.
2017-12-15 06:25:14 -07:00
Piers Daniell
1c5443c693 Add implementation of SPV_EXT_fragment_fully_covered
This implementation uses the GLSL extension
GL_NV_conservative_raster_underestimation to generate the new SPIR-V
FullyCoveredEXT built in.
2017-12-14 07:42:23 -07:00
John Kessenich
6a14f78061 HLSL: Fix #1163: treat buffers as references when calling functions.
This continues to prevent writing output buffers (out from a function),
but fixes the problem where the copy-in/out was not getting done.

Making everything work will require knowing both in/out-ness and bufferness,
but these are currently mutually exclusive, because both are storage
qualifiers.
2017-12-04 02:48:10 -07:00
John Kessenich
cbdf871d7f SPV: SampleMask does not depend on SampleRateShading.
Fixes #1158.
Fixes #1159.
2017-11-20 16:32:49 -07:00
John Kessenich
a372a3ed1e Versioning: Update some version strings. Still need better overall version. 2017-11-02 22:34:43 -06:00
GregF
cc80d80d8d Update spirv-tools known-good 2017-10-23 16:48:42 -06:00
John Kessenich
fe4e572c53 GLSL->SPIR-V: Put precision decorations on imageLoad(). 2017-10-19 02:07:30 -06:00
John Kessenich
07ed11f9a0 SPV: GeneratorVersion: bump version number because of atomic decrement change. 2017-10-07 11:41:20 -06:00
John Kessenich
48d6e798bc SPV: Correct semantics of atomic-counter decrement.
The semantics differ between GLSL/HLSL and SPIR-V.
Translate between these.
2017-10-06 21:21:48 -06:00
John Kessenich
d41993d9d2 SPV: rationalize parameter handling for "original" and "writable" parameters. 2017-09-29 09:58:11 -06:00
John Kessenich
bed4e4f7e4 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.
2017-09-29 09:57:00 -06:00
GregF
cd1f169c6a 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.
2017-09-27 15:06:05 -06:00
Rex Xu
e8fe8b0de9 Implement extension GL_NV_shader_atomic_int64 2017-09-27 12:06:27 +08:00
John Kessenich
5f77d864f3 HLSL: Fix #1064: Don't include empty structures on OpEntryPoint 2017-09-19 11:23:58 -06:00
LoopDawg
a5d8616478 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.
2017-09-14 16:50:37 -06:00
John Kessenich
ba6a3c290e 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.
2017-09-13 13:22:50 -06:00
amhagan
05506bb874 Implement the extension GL_AMD_shader_fragment_mask 2017-09-09 22:05:24 +08:00