Commit Graph

586 Commits

Author SHA1 Message Date
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
Allan MacKinnon
9fbc561947
glslangValidator: Exit with an error if output file cannot be written
Propagate the error from glslang::OutputSpv[Hex|Bin] and exit with an error code if there is an error.
2023-05-23 14:07:48 -06:00
Allan MacKinnon
a5bf69936d [glslang] Strip trailing whitespace
There are many other files in the repo that have trailing whitespace
but this PR only cleans `glslang/SPIRV` and `glslang/Standalone`.
2023-05-22 12:04:40 -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
Rex Xu
8ff8b45131 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-04-03 18:02:49 -04:00
Arcady Goldmints-Orlov
cdb350b356 Fix generation of conditionals with a struct result in SPIR-V
It is possible for the SPIR-V code generator to receive a conditional
where the two branches have the same shader language level type but
different SPIR-V types because of things like offset decorations. This
change modifies visitSelection() to handle this case by using either
multiTypeStore() or, if that is available, OpCopyLogical.

Fixes #3164
2023-04-03 12:33:59 -04:00
Qingyuan Zheng
f8a2442a16 Improve line info for symbol access and assignment 2023-04-01 21:04:46 -06:00
Maciej
95ad533eb0 Block-decorate Vulkan Structs with RuntimeArrays
Fixes KhronosGroup/glslang#2439

When decorating a struct for Vulkan, add [Buffer]Block decoration if the
struct has a RuntimeArray member, as required by VUID-...-04680.
2023-02-02 16:33:32 -07:00
alelenv
4fc43cd3c1
Add support for GL_NV_shader_invocation_reorder. (#3054) 2022-12-09 13:19:08 -07:00
Greg Fischer
ed257e2bdf
Merge pull request #3066 from ShchchowAMD/shaochi/bindless
[glslang][extension] Add support for ARB_bindless_texture.
2022-12-07 14:38:31 -07:00
Zhou
16526fd9d2 [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.
2022-12-07 13:32:39 +08:00
Gilad Ben-Yossef
0464ff4515 GL_ARM_shader_core_builtins support
Add support for GL_ARM_shader_core_builtins and SPV_ARM_core_builtins,
including initial tests
2022-12-05 14:15:47 +02:00
Johannes Kauffmann
a7603c132d Use nullptr where possible instead of NULL or 0 2022-11-30 09:33:28 -07:00
Shahbaz Youssefi
6b2493a4d8 Remove GLSLANG_ANGLE
ANGLE no longer links with glslang.  This change reverts
1ef2e250fc which added a flag to strip
glslang to reduce its binary size.  This flag is no longer needed.
2022-11-08 15:11:36 -05:00
Graeme Leese
d570b2b05b Change Volatile generation for HelperInvocation
For SPIR-V 1.6 HelperInvocation accesses need to be volatile to avoid
undefined values when shaders execute 'demote'. Previously this was
always decorated on the gl_HelperInvocation variable, but this is not
valid when the Vulkan memory model is in use.

When the memory model is enabled, stop decorating the variable
declaration and apply the memory semantic to access chain loads instead.

Fixes #3042
2022-10-14 15:23:41 +01:00
Jeremy Hayes
78221d619e Update CHANGES for release 11.12.0 2022-10-13 10:58:53 -06:00
Greg Fischer
8243ca3c30
Merge pull request #3021 from qingyuanzNV/fix_opline_prepending_opfunction_with_pp
Fix OpLine prepending OpFunction reports wrong file when #line is pre…
2022-09-21 16:49:46 -06:00
Pankaj Mistry
cd9b971a5e Make a utility function for termination instructions that take input operands.
Use the new utility function for generating OpEmitMeshTasksEXT.
2022-09-09 13:11:20 -07:00
Greg Fischer
df7fec2cfa
Merge pull request #3023 from pmistryNV/GL_EXT_mesh_shader
Make OpEmitMeshTasksEXT a terminal instruction
2022-09-09 11:44:17 -06:00
Greg Fischer
284ceb6d45
Merge pull request #2985 from jeremy-lunarg/hayes-nonsemantic-shader-debuginfo-rebase
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.
2022-09-09 10:13:02 -06:00
Pankaj Mistry
71f5f219ad Fix for issue #3020
Make OpEmitTMeshasksEXT a terminal instructions
2022-09-08 18:58:55 -07:00
Qingyuan Zheng
c52b3d5075 Fix OpLine prepending OpFunction reports wrong file when #line is present 2022-09-06 23:57:18 -07:00
Pankaj Mistry
228c67228a GL_EXT_mesh_shader/SPV_EXT_mesh_shader implementation
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
2022-09-01 18:02:21 -07:00
Jeremy Hayes
7a914ce926 Implement NonSemantic.Shader.DebugInfo.100
See https://github.com/KhronosGroup/SPIRV-Registry.
2022-08-26 16:17:54 -06:00
Harlen
cc86f0d13f Fix strict aliasing violation 2022-08-26 13:26:56 -03:00
Greg Fischer
22d39cd684
Merge pull request #2977 from AMD-dwang/AMD_shader_early_and_late_fragment_tests
Add SPV_AMD_shader_early_and_late_fragment_tests
2022-07-27 11:23:16 -06:00
dwang102
070863af69 Add SPV_AMD_shader_early_and_late_fragment_tests 2022-07-18 14:20:18 +08:00
Jeremy Hayes
8bdc3d4d31 Emit Int64Atomics for imageAtomicStore
This covers a corner case wherein imageAtomicStore is used exclusively.
The proxy type for imageAtomicStore is inferred from the image type.

Fix #2975.
2022-07-14 17:37:52 -06:00
Greg Fischer
c1ae2f33b5 Do not generate samplerBuffer for spirv1.6 and beyond
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
2022-06-21 17:42:53 -06:00
Andrea Faulds
6cdae46314 Avoid duplicate BuiltIn variables for ray tracing matrices (fix #2921)
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.
2022-06-01 10:43:13 +02:00
Greg Fischer
316f12ac1d
Merge pull request #2950 from qingyuanzNV/insert_opline_before_opfunction2
Generate OpLine Before OpFunction
2022-05-31 13:25:22 -06:00
stusmith
ebf45697be Add support for VK_EXT_fragment_shader_barycentric 2022-05-25 13:02:02 +01:00
Qingyuan Zheng
279c28e70a generate OpLine before OpFunction 2022-05-23 23:05:43 -07:00
Marius Bjorge
3015d00ee0 Adding support for GL_EXT_ray_cull_mask 2022-05-05 12:56:04 +02:00
Greg Fischer
b7968b7dbc Generate Int8, Int16 and Float16 capabilities for constants
Fixes #2905
2022-03-25 14:36:01 -06:00
Greg Fischer
7a49192d23 Add support for spirv1.6
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
2021-12-16 15:01:42 -07:00
Ashwin Lele
e306f02927 Do not output location decoration for certain variables in ray tracing storage
classes.
2021-12-06 13:09:03 -08:00
Rex Xu
fe54126c05 Fix an issue of spirv_by_reference
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.
2021-11-23 16:40:45 +08:00
Rex Xu
bee91eb479 Fix an issue of spirv_type used in local variable definitions
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().
2021-11-18 20:17:04 +08:00
Rex Xu
07aec25f82 Make modifications of GL_EXT_spirv_intrinsics
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.
2021-10-15 20:22:36 +08:00
Greg Fischer
fb0e4983e4
Merge pull request #2767 from greg-lunarg/i2763
Fix unreachable code in getSampledType()
2021-09-23 10:41:34 -06:00
Greg Fischer
3d03b7822e
Scalarize vector readFirstInvocationARB (#2766)
Fixes #2761
2021-09-23 10:40:43 -06:00
Greg Fischer
4ea41b650d Fix unreachable code in getSampledType()
Fixed #2763
2021-09-22 15:16:30 -06:00
Jeremy Hayes
012436d680 Fix GCC warnings
Fix -Wsign-compare warnings.
Fix -Wunused-parameter warnings.
2021-08-31 16:40:35 -06:00
alelenv
fc60f77aa2 Add support for GL_NV_ray_tracing_motion_blur. 2021-08-10 10:40:28 -07:00
Nathan Reed
fc9897d1ba
Fix OpImageRead result type when compiling HLSL (#2706)
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
2021-07-28 09:29:17 -06:00
Peter Kasting
e8cffa5b7f Fix some instances of -Wunused-but-set-variable.
Bug: chromium:1203071
2021-07-26 07:34:37 -07:00
Shahbaz Youssefi
097215f618 Fix loading bool arrays from interface blocks
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
2021-07-15 22:29:48 -04:00