Commit Graph

1022 Commits

Author SHA1 Message Date
Christopher Degawa
76cc41d26f disassemble: Add cstdint for uint32_t
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
2024-11-06 11:00:52 -05:00
Jeff Bolz
d0e67c5813 Implement GLSL_NV_cooperative_matrix2 2024-11-04 11:33:58 -05:00
Ronny Chan
3454c3618b
Emit OpModfStruct for GLSL EOpModf instead of OpModf
* Update tests to account for `OpModfStruct`
2024-10-25 11:58:12 -04:00
Sajjad Mirza
f69d2768e5
Use line and column from node on DebugLexicalBlock.
* Fix bug in TestFixture.h, debug info gets enabled when nonsemantic debug info is requested.
2024-10-04 14:11:27 -04:00
Sven van Haastregt
4e91335863 Remove extra semicolons
Fix various "extra ';'" compiler warnings.

No functional changes.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-04 11:57:17 -04:00
Jeff Bolz
ca04c2a16a
Fix nonsemantic debuginfo line attribution for cooperative matrix
* Generate debuginfo for coopmat types, treating them as an opaque composite. Restore the debug source location after calling convertGlslangToSpvType, fixes the line info in this unit test

* Add a cooperative matrix test case, based on the shader from https://github.com/jeffbolznv/vk_cooperative_matrix_perf/blob/master/shaders/shmem.comp
2024-09-30 13:53:27 -04:00
Malcolm Bechard
4a9f088915 a few more tweaks for #3681
expose TIoMapper::setAutoPushConstantBlock()
add overload for MapToSpirvToolsEnv() that takes TIntermediate instead of SpvVersion.
2024-09-25 11:17:35 -04:00
Arcady Goldmints-Orlov
ec7e23f458 Final round of symbol visibility fixes
This change adds GLSLANG_EXPORT in a couple more places, as well as
adding a new symbol visibility annotation GLSLANG_EXPORT_FOR_TESTS which
is defined the same as GLSLANG_EXPORT but documents the intention that
the symbols marked with it are only meant to be used by glslang's test
suite and do not form part of the public API and are thus not subject to
ABI stability guarantees.
2024-09-19 17:26:52 -04:00
Arcady Goldmints-Orlov
36ccaa31bd Explicitly export symbols from libSPVRemapper
Windows requires symbols to be explicitly exported from DLLs, this
change simply marks the entire spirvbin_t class as exported.

The macros from visibility.h are included inline to get around include
path issues.
2024-09-13 07:28:49 -07:00
Qingyuan Zheng
a496a34b43 Sanitize debug source location tracking for implicit branch and return
This patch tries to attach debug location of a branch/return instruction to its predecessor or the closing brace. If none could be found, no debug info should be emitted.
2024-09-02 14:20:19 -04:00
Arcady Goldmints-Orlov
b1fac200c4 Add symbol visibility annotations to symbols in SPIRV/
Symbols in the SPIRV/ directory that are meant to be part of the public
API of glslangnow have GLSLANG_EXPORT annotations that make sure they
will be accessible when building glslang as a shared library if
-fvisibility=hidden is enabled.
2024-09-02 13:46:30 -04:00
Arcady Goldmints-Orlov
b45d21b287 cmake: Fix dependencies of newly-stubbed libraries
Some downstream projects may only link to e.g. the glslang::SPIRV
library and rely on transitive dependencies to pull in everything else.
To keep this working, the SPIRV and MachineIndependent library stubs are
now linked against the glslang library.
2024-08-29 11:27:44 -04:00
Matthew Moulton
5073d93ec4
Apply GLSL memory decorations to top-level OpVariable
Apply memory decorations from GLSL source to the top-level OpVariable.
Previously, these decorations would only be applied to individual
members. While this is correct behavior, it is more convenient for some
front ends to see the decorations (specifically ReadOnly and WriteOnly)
applied to the whole variable rather than individual members.
2024-08-28 17:46:16 -04:00
Arcady Goldmints-Orlov
592de6cf78 Clean up unused includes. 2024-08-20 09:09:44 -04:00
Daniel Story
4f01996c9d Merge ancillary libraries into main glslang library and stub originals 2024-08-15 17:32:47 -04:00
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