Commit Graph

931 Commits

Author SHA1 Message Date
Nathaniel Cesario
504608c6e3 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-12-11 20:03:17 +00:00
Wooyoung Kim
bd0edbc7e0 extension: GL_QCOM_image_processing support 2023-12-11 20:03:17 +00:00
Arseny Kapoulkine
76dd399629 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-12-11 20:03:17 +00:00
dan sinclair
1352540a63 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-12-11 20:03:17 +00:00
Boris Zanin
f56d219587 Implement support for GL_KHR_cooperative_matrix extension 2023-12-11 20:03:16 +00:00
scribam
700c328ea3 Remove useless semicolons 2023-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
f83eeaebf5 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-12-11 20:03:16 +00:00
Rex Xu
4218bbe746 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-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
d88a85c288 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-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
26751a0558 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-12-11 20:03:16 +00:00
Sven van Haastregt
36d3c1ff1d 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-12-11 20:03:16 +00:00
Rémi Verschelde
fded2b4341 CMake: Use set_target_properties instead of set_property
This makes the cmake code a bit cleaner and more consistent.
2023-12-11 20:03:16 +00:00
Allan MacKinnon
bef8f6335e glslangValidator: Exit with an error if output file cannot be written
Propagate the error from glslang::OutputSpv[Hex|Bin] and exit with an error code if there is an error.
2023-12-11 20:03:16 +00:00
Allan MacKinnon
ab739640cf [glslang] Strip trailing whitespace
There are many other files in the repo that have trailing whitespace
but this PR only cleans `glslang/SPIRV` and `glslang/Standalone`.
2023-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
1f727e86c8 Add decorations to structs with buffer references
The containsPhysicalStorageBufferOrArray function now handles struct
types correctly, checking their contents recursively for buffer
reference types. As a result, OpVariables containing structs that have
members that are buffer references now have the appropriate
AliasedPointer or RestrictPointer decoration as per the spec.

Fixes #3188
2023-12-11 20:03:16 +00:00
Johannes Kauffmann
fed6709f25 SPIRV: remove pre-C++11 workaround 2023-12-11 20:03:16 +00:00
Johannes Kauffmann
12e9fdc2ec SPIRV: hex_float: remove workaround for VS2013 2023-12-11 20:03:16 +00:00
janharaldfredriksen-arm
d5a8bab702 Add GLSL_EXT_shader_tile_image 2023-12-11 20:03:15 +00:00
Eric Werness
c51a510b03 GL_EXT_ray_tracing_position_fetch 2023-12-11 20:03:15 +00:00
Chuang Zhu
9468109f82 Use CMAKE_INSTALL_FULL_LIBDIR in compat cmake files
According to
https://cmake.org/cmake/help/v3.25/module/GNUInstallDirs.html,
CMAKE_INSTALL_LIBDIR can be an absolute path. For instance, Nixpkgs
[defined it to an absolute path in /nix/store](3d17b4c305/pkgs/development/tools/build-managers/cmake/setup-hook.sh (L101)).
The output in this case is:

	# result-glslang/lib/cmake/glslangTargets.cmake:5
	include("${CMAKE_CURRENT_LIST_DIR}/../..//nix/store/3mif2zibig0cilk5dbz334278n0vlq9s-glslang-1.3.231.0/lib/glslang/glslang-targets.cmake")

Signed-off-by: Chuang Zhu <git@chuang.cz>
2023-12-11 20:03:15 +00:00
Jeremy Hayes
7fafb89266 Fix DebugCompilationUnit scope
Fix 3167.
2023-12-11 20:03:15 +00:00
Rex Xu
cb579ee0d9 Parameters of spirv_decorate_id should accept variables
spirv_decorate_id will generate OpDecorateId. The parameter list should
accept variables as part of decorations. This is because OpDecorateId
allows this. The spec says:

  All such <id> Extra Operands must be constant instructions or
  OpVariable instructions.
2023-12-11 20:03:15 +00:00
Arcady Goldmints-Orlov
01dad4e801 Fix generation of conditionals with a struct result in SPIR-V
It is possible for the SPIR-V code generator to receive a conditional
where the two branches have the same shader language level type but
different SPIR-V types because of things like offset decorations. This
change modifies visitSelection() to handle this case by using either
multiTypeStore() or, if that is available, OpCopyLogical.

Fixes #3164
2023-12-11 20:03:15 +00:00
Qingyuan Zheng
632704e140 Improve line info for symbol access and assignment 2023-12-11 20:03:15 +00:00
Arcady Goldmints-Orlov
571944fd00 Refactor Builder::createTextureCall() to use std::vector
Use a temporary std::vector to accumulate arguments, rather than a
stack-allocated array with a fixed size. This is safer and more
future-proof.
2023-12-11 20:03:15 +00:00
Jan Engelhardt
b8f0b00b36 build: set SOVERSION on all libraries
Commit fbe9a23baf erroneously
only added SOVERSION to libglslang.so, but none of the others
that are produced.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2023-12-11 20:03:15 +00:00
Maciej
0afb68fbb8 Block-decorate Vulkan Structs with RuntimeArrays
Fixes KhronosGroup/glslang#2439

When decorating a struct for Vulkan, add [Buffer]Block decoration if the
struct has a RuntimeArray member, as required by VUID-...-04680.
2023-12-11 20:03:15 +00:00
Jeremy Hayes
2002626a54 Fix debuginfo disassembly 2023-12-11 20:03:14 +00:00
Jeremy Hayes
c7a35b5490 Fix const parameter debug types
Constant qualified parameter types were not being correctly added to
the DebugTypeFunction instruction.

Fix #3095.
2023-12-11 20:03:14 +00:00
David Neto
2a7fe2486e Remove the name of unused formal paramters
This eliminates a compiler warning in some configurations.
2023-12-11 20:03:14 +00:00
alelenv
7f2dc1ba32 Add support for GL_NV_shader_invocation_reorder. (#3054) 2023-12-11 20:03:14 +00:00
Zhou
28759b4557 [glslang][EXT] Support extension ARB_bindless_texture.
Add missing callgraph clean for bindless status flag.

Add test cases. Add support to check special extensions not be available for Vulkan when using GLSL.
2023-12-11 20:03:14 +00:00
Gilad Ben-Yossef
0c5e1e3dd8 GL_ARM_shader_core_builtins support
Add support for GL_ARM_shader_core_builtins and SPV_ARM_core_builtins,
including initial tests
2023-12-11 20:03:14 +00:00
Johannes Kauffmann
1a0a931fb7 Use nullptr where possible instead of NULL or 0 2023-12-11 20:03:14 +00:00
Greg Fischer
317014c0aa Add EliminateDeadOutputStores to API.
Also eliminates dead output variables and unused output variable
components. Finally calls aggressive dead code elimination.

AnalyzeDeadOutputStores also supplied to be called on the following
shader to provide input for the Eliminate* function.
2023-12-11 20:03:14 +00:00
Sven-Hendrik Haase
405aba1aa8 Fix locations of cmake files in side compat shims
In https://github.com/KhronosGroup/glslang/pull/3027, the installed cmake files were
stuck into a /cmake subdir but this isn't reflected in these compatibility shims.
2023-12-11 20:03:14 +00:00
Shahbaz Youssefi
c68ce50997 Remove GLSLANG_ANGLE
ANGLE no longer links with glslang.  This change reverts
1ef2e250fc which added a flag to strip
glslang to reduce its binary size.  This flag is no longer needed.
2023-12-11 20:03:14 +00:00
Rémi Verschelde
5c603db0eb Convert spirv.hpp line endings to LF (Unix style)
This was the only header using CRLF, the rest already uses LF.
2023-12-11 20:03:13 +00:00
Graeme Leese
1f233fa5c9 Change Volatile generation for HelperInvocation
For SPIR-V 1.6 HelperInvocation accesses need to be volatile to avoid
undefined values when shaders execute 'demote'. Previously this was
always decorated on the gl_HelperInvocation variable, but this is not
valid when the Vulkan memory model is in use.

When the memory model is enabled, stop decorating the variable
declaration and apply the memory semantic to access chain loads instead.

Fixes #3042
2023-12-11 20:03:13 +00:00
Jeremy Hayes
45374da698 Update CHANGES for release 11.12.0 2023-12-11 20:03:13 +00:00
Malcolm Bechard
067f33d239 only use dead input elimination on vertex shaders
It can't be safely used unilaterally on other stages, since that will
result in output/input mismatches between stages. They arn't
having their output variables eliminated accordingly.
2023-12-11 20:03:13 +00:00
Jeremy Hayes
d3fcb30389 Use DebugDeclare for local variables
Previously we had decided to issue DebugValue directly in glslang.
However, this was incorrect and causing issues with RenderDoc.
2023-12-11 20:03:12 +00:00
Qingyuan Zheng
7015946384 Fix OpLine prepending OpFunction reports wrong file when #line is present 2023-12-11 20:03:12 +00:00
Pankaj Mistry
5c688f77fa Make a utility function for termination instructions that take input operands.
Use the new utility function for generating OpEmitMeshTasksEXT.
2023-12-11 20:03:12 +00:00
Pankaj Mistry
56de853fda Fix for issue #3020
Make OpEmitTMeshasksEXT a terminal instructions
2023-12-11 20:03:12 +00:00
Jeremy Hayes
deb8e38707 Implement NonSemantic.Shader.DebugInfo.100
See https://github.com/KhronosGroup/SPIRV-Registry.
2023-12-11 20:03:12 +00:00
sean
828a040306 Fix: Remove NV suffix from C interface 2023-12-11 20:03:12 +00:00
Pankaj Mistry
ed789649ce GL_EXT_mesh_shader/SPV_EXT_mesh_shader implementation
Added following updates to GL_EXT_mesh_shader implementation:

1. Added SPIRV and GLSL test cases
2. Added checks to ensure NV and EXT mesh shader builtins cannot be used interchangeably.
3. Updated the language name by removing the postfix "NV" to MeshShader and TaskShader.
4. Added checks for grammar checking to comply with the spec.

5. Added gl_NumWorkGroups builtin to Mesh shader
6. Fixed data type of gl_PrimitiveLineIndicesEXT and gl_PrimitiveTriangleIndicesEXT
7. Added new constants to the resources table
8. Updates to handle new storage qualifier "taskPayloadSharedEXT"
9. Updated test cases by replacing "taskEXT" with storage qualifier "taskPayloadSharedEXT"

Addressed  Review comments
1. Fixed instruction description used by glslang disassembly.
2. Updated OpEmitMeshTasksEXT as per spec update
3. Fixed implementation that errors out if there are more then one taskPayloadSharedEXT varjables.
4. Fixed miscellaneous error logs and removed unwanted code.

SPIRV 1.6 related build failure fixes
- Update SPIRV header to 1.6
- Fix conflict wiht SPIRV 1.6 change, where localSizeId is used for execution mode for mesh/task shaders

Enable SPIRV generated for EXT_mesh_shader to be version 1.4

GL_EXT_mesh_shader: Add checks for atomic support and corresponding test cases
2023-12-11 20:03:12 +00:00
Harlen
557f31d8fe Fix strict aliasing violation 2023-12-11 20:03:12 +00:00
Andrea Pappacoda
a06a94a446 build: install glslang-config.cmake to libdir
As glslang ships architecture dependant files, the Config file should be
installed to libdir, not datadir. See
https://github.com/KhronosGroup/glslang/pull/2989#discussion_r955367103
for more details.

Here's the diff between the install tree before and after this patch:

    $ diff <(tree install-datadir) <(tree install)
    1c1
    < install-datadir
    ---
    > install
    74,99c74,98
    <         ├── lib
    <         │   ├── cmake
    <         │   │   ├── glslang-default-resource-limitsTargets.cmake
    <         │   │   ├── glslangTargets.cmake
    <         │   │   ├── glslangValidatorTargets.cmake
    <         │   │   ├── HLSLTargets.cmake
    <         │   │   ├── OGLCompilerTargets.cmake
    <         │   │   ├── OSDependentTargets.cmake
    <         │   │   ├── spirv-remapTargets.cmake
    <         │   │   ├── SPIRVTargets.cmake
    <         │   │   └── SPVRemapperTargets.cmake
    <         │   ├── libGenericCodeGen.a
    <         │   ├── libglslang.a
    <         │   ├── libglslang-default-resource-limits.a
    <         │   ├── libHLSL.a
    <         │   ├── libMachineIndependent.a
    <         │   ├── libOGLCompiler.a
    <         │   ├── libOSDependent.a
    <         │   ├── libSPIRV.a
    <         │   └── libSPVRemapper.a
    <         └── share
    <             └── glslang
    <                 ├── glslang-config.cmake
    <                 ├── glslang-config-version.cmake
    <                 ├── glslang-targets.cmake
    <                 └── glslang-targets-debug.cmake
    ---
    >         └── lib
    >             ├── cmake
    >             │   ├── glslang-default-resource-limitsTargets.cmake
    >             │   ├── glslangTargets.cmake
    >             │   ├── glslangValidatorTargets.cmake
    >             │   ├── HLSLTargets.cmake
    >             │   ├── OGLCompilerTargets.cmake
    >             │   ├── OSDependentTargets.cmake
    >             │   ├── spirv-remapTargets.cmake
    >             │   ├── SPIRVTargets.cmake
    >             │   └── SPVRemapperTargets.cmake
    >             ├── glslang
    >             │   ├── glslang-config.cmake
    >             │   ├── glslang-config-version.cmake
    >             │   ├── glslang-targets.cmake
    >             │   └── glslang-targets-debug.cmake
    >             ├── libGenericCodeGen.a
    >             ├── libglslang.a
    >             ├── libglslang-default-resource-limits.a
    >             ├── libHLSL.a
    >             ├── libMachineIndependent.a
    >             ├── libOGLCompiler.a
    >             ├── libOSDependent.a
    >             ├── libSPIRV.a
    >             └── libSPVRemapper.a
    101c100
    < 15 directories, 83 files
    ---
    > 14 directories, 83 files
2023-12-11 20:03:12 +00:00