Oes spec says:
For the both the input array gl_SampleMaskIn[] and the output array gl_SampleMask[], bit B of mask M
(gl_SampleMaskIn[M] or gl_SampleMask[M]) corresponds to sample 32*M+B. These arrays have
ceil(gl_MaxSamples/32) elements, where gl_MaxSamples is the maximum number of color samples
supported by the implementation.
But glslang report error "array must have size before use length".
layout(location = 0) out mediump vec4 fragColor;
void main (void)
{
for (int i = 0; i < gl_SampleMask.length(); ++i)
gl_SampleMask[i] = int(0xAAAAAAAA);
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
* Add two test items, one is for gl_MaxSapmles = 32 and the other one is for gl_MaxSapmles = 64.
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.
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.
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.
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
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
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.
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.
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.
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.
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.
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 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
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>
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.
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.
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.
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.
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
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.
This bug got introduced as part of EXT_mesh_shader changes 228c672
Also updated barycentric test cases to add coverage for multiple pervertexEXT array inputs
gl_SubGroupARB was being correctly declared as an Input variable in
Vulkan but it was missing the Flat decoration, which made spirv-val emit
the VUID-StandaloneSpirv-Flat-04744 validation error with shaders using
that built-in.
Implement NonSemantic.Shader.DebugInfo.100 debug instruction generation.
These instructions will be generated under the -gV and -gVS command line options. These instructions enable source-level shader debugging with Renderdoc.
This is an alpha release of this capability. Additional improvements are forthcoming. Use and feedback are welcome.
Added following updates to GL_EXT_mesh_shader implementation:
1. Added SPIRV and GLSL test cases
2. Added checks to ensure NV and EXT mesh shader builtins cannot be used interchangeably.
3. Updated the language name by removing the postfix "NV" to MeshShader and TaskShader.
4. Added checks for grammar checking to comply with the spec.
5. Added gl_NumWorkGroups builtin to Mesh shader
6. Fixed data type of gl_PrimitiveLineIndicesEXT and gl_PrimitiveTriangleIndicesEXT
7. Added new constants to the resources table
8. Updates to handle new storage qualifier "taskPayloadSharedEXT"
9. Updated test cases by replacing "taskEXT" with storage qualifier "taskPayloadSharedEXT"
Addressed Review comments
1. Fixed instruction description used by glslang disassembly.
2. Updated OpEmitMeshTasksEXT as per spec update
3. Fixed implementation that errors out if there are more then one taskPayloadSharedEXT varjables.
4. Fixed miscellaneous error logs and removed unwanted code.
SPIRV 1.6 related build failure fixes
- Update SPIRV header to 1.6
- Fix conflict wiht SPIRV 1.6 change, where localSizeId is used for execution mode for mesh/task shaders
Enable SPIRV generated for EXT_mesh_shader to be version 1.4
GL_EXT_mesh_shader: Add checks for atomic support and corresponding test cases
Previously, GL_KHR_ray_tracing was a required extension to generate
OpConvertUToAccelerationStructureKHR conversion instructions from uint64
and uvec2. However, both GL_KHR_ray_tracing and GL_KHR_ray_query should
provide this construction.
Change-Id: I6564c127fd28d9b527d334958a5adc168f5cdd9a
This type was removed from spirv1.6. If samplerBuffer is specified in
GLSL, generate textureBuffer. If samplerBuffer type is constructed,
just return the buffer.
Fixes#2956
Fixes an issue where invalid SPIR-V was generated when
gl_ObjectToWorldEXT and gl_ObjectToWorld3x4EXT, or
gl_WorldToObjectEXT and gl_WorldToObject3x4EXT, were used in the same
shader. The SPIR-V specification requires that there be at most one
OpVariable decorated with a given BuiltIn value.