Commit Graph

977 Commits

Author SHA1 Message Date
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
Juan Ramos
b008c0ee45 Fix unused parameter warning
paramNames was going unused in makeFunctionEntry
2023-11-22 16:42:21 -05:00
Moritz Heinemann
eac012fff3 Fix spirv-tools dependency 2023-11-20 18:28:38 -05:00
Qingyuan Zheng
109b5979d3 Support NonSemantic DebugValue and generate it for const arg
For passing-by-value semantic, DebugDeclare cannot be used for parameters because there's no pointer.
2023-11-14 14:46:44 -07:00
Arcady Goldmints-Orlov
1dcb072cda cmake: only install public headers
Only the headers that are part of glslang's public interface are
installed. Previously, all of its headers were installed, which exposed
a lot of internal implementation details and made it difficult to
maintain backward compatiblity. This reduces the API surface somewhat
and will make it easier to maintain API and ABI compatibility.
2023-11-11 08:55:43 -07:00
Arcady Goldmints-Orlov
806d9abbad Remove SPVRemapper.h dependency on spvIR.h
The only thing it uses from spvIR.h is the NoResult constant, which is
now defined inline.
2023-11-11 08:55:43 -07:00
Arcady Goldmints-Orlov
6f9ab3c2de Remove GlslangToSpv.h dependency on SpvTools.h
The dependency was only because of the SpvOptions struct which is used
in both, but really is part of the glslang public interface and should
be in the public GlslangToSpv.h header.
2023-11-11 08:55:43 -07:00
Arcady Goldmints-Orlov
62de186c33 Remove GlslangToSpv.h dependency on intermediate.h
GlslangToSpv.h only declares functions with opaque references to to
TIntermediate, for which a simple "class TIntermediate;" declaration is
adequate. This means that Include/intermediate.h no longer needs to be
installed as part of glslang's public interface.
2023-11-11 08:55:43 -07:00
Rex Xu
a8d39f97cd Add a helper applySpirvDecorate to handle spirv_decorate_xxx directives
Some code paths could be shared.
2023-11-09 08:49:40 -07:00
Rex Xu
65f59c81e7 GL_EXT_spirv_intrinsics: Fix a typo in function naming
hasSprivDecorate => hasSpirvDecorate

Also, revise a comment.
2023-11-06 12:50:02 -05:00
Kévin Petit
a9e698322e
Align spirv.hpp to SPIRV-Headers for SPV_KHR_cooperative_matrix
Some of the enumerants used by this extension were missing a KHR suffix.
2023-10-25 19:59:52 -04:00
Chao Chen
979423d84f Add correct line number to OpDebugFunction and OpDebugScope for function:
1. Pull OpDebugFunction, OpDebugScope and OpDebugVariable for params out
   of makeFunctionEntry.
2. Put above in a separate function called setupDebugFunctionEntry,
   which also accept line number and set it correctly in builder.
3. Call setupDebugFunctionEntry in makeFunction. Also special case
   handle entry function since it's created ealier elsewhere.
2023-10-24 13:37:19 -07:00
Arcady Goldmints-Orlov
7fa0731a80 Initialize spv_options in glslang_program_SPIRV_generate
This will prevent any recurrence of issues like the one addressed by
PR #3364.
2023-10-19 16:57:31 -04:00
Andrew MacDonald
fd1f96d202 Add missing initialization of compile_only field for SPIRV C interface 2023-10-16 19:18:15 -04:00
Arcady Goldmints-Orlov
0504953b35 spirv: don't emit invalid debuginfo for buffer references
Currently no debug info is emitted for buffer reference types, which
resulted in the SPIR-V backend code asserting when trying to emit the
debug info for struct member that had such a type. Instead, the code now
skips such struct members. Full debug info for buffer references may
require forward references in the debug info instructions, which is
currently prohibited by the spec.
2023-10-13 17:49:26 -04:00
Arcady Goldmints-Orlov
48f9ed8b08 spirv: only set LocalSizeId mode when necessary
SPIR-V 1.6 added the LocalSizeId execution mode that allows using
spec constants for setting the work-group size, however it does not
deprecate the LocalSize mode. This change causes the LocalSizeId mode to
only be used when at least one of the workgroup size is actually
specified with a spec constant.

Fixes #3200
2023-10-12 14:45:33 -04:00
alelenv
3f02132668
Add support for GL_NV_displacement_micromap.
* Add support for GL_NV_displacement_micromap.
* Update known_good for spirv-headers and spirv-tools.
2023-10-02 15:07:50 -04: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
Rex Xu
323836e46b Use std::variant to represent TSpirvTypeParameter
This PR is try to address the review comment:
https://github.com/KhronosGroup/glslang/pull/3253#discussion_r1254932979.
2023-09-11 21:12:35 -04:00
Sajjad Mirza
afe6e781bd
Emit correct nonsemantic debug info for explicitly sized types
Previously, the type names in the nonsemantic shader debug info would be
"int", "uint", or "float" for all numeric types. This change makes the
correct names such as "int8_t" or "float16_t" get emitted.
2023-09-11 20:11:22 -04:00
Nathaniel Cesario
a1f8cd429f Fix ByteAddressBuffer as function parameter
Make sure that an id represents a variable before adding it to an entry
point's interface.

Fixes #3297.
2023-08-31 16:22:03 -06:00
Wooyoung Kim
db8719ae07
extension: GL_QCOM_image_processing support 2023-08-21 18:14:52 -06:00
Arseny Kapoulkine
34d4f78f03
Fix interaction between GL_EXT_mesh_shader and GL_EXT_fragment_shading_rate
Before this change, using gl_MeshPrimitivesEXT in mesh shader would
unconditionally create gl_MeshPrimitivesEXT.gl_PrimitiveShadingRateEXT
field and add PrimitiveShadingRateKHR capability to the output SPIRV
file, which would subsequently trigger validation errors when creating
the shader module unless the application requested primitive shading
rate feature.

What should happen instead is that unless GL_EXT_fragment_shading_rate
extension is enabled, we should not allow using
gl_PrimitiveShadingRateEXT and should not emit the associated fields
into the output.

This change fixes this by using existing filterMember mechanism that is
already used in a few other cases like this, and adjusting the required
extension on the field member which will generate an error when
gl_PrimitiveShadingRateEXT is used without enabling the extension.
2023-08-07 11:38:17 -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
Boris Zanin
808c7ed17c Implement support for GL_KHR_cooperative_matrix extension 2023-07-26 16:39:17 -06:00
scribam
c81b34fb24 Remove useless semicolons 2023-07-24 15:36:54 -06:00
Arcady Goldmints-Orlov
f47028995c Use std::call_once in spv::Parameterize()
There was a race condition in this function as it used a static variable
to attempt to ensure global initialization was only done once, which was
not thread-safe. Instead, use std::call_once, which was added to C++11
for this exact case.

Fixes #342
2023-07-13 18:14:29 -04:00
Rex Xu
051f18c0cc Spirv_intrinsics: Add support of type specifier to spirv_type
Previously, spirv_type doesn't accept type specifier as its parameter.
With this change, we can input non-array type specifier. This is because
some SPIR-V type definition intructions often need to reference other
SPIR-V types as its source operands. We add the support to facilitate
such usage.
2023-07-11 13:26:22 -04:00
Arcady Goldmints-Orlov
3ebb72cc74 Add an assert that ID operands are non-zero
Zero is not a valid ID value and the SPIR-V emitter library should never
be emitting instructions with ID values of 0.
2023-06-27 13:49:14 -04:00
Arcady Goldmints-Orlov
d89c0b1d13 Force generateDebugInfo when non-semantic debug info is enabled
From the command line, the debug options "stack", with -gVS enabling all
of generateDebugInfo, emitNonSemanticShaderDebugInfo and
emitNonSemanticShaderDebugSource, however the programmatic interface
allows setting the latter options without the former. In this case, the
string corresponding to the source filename never gets emitted and some
debuginfo instructions end up with zero ID operands, resulting in
invalid SPIR-V.

Fixes #3240
2023-06-27 13:49:14 -04:00
Sven van Haastregt
9575e33186 Fix unused parameter warning in Release builds
The `function` parameter is only used by an assert currently, so mark
it as "maybe unused".  Alternatively the parameter could be removed,
but avoid such API churn for now.
2023-06-21 16:43:18 -04:00