2339 Commits

Author SHA1 Message Date
Pankaj Mistry
d6da7656ea Clean the implementation of GL_EXT_texture_shadow_lod.
Move the parameter verifictation to a centralized place where all the builtins
are verified for correctness.

Add verification for the new builtins with version and extension check
These builtins are supported on GLSL since version 130 and GLES since
version 300.
2023-12-11 20:03:18 +00:00
alelenv
1ace3e8355 Add support for GL_NV_displacement_micromap.
* Add support for GL_NV_displacement_micromap.
* Update known_good for spirv-headers and spirv-tools.
2023-12-11 20:03:18 +00:00
chirsz-ever
3877be8117 Improve preprocessor ouput format
Modify preprocessor.simple.vert to test spaces before parenthesis.
2023-12-11 20:03:18 +00:00
Nathaniel Cesario
ad982d811d 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-12-11 20:03:18 +00:00
Nathaniel Cesario
d4b7b7b77b Fix segfault with atomic arg check
Makes sure that we have an l-value before checking the storage type of
the mem argument passed to an atomic memory operation.

Fixes #3332.
2023-12-11 20:03:18 +00:00
Rex Xu
717e3ddf66 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-12-11 20:03:18 +00:00
Nathaniel Cesario
dddab4ac77 Fix textureOffset overload
float textureOffset(sampler2DArrayShadow sampler, vec4 P, ivec2 offset)
was incorrectly requiring the GL_EXT_texture_shadow_lod extension.

NOTE: Prior to GLSL 440, this prototype was defined as

float textureOffset(sampler2DArrayShadow sampler, vec4 P, vec2 offset)

i.e., the type of 'offset' was specified as 'vec2' rather than 'ivec2'.
This is believed to be a typo.

Fixes #3325.
2023-12-11 20:03:17 +00:00
Nathaniel Cesario
467e8804e4 Use temporary parser for mangled names
Use a temporary parser to retrieve the mangled names of specific
function overloads. This is necessary for GL_EXT_texture_shadow_lod.
2023-12-11 20:03:17 +00:00
Nathaniel Cesario
23c80a83a8 Add GL_EXT_texture_shadow_lod support
Closes #3302.
2023-12-11 20:03:17 +00:00
Ralf Habacker
f121169feb Revert "CMake: Make glslang-default-resource-limits STATIC"
Fixes #3316

This reverts commit 6f22e41e0de13aff75807cca9662730d8b3e54b6.
2023-12-11 20:03:17 +00:00
Pedro Olsen Ferreira
a9a481664d Fix ODR violations
On a shared build, these symbols exist in both libglslang.so and
libSPIRV.so, leading to an ODR violation at runtime.
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
Rex Xu
0da98c51c4 Spirv_intrinsics: Remove early return in layoutTypeCheck
Previously, when GL_EXT_spirv_intrinsics are enabled, we disable all
checks in layoutTypeCheck. This is too coarse because we can use nothing
in GL_EXT_spirv_intrinsics in a shader while the necessary processing is
skipped, such as addUsedLocation.

In this change, we apply fine check and more might be added if we
encounter new cases in the future.
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
Arcady Goldmints-Orlov
b4443eb859 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-12-11 20:03:17 +00:00
Arcady Goldmints-Orlov
e40191047c Remove glslang.m4
The m4 grammar build mechanism was only ever needed as a preprocessor
for bison, to be used with GLSLANG_WEB, which has now been removed.

Fixes #2958
2023-12-11 20:03:17 +00:00
Arcady Goldmints-Orlov
73b75b1998 Remove a stray GLSLANG_WEB ifdef 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
画卦伏羲
7247854500 Fix [type] command file url forward slashes issue when use mingw 2023-12-11 20:03:17 +00:00
Arcady Goldmints-Orlov
4540ec6cf3 Remove OSDependent TLS functions
These are no longer used now that the PoolAllocator uses the standard
c++11 thread_local storage mechanism.
2023-12-11 20:03:17 +00:00
Ben Clayton
f527002d45 Simplify PoolAlloc with use of thread_local.
glslang is using C++ 11, which has first class support for variables of the `thread_local` storage class.

By dropping the use of the `OS_[GS]etTLSValue`, we can simplify the logic, and have it support a thread-local default allocator if none is provided.

Issue: #2346
2023-12-11 20:03:16 +00:00
Boris Zanin
f56d219587 Implement support for GL_KHR_cooperative_matrix extension 2023-12-11 20:03:16 +00:00
Sven van Haastregt
16af4d6c49 Fix typo in error message 2023-12-11 20:03:16 +00:00
scribam
700c328ea3 Remove useless semicolons 2023-12-11 20:03:16 +00:00
Sven van Haastregt
917e466f9d Silence unused parameter warning
The parameter could be removed, but keep it for consistency with other
`makeSpirvTypeParameters` overloads.
2023-12-11 20:03:16 +00:00
Nathaniel Cesario
4bf5ec0c1e web: Fix emscripten build
The web/emscripten build has been broken for an unknown amount of time
and for multiple reasons:
  - Calling `cat` on Windows
  - The latest version of wasm-ld does not support the `--no-undefined`
    flag
  - `ccall` was not being exported

Fixes #3272.
2023-12-11 20:03:16 +00:00
Juan Ramos
e7c558ba38 cmake: Fix Android build for r25 NDK
Currently with the build instructions provided in README.md
the build will fail.

In the r25 NDK the CMake toolchain defaults to the legacy path,
due to a bug in the current implementation.

https://github.com/android/ndk/issues/323
2023-12-11 20:03:16 +00:00
Pedro Olsen Ferreira
02aa2b282b Fix maybe-uninitialized warning
The 'set' and 'setRT' variables were warning as maybe-uninitialized even
though in practice that case would never trigger (due to how the
function flow-controls).
The code blocks where these variables are actually read do not overlap,
so merge them into the same 'set' variable.
Simplify the control flow of the function with early-returns, which
drops indentation and simplifies the function.
2023-12-11 20:03:16 +00:00
Dawid-Lorenz-Mobica
a94c5ff864 HLSL: support binary literals
Fixes #3089
2023-12-11 20:03:16 +00:00
Zeqiang Li
1804b08805 Add missing initialization members for web (#3246) 2023-12-11 20:03:16 +00:00
Malcolm Bechard
b8227c215e Rework how auto push_constant upgrading works a bit.
Ensure we traverse the entire tree and upgrade all references to the
given symbol so it can be upgraded to push_constant. Without this change
only one instance was upgraded, and others were left as uniform buffers.
2023-12-11 20:03:16 +00:00
Dawid Lorenz
56b1090f33 Add support for pre and post HLSL qualifier validation
The change makes it possible to define a const variable after the marked
type. Example "float const"
2023-12-11 20:03:16 +00:00
Dawid Lorenz
10da9c9550 Add support for pre and post HLSL qualifier validation
The change makes it possible to define a const variable after the marked
type. Example "float const"
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
Pablo Delgado Krämer
7b27be3f49 Fix GL_NV_shader_invocation_reorder #define typo 2023-12-11 20:03:16 +00:00
Sven van Haastregt
5f8a1985bd Fix -Wmaybe-uninitialized warnings
Fix some potentially uninitialized uses that are reported by GCC 13
with `-O3`.
2023-12-11 20:03:16 +00:00
rcombs
58bbccc3cf glslang_c_interface: use valid C function prototypes
Prototypes are required in C.
2023-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
d7c51a7dce CMake: Make glslang-default-resource-limits STATIC 2023-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
6ae905e638 Include <cstdint> header in Common.h
This change also cleans up some ifdef'd code for no longer supported
versions of MSVC.

Fixes: #3139
2023-12-11 20:03:16 +00:00
Johannes Kauffmann
f6c1769134 Common.h: don't use to_string workaround on MSVC
Pre-VS2012 is no longer supported.

It might still be needed on Android, I haven't tested this.
2023-12-11 20:03:16 +00:00
Johannes Kauffmann
0c479ae4ae PP: remove workaround for VS2015 2023-12-11 20:03:16 +00:00
Ryan Harrison
b2af3b916e Correct ctor order to make '-Wreorder-ctor' pass
These lines in the ctor being out of order are causing -Wreorder-ctor
to fire when trying to integrate glslang ToT into Chromium/Dawn/etc,
https://logs.chromium.org/logs/dawn/buildbucket/cr-buildbucket/8781562047251466593/+/u/compile_with_ninja/stdout.
2023-12-11 20:03:16 +00:00
Alexey Ozeritskiy
6929ac54eb Use custom callbacks if they are available in 'i->callbacks' 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
David Neto
941df35580 fix error message for vertex struct input
Vertex shaders can have pipeline inputs that are arrays, but not structure
inputs. (GLSL 4.5 section 4.3.4)

But the error message for struct inputs says "cannot be a structure or array".
This PR removes the "or array" part.

Note: The array case is handled immediately after the check for
structure type.

Co-authored-by: Arcady Goldmints-Orlov <arcady@lunarg.com>
2023-12-11 20:03:15 +00:00
Try
7536f5670b fix crash in HLSL frontend
fix crash, when converting HLSL return of hull shader into spirv/glsl like arrayed output.

fix #2914
2023-12-11 20:03:15 +00:00
spencer-lunarg
1c2f7a3a4f Improve error message of alignment offset 2023-12-11 20:03:15 +00:00
Rex Xu
68e8d79cad Fix an issue when we merge multiple spirv_decorate_xxx directives
There is a typo.
2023-12-11 20:03:15 +00:00