This is intended so that downstream projects consuming glslang with FetchContent or similar means can use `-Wimplicit-fallthrough` without getting warning spam.
I've used my best judgement to determine whether the implicit fallthrough was desired, or was simply unreachable code.
`std::unreachable` is unavailable until C++23, but I saw places where `default: assert(0);` was used, so copied that.
There were a few places where some code might actually have been reachable and intended to return a value that represented an error, so someone should double check that kind of thing.
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
- Correctly populate the field `currentFileId` with the presence of include directive
- Support lazy OpLine/OpDebugLine generation only when a real instruction is added instead of a debug location is set
- Improve the debug location tracking to per-block instead of just per-builder
- A few bug fixes related to debug source info
Co-authored-by: Neil Hickey <neil.hickey@arm.com>
Co-authored-by: Stuart Brady <stuart.brady@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
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.
Only the headers that are part of glslang's public interface are
installed. Previously, all of its headers were installed, which exposed
a lot of internal implementation details and made it difficult to
maintain backward compatiblity. This reduces the API surface somewhat
and will make it easier to maintain API and ABI compatibility.
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.
GlslangToSpv.h only declares functions with opaque references to to
TIntermediate, for which a simple "class TIntermediate;" declaration is
adequate. This means that Include/intermediate.h no longer needs to be
installed as part of glslang's public interface.
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.
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.
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
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.
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.
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.
There was a race condition in this function as it used a static variable
to attempt to ensure global initialization was only done once, which was
not thread-safe. Instead, use std::call_once, which was added to C++11
for this exact case.
Fixes#342
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.
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
The `function` parameter is only used by an assert currently, so mark
it as "maybe unused". Alternatively the parameter could be removed,
but avoid such API churn for now.