1934 Commits

Author SHA1 Message Date
Arcady Goldmints-Orlov
3238c9c694 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-12-11 20:03:18 +00:00
Arcady Goldmints-Orlov
9b67a0ae3c 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-12-11 20:03:18 +00:00
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
Sajjad Mirza
33cef2f02d 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-12-11 20:03:18 +00:00
Nathaniel Cesario
85308a427f Add a generic texel fetch test
Test all core sampler functions.
2023-12-11 20:03:17 +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
23c80a83a8 Add GL_EXT_texture_shadow_lod support
Closes #3302.
2023-12-11 20:03:17 +00:00
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
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
Boris Zanin
f56d219587 Implement support for GL_KHR_cooperative_matrix extension 2023-12-11 20:03:16 +00:00
Arcady Goldmints-Orlov
35a3b0251c Remove obsolete files
WORKSPACE is related to Bazel, which is no longer supported
Test/makeDoc uses an option that glslang no longer supports.
2023-12-11 20:03:16 +00:00
Nathaniel Cesario
635ce4f2e2 cmake: Rename glslang to glslangValidator
Rename glslangValidator to glslang and adds a glslangValidator symlink
to the build and install directories.

Closes #47.
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
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
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
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
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
Arcady Goldmints-Orlov
3b33c7a3c2 Add a test for empty structs in HLSL hull shaders 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
Moritz Heinemann
f0f119233f Add more preamble tests 2023-12-11 20:03:15 +00:00
Moritz Heinemann
98137dc808 Add option to glslangValidator to inject preamble 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
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
094b567af7 Add tests for conditionals that return a struct value
There are 3 separate tests added to cover the 3 cases in
visitSelection(). With SPIR-V versions prior to 1.4, control flow is
generated, with GLSL generating code to execute only the appropriate
branch of the conditional while HLSL executes both branches and uses the
control flow to select the appropriate one. Finally, with SPIR-V
versions newer than 1.4, OpSelect can be used on structs.

Note that the hlsl.structcopy.comp and hlsl.structcopylogical.comp tests
have identical shader code, but are compiled with different versions of
SPIR-V and result in different codepaths being used and different SPIR-V
generated.
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
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
Randall C. O'Reilly
0ab71c6180 updated test to test atomic float add and test results 2023-12-11 20:03:15 +00:00
Maciej
9dec5d66ce Add test 2023-12-11 20:03:15 +00:00
rdb
1465a518fc HLSL: Add missing relaxed-precision float/int matrix expansions 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
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
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
Try
866b02800d update failing test-cases 2023-12-11 20:03:13 +00:00