Commit Graph

461 Commits

Author SHA1 Message Date
Rex Xu
fb18b6df28 Fix an issue of SPV generation for imageAtomicStore.
For GLSL function imageAtomicStore, it will be translated to
OpImageTexelPointer + OpAtomicStore. The result type of
OpImageTexelPointer must be the same as the sampled type of OpTypeImage.
On translation, the result type is mistakenly fetched from operand list
operands[2] while operands[2] corresponds to sampleNum whose type is
always uint. This leads to an error if the image type is iimageXXX that is
int image.
2020-02-22 22:04:31 +08:00
Roy
05a5b53208 Fix glslang can't link multiple AST in a single stage
Root cause:
GlslangToSpv use symbol structure's ptr as a map key, but multiple shader object can build a new AST.
In the AST the the same symbol has different ptr point to their structure, so indext map faild.

solution:
Add a new map glslangTypeToIdMap to map ptr to symbol id, and use symbol id to index memberRemapper.
2020-01-03 16:30:37 +08:00
John Kessenich
5de15a256e HLSL: Fix #2037: Integer dot used incorrect input for adds. 2019-12-26 10:56:54 -07:00
Ian Romanick
b3bd402c7c INTEL_shader_integer_functions2: Add SPIR-V generation
v2: Move addCapability and addExtension extension calls from
TGlslangToSpvTraverser::createBinaryOperation to
TGlslangToSpvTraverser::visitAggregate.  Suggested by JohnK.
2019-12-03 11:06:41 -08:00
John Kessenich
31c3370d83 Bump up the generator version, which is exposed in SPV test results. 2019-11-02 21:26:40 -06:00
David Neto
8c3d5b4b6c SPIR-V: Aggressively prune unreachable merge, continue target
More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
  - a merge block becomes OpLabel, then OpUnreachable
  - a continue target becomes OpLabel, then an OpBranch back to the
    loop header
- any basic block which is dominated by such a merge block or continue
  target is removed as well.
- decorations targeting the removed instructions are removed.

Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
2019-10-29 15:33:54 -04:00
John Kessenich
f8d1d7442b Web: Reclaim more space and make all work w/wo GLSLANG_WEB. 2019-10-23 03:15:55 -06:00
John Kessenich
e5eee8fb03 Web: Add basic atomics for SSBOs. 2019-10-23 00:25:39 -06:00
John Kessenich
3dd1ce5b54 Web: Add SSBOs and a few other missing compute features. 2019-10-23 00:25:39 -06:00
John Kessenich
51ed01c877 Web: Add compute stage. 2019-10-23 00:25:39 -06:00
Jeff Bolz
016ddee83a Only apply volatile semantics to atomics when using Vulkan Memory Model 2019-10-17 11:22:57 -05:00
Ryan Harrison
7c9accb653 Remove unnecessary semi-colons and add warning about them
These are causing integration issues with Chromium down stream since
it is more strict about these.
2019-10-11 11:25:04 -04:00
John Kessenich
ee8e9c1522 Fix #1924: Promote SPV_EXT_physical_storage_buffer to KHR when required.
If the semantics that require the KHR form over the EXT form are seen
(OpBitcast between a vector and a pointer) promote the requested extension
from the EXT to the KHR.
2019-10-10 20:54:21 -06:00
John Kessenich
1ff0c181bb Fix #1924: Emit SPV_EXT_physical_storage_buffer, not the KHR form.
The KHR form comes along as part of 1.5, and otherwise should require
another form of request to emit it.
2019-10-10 12:01:13 -06:00
John Kessenich
90e402f42b SPV_KHR_physical_storage_buffer/SPV: Add GL_EXT_buffer_reference_uvec2
Adds uvec2 <-> reference constructor support.
Switches from EXT to KHR for physical_storage_buffer.
2019-09-18 23:52:36 -06:00
John Kessenich
e4e56bcf86
Merge pull request #1902 from jeffbolznv/extended_types
Add GL_EXT_shader_subgroup_extended_types support
2019-09-17 23:18:20 -06:00
Jeff Bolz
c5b669e04c Add GL_EXT_shader_subgroup_extended_types support 2019-09-17 23:44:27 -05:00
John Kessenich
8317e6c683 SPV: Support SPIR-V 1.5; five extensions no longer need OpExtension.
The generalization to addIncorporatedExtension() also fixed a 1.3
corner case with SPV_KHR_16bit_storage.
2019-09-16 07:14:10 -06:00
Jeff Bolz
387657e4cf GL_NV_integer_cooperative_matrix support 2019-08-22 20:37:59 -05:00
John Kessenich
deec1933e9 Web: Turn off includes, independent preprocessing path, fine tune all.
Saved about 21K, size down to 380K of MSVC x86 code.
Fixed one bug that needs to be looked at on the master branch:
The test for needing a Vulkan binding has a bug in it, "!layoutAttachment"
which does not mean "no layoutAttachment", because that is non-zero.
This is why some test and test results changed.
2019-08-20 23:21:56 -06:00
John Kessenich
b9197c812e Web: Make switched methods all be non-virtual, more web-dependent code,
added a few more HLSL flag tests.  This was mostly focused on the SPV generator.
Saves about 17K.
2019-08-20 23:21:56 -06:00
John Kessenich
fb4f2333da Web: Use isEsProfile() instead of run-time testing; remove more atomics
Saves 2.5K, and design is better.
2019-08-20 23:21:56 -06:00
John Kessenich
155d351f86 Web: Remove unused stage functionality, SPIR-V logger, and hex_utils
Saves another 20K.
2019-08-20 23:21:56 -06:00
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
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
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
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
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
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
John Kessenich
6e384fef6c Build: Fix 3 warnings. 2019-05-10 06:47:00 -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