Commit Graph

1960 Commits

Author SHA1 Message Date
Nathaniel Cesario
5ad3d41364 Output 8 and 16 bit capabilities OpSpecConstantOp
OpSpecConstants with 8 or 16 width types require the corresponding
capabilities.

Fixes #3449.
2023-12-15 18:36:00 -05:00
jimihem
a7785ea1ff
Support GL_EXT_draw_instanced extension. 2023-12-12 18:22:04 -05:00
“jimihe”
07e8220d4e support GL_EXT_texture_array extention. 2023-12-12 14:31:34 -05:00
“jimihe”
feb5437942 PP: Report an error when a # is not the first thing on a line
According to the GLSL spec
Each number sign (#) can be preceded in its line only by spaces or horizontal tabs.
It may also be followed by spaces and horizontal tabs, preceding the directive.
2023-12-07 19:29:48 -05:00
Arcady Goldmints-Orlov
530a6266b2 Fix tokenLength test to not trigger spurious preprocessor error
The preprocessor now reports errors for #'s appearing in the wrong
place, which were being triggered by this test. This test is rewritten
slightly to only report the errors we want.
2023-12-07 19:29:48 -05:00
Chao Chen
9a35abff55 Always enable the generation of OpDebugBasicType for bool type 2023-12-06 19:23:45 -05:00
Arcady Goldmints-Orlov
a1138bacff Improve overflow_underflow_toinf_0 test somewhat
Add test cases that will make explicit ±0.0 and ±INF appear in the AST
output to make sure those cases are handled correctly.
2023-11-30 19:10:11 -05:00
Arcady Goldmints-Orlov
a187f47e2c Move overflow_underflow_toinf_0 from runtests to gtest
gtest is the preferred framework for simple tests that don't require
passing special command-line options to glslang.
2023-11-30 19:10:11 -05:00
Samuel Bourasseau
c59b876ca0
Implement relaxed rule for opaque struct members 2023-11-28 19:19:02 -05:00
Nathaniel Cesario
19d541a91d Fix some compiler warnings
This change primarily fixes some -Wconversion warnings from gcc, but
also silences a warning triggered in glslang_tab.cpp, which is generated
code from bison.

There are still several GCC conversion warnings in Types.h due to the
use of bit fields that will be resolved in a future change.
2023-11-28 19:16:16 -05:00
FrostyLeaves
153064f2c7 fix: Support SV_ViewID keywords for hlsl. 2023-11-22 17:04:38 -05:00
“jimihe”
854db99ff1 Out-of-range floats should overflow/underflow to infinity/0.0
glslang representing literal constants with double precision, so 1.0e40 and 1.0e-50 are normal values.

        Shader1:
        precision highp float;
        out vec4 my_FragColor;
        void main()
        {
        // Out-of-range floats should overflow to infinity
        // GLSL ES 3.00.6 section 4.1.4 Floats:
        // "If the value of the floating point number is too large (small) to be stored as a single precision value, it is converted to positive (negative) infinity"
        float correct = isinf(1.0e40) ? 1.0 : 0.0;
        my_FragColor = vec4(0.0, correct, 0.0, 1.0);
        }
        The expected ouput result of this test is vec4(0.0, 1.0, 0.0, 1.0),
        but it's vec4(0.0,0.0,0.0,1.0).Because the return value of isInf is
        false.

        precision highp float;
        out vec4 my_FragColor;
        void main()
        {
        // GLSL ES 3.00.6 section 4.1.4 Floats:
        // "A value with a magnitude too small to be represented as a mantissa and exponent is converted to zero."
        // 1.0e-50 is small enough that it can't even be stored as subnormal.
        float correct = (1.0e-50 == 0.0) ? 1.0 : 0.0;
        my_FragColor = vec4(0.0, correct, 0.0, 1.0);
        }
        The expected ouput result of this test is vec4(0.0, 1.0, 0.0, 1.0),
        but it's vec4(0.0,0.0,0.0,1.0).

        For f32 and f16 type, when the literal constant out of range of the f32
        and f16 number, the value should overflow or underflow to inf or zero.

            glcts test item
        KHR-GLES3.number_parsing.float_out_of_range_as_infinity
2023-11-17 16:30:22 -05:00
Qingyuan Zheng
845e5d5a28 Fix the corrupted test because of rebase 2023-11-14 14:46:44 -07:00
Qingyuan Zheng
109b5979d3 Support NonSemantic DebugValue and generate it for const arg
For passing-by-value semantic, DebugDeclare cannot be used for parameters because there's no pointer.
2023-11-14 14:46:44 -07:00
Nathaniel Cesario
52c59ecd3d Fix interpolant ES error
The restriction of no swizzling and no struct fields as an interpolant
were not being checked when using the ES profile.

Fixes #3277.
2023-11-11 08:53:16 -07:00
Nathaniel Cesario
091b9fd979 Fix GL_ARB_shader_storage_buffer_object version
Ensure that GL_ARB_shader_storage_buffer_object is available from
version GL 400 to GL 420.

Closes #3263.
2023-11-07 15:56:52 -07:00
Malcolm Bechard
1dde7113bb tweak error behavior for redeclared uniforms for vulkan-relaxed
avoids nullptr crash from reading memberType's name, and more user
friendly error message.
2023-10-31 15:02:38 -04:00
Kévin Petit
a9e698322e
Align spirv.hpp to SPIRV-Headers for SPV_KHR_cooperative_matrix
Some of the enumerants used by this extension were missing a KHR suffix.
2023-10-25 19:59:52 -04:00
Chao Chen
979423d84f Add correct line number to OpDebugFunction and OpDebugScope for function:
1. Pull OpDebugFunction, OpDebugScope and OpDebugVariable for params out
   of makeFunctionEntry.
2. Put above in a separate function called setupDebugFunctionEntry,
   which also accept line number and set it correctly in builder.
3. Call setupDebugFunctionEntry in makeFunction. Also special case
   handle entry function since it's created ealier elsewhere.
2023-10-24 13:37:19 -07:00
Arcady Goldmints-Orlov
0504953b35 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-10-13 17:49:26 -04:00
Arcady Goldmints-Orlov
48f9ed8b08 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-10-12 14:45:33 -04:00
Pankaj Mistry
5ff0c048b7
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-10-02 15:10:11 -04:00
alelenv
3f02132668
Add support for GL_NV_displacement_micromap.
* Add support for GL_NV_displacement_micromap.
* Update known_good for spirv-headers and spirv-tools.
2023-10-02 15:07:50 -04:00
chirsz-ever
2bfacdac91 Improve preprocessor ouput format
Modify preprocessor.simple.vert to test spaces before parenthesis.
2023-09-22 16:34:08 -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
Nathaniel Cesario
efc33d1ee5 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-09-15 17:43:04 -04:00
Sajjad Mirza
afe6e781bd
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-09-11 20:11:22 -04:00
Nathaniel Cesario
f3f23fece3 Add a generic texel fetch test
Test all core sampler functions.
2023-09-11 16:51:11 -04:00
Nathaniel Cesario
e8d657bdbe 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-09-11 16:51:11 -04:00
Nathaniel Cesario
ffefbcd9f3 Add GL_EXT_texture_shadow_lod support
Closes #3302.
2023-09-05 19:00:10 -04:00
Nathaniel Cesario
a1f8cd429f 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-08-31 16:22:03 -06:00
Wooyoung Kim
db8719ae07
extension: GL_QCOM_image_processing support 2023-08-21 18:14:52 -06:00
Rex Xu
b70669a059 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-08-15 09:37:26 -06:00
Arseny Kapoulkine
34d4f78f03
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-08-07 11:38:17 -06:00
Boris Zanin
808c7ed17c Implement support for GL_KHR_cooperative_matrix extension 2023-07-26 16:39:17 -06:00
Arcady Goldmints-Orlov
65397339c5 Remove obsolete files
WORKSPACE is related to Bazel, which is no longer supported
Test/makeDoc uses an option that glslang no longer supports.
2023-07-20 16:12:44 -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
Dawid-Lorenz-Mobica
d5f3ad6c9a
HLSL: support binary literals
Fixes #3089
2023-07-18 09:35:36 -06:00
Dawid Lorenz
44779f508a 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-07-11 13:36:38 -04:00
Dawid Lorenz
4ae01c5f41 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-07-11 13:36:38 -04:00
Rex Xu
051f18c0cc 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-07-11 13:26:22 -04:00
Arcady Goldmints-Orlov
d89c0b1d13 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-06-27 13:49:14 -04:00
Arcady Goldmints-Orlov
9caca7a17b 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-05-19 11:35:18 -06:00
janharaldfredriksen-arm
0bbec2e8f6 Add GLSL_EXT_shader_tile_image 2023-05-08 19:49:25 -06:00
Eric Werness
9d8c7b75c9 GL_EXT_ray_tracing_position_fetch 2023-05-05 09:12:37 -06:00
David Neto
b8955549ef 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-04-20 18:25:55 -04:00
Arcady Goldmints-Orlov
68f073b195 Add a test for empty structs in HLSL hull shaders 2023-04-13 09:49:00 -04:00
spencer-lunarg
9fe5223370 Improve error message of alignment offset 2023-04-10 16:21:15 -04:00
Moritz Heinemann
bdba39bae6 Add more preamble tests 2023-04-06 13:38:39 -04:00
Moritz Heinemann
893145ead2 Add option to glslangValidator to inject preamble 2023-04-06 13:38:39 -04:00