Commit Graph

717 Commits

Author SHA1 Message Date
John Kessenich
39697cdb9d Web: Remove unnecessary GLSL numeric types, and some collateral.
This saves another 40K of x86 binary, which is about 13% of the target size.
2019-08-20 23:21:56 -06:00
John Kessenich
3e4b6ff76a Web: Tighten up sampling code and interfaces.
Saves about 9K.
2019-08-20 23:21:56 -06:00
John Kessenich
eaf4496312 Web: Complete the removal of vendor-specific #ifdef's, including CMake. 2019-08-20 23:21:56 -06:00
John Kessenich
a28f7a75d1 Web: Generalize _EXTENSIONS* in SPIR-V back-end.
About 50 fewer #ifdefs.
About 14K smaller.
Note, the base size is ill-defined due to optimizer settings (size vs. performance),
compression, and target architecture.  Some recent %'s are accidentally reported as
3X the real savings.  Early %'s were accurate.  What matters though is that each
step got worthwhile gains, and what the final size ends up being.
2019-08-20 23:21:55 -06:00
John Kessenich
7015bd658e Web: Remove/rationalize a set of *_EXTENSIONS, using GLSLANG_WEB.
Focus was on the front end (not SPIR-V), minus the grammar.
Reduces #ifdef count by around 320 and makes the web build 270K smaller,
which is about 90% the  target size.

The grammar and scanner will be another step, as will the SPIR-V backend.
This makes heavy use of methods #ifdef'd to return false as a global way
of turning off code, relying on C++ DCE to do the rest.
2019-08-20 23:21:55 -06:00
John Kessenich
23d27751e8 Web: Selectively remove a few key features, using #ifndef GLSLANG_WEB
Save about 100K.

N.B.: This is done by eliminating a function call, at a high level,
not by #ifdef'ing a bunch of code.

Also, removed no longer needed *_EXTENSION #ifdef in the code not
needed by GLSLANG_WEB.
2019-08-20 23:21:55 -06:00
James Rumble
c6f7294ced
Handle install vs build include directories
Fix target_include_directories to appropriately handle build-tree and the install-tree.
2019-08-06 15:29:31 +01:00
James Rumble
ab6d1499e1
Export glslang targets on installation
This allows the targets to be used in other cmake projects. See the following for more details:
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
https://foonathan.net/blog/2016/07/07/cmake-dependency-handling.html
2019-08-06 14:47:51 +01:00
John Kessenich
3cea2e5882 Bump revision and give the bots another chance to work. 2019-08-02 06:34:15 -06:00
John Kessenich
7fc8683491
Merge pull request #1813 from jeffbolznv/compositeconstruct
Handle SPIR-V type mismatch when constructing a composite
2019-07-28 23:20:26 -06:00
Ashwin Lele
c1e61d6cff Fix bugs in missing Builtin decoration for some NV builtins for tessellation
control shaders.
Fix bug in member remapping.
2019-07-22 12:36:38 -07:00
John Kessenich
2bb2da9193 SPV: Update to latest SPIR-V header. 2019-07-22 07:06:50 -06:00
Rex Xu
bb7307b4a8 OpIsHelperInvocationEXT should declare relevant SPV extension and capability 2019-07-15 14:57:20 +08:00
Jason Macnak
dbd4c3ce11 spirv: Generate missing SampleMaskOverrideCoverageNV capability op
The SampleMaskOverrideCoverageNV capability should be declared when
gl_SampleMask is used.
2019-07-12 14:33:02 -07:00
amhagan
91fb0091a2 Add support for SPV_KHR_shader_clock 2019-07-10 21:34:12 -04:00
Jeff Bolz
6a50a7850d update spirv-headers to pick up demote_to_helper_invocation 2019-07-02 10:58:15 -05:00
Jeff Bolz
ba6170b534 Implement GL_EXT_demote_to_helper_invocation 2019-07-01 09:36:15 -05:00
Jeff Bolz
531344905f Handle SPIR-V type mismatch when constructing a composite 2019-06-25 13:32:35 -05:00
Shahbaz Youssefi
6cca0e983e Remove extraneous semicolons
They cause a warning (-Wextra-semi) that can lead to a compile error
(-Werror).
2019-06-25 13:20:16 -04:00
John Kessenich
9c14f77f5d AST/SPV: Fix #930: translate uvec4 <-> uint64 for SubgroupGeMask et. al.
On reading built-in variables SubgroupEqMask, SubgroupGeMask, SubgroupGtMask,
SubgroupLeMask, and SubgroupLtMask, the AST expects 64-bit ints, while SPIR-V
is defined as vectors of 32-bit ints.

The declaration type has to be translated in the opposite direction.
2019-06-18 00:36:17 -06:00
John Kessenich
a9b00ac5d5
Merge pull request #1806 from KhronosGroup/nan-clamp
SPV: Add a switch for favoring non-NaN operands in min, max, and clamp.
2019-06-18 00:26:25 -06:00
John Kessenich
5d73a3c95c
Merge pull request #1698 from jeffbolznv/private_storage_variables
Add Float16/Int8/Int16 capabilities for private variables and function parameters
2019-06-17 23:42:13 -06:00
John Kessenich
605afc7b1b SPV: Add a switch for favoring non-NaN operands in min, max, and clamp. 2019-06-17 23:33:09 -06:00
Jeff Bolz
38a52fca93 Add gl_SemanticsVolatile to GL_KHR_memory_scope_semantics, and make volatile-qualified atomics generate MemorySemanticsVolatile when using the Vulkan memory model 2019-06-14 09:57:01 -05:00
Daniel Koch
2cb2f197a7 Add support for GL_NV_shader_sm_builtins
Including spirv and AST tests

Also increase size of TBuiltInVariable bitfields since we've now exceeded 127
and add a static_assert to make this easier to find next time it happens!
2019-06-08 08:53:11 -04:00
Jeff Bolz
fd556e32b3 Use spvValidatorOptionsSetBeforeHlslLegalization for pre-legalized HLSL 2019-06-07 14:42:08 -05:00
Jeff Bolz
c6f0ce8dbc Support GL_ARB_fragment_shader_interlock 2019-06-03 11:55:25 -05:00
Daniel Koch
593a4e0aa5 Fix subgroup support for ray tracing
Closes #1735

GlslangToSpv.cpp
- minor formatting cleanup

BaseTypes.h
- minor formatting cleanup
- add subgroup builtins to GetBuiltInVariableString
  (was resulting in "unknown built-in variable" messages in test output)

Initialize.cpp
- better naming and re-use of strings for subgroup builtin variable declarations
- define subgroup builtin variables in ray-tracing shaders

intermOut.cpp
- add handling of the EOpSubgroupParition* variables
  (was resulting in "ERROR: Bad aggregation op" messages in test output)

Update test results.
2019-05-31 14:17:36 -04:00
Daniel Koch
9bb17cd0eb Return consistent names from CapabilityString
Don't prefix with "Capability" since the majority of them don't.
Also add missing CapabilityImageFootprintNV
2019-05-28 15:23:10 -04:00
Matthew Albrecht
cda52d5333 Fixed .dll install on MSVC. 2019-05-23 19:06:44 -05:00
John Kessenich
6e384fef6c Build: Fix 3 warnings. 2019-05-10 06:47:00 -06:00
John Kessenich
b64952eddd SPV 1.4: Move to 1.4 validation, removing all 1.4 validation failures. 2019-05-10 00:02:45 -06:00
John Kessenich
f43c739ac5 SPV 1.4: Emit SignExtend and ZeroExtend for integer image reads/writes. 2019-05-10 00:02:45 -06:00
John Kessenich
61a5ce190a SPV 1.4: Lookup tables: Use variable initializer and NonWritable...
...when doing a variable lookup on an array of constants.
2019-05-10 00:02:45 -06:00
John Kessenich
fbb6bdf046 SPV 1.4: Add support for OpCopyLogical, careful of Boolean differences. 2019-05-10 00:02:45 -06:00
John Kessenich
1f4d04687b SPV 1.4: Implement the 5 new loop controls. 2019-05-10 00:02:45 -06:00
John Kessenich
0c1e71a123 SPV 1.4: Use OpSelect for trivial typed non-scalar/vector expressions. 2019-05-10 00:02:45 -06:00
John Kessenich
7c7731ecbb SPV 1.4: Generate all globals on OpEntryPoint interface list. 2019-05-10 00:02:45 -06:00
John Kessenich
2dd4ab3a4a SPV: Move to the SPIR-V 1.4 header. 2019-05-09 23:59:37 -06:00
Jeff Bolz
88220d507e For nonuniformEXT constructor, make a copy of the node to decorate 2019-05-08 10:24:46 -05:00
Jeff Bolz
faac86e5d6 If a shader's only use of float16 is for FConvert, add the Float16 capability.
When visiting instructions, check that there are no 16-bit storage capabilities
and add the Float16 capability. Same for int8/int16.
2019-05-01 11:45:51 -05:00
John Kessenich
3416d48b59 Update to latest SPIR-V header and bump revision. 2019-04-04 09:38:26 -06:00
Daniel Koch
8b2f96d3fe Check if _MSC_VER is defined before using.
Fixes compilation errors on some platforms.
2019-04-03 17:21:06 -04:00
John Kessenich
bd0f5ad278
Merge pull request #1733 from null77/fix-msvc-warn
Suppress MSVC warning about unused variable.
2019-03-18 23:41:27 +07:00
Jamie Madill
099a80dd76 Suppress MSVC warning about unused variable.
One variable was only used in an 'assert' call. MSVC flagged this
as unused in Release. Suppress the warning and also add a static
cast to void so the variable becomes referenced.
2019-03-18 11:38:53 -04:00
Panagiotis Christopoulos Charitos
35aeb042a2 Avoid running the validator as part of the optimization pass.
The spvtools::Optimizer::Run method glslang is using constructs a default set
of spvtools::OptimizerOptions. This default set of options instructs the
validator to run. That is not quite correct since glslang will invoke the
validator _explicitly_ after the optimization pass.

Change-Id: I30f458304c6e7f81e89fc4ebd25eabbbd8348063
2019-03-18 11:34:17 +01:00
John Kessenich
b184e41a06 Build: Update to the most recent SPIR-V headers, for Rev. 7 of SPV 1.3 2019-03-17 22:29:25 -06:00
John Kessenich
40c16ec0b3
Merge pull request #1717 from jeffbolznv/getBufferReferenceAlignment
Move getBufferReferenceAlignment to be a method of TType
2019-03-07 11:05:08 +07:00
Jeff Bolz
7895e473c3 Move getBufferReferenceAlignment to be a method of TType
This is a better place for it logically, since it is not specific to
glsl->spirv translation. And in a future change I want to use it outside
of glslangtospv.
2019-03-06 13:40:33 -06:00
Jeff Bolz
3fd1232665 Improved fix for buffer reference constants
This is an alternate fix for the issue described in commit be63facd, whose
solution didn't work if there were non-trivial operations involved in computing
a constant initializer which caused the 'constant unfolding' code to kick in
(addConstantReferenceConversion). Instead, this change does the 'unfolding'
later in createSpvConstantFromConstUnionArray. If a reference-type constant has
survived that long, then folding is already done, this must be a 'real' (inside
a function) use of the constant, and it should be safe to unfold and apply the
bitcast.
2019-03-06 09:28:29 -06:00
John Kessenich
79d25ea0ce
Merge pull request #1714 from jeffbolznv/volatil
Fix interactions between 'volatile' and the Vulkan memory model
2019-03-06 20:43:07 +07:00
John Kessenich
cc4a756d48 Build: Update to latest SPIR-V header. 2019-03-06 11:21:38 +07:00
Jeff Bolz
38cbad15ca Fix interactions between 'volatile' and the Vulkan memory model
Last year we changed 'volatile' to also act as 'coherent', but when I
resolved the memory model changes against that change I missed handling
volatile in a couple places that we check for coherent. There was also
a place in post-processing that acted as if the volatile memory access
flag has a literal number associated with it, when it doesn't.
2019-03-05 14:40:07 -06:00
Jeff Bolz
1994fe4523 Fix NV_EXTENSIONS-disabled build 2019-02-28 11:59:35 -06:00
Jeff Bolz
4605e2ed2b Implement GL_NV_cooperative_matrix 2019-02-25 23:42:59 -06:00
Nico Weber
76577b1aec Fix -Wextra-semi warnings in headers used in Chromium 2019-02-21 11:05:21 -05:00
Jeff Bolz
2b2316d3fa Add Float16/Int8/Int16 capabilities for private variables and function parameters 2019-02-17 22:50:00 -06:00
baldurk
332b173c82 Fix mismatched integer comparison (size_t/unsigned int vs int) 2019-01-30 17:29:44 +00:00
John Kessenich
d72f488cc6 Build: fix warnings. Fixes #1653. 2019-01-16 14:55:37 +07:00
John Kessenich
69932ab47f
Merge pull request #1645 from KhronosGroup/dupe-accelstruct
Don't output duplicate OpTypeAccelerationStructureNV declarations
2019-01-08 09:39:32 +07:00
Piers Daniell
3cf3f96292 Don't output duplicate TypeAccelerationStructureNV declarations 2019-01-07 14:17:44 -07:00
Jeff Bolz
9f2aec49e9 GL_EXT_buffer_reference 2019-01-07 12:36:13 -06:00
John Kessenich
d12fbc4c0c SPV: Move to the latest header. 2019-01-07 23:52:34 +07:00
Greg Fischer
d445bb2867 Create separate OpSource for each included file 2018-12-28 12:06:43 -07:00
John Kessenich
9ed38739b9
Merge pull request #1627 from greg-lunarg/lines8
Add passes to spirv-opt passes to preserve source line info when compiling -g.
2018-12-18 10:38:32 -07:00
Greg Fischer
5620a2f95e Add passes to legalization to preserve source line info when generated. 2018-12-16 13:13:46 -07:00
Jeff Bolz
61a0cd19cc Fix bug where shaderRecordNV buffers were using StorageBuffer storage class 2018-12-14 20:59:53 -06:00
John Kessenich
b23d232ec5 Licensing. Fixes #958. Add licenes file and update copyrights. 2018-12-14 10:47:35 -07:00
John Kessenich
236eb0d325 GLSL/SPV: XFB: No streams on types, but support them on built-in blocks.
From internal Khronos discussions, work, and testing.
2018-12-13 12:06:12 -07:00
Jeff Bolz
0a93cfbb79 Update to newest SPIRV-Tools. It checks the Vulkan rule that all resources must have a set and binding decoration, which many tests fail. So add code to set a default value of zero. Also disable PCH for Ninja builds. 2018-12-11 20:58:29 -06:00
Rémi Verschelde
ebfd91a719 Remove Unix executable permission from text files 2018-12-10 10:49:16 +01:00
greg-lunarg
5d43c4aac7 SPV: Fix #1575, fix #1593: Support HLSL #line
SPIR-V OpLines now contain filenames from HLSL-style #lines.
2018-12-07 17:36:33 -07:00
John Kessenich
667506a5ea
Merge pull request #1602 from Igalia/apinheiro/prevent-xfbstride-twice
GlslangToSpv: prevent add XfbStride twice
2018-11-29 10:43:25 -07:00
Alejandro Piñeiro
16ef9da372 GlslangToSpv: prevent add XfbStride twice
Without this commit, if the XfbStride was explicitly set, the
decoration was added twice on the shader.

v2 (changes after Jonh Kessenich first review)
   * Simplified by just removing the firs assignment
   * Removed assert
2018-11-29 11:49:04 +01:00
John Kessenich
8c869679f2 SPV: For GLSL only, bitcast OpArrayLength result back to int.
This makes the rest of the AST consuming the result match GLSL
semantics and hence get complete type matching.
2018-11-28 07:01:37 -07:00
John Kessenich
e045c23a34 SPV: Generate OpArrayLength with no signedness. 2018-11-27 09:19:10 -07:00
John Kessenich
d7baecfab7
Merge pull request #1595 from dgkoch/EXT_fragment_invocation_density
Implement GL_EXT_fragment_invocation_density
2018-11-27 06:41:36 -07:00
Alan Baker
440f95b1e7 Update known good SPIRV tools and headers
* Fixes use of optimizer
* Updated test outputs
 * GeometryStreams and TransformFeedback no longer fail validation
2018-11-26 11:24:22 -05:00
Daniel Koch
5154db5183 Implement GL_EXT_fragment_invocation_density
including SPV generation using SPV_EXT_fragment_invocation_density.
This is an alias of the functionality in SPV_NV_shading_rate, and thus in some
cases we can only have one set of the tokens present (switch statements), so
we have picked the EXT version. This required updating the expected test
results for SPV_NV_shading_rate.

Also updated the known-good for spirv-headers so that the validator in
spirv-tools knows about the new extension.
2018-11-26 10:01:58 -05:00
John Kessenich
83fe01e274 SPV: non-functional: update to latest headers. 2018-11-26 06:34:38 -07:00
John Kessenich
e3b76ed608 Merge branch 'scalar_block_layout' of https://github.com/jeffbolznv/glslang into jeffbolznv-scalar_block_layout 2018-11-16 09:57:33 -07:00
t.jung
b16bea801c [HLSL/Spir-V] fix for incorrect spir-v on int dot(int, int)
Decomposes OpDot into corresponding multiplies and additions.
2018-11-15 11:02:30 +01:00
Jeff Bolz
7da39ed968 Implement GL_EXT_scalar_block_layout 2018-11-14 09:30:53 -06:00
t.jung
697fdf015f HLSL: fix invalid spir-v vector * scalar for float1
Missing check for float results in always emitting OpIMul even for float types
2018-11-14 14:27:22 +01:00
Dan Sinclair
12fcaa2cc2 Review feedback 2018-11-13 09:17:44 -05:00
Dan Sinclair
70661b9c08 Handle potentially uninitialized result 2018-11-12 13:56:52 -05:00
GregF
68fbda9862 Add DeadBranchElim before MergeReturn in legalization.
MergeReturn now requires this or could throw an error.
2018-11-08 10:35:45 -07:00
John Kessenich
cdf7a85b14
Merge pull request #1557 from nicebyte/spec-const-decorations
Add names for composite spec constants in SPIR-V
2018-11-02 10:23:22 -06:00
Grigory Dzhavadyan
4c9876b34c Add names for composite constants in SPIR-V
Consider the following code:

    layout(constant_id=0) const int Y = 1;
    layout(constant_id=1) const int Z = 2;
    layout(constant_id=3) const int X = Y + Z;

Previously, it would produce SPIR-V decorations like this:

    Decorate 21(Y) SpecId 1
    Decorate 22 SpecId 3
    Decorate 33(Z) SpecId 0

This seems inaccurate, since the spec constant `X` that is dependent on
the two others did not get a name in the SPIR-V decorations. This behavior
may potentially negatively affect shader introspection capabilities.

This change alters the behavior to always add a name, which results in the code
above producing the following decorations:

    Decorate 21(Y) SpecId 1
    Decorate 22(X) SpecId 3
    Decorate 33(Z) SpecId 0
2018-11-02 00:45:12 -07:00
Ashwin Lele
ff1783db87 Multiple features and misc fixes for final raytracing non experimental version. 2018-10-31 07:55:24 -07:00
John Kessenich
b2b3d81e9b
Merge pull request #1556 from Kangz/msvc
Fix MSVC warning C4065: 'default' but no 'case' labels
2018-10-29 16:16:46 -06:00
Corentin Wallez
04a2fe93d0 Fix MSVC warning C4065: 'default' but no 'case' labels
This would happen in SpvPostProcess when we don't enable AMD extensions.
2018-10-29 16:24:00 +01:00
John Kessenich
25ed3fce0c
Merge pull request #1542 from sheredom/fix_8bit_storagebuffer
Fix 8-bit storage nearly always using the UniformAndStorageBuffer8BitAccess capability.
2018-10-26 10:27:46 -06:00
John Kessenich
8717a5d39a SPV/Standalone: Support specifying arbitrary versions of SPIR-V. 2018-10-26 10:16:47 -06:00
Neil Henning
b6b01f067b Fix 8-bit storage nearly always using the
UniformAndStorageBuffer8BitAccess capability.

When using the 8-bit storage extension it basically always used the
`UniformAndStorageBuffer8BitAccess` capability, even in cases where it
wasn't required. For instance if we are targeting Vulkan 1.1 (SPIR-V 1.3
or higher), and we are only using 8-bit types in an SSBO, we only need
the `StorageBuffer8BitAccess` capability.

I fixed this by enabling storage buffer use in Vulkan 1.1 / SPIR-V 1.3
or higher, and then changing the logic to match.

I also added some tests that will output different capabilities when run
on Vulkan 1.0 and 1.1, thus they are added twice to the test list (one
for each version).

Fixes #1539
2018-10-26 14:23:41 +01:00
Sahil Parmar
38772c0434 Allow GL_NV_mesh_shader in fragment shaders for perprimitiveNV
- Emit relevant capability/extension for use of perprimitiveNV in fragment shader
- Remove redundant checks for mesh shader qualifiers in glslang.y
- Add profile version check for use of extension GL_NV_mesh_shader
- Add a new gtest for use of perprimitiveNV in fragment shader
2018-10-25 23:50:59 -07:00
Dan Sinclair
70f13b2ed5 Fixup unused parameter warnings
This CL removes the current parameters which are unused in order to
fixup the issued clang warnings.
2018-10-24 09:54:48 -04:00
Jeff Bolz
ab3c965a46 Fix flags.nonprivate to be true for workgroup memory, which is implicitly workgroupcoherent/nonprivate 2018-10-15 22:46:48 -05:00
John Kessenich
5ff3c3da3b Interfaces: Remove NV_EXTENSIONS from two more headers.
This also fixes some cpp files that uncover issues when building
with the flags turned off.
2018-09-26 09:38:20 -06:00
Dan Sinclair
aac6d63716 Use unsigned int instead of uint32_t 2018-09-25 16:32:06 -04:00