Commit Graph

366 Commits

Author SHA1 Message Date
Steve Urquhart
9f37ad360e Support files with UTF8BOM character 2024-03-13 13:03:10 -04:00
Sharo
d73712b8f6
Add flags for outputting absolute paths for messages (#3467)
Uses std::filesystem to create absolute paths.
Also adds "shaderFileName" to TSinkBase so it can be used during message
outputs.
2024-03-07 19:02:45 -05: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
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
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
Moritz Heinemann
b820431a2c No external install include dir 2023-11-27 19:13:13 -05:00
Juan Ramos
4c121b68c8
cmake: Remove find_host_package macro
Originally added in https://github.com/KhronosGroup/glslang/pull/2395

With the rational of causing issues when cross-compiling for iOS.

This is no longer the case.
2023-11-22 16:48:14 -05:00
Moritz Heinemann
eac012fff3 Fix spirv-tools dependency 2023-11-20 18:28:38 -05: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
Nathaniel Cesario
8fa46582ec Remove debugOptions from internal classes
The debug options passed down from the public ShConstruct* functions to
internal code is unused. This change removes the internal debugOptions
fields and attempts to make it more obvious these fields are not used.

This change does not change the public-facing interface.

This change also adds the -Wshorten-64-to-32 warning to the StandAlone
build in order to avoid unwanted 64-to-32 bit conversions in the future.

Closes #3348.
2023-10-25 20:13:20 -04:00
Nathaniel Cesario
b0ed478885 Fix race condition identified by TSAN
Guard global variables 'CompileFailed' and 'LinkFailed' in the
StandAlone application with atomics.
2023-09-29 18:39:17 -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
Sven van Haastregt
70d125b924 cmake: Don't link SPVRemapper into glslang executable
The functionality of `libSPVRemapper` is only used by the
`spirv-remap` executable, so don't link it into the `glslang`
executable.
2023-08-18 09:52:54 -06:00
Nathaniel Cesario
79a9f7f652 Fix continuous deployment
There should not be a '/' after $ENV{DESTDIR} in the cmake install script.

This change also:
- Uses lukka/get-cmake github action consistently across jobs
- Add the glslang binary to the continuous deployment archive
2023-08-07 10:52:22 -06:00
Arcady Goldmints-Orlov
396596ca4a Replace GlobalLock functions with std::mutex
The usage of GetGlobalLock/ReleaseGlobalLock/InitGlobalLock is replaced
by std::lock_guard which is available as of c++11, and the functions are
removed from the OSDependent ossource.cpp files.
The standalone glslang binary now explicitly depends on OSDependent, as
nothing in in the glslang library uses those functions anymore and they
are not implicitly picked up by the linker.
2023-07-31 20:12:51 -06:00
Tim Biermann
171a322025 respect destdir for compat symlink 2023-07-31 14:04:22 -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
Allan MacKinnon
c8c669fc2a
spirv-remap: Support outputting each SPIR-V module to a filename
The `spirv-remap` tool now supports two output modes:
  * Outputting one or more inputs to a single directory -- the previous
    behavior
  * One output file per input -- new behavior.
2023-07-28 10:13:55 -06:00
Nathaniel Cesario
865fe73958 cmake: Fix symlink on Windows
Copy the old glslangValidator name on Windows rather than creating a
symlink. While cmake 3.13 and above supports creating symlinks on
Windows, a security policy change is required in general to allow
the creation of symlinks for non-trusted users. See
https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links

Fixes #3268.
2023-07-19 17:16:37 -06:00
Nathaniel Cesario
856e280502 cmake: Rename glslang to glslangValidator
Rename glslangValidator to glslang and adds a glslangValidator symlink
to the build and install directories.

Closes #47.
2023-07-18 15:23:50 -06:00
juan-lunarg
5793fbd624 cmake: Fix CMake 3.27 warnings
The FindPythonInterp and FindPythonLibs modules, which have
been deprecated since CMake 3.12, have been removed by policy
CMP0148. Port projects to FindPython3, FindPython2, or FindPython.
2023-06-16 16:12:26 -04:00
Allan MacKinnon
9fbc561947
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-05-23 14:07:48 -06:00
Allan MacKinnon
a5bf69936d [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-05-22 12:04:40 -06:00
Johannes Kauffmann
e00517acfe SPIRV: remove pre-C++11 workaround 2023-05-10 09:55:02 -06:00
Sruthik P
bc6b2bc17a glslang: Do not link with pthread on QNX
On QNX, pthread APIs are provided as part of libc and a separate pthread
library does not exist.

This change updates the makefile of glslang to not link with pthread on
QNX, thereby enabling glslang to be built for QNX platforms.
2023-05-03 09:09:01 -06:00
Chuang Zhu
dfc97740ff 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-05-02 15:46:45 -06:00
Arcady Goldmints-Orlov
f766ee96f5 Improve help text for the new -P option 2023-04-12 18:24:35 -04:00
Moritz Heinemann
893145ead2 Add option to glslangValidator to inject preamble 2023-04-06 13:38:39 -04:00
Moritz Heinemann
f5fa593143 move ResourceLimits from StandAlone to glslang dir (Fix #3064) 2023-02-15 20:06:26 +01:00
Jan Engelhardt
4386679bcd 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-02-03 15:19:35 -07:00
Daniel Story
a88f674124 Fix issues with MaxDualSourceDrawBuffersEXT 2022-12-21 11:53:50 -08:00
Johannes Kauffmann
a7603c132d Use nullptr where possible instead of NULL or 0 2022-11-30 09:33:28 -07:00
Sven-Hendrik Haase
88fd417b0b 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.
2022-11-16 16:54:09 -07:00
Greg Fischer
90c5214344 Improve ResourceLimits interface to be more forward compatible
New interface allows users to generate ResourceLimits for interface so
that additions to TBuiltInResource do not break the ABI.

Users should use the glslang-default-resource-limits library and the
Public/ResourceLimits.h header. Similar changes have been made to the
C interface. Use Public/resource_limits_c.h.

Fixes #2822
2022-11-01 12:06:51 -06:00
Greg Fischer
284ceb6d45
Merge pull request #2985 from jeremy-lunarg/hayes-nonsemantic-shader-debuginfo-rebase
Implement NonSemantic.Shader.DebugInfo.100 debug instruction generation.

These instructions will be generated under the -gV and -gVS  command line options. These instructions enable source-level shader debugging with Renderdoc.

This is an alpha release of this capability. Additional improvements are forthcoming. Use and feedback are welcome.
2022-09-09 10:13:02 -06:00
Pankaj Mistry
228c67228a 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
2022-09-01 18:02:21 -07:00
Jeremy Hayes
7a914ce926 Implement NonSemantic.Shader.DebugInfo.100
See https://github.com/KhronosGroup/SPIRV-Registry.
2022-08-26 16:17:54 -06:00
Andrea Pappacoda
1b32fc8eb2
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
2022-08-25 23:15:14 +02:00
MACHIZAUD Andréa
fb64704060
Add unified glslang CMake config collecting glslang-targets targets (#2989) 2022-08-02 18:16:03 -06:00
ahagan
b5aae62731 Add whitelist filtering for debug comments in SPIRV-Remap. 2022-05-11 12:08:25 -04:00
Greg Fischer
f1d286fcc2
Merge pull request #2851 from chaoticbob/version-override
Added GLSL version override functionality and CLI
2022-03-24 17:51:54 -06:00
Alexey Panteleev
d44871ca08 Escape the characters that Make considers special in the dependency files. 2022-03-11 17:56:15 -08:00
Greg Fischer
ca0d54d51b Enhance readability of error messages for GLSL
Specifically, make GLSL link error messages more specific and output
only information relevant to the error.

Also change type printing to more closely reflect GLSL syntax. This
is the default for link error messages, but must me enabled with the
new option --enhanced-msgs for compilation error messages.

Also with --enhanced-msgs, only emit one error message per source
line.
2022-02-01 12:10:08 -07:00
Greg Fischer
9ebd8ff6c1 Add Vulkan 1.3 support
Also update known goods to Vulkan 1.3 support
Also re-enable SPIR-V 1.6 tests with vulkan1.3 target
Also re-cache SPIRV 1.6 header which somehow regressed back to 1.5
2022-01-26 17:57:31 -07:00
Hai Nguyen
1f10dddac4 Revisions to GLSL version override
- Reverted public function interface changes for C++.
- Added override member variable to TShader.
- Added accessor TShader::setOverrideVersion.
- Reverted changes to tests.
2022-01-01 19:02:14 -05:00
Hai Nguyen
9a98d32366 Added GLSL version override interface and CLI
This change list allows a user to override the GLSL version from the
command line or through the C and C++ interfaces. This will override the
override happens in ProcessDeferred() before DeduceVersionProfile() so
the process should still error out if the version is insufficient for
the shader code.

- Added --glsl-version <version> to CLI.
- Added parameter to route glslVersion as override version to
  preprocessor and parse functions to C++ interface.
- Updated C interface with function to override GLSL version.
2022-01-01 04:31:44 -05:00
Greg Fischer
7a49192d23 Add support for spirv1.6
Add command line support which enables the following behavior:

- Remap discard

  Map discard to DemoteToHelperInvocation for HLSL shaders. Map to
  OpTerminateInvocation for GLSL shaders.

- Decorate HelperInvocation with Volatile

- Use localSizeId for execution mode

  WorkGroupSize is deprecated in spirv1.6

Also update known goods to SPIRV 1.6
2021-12-16 15:01:42 -07:00
Greg Fischer
e9564feb55 Add --hlsl-dx-position-w option
This reciprocates the w component of SV_Position in HLSL fragment shaders
to provide DirectX compatibility for HLSL shaders in Vulkan.

Fixes #2244
2021-11-16 18:42:12 -07:00
David Neto
36333d1fb9 Fix Cmake rule for extension header generation
Allow glslang to be embedded in an enclosing project (such as Shaderc)
2021-10-19 17:32:52 -04:00
amhagan
035a3bbc4a GL_EXT_spirv_intrinsics - Port extensions
Add mechanism to use GL_EXT_spirv_intrinsics headers in glslang.
Ported GL_EXT_shader_realtime_clock as an example.
2021-10-15 14:13:08 -04:00