1772 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
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
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
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
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
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
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
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
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
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
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
b47ecbb53c Fix double expansion of macro arguments.
This adds a new fullyExpanded flag that makes sure that macro arguments
only get expanded once. This can happen either in PrescanMacroArg, or, if
there is token pasting or a function-like macro name has been passed as
an argument and may need to be expanded when used as a function.
2023-12-11 20:03:15 +00:00
Johan Mattsson
2247294c22 Fix potential NULL dereference 2023-12-11 20:03:15 +00:00
Johan Mattsson
4959424f12 Fix potential NULL dereference 2023-12-11 20:03:15 +00:00
Hans Wennborg
bd1b8f8a5b GLSL: Fix integer overflow warnings in Constant.cpp
New versions of Clang warn:

```
glslang/MachineIndependent/Constant.cpp(216,114):
error: overflow in expression; result is -9223372036854775808 with type 'long long' [-Werror,-Winteger-overflow]
                else if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == (long long)-0x8000000000000000ll)
                                                                                                                 ^
glslang/MachineIndependent/Constant.cpp(217,61):
error: overflow in expression; result is -9223372036854775808 with type 'long long' [-Werror,-Winteger-overflow]
                    newConstArray[i].setI64Const((long long)-0x8000000000000000ll);
                                                            ^
2 errors generated.
```

Using LLONG_MIN instead avoids the problem. I think it's also more
clear, and the code for EOpMod further down already does this.
2023-12-11 20:03:15 +00:00
Maciej
d881c507ea Move check if useStorageBuffer needs to be set.
From TParseContext used only by GLSL, to TParseContextBase inherited by both GLSL and HLSL paths.
It caused compilations from HLSL to SPIR-V 1.3+ to use BufferBlock decoration which is no longer valid.
2023-12-11 20:03:14 +00:00
Arcady Goldmints-Orlov
2d537a62b1 Reject non-float inputs/outputs with version < 120
GLSL 1.20 and prior stated that "the attribute qualifier can be used
only with float, floating-point vectors, and matrices" and likewise
for varying.

Fixes: #3111
2023-12-11 20:03:14 +00:00
Greg Fischer
254c47f875 Fix crash on bad structure member reference
Fixes #3105
2023-12-11 20:03:14 +00:00
Chow
fa1570a4c0 [glslang] Refine implicit array size interfaces. (#3074)
* [glslang] Refine implicit array size interfaces.

Help to check builtin and other variables if across stages.
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
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
Try
6049a8ce61 mesh shader: fix implicit index-array size calculation for lines and triangles
#fixed #3041
2023-12-11 20:03:13 +00:00