Commit Graph

717 Commits

Author SHA1 Message Date
Dan Sinclair
257b25c81f Add BUILD.gn configuration.
This CL adds the necessary configuration to build glslang inside a
Chromium checkout. Two build warnings were fixed in the process to
make things compile.
2018-09-24 16:57:55 -04:00
Chao Chen
5b2203db04 Add-support-for-SPV_NV_shading_rate 2018-09-19 13:07:43 -07:00
Chao Chen
b50c02ef53 Add-support-for-SPV_NVX_raytracing 2018-09-19 13:07:43 -07:00
Chao Chen
3c3669904c Add-support-for-SPV_NV_mesh_shader 2018-09-19 13:07:43 -07:00
Chao Chen
3a1379667d 0003-Add-support-for-SPV_NV_shader_image_footprint 2018-09-19 13:07:42 -07:00
Chao Chen
beae2251b7 Add-support-for-SPV_NV_compute_shader_derivatives 2018-09-19 13:07:42 -07:00
Chao Chen
9eada4b971 Add-support-for-SPV_NV_fragment_shader_barycentric 2018-09-19 13:07:42 -07:00
John Kessenich
6dd4757f0f Update to latest spirv.hpp header (which fixed a typo). 2018-09-19 13:58:01 -06:00
John Kessenich
7105cb308a SPV: Move to latest SPIR-V header (latest NV extensions support). 2018-09-19 03:54:48 -06:00
John Kessenich
d122a72852 Build: Fix some warnings. 2018-09-18 03:43:30 -06:00
Dennis Luxen
fc89f065e9
Fix compiler warning emitted from GCC8
the following warning gets emitted:

```
In file included from ./Vulkan/glslang/SPIRV/hex_float.h:39,
                 from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/bitutils.h: In instantiation of ‘Dest spvutils::BitwiseCast(Src) [with Dest = spvutils::Float16; Src = short unsigned int]’:
./Vulkan/glslang/SPIRV/hex_float.h:138:47:   required from ‘T spvutils::FloatProxy<T>::getAsFloat() const [with T = spvutils::Float16]’
./Vulkan/glslang/SPIRV/hex_float.h:821:52:   required from here
./Vulkan/glslang/SPIRV/bitutils.h:29:14: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class spvutils::Float16’; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
   std::memcpy(&dest, &source, sizeof(dest));
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/hex_float.h:43:7: note: ‘class spvutils::Float16’ declared here
 class Float16 {
       ^~~~~~~
In file included from ./Vulkan/glslang/SPIRV/hex_float.h:39,
                 from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/bitutils.h: In instantiation of ‘Dest spvutils::BitwiseCast(Src) [with Dest = spvutils::FloatProxy<spvutils::Float16>; Src = short unsigned int]’:
./Vulkan/glslang/SPIRV/hex_float.h:431:28:   required from ‘void spvutils::HexFloat<T, Traits>::setFromSignUnbiasedExponentAndNormalizedSignificand(bool, spvutils::HexFloat<T, Traits>::int_type, spvutils::HexFloat<T, Traits>::uint_type, bool) [with T = spvutils::FloatProxy<spvutils::Float16>; Traits = spvutils::HexFloatTraits<spvutils::FloatProxy<spvutils::Float16> >; spvutils::HexFloat<T, Traits>::int_type = short int; spvutils::HexFloat<T, Traits>::uint_type = short unsigned int]’
./Vulkan/glslang/SPIRV/hex_float.h:633:5:   required from ‘void spvutils::HexFloat<T, Traits>::castTo(other_T&, spvutils::round_direction) [with other_T = spvutils::HexFloat<spvutils::FloatProxy<spvutils::Float16>, spvutils::HexFloatTraits<spvutils::FloatProxy<spvutils::Float16> > >; T = spvutils::FloatProxy<float>; Traits = spvutils::HexFloatTraits<spvutils::FloatProxy<float> >]’
./Vulkan/glslang/SPIRV/hex_float.h:817:39:   required from here
./Vulkan/glslang/SPIRV/bitutils.h:29:14: warning: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class spvutils::FloatProxy<spvutils::Float16>’ from an array of ‘short unsigned int’ [-Wclass-memaccess]
   std::memcpy(&dest, &source, sizeof(dest));
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./Vulkan/glslang/SPIRV/SpvBuilder.cpp:49:
./Vulkan/glslang/SPIRV/hex_float.h:115:7: note: ‘class spvutils::FloatProxy<spvutils::Float16>’ declared here
 class FloatProxy {
       ^~~~~~~~~~
```
2018-09-12 10:34:54 +02:00
John Kessenich
afe0c66f65 SPV: Fix #1487: Only declare AMD int16/half_float extensions when needed. 2018-09-10 18:10:51 -06:00
John Kessenich
ddfb4a8022 Merge branch 'jeffbolznv-memory_scope_semantics' 2018-09-07 08:58:53 -06:00
Jeff Bolz
36831c9bad GL_KHR_memory_scope_semantics 2018-09-06 20:36:14 -05:00
John Kessenich
97068d8b30
Merge pull request #1465 from otakuto/remove-execute-permissions
Remove execute permissions
2018-08-31 08:14:47 -07:00
Denis Zdorovtsov
949344f081
Update SpvTools.cpp
Fix build.
2018-08-31 17:36:15 +03:00
John Kessenich
4e11b615db SPV: Turn off the default validation done by the SPIRV-Tools optimizer.
Also use the glslang namespace qualifier consistently and validate after
legalization, not before. (But most tests don't legalize.)
2018-08-30 16:59:13 -06:00
John Kessenich
c340425bb2 SPV: Add option for controling when the SPIRV-Tools validator is used. 2018-08-23 15:29:08 -06:00
John Kessenich
717c80a9de SPV: Isolate SPIRV-tools glue to its own file. 2018-08-23 15:17:10 -06:00
John Kessenich
cc14f2d329 SPV: Add SPIRV-Tools validator. This needs the latest SPIR-Tools. 2018-08-23 13:46:48 -06:00
John Kessenich
e7df8e0b76 Non-functional: Rationalize some existing use of SPIRV-Tools. 2018-08-22 17:12:46 -06:00
David Neto
9fd2a8cdfc Use our own SPIRV-Tools message stringifier
Stop including an internal SPIRV-Tools header. It has been
deleted.

Fixes #1477
2018-08-20 10:36:27 -04:00
John Kessenich
31aa3d6019 SPV: only declare the pure 8/16-bit capabilities when needed.
Only when operations stray outside the 8/16-bit storage-capabilities
are the general (pure 8/16-bit) capabilities needed.
2018-08-16 15:54:21 -06:00
John Kessenich
149afc3930 SPV: More corrections of <id> versus "immediate" operands. 2018-08-14 13:31:43 -06:00
John Kessenich
228e964bcc SPV: Correct SPIR-V operands for <id> versus immediate. 2018-08-13 21:37:59 -06:00
John Kessenich
c4510e5ebc
Merge pull request #1466 from Kangz/warning_fixes
Fix -Wignored-qualifier and -Wunused-variable warnings
2018-08-09 12:49:56 -07:00
Corentin Wallez
e70614223f Fix -Wignored-qualifier and -Wunused-variable warnings 2018-08-09 14:54:33 +02:00
otakuto
d03da06ac1 Remove execute permissions 2018-08-07 03:16:20 +09:00
John Kessenich
f04c51b3bd Non-Functional: Add postprocess as more robust way to add capabilities
When capabilities are needed for specific SPIR-V instructions, it is
fragile to do so based on GLSL/AST usage; it should be based on actual
instructions they got translated to.
2018-08-03 15:56:12 -06:00
John Kessenich
5a7321eb03 Merge branch 'master' of https://github.com/zeux/glslang into zeux-master 2018-07-20 17:11:44 -06:00
John Kessenich
ebd989dd58
Merge pull request #1437 from mattparks/patch-2
CMake options for postfix and SPVRemapper.
2018-07-18 17:15:32 -07:00
Jeff Bolz
c140b96892 Add missing OpExtension SPV_EXT_descriptor_indexing for dynamic indexing capabilities 2018-07-12 16:51:18 -05:00
Matthew Albrecht
857f25cfd2 Added the cmake option to disable building SPVRemapper. 2018-07-07 16:54:34 -05:00
Arseny Kapoulkine
112e2858cf SPIRV: Simplify matrix->matrix constructor
When constructing a matrix from another matrix with smaller dimensions,
there's no need to extract the scalars out of columns and rebuild the
resulting matrix from scalars - instead, we can just construct shorter
vectors with OpShuffle and combine them to the final result.

This keeps the common casts such as mat3(mat4) in vector registers,
which may improve performance for some GPUs, and cleans up output of
translation tools like SPIRV-Cross.

Fixes #1412.
2018-07-05 15:55:12 -07:00
Lei Zhang
a2c39a2947 Use public SPIRV-Tools header 2018-07-04 14:53:45 -04:00
John Kessenich
312dcfb070 Implement GL_EXT_shader_16bit_storage and GL_EXT_shader_8bit_storage extensions.
These introduce limited support for 8/16-bit types such that they can only be accessed in buffer memory and converted to/from 32-bit types.

Contributed from Khronos-internal work.
2018-07-03 13:51:31 -06:00
John Kessenich
e2156222d3 SPV: Add option to print disassembly in standard form using SPIRV-Tools. 2018-07-02 15:54:12 -06:00
GregF
c6831d1ed4 Add support for OpConstantNull and OpConstantSampler to spirv-remap
Fixes issue #1408
2018-06-19 13:51:28 -06:00
John Kessenich
ba018e6762 SPV: Fix #1399 emit ImageGatherExtended when using ConstOffsets operand 2018-06-05 08:53:36 -06:00
John Kessenich
ad7645f4f5 Fix #1360: uint->int width conversions must still be typed as uint. 2018-06-04 20:09:30 -06:00
John Kessenich
14b85d3ff3 Fix #1395: GLSL volatile maps to SPIR-V Volatile and Coherent.
The major version number was bumped in the previous commit to support
this.
2018-06-04 15:36:03 -06:00
John Kessenich
d6c975572e Change the major revision number for next commit. 2018-06-04 15:33:31 -06:00
John Kessenich
32d3ec3199
Merge pull request #1394 from greg-lunarg/kg20
Update spirv-tools known-good.
2018-05-31 18:31:18 -06:00
GregF
b0c42b2884 Update spirv-tools known-good.
Includes:

Fold FMix feeding Extract, and use the simplification pass.
2018-05-31 16:17:18 -06:00
John Kessenich
b91189dbe5
Merge pull request #876 from ligfx/cmaketargetincludedirectories
CMake: use target_include_directories to expose includes
2018-05-27 19:29:42 -06:00
Michael Maltese
a895f378ee CMake: use target_include_directories to expose includes
This makes glslang simpler to embed in larger projects.
2018-05-27 11:36:32 -07:00
Jeff Bolz
af7a94876c Add bit width of types to disassembleInstruction 2018-05-24 21:08:20 -05:00
Rex Xu
b4a2a6cf94 Fix issue #1376: SPV_AMD_gpu_shader_half_float is not emitted under
vulkan1.1

Interpolation functions, using 16-bit interpolants, should always emit
this extension string regardless of vulkan enviornment version.
2018-05-17 13:51:28 +08:00
John Kessenich
1831087e48 SPV: Fix #1374: For an SSBO 16-bit access, only emit StorageUniformBufferBlock16 capability. 2018-05-14 22:08:53 -06:00
John Kessenich
d3ed90be3a Fix #944: Convert argument type to match formal parameter type. 2018-05-04 11:43:03 -06:00
Matthew Albrecht
1199cf92f7 Fixed install for SPIRV, glslang, and hlsl when building shared libs 2018-04-26 14:07:46 -05:00
Rex Xu
7c88aff1a9 Specify SPV_AMD_gpu_shader_int16 extension string when frexp() takes 16-bit
exp operand
2018-04-14 21:40:49 +08:00
John Kessenich
b9e9e57f12
Merge pull request #1326 from mattparks/patch1
Allowed for LIB_TYPE to be set to switch between static and shared libs for glslang, SPIRV, and HLSL
2018-04-11 18:14:46 -06:00
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
Matthew Albrecht
6c5f649ae8 Allowed for LIB_TYPE to be set to switch between static and shared libs for glslang, SPIRV, and HLSL 2018-03-30 09:32:03 -05:00
John Kessenich
10971553b8 Non-Functional: Remove unused parts of the disassembler. 2018-03-30 00:11:39 -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
97e35420a6 Non-functional: always return value from makeFpConstant().
Should fix #1308.
2018-03-22 23:44:11 -06:00
John Kessenich
5d610ee1dc Implement SPV_GOOGLE_hlsl_functionality1.
Enabled via -fhlsl_functionality1
2018-03-16 20:21:44 -06:00
John Kessenich
cb32c54466
Merge pull request #1289 from Igalia/igalia/dmat-scalar-division
Use the correct type for the constant for matrix/scalar division
2018-03-15 23:49:59 -06:00
Daniel Koch
bfe0952118 Fix build several build errors
glslang/SPIRV/SpvBuilder.cpp:2533:27: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
        for (int c = 0; c < accessChain.swizzle.size(); ++c)
                        ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

glslang/hlsl/hlslParseHelper.cpp:69:5: error: field 'cullDistanceInput' will be initialized after field 'clipDistanceOutput' [-Werror,-Wreorder]
    cullDistanceInput(nullptr),
    ^
1 error generated.

glslang/glslang/MachineIndependent/attribute.cpp:85:16: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
    if (argNum >= args->getSequence().size())
        ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2018-03-13 17:06:51 -04: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
a51525059f
Merge pull request #1269 from bkaradzic/master
Fixed GCC+Clang errors and warnings on Linux and OSX.
2018-03-07 14:31:57 -07: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
Branimir Karadžić
1de8e54d66 Fixed GCC+Clang errors and warnings on Linux and OSX. 2018-03-03 13:04:12 -08:00
Rex Xu
e518772dc9 SPV: The result type of OpArrayLength should be UINT 2018-03-03 22:06:27 +08:00
John Kessenich
e58d58b782 Non-functional: Move to latest headers. 2018-03-02 12:36:02 -07:00
John Kessenich
29c49e1089
Merge pull request #1266 from amdrexu/feature
Implement the extension GL_AMD_gpu_shader_half_float_fetch
2018-03-02 11:23:15 -07:00
Rex Xu
81f4c03a76 Fix issues of SPIRV headers 2018-03-02 17:42:37 +08: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
5630d0ec79 Fix typo. 2018-03-02 01:09:28 -07: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
46413d5780 SPV: Fix #1258: cache constant structs by id, not opcode.
Constants were generally cached by type opcode, but all structures share the
same type opcode (OpTypeStruct), so they need to be cached by type id.
2018-02-26 19:35:39 -07:00
John Kessenich
57f6a016f0 SPV: Complete OpModuleProcessed implementation, enabled by have 1.2 headers. 2018-02-22 19:36:18 -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
5c3eed542d SPV: Create more access chains addressing a few swizzling issues.
- Fixes #1233
- Treats local bools like anything else
- more consistently deals with a dynamic component selection
2018-02-06 07:24:12 -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
John Kessenich
43f5b27321 Non-Functional: Use OpModuleProcessed from the unified header. 2018-01-31 18:06:44 -07:00
John Kessenich
6c1c2766b6 SPV: Bump SPIR-V header to the unified1 version (version 1.2). 2018-01-29 16:16:11 -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
2505057af8 SPV: Memory model: Reduce set of memory-semantic bits requested for "all". 2017-12-16 00:34:08 -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
e9e0cb60ec Update to latest public headers. 2017-12-14 03:00:44 -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
e86b4c84d6 Remapper: Fix strip algo when strip ranges overlap 2017-11-02 14:01:57 -06:00
GregF
cc80d80d8d Update spirv-tools known-good 2017-10-23 16:48:42 -06:00
John Kessenich
7a9db71f46 SPV: Don't emit StorageImageMultisample capability for subpass images. 2017-10-20 10:56:50 -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
9cf5dfbdc7 Merge pull request #1063 from LoopDawg/remapper-error-cleanup
Remapper: make remapper robust against non-exiting error handlers
2017-09-23 06:32:02 -06:00
GregF
fd34f0e602 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.
2017-09-21 17:01:47 -06:00
LoopDawg
8004d36528 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.
2017-09-20 15:19:43 -06: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
John Kessenich
4f4683d251 Merge pull request #1050 from amdrexu/feature
Implement the extension GL_AMD_shader_fragment_mask
2017-09-12 09:09:37 -06:00
John Kessenich
ea1ea974eb Address #1052: Have language-level exits of case statements. 2017-09-11 19:25:17 -06:00
amhagan
05506bb874 Implement the extension GL_AMD_shader_fragment_mask 2017-09-09 22:05:24 +08:00
LoopDawg
76117921b9 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.
2017-09-06 15:04:52 -06:00
LoopDawg
2baa774259 Linux build warning fix
* Remove complaint about unused function parameter in resolveUniformLocation()
* Remove complaint about defined but not used variable in spvIR.h
2017-08-31 18:09:58 -06:00
John Kessenich
8268a35504 Build: Attempt better support for VS 2012.
Fix #1020. Fix #1021. Fix #1022.
2017-08-25 21:35:37 -06:00
John Kessenich
74c5f711b4 Merge pull request #1014 from KhronosGroup/SPV_EXT_shader_viewport_index_layer
SPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer.
2017-08-25 13:33:16 -06:00
John Kessenich
35343cb84d Merge pull request #1034 from KhronosGroup/module-processes
SPV reflection: Add OpModuleProcessed for compile options.
2017-08-25 13:05:54 -06:00
John Kessenich
b41bff69d2 SPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer. 2017-08-25 13:04:39 -06:00
John Kessenich
2a27116cae SPV reflection: Add OpModuleProcessed for compile options. 2017-08-25 11:48:02 -06:00
John Kessenich
fc3436941e Merge pull request #1029 from amdrexu/feature2
Implement extension GL_AMD_shader_image_load_store_lod
2017-08-23 23:13:19 -06:00
Rex Xu
129799a709 Implement extension GL_AMD_shader_image_load_store_lod 2017-08-24 06:56:39 +08:00
Rex Xu
e8fdd79f2e SPV: Implement extension SPV_EXT_shader_stencil_export 2017-08-24 06:26:15 +08:00
John Kessenich
786e8795ee Build: Fix build when NV_EXTENSIONS is not enabled. 2017-08-19 15:54:49 -06:00
John Kessenich
d6be6da031 SPV: Fix #1016: Don't allow non-GLSL-extension protected Layer and ViewportIndex members. 2017-08-17 23:49:39 -06:00
John Kessenich
260f50616a 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.
2017-08-14 22:10:00 -06:00
John Kessenich
0d0c6d38f0 GLSL 4.6: Implement atomic counter ops and SPV_KHR_shader_atomic_counter_ops. 2017-07-31 03:00:04 -06:00
Rex Xu
286ca432cf SPV: Memory qualifiers should decorate top-level block members 2017-07-27 14:33:16 +08:00
John Kessenich
d2d3a14237 SPV: Update to latest 1.0 headers, removing redundancies in GLSL.ext.AMD.h. 2017-07-25 21:03:29 -06:00
LoopDawg
ef94b1a5ca Fix dref explicit LOD form of sample with cube texture arrays
The dref parameter was being used as the LOD.  Now it it's properly the dref.
2017-07-24 18:45:37 -06:00
John Kessenich
961cd35b73 SPV: Fix #995: Include memory decorations on parameters. 2017-07-18 03:07:43 -06:00
John Kessenich
fad6297206 SPV: Non-functional: support lists of decorations per parameter. 2017-07-18 02:46:59 -06:00
John Kessenich
735d7e56a6 Address part A of #982: $Global will use std140 instead of HLSL offsets.
From comment about this:
Adjust alignment for HLSL rules
TODO: make this consistent in early phases of code: adjusting this late means inconsistencies with earlier code, which for reflection is an issue.
Until reflection is brought in sync with these adjustments, don't apply to $Global,
which is the most likely to rely on reflection, and least likely to rely
implicit layouts.
2017-07-13 11:39:16 -06:00
Rex Xu
57e65929e4 HLSL: Translate directive [flatten] and [branch] to SPV control mask. 2017-07-06 11:31:33 +08:00
John Kessenich
9645f78293 Merge pull request #965 from chaoc/spv-khr-post-depth-coverage
Implement SPV_KHR_post_depth_coverage
2017-07-05 14:48:19 -06:00
chaoc
c120452754 Implement SPV_KHR_post_depth_coverage
Added support for both extension GL_ARB_post_depth_coverage and GL_EXT_post_depth_coverage.
2017-07-05 12:27:15 -07:00
John Kessenich
17b5f9175d Merge pull request #969 from d3x0r/patch-1
Add option to skip installation
2017-07-04 11:00:42 -06:00
Rohith Chandran
6206091e63 Fix CMake scripts: The set_property script can be used to set only a single property, so now setting the POSITION_INDEPENDENT_CODE property correctly. 2017-07-04 10:53:45 -04:00
d3x0r
4e53d9052d Update CMakeLists.txt 2017-07-04 06:00:35 -07:00
Rex Xu
37cdceed41 Implement extension GL_ARB_shader_stencil_export 2017-06-29 17:50:46 +08:00
John Kessenich
e2ff404f6b Merge pull request #917 from KhronosGroup/remove-redundant-locations
Replace #422: Remove the redundant location setting in AST->SPIR-V.
2017-06-15 12:11:37 -06:00
Rex Xu
301a2bc8a7 SPV: Fix an typo of SPV_AMD_texture_gather_bias_lod 2017-06-14 23:09:39 +08:00
Rex Xu
cabbb788b4 Implement extension GL_AMD_gpu_shader_int16
- Add int16 types (int16_t, uint16_t, i16vec, u16vec).
- Add int16 support to GLSL operators.
- Add int16 type conversions (to int16, from int16).
- Add int16 built-in functions.
2017-06-09 17:11:23 +08:00
Rex Xu
225e0fcadd Implement the extension GL_AMD_texture_gather_bias_lod 2017-06-05 16:41:06 +08:00
John Kessenich
7cdf3fc3c6 Replace #422: Remove the redundant location setting in AST->SPIR-V.
This was redundant in two ways:
1) it replicated algorithms owned in the front end, and
2) it sometimes left location information on both a block and its members.
2017-06-04 13:22:39 -06:00
John Kessenich
e485c7af58 SPV: Debug output: Include OpLine information for execution path.
Note that declaratives are not handled, only procedurals.
2017-05-31 18:50:53 -06:00
John Kessenich
121853f4df SPV: Add OpSource shader source code and file name. 2017-05-31 17:14:15 -06:00
John Kessenich
d6af18f621 Merge pull request #901 from LoopDawg/imat-construct
HLSL: Add imat, umat, and bmat constructors
2017-05-24 23:12:58 -06:00
John Kessenich
84cc15f0d0 HLSL: Fix #903: Don't short-circuit && or ||. 2017-05-24 16:47:32 -06:00
LoopDawg
174ccb8f1d HLSL: Add imat, umat, and bmat constructors
Fixes #894
2017-05-20 21:54:16 -06:00
John Kessenich
7b8c386c5d More non-determinism fixed. 2017-05-19 23:44:51 -06:00
John Kessenich
b6cabc4f24 Fix C++ portability, non-deterministic order of argument evaluation. 2017-05-19 23:29:50 -06:00
John Kessenich
80f92a190a Fix #857: Convert uniform int to local bool for struct alias assignment.
This was done for one direction, but not both directions, so this commit
picks up the other direction.
2017-05-19 23:00:13 -06:00
John Kessenich
0d2b4713c5 HLSL: Don't do logical short-circuits when the operands are bool-vectors.
This seems a bit ill-defined, and was generating code that made OpPhi of two
operands that were Boolean vectors result in a scalar bool.
2017-05-19 20:19:00 -06:00
LoopDawg
65c2eed65d Remapper: handle embedded opcode in OpSpecConstantOp
OpSpecConstantOp contains an embedded opcode which is given as a literal
argument to the OpSpecConstantOp.  The subsequent arguments are as the
embedded op would expect, which may be a mixture of IDs and literals.  This
adds support for that to the remapper binary parser.  Upon seeing such an
embedded op, the parser flips over to parsing the argument list as
appropriate for that opcode.

Fixes #882.
2017-05-18 16:13:04 -06:00
Lei Zhang
2840f63fbc Use unordered_set in ReadableOrderTraverser.
Previously we are using unordered_map to map to bool, which can
be simplified with unordered_set.
2017-05-11 20:48:34 -04:00
Aras Pranckevicius
23d3c712bc [lumped builds] Add include guards (#pragma once) to header files that did not have any.
The codebase seems to use both “#pragma once“ approach, and “#ifndef / #define” approach,
so I picked pragma once as that one is less typing & less brittle.

When glslang is built with some other build system and lumped/unity builds are used,
without the include guards some headers would get included multiple times, leading to duplicate
declaration errors.
2017-05-10 16:58:38 +03:00
John Kessenich
a5c5fb6118 SPV: Emit extension for using StorageClassStorageBuffer. 2017-05-05 05:09:58 -06:00
steve-lunarg
f1709e7146 HLSL: implement [unroll] and [loop] attributes
This adds infrastructure suitable for any front end to create SPIR-V loop
control flags.  The only current front end doing so is HLSL.

[unroll] turns into spv::LoopControlUnrollMask
[loop] turns into spv::LoopControlDontUnrollMask
no specification means spv::LoopControlMaskNone
2017-05-03 13:44:40 -06:00
David Seifert
22afc38b55 Modernise CMake #2
This reverts commit cfc69d95af.
* Change CMAKE_INSTALL_PREFIX default on Windows in order
  to prevent permission denied errors when trying to install
  to "Program Files".
2017-04-29 11:23:15 +02:00
John Kessenich
cfc69d95af Revert "Modernise CMake" 2017-04-28 22:04:24 -06:00
David Seifert
5a5699bdbd Modernise CMake
* Use `GNUInstallDirs` in order to respect GNU conventions.
  This is especially important for multi-arch/multi-lib setups.
* Specify position independent mode building properly, without
  using the historic hack of adding `-fPIC` as a definition.
  This makes the build system more portable.
* Only detect C++ (and not C) to slightly speed up configuring.
* Specify C++11 mode using modern CMake idioms.
* Fix some whitespace issues.
2017-04-28 22:46:52 +02:00
John Kessenich
670271890d SPV: Support test #pragma for generating the StorageBuffer storage class.
Longer term, this storage class should be generated based on the mode
of compilation.
2017-04-19 18:34:49 -06:00
John Kessenich
d1141843c0 SPV Non-functional: fix ordering causing problems with another branch. 2017-04-13 17:08:11 -06:00
John Kessenich
ae79697db1 Merge pull request #827 from amdrexu/feature4
Implement the extension SPV_KHR_16bit_storage
2017-04-08 10:03:45 -06:00
John Kessenich
a09eefd8aa Non-functional: Fix typos in comments. 2017-04-07 15:40:30 -06:00
John Kessenich
6fa17641b5 HLSL: Emit the OpSource HLSL instruction for HLSL, using new headers. 2017-04-07 15:40:01 -06:00
Rex Xu
f89ad98013 Implement the extension SPV_KHR_16bit_storage 2017-04-07 23:22:33 +08:00
John Kessenich
38a425355b SPV: Move to latest public headers. 2017-04-06 17:21:58 -06:00
John Kessenich
4f1403ed1b SPV: Fix #807: use --hlsl-offsets to allow hlsl-style offsets in a buffer.
Corresponds to the EShMsgHlslOffsets flag in messages.
Works for both GLSL and HLSL.
2017-04-05 17:38:20 -06:00
steve-lunarg
e741249b72 HLSL: pass tessellation execution modes through to SPIR-V
The SPIR-V generator had assumed tessellation modes such as
primitive type and vertex order would only appear in tess eval
(domain) shaders.  SPIR-V allows either, and HLSL allows and
possibly requires them to be in the hull shader.

This change:

1. Passes them through for either tessellation stage, and,

2. Does not set up defaults in the domain stage for HLSl compilation,
to avoid conflicting definitions.
2017-03-31 11:47:18 -06:00
John Kessenich
e434ad923e Fix #809: smear scalar condition in OpSelect for selecting vector operands. 2017-03-30 10:16:22 -06:00
John Kessenich
714e58b2fc Merge pull request #801 from amdrexu/bugfix
HLSL: Fix an issue of frexp().
2017-03-29 10:04:30 -06:00
Rex Xu
bcf291a7ba Don't emit NV-specific interface members if NV extensions are disabled. 2017-03-29 23:01:36 +08:00
Rex Xu
470026f9d7 HLSL: Fix an issue of frexp().
The "exp" parameter is floating-point type in HLSL intrinsic while it is
integer type in GLSL built-in function.
2017-03-29 17:12:40 +08:00
John Kessenich
aa3c64c214 Fix #800 (mostly): set of Linux warnings. 2017-03-28 09:52:38 -06:00
John Kessenich
0e7378446b Fix #790: Don't emit NV-specific interface members unless enabled by extension. 2017-03-24 18:40:40 -06:00
John Kessenich
3778979cd4 HLSL: non-static member functions: track and find active anonymous 'this' scopes and members.
Thanks to @steve-lunarg for his input and discussions on handling member functions.
2017-03-21 23:56:40 -06:00
John Kessenich
4960baaf66 HLSL: Basic turn on of non-static member functions.
Still need: pass by reference in SPIR-V and symbol-table level
for accessing 'this' members from member functions.
2017-03-19 18:09:59 -06:00
Rex Xu
5e317ffe40 SPV: Fix unexpected declarations of capability and extension 2017-03-16 23:02:39 +08:00
steve-lunarg
0b5c2ae70e Preserve signedness in SPV image query ops
The AST->SPIRV translation of image queries was dropping signedness,
causing some validation troubles.
2017-03-10 12:51:59 -07:00
John Kessenich
0479437a5c SPV: Fix #739: OpSelect can only operate on scalars and vectors. 2017-03-01 13:49:11 -07:00
John Kessenich
69a2c69649 Merge pull request #736 from steve-lunarg/structbuffer-params
HLSL: add structuredbuffer pass by reference in fn params
2017-02-28 13:10:51 -07:00
John Kessenich
42e33c9bec SPV: Update SPV header to official Rev. 10 of 1.0, and fix the consequences of doing so. 2017-02-27 01:50:28 -07:00
John Kessenich
6c8aaacd28 SPV: Implement new extensions GL_KHX_device_group and GL_KHX_multiview.
These correspond to SPV_KHR_device_group and SPV_KHR_multiview.
Also, bring tests up to date with Khronos internals, and some misc. related changes.
2017-02-27 01:20:51 -07:00