Commit Graph

31 Commits

Author SHA1 Message Date
Steven Perron
33c7e30860
Don't emit duplicate decorations. (#3635)
It is invalid if the same decoration is applied to the same id multiple
times. This adds a check before adding a decoration that the decoration
is not already in the list. If it is, then the duplicate is not added.

Fixes #3627
2024-06-28 19:16:59 -04:00
arcady-lunarg
7c3c50ea94
spirv: Add a postprocessing pass to fix up uses of OpSampledImage
SPIR-V requires that any instruction using the result of an
OpSampledImage instruction be in the same block as the OpSampledImage.
This is hard to guarantee in code generation but easy to fix after the
fact, by simply inserting a new OpSampledImage before the user of its
result if needed, with the new instruction having the same operands as
the original OpSampledImage.
This change adds a new pass to spv::Builder::postProcess that does this.
This might leave the original OpSampledImage instructions "orphaned"
with no users of their result ID, but dead code elimination would take
care of those further down the line.
2024-05-20 13:25:55 -04:00
Chris Djali
8ca24e7cf1
Remove implicit fallthrough (#3518)
This is intended so that downstream projects consuming glslang with FetchContent or similar means can use `-Wimplicit-fallthrough` without getting warning spam.

I've used my best judgement to determine whether the implicit fallthrough was desired, or was simply unreachable code.
`std::unreachable` is unavailable until C++23, but I saw places where `default: assert(0);` was used, so copied that.
There were a few places where some code might actually have been reachable and intended to return a value that represented an error, so someone should double check that kind of thing.
2024-02-19 17:45:45 -05:00
Nathaniel Cesario
4c57db1595 Add --no-link option
Adds the --no-link option which outputs the compiled shader binaries
without linking them. This is a first step towards allowing users to
create SPIR-v binary, non-executable libraries.

When using the --no-link option, all functions are decorated with the
Export linkage attribute.
2023-09-18 17:31:05 -04:00
Wooyoung Kim
db8719ae07
extension: GL_QCOM_image_processing support 2023-08-21 18:14:52 -06:00
dan sinclair
d291b15911
Remove GLSLANG_WEB and GLSLANG_WEB_DEVEL
This CL removes the GLSLANG_WEB and GLSLANG_WEB_DEVEL
cmake build options and their usage in the codebase.

Issue #2958
2023-07-28 11:49:10 -06:00
Gilad Ben-Yossef
0464ff4515 GL_ARM_shader_core_builtins support
Add support for GL_ARM_shader_core_builtins and SPV_ARM_core_builtins,
including initial tests
2022-12-05 14:15:47 +02:00
Greg Fischer
82b2668d58 Allow 8/16-bit integer as array index
Also enable 8/16 bit int capability in SPIR-V in such cases.

Also enable 64 bit capabilities when used in operations.

Fixes #2779
2021-10-20 15:15:30 -06:00
Chris Forbes
dd097e5adb Untangle use of core glslang version enums in SpvPostProcess
This is the only thing requiring GlslangToSpv.h to be included here.

Change-Id: I72e9e278aa1e6d717e83f9dbf11e089aafe2eb0e
2021-10-14 08:43:34 -07:00
Caio Marcelo de Oliveira Filho
4bfbf62794 Add support for GL_EXT_shared_memory_block
Uses SPV_KHR_workgroup_memory_explicit_layout.  Note that if
GL_EXT_scalar_block_layout is enabled, Workgroup blocks can also use
scalar layout.
2021-01-29 11:23:05 -08:00
Jeff Bolz
bfd84a39f2 Add missing capability when QueueFamily scope is used
Also, if this capability is added and the memory model is not
otherwise enabled by pragma, enable it as part of postprocessing.
2021-01-27 13:14:34 -06:00
David Neto
e43e8ba9f3 SPIR-V postprocessing: WEB case only needs CFG mods
The SPIR-V post-processing to discover capabilities and
extensions does not apply to WebGPU compilation.  So don't include
that code.

This reclaims some of the code space added by #1943
2019-11-07 17:55:22 -05: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
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
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
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
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
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
baldurk
332b173c82 Fix mismatched integer comparison (size_t/unsigned int vs int) 2019-01-30 17:29:44 +00:00
Jeff Bolz
9f2aec49e9 GL_EXT_buffer_reference 2019-01-07 12:36:13 -06:00
John Kessenich
b23d232ec5 Licensing. Fixes #958. Add licenes file and update copyrights. 2018-12-14 10:47:35 -07:00
Rémi Verschelde
ebfd91a719 Remove Unix executable permission from text files 2018-12-10 10:49:16 +01: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
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
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
97068d8b30
Merge pull request #1465 from otakuto/remove-execute-permissions
Remove execute permissions
2018-08-31 08:14:47 -07: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
228e964bcc SPV: Correct SPIR-V operands for <id> versus immediate. 2018-08-13 21:37:59 -06: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