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.
It was counting bits up to the current lane included, whereas the
documentation says it should be excluded. This now matches dxc's behavior
as well.
Fix#2929
For recent GLSL versions, if texture2D function call appears, the error
message reports an unsupported type constructor. Change message to
unsupported function. Likewise for other removed texture* function calls.
Before this change, the example is rejected by DXC:
$ dxc -T ps_6_0 hlsl.namespace.frag
hlsl.namespace.frag:22:73: error: call to non-static member function
without an object argument
return N1::getVec() + N2::getVec() + N2::N3::getVec() + N2::N3::C1::getVec() * N2::gf;
~~~~~~~~~~~~^~~~~~
The call to the class member function requires an object, or we ned to
make the function static. This update makes the function static.
This also fixes SPIR-V validation: without this change the call
to that getVec does not have enough arguments:
error: line 69: OpFunctionCall Function <id>'s parameter count does not
match the argument count.
%43 = OpFunctionCall %v4float %N2__N3__C1__getVec_
Specifically, make GLSL link error messages more specific and output
only information relevant to the error.
Also change type printing to more closely reflect GLSL syntax. This
is the default for link error messages, but must me enabled with the
new option --enhanced-msgs for compilation error messages.
Also with --enhanced-msgs, only emit one error message per source
line.
For GL_EXT_vulkan_glsl_relaxed. When merging the default uniform block,
there were cases where symbols in the tree wern't updated to match the
new block structure after merging blocks together.
This change traverses the symbol tree and updates any references to the
merged block.
Also update known goods to Vulkan 1.3 support
Also re-enable SPIR-V 1.6 tests with vulkan1.3 target
Also re-cache SPIRV 1.6 header which somehow regressed back to 1.5
Add command line support which enables the following behavior:
- Remap discard
Map discard to DemoteToHelperInvocation for HLSL shaders. Map to
OpTerminateInvocation for GLSL shaders.
- Decorate HelperInvocation with Volatile
- Use localSizeId for execution mode
WorkGroupSize is deprecated in spirv1.6
Also update known goods to SPIRV 1.6
1. The test cases of OpReadClockKHR is invalid. The return type is
unsigned integer rather than signed integer.
2. When SPIR-V decorate or SPIR-V type is specified, we should avoid
auto location mapping because the semantics are totally decided by
SPIR-V tokens.
When using this qualifier for a parameter, we make it as a pointer.
However, the function TranslateStorageClass() is therefore called and
the storage class should only be set to Function when it is invoked
to translate parameter types rather than actual argument types.
We previously use createOp() in SPV builder to create type declaration.
However, all type declarations should be placed in const-type-variable
declaration section. And duplicated type defintions ought to be avoided.
We now make a method in SPV builder to perform this operation with a
more general solution: makeGenericType().
Remove remaining conversions from negative float64_t to unsigned
integers, which are undefined behavior.
As a result, this test will also succeed on platforms that implement
those conversions differently than x86. That addresses one of the issues
in #2815.
Add conversions from negative float16_t and float32_t to bool, all
signed integer types (i.e., including those in
GL_EXT_shader_explicit_arithmetic_types), and all float types (from the
same extension) to extend coverage.
Note that converting negative float values to unsigned integers is
undefined behavior. Thus, we exclude them.
1. spirv_execution_mode_id and spirv_decorate_id could support
specialization constants. The original implementation always
assume only normal frontend constants are valid. It is not true.
2. spirv_type donesn't support type_specifier as an option of
spirv_type_parameter. At present, only constant_expression is the
valid option.
instead of allowing for multiple declarations of the variable in the
resulting SPIR-V, instead use a retargeted mechanism to cause references
to gl_VertexID and gl_InstanceID to use the gl_VertexIndex and
gl_InstanceIndex symbol.
Full vector and fully specified vector swizzle stores are not affected by this change, only partial swizzles ie swizzles with fewer components than the vector being stored to.
Previously the vector being stored to loaded and any components not specified in the swizzle were used to create a full store to the vector.
While this change generates more SPIR-V instructions, it is necessary for correctness.
Fixes#2518.
Fix OpImageRead result type when compiling HLSL
- Per the Vulkan spec, OpImageRead must return a 4-component vector always. When compiling HLSL, loads from a RWTexture of a template type with < 4 components would incorrectly generate an OpImageRead with a < 4 component result, resulting in validation errors.
- This was previously fixed for OpImageFetch in commit 4425f24; this commit does the same thing for OpImageRead.
- Added associated tests and expanded existing image fetch tests to check all the different types of textures, in both float and int incarnations, for completeness.
- Update other HLSL tests involving OpImageRead
SPIR-V disallows bool in interface blocks, which is emulated with uint.
When loading a bool variable (through accessChainLoad()), it's converted
from uint to bool if it came from an interface block.
This was handled for bool and bvecN, but not for bool arrays. This
change implements the conversion for bool arrays.
Closes#2694