Commit Graph

1007 Commits

Author SHA1 Message Date
Arcady Goldmints-Orlov
5398d55e33 Remove execute permissions from source files. 2024-08-06 14:42:01 -06:00
Sergei Trofimovich
e40c14a3e0 SPIRV/SpvBuilder.h: add missing <cstdint> include
Without the change `glslang` build fails on upcoming `gcc-15` as:

    In file included from /build/source/SPIRV/GlslangToSpv.cpp:45:
    SPIRV/SpvBuilder.h:248:30: error: 'uint32_t' has not been declared
      248 |     Id makeDebugLexicalBlock(uint32_t line);
          |                              ^~~~~~~~
2024-08-02 17:00:44 -06:00
Malcolm Bechard
8590f62c14 add optimizerAllowExpandedIDBound to SpvOptions
This option increases the max_id_bound in the optimizer to 0x3FFFFFFF, and then runs a
compact-id pass if the final result has a max_id greater than the standard limit of 0x3FFFFF.
2024-07-30 21:49:42 -04:00
Arcady Goldmints-Orlov
7e896697dc Add SPIRV/SpvTools.h back to the public headers
Clean up the includes in SpvTools.h so that it doesn't require any
transitive dependencies and add it back to the headers that get
installed.
2024-07-30 19:07:19 -04:00
Pavel Asyutchenko
9f34b25f30 Fix HLSL offsets for non-cbuffers (#3668) 2024-07-29 19:24:33 -04:00
Arcady Goldmints-Orlov
592aed9c20 Don't emit debug instructions before an OpPhi
Nonsemantic instructions aren't allowed before an OpPhi, so don't emit
line and debug scope instructions when the instruction being emitted is
an OpPhi.
2024-07-22 17:43:12 -04:00
Mason Remaley
5939e32b87 Fixes undefined behavior due to unspecified enum backing
In C++, enums can only represent "in range" values. If the backing
type is not specified, then the result of using bitwise negation on
an enum is not gaurenteed to be in range, resulting in UB.

This was caught by UBSAN, stack trace is as follows:

0.  0x000000000426e391 in spv::operator& (a=spv::MemoryAccessMaskNone,
    b=(spv::MemoryAccessVolatileMask | spv::MemoryAccessAlignedMask | spv::MemoryAccessNontemporalMask | spv::MemoryAccessMakePointerVisibleMask | spv::MemoryAccessNonPrivatePointerMask | spv::MemoryAccessAliasScopeINTELMaskMask | spv::MemoryAccessNoAliasINTELMaskMask | unknown: 0xfffcffc0)) at SPIRV/spirv.hpp:2804
1.  0x00000000041e81e0 in (anonymous namespace)::TGlslangToSpvTraverser::accessChainLoad (this=0x7fffffffcbb8, type=...) at SPIRV/GlslangToSpv.cpp:5127
2.  0x00000000041bc059 in (anonymous namespace)::TGlslangToSpvTraverser::visitBinary (this=0x7fffffffcbb8, node=0x5f6a6c8) at SPIRV/GlslangToSpv.cpp:2192
3.  0x0000000003db8660 in glslang::TIntermBinary::traverse (this=0x5f6a6c8, it=0x7fffffffcbb8) at glslang/glslang/MachineIndependent/IntermTraverse.cpp:92
4.  0x0000000003db952e in glslang::TIntermAggregate::traverse (this=0x5f6a7d8, it=0x7fffffffcbb8) at glslang/glslang/MachineIndependent/IntermTraverse.cpp:175
5.  0x00000000042082db in (anonymous namespace)::TGlslangToSpvTraverser::makeGlobalInitializers (this=0x7fffffffcbb8, initializers=...) at SPIRV/GlslangToSpv.cpp:5618
6.  0x00000000041c511f in (anonymous namespace)::TGlslangToSpvTraverser::visitAggregate (this=0x7fffffffcbb8, visit=glslang::EvPreVisit, node=0x5f6a9b8) at SPIRV/GlslangToSpv.cpp:2907
7.  0x0000000003db8fb9 in glslang::TIntermAggregate::traverse (this=0x5f6a9b8, it=0x7fffffffcbb8) at glslang/glslang/MachineIndependent/IntermTraverse.cpp:159
8.  0x00000000041acc04 in glslang::GlslangToSpv (intermediate=..., spirv=..., logger=0x7fffffffdc38, options=0x7fffffffdc2f) at SPIRV/GlslangToSpv.cpp:10398
9.  0x0000000003bfd6f1 in CompileAndLinkShaderUnits (compUnits=...) at StandAlone/StandAlone.cpp:1547
10. 0x0000000003bfe2f8 in CompileAndLinkShaderFiles (Worklist=...) at StandAlone/StandAlone.cpp:1640
11. 0x0000000003bfec2c in singleMain () at StandAlone/StandAlone.cpp:1713
12. 0x0000000003bff4dd in main (argc=5, argv=0x7fffffffe3d8) at StandAlone/StandAlone.cpp:1767
2024-07-03 15:59:55 -04:00
Qingyuan Zheng
704107fda3 Fix function call line number for calls spanning multiple lines. 2024-07-02 14:38:40 -04:00
Qingyuan Zheng
85262fb20e Fill correct file name to OpDebugFunction and add line info for parameters' OpDebugDeclare 2024-07-02 14:23:59 -04:00
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 Goldmints-Orlov
0c15a28c94 refactor: Make type component/constituent counts unsigned
A type can't have a negative number of constituents, components, rows,
or columns. Therefore, the utility functions to query said information
on types and values should return unsigned int rather than int.
2024-06-24 13:52:56 -04:00
Arcady Goldmints-Orlov
33d517470e Generate vector constructions more efficiently when sizes match
When two vectors are the same size, there is no need to extract the
components and construct a new vector.
2024-06-24 13:52:56 -04:00
AnyOldName3
a92c61f845 Add aliases for the public libraries
This makes things consistent between when glslang is installed and imported versus when it's included as nested CMake project.
You can now use `glslang::glslang` in both cases instead of needing the non-namespaced version sometimes and the namespaced one other times.

Resolves one of the problems discussed in https://github.com/KhronosGroup/glslang/issues/3509
2024-06-11 15:34:07 -04:00
Pedro Olsen Ferreira
02263efcd6 Add support for the ARM extended matrix layout 2024-06-11 15:33:49 -04:00
Arcady Goldmints-Orlov
73eccd4b67 Add the KHR suffix for OpExtInstWithForwardRefsKHR instruction 2024-06-06 18:46:14 -04:00
Arcady Goldmints-Orlov
81f7045aa0 Emit debug info for buffer references
Using OpExtInstWithForwardRefs, the debug type information for buffer
reference types can be emitted alongside the OpFowardPointer opcode.
2024-06-06 18:46:14 -04:00
Arcady Goldmints-Orlov
996c5d3123 Add support for OpExtInstWithForwardRefs 2024-06-06 18:46:14 -04:00
Jeff Bolz
4da479aa6a Generate SPV_EXT_replicated_composites when requested by pragma.
Implement GL_EXT_spec_constant_composites.
2024-06-03 18:13:07 -04:00
Jeff Bolz
6a8b2b2439 Reuse loads generated for repeated function arguments 2024-06-03 18:13:07 -04:00
Max Andersson
1cad045cc2 Make gl_HitT proper aliases of gl_RayTmax
Changes the gl_HitT builtins properly alias
their gl_RayTmax. Previously they ended up as
duplicate variables, rather than aliased.
2024-05-24 11:08:06 -07: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
Wooyoung Kim
a4f870053f
A couple of fixes to the GL_QCOM_image_processing2 support (#3578)
1) handle the extension requirements of GL_QCOM_image_processing2
   correctly
2) add QCOM image processing decorations to ids only once.
2024-04-23 18:34:51 -04:00
Herman Semenov
b9b8fd917b Using reserve() in GlslangToSpv 2024-04-22 11:52:16 -04:00
Pavel Asyutchenko
593dbafd0d
Better follow HLSL offsets rules (#3575)
Matrices consuming one vector are treated like vectors for alignment, and
there is no "trailing padding" for matrices and arrays.
2024-04-17 19:34:28 -04:00
alan-baker
1e4f53ab2d
Prevent duplicate SPIR-V decorations (#3570)
* Update SPIRV-Tools
  * https://github.com/KhronosGroup/SPIRV-Tools/pull/5641 added
    validation that caught errors
* Modified glslang to prevent duplicate Restrict and Coherent
  decorations
* Modify createConstructor to avoid adding duplicate RelaxedPrecision
  decorations when generating a scalar
2024-04-15 11:39:23 -04:00
Herman Semenov
2db79056b4 Maximum optimization inserts using reserve() for operands 2024-04-11 15:10:58 -04:00
Rex Xu
3225778615 Fix an issue of getExtBuiltins()
This function is used to import SPIR-V extended instruction set. It
mistakenly treated the name of SPIR-V extended instruction set as the
name of SPIR-V extension. For example, when we have such code

  getExtBuiltins("NonSemantic.DebugBreak")

'NonSemantic.DebugBreak' is added to SPIR-V extension. Rather, the
SPIR-V extension name should be 'SPV_KHR_non_semantics_info'. Therefore,
we must avoid this since the name of SPIR-V extended instruction set is
not necessarily equal to that of relevant SPIR-V extension. Adding a
SPIR-V extension must be done by calling addExtension() explicitly
outside this function.

This change also fixes disassembly issues of debugBreak().
2024-03-22 12:35:30 -04:00
Wooyoung Kim
10ee92feb0
Support for SPV_QCOM_image_processing2 (#3539) 2024-03-20 18:56:00 -04:00
Jeff Bolz
2518af09c8 Change fp16_vector_atomic to not require other SPIR-V atomic extensions 2024-02-22 11:51:25 -05:00
Arcady Goldmints-Orlov
7ffa289495 Add extra break statements to quiet clang warnings.
Clang complains about code that falls through into an empty default
case, so add some breaks to placate it.
2024-02-20 19:12:06 -05:00
Arcady Goldmints-Orlov
606209e07d Use [[fallthrough]] attribute instead of comments.
Now that we require C++17, the [[fallthrough]] attribute is available as
an alternative to load-bearing comments.
2024-02-20 19:12:06 -05: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
Bjorn
d84255296c
Clear spirv vector before generating spirv output
This makes spir-v generation idempotent.
2024-02-14 19:44:34 -05:00
Sajjad Mirza
7a2a1623d8
Emit debug info for accelerationStructure and rayQuery variables. (#3502)
* Add debug info for accelerationStructure and rayQuery variables.
* Add test case for accelerationStructure and rayQuery
2024-02-14 19:43:02 -05:00
Jeff Bolz
48702616ec NV_shader_atomic_fp16_vector 2024-02-14 18:55:55 -05:00
Sven van Haastregt
9fd0fcd737 Add GL_EXT_expect_assume support
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-02-13 16:13:35 -08:00
David Neto
b4a6efcda2 Allow external control of whether Glslang will be tested or installed
Expose GLSLANG__TESTS and GLSLANG_ENABLE_INSTALL as options
that can be controlled from an enclosing project, or from the
command line.

They retain the prior default behaviour. In particular, if Glslang
is not the top level project, then they default to OFF.

Fixes: #3507
2024-02-13 15:35:02 -08:00
Qingyuan Zheng
30661abd9c
Clean up the debug line info tracking and generation.
- Correctly populate the field `currentFileId` with the presence of include directive
- Support lazy OpLine/OpDebugLine generation only when a real instruction is added instead of a debug location is set
- Improve the debug location tracking to per-block instead of just per-builder
- A few bug fixes related to debug source info
2024-02-09 10:27:40 -08:00
Sven van Haastregt
b1f7affe94 Add GL_KHR_shader_subgroup_rotate support
Co-authored-by: Neil Hickey <neil.hickey@arm.com>
Co-authored-by: Stuart Brady <stuart.brady@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-02-06 11:04:16 -08:00
laddoc
725017a588 Support extension EXT_shader_quad_control 2024-01-30 16:28:38 -05:00
Younggwan Kim
f6f9840eab SPV: Complete OpAssumeTrueKHR, OpExpectKHR 2024-01-26 14:21:54 -05:00
Jeff Bolz
79536da264 Fix 'maximally_reconverges' token to match the GLSL spec 2024-01-25 19:30:47 -05:00
Jeff Bolz
8066fa086b Implement GL_EXT_maximal_reconvergence 2024-01-25 13:46:25 -05:00
Arcady Goldmints-Orlov
57d86ab763 cmake: remove generation of deprecated *Targets.cmake files
These files have had a deprecation notice for a few years now and the
cmake find_package mechanism should be used instead.
2024-01-17 16:43:13 -05:00
Sajjad Mirza
e17ecb0e80
Emit DebugTypePointer when non-semantic debug info is enabled 2023-12-28 11:00:37 -05:00
Nathaniel Cesario
5ad3d41364 Output 8 and 16 bit capabilities OpSpecConstantOp
OpSpecConstants with 8 or 16 width types require the corresponding
capabilities.

Fixes #3449.
2023-12-15 18:36:00 -05:00
Chao Chen
9a35abff55 Always enable the generation of OpDebugBasicType for bool type 2023-12-06 19:23:45 -05:00
Juan Ramos
cf1fbbff44 Only install/test if PROJECT_IS_TOP_LEVEL
Further remove installing glslangtests. There isn't a need to do
that. glslangtests isn't a deliverable.
2023-12-01 18:35:36 -05:00
Nathaniel Cesario
19d541a91d Fix some compiler warnings
This change primarily fixes some -Wconversion warnings from gcc, but
also silences a warning triggered in glslang_tab.cpp, which is generated
code from bison.

There are still several GCC conversion warnings in Types.h due to the
use of bit fields that will be resolved in a future change.
2023-11-28 19:16:16 -05:00
Moritz Heinemann
b820431a2c No external install include dir 2023-11-27 19:13:13 -05:00