Commit Graph
83 Commits
Author SHA1 Message Date
Hans-Kristian Arntzen 085818ff35 Add ability to override namespace of included spir-v header.
Allows working around issue where the hpp11 header of SPIR-V uses a conflicting
namespace.
2025-09-23 15:29:25 +02:00
Hans-Kristian Arntzen 0a88b2d5c0 Merge pull request #2535 from KhronosGroup/fix-2525
Honor float controls on a per-op level in some situations
2025-08-18 14:41:26 +02:00
Hans-Kristian Arntzen 1c7a5584bf Merge pull request #2533 from DiligentGraphics/diligent-sdk-1.4.321
Add source language to parsed IR source data
2025-08-18 14:36:10 +02:00
Hans-Kristian Arntzen f2a2b1bc7a Add helper to query effective float_controls2 per-op. 2025-08-18 14:29:11 +02:00
assiduous c5f8ea1dcf Add source language to parsed IR source data 2025-08-16 10:35:01 -07:00
Hans-Kristian Arntzen 8c018ed657 Implement line directive from ShaderDebugInfo.100. 2025-08-06 12:53:29 +02:00
Hans-Kristian Arntzen 1c86e5e802 Set parent type for coopvec. 2025-07-28 13:14:24 +02:00
Hans-Kristian Arntzen 421220a872 Refactor all extended type info into union. 2025-07-28 13:09:26 +02:00
Stephan Seitz 11584d5e54 glsl: implement SPV_NV_cooperative_vector
https://github.khronos.org/SPIRV-Registry/extensions/NV/SPV_NV_cooperative_vector.html
The implementation tries to follow the code for SPV_EXT_cooperative_matrix.

The extension could be mapped in a follow-up to the following HLSL
proposal https://github.com/microsoft/hlsl-specs/blob/main/proposals/0026-hlsl-long-vector-type.md
2025-07-28 12:30:53 +02:00
Patrik Wallin Hybelius 470abe4d2a Add support for GL_ARM_tensors
Change-Id: Ic454861961f620caac310e0bbc4de9fb10f50aeb
Signed-off-by: Patrik Wallin Hybelius <[email protected]>
2025-06-30 12:17:44 +02:00
Hans-Kristian Arntzen 94cc87bce7 Merge branch 'expose-FPFastMathDefault' of https://github.com/billhollings/SPIRV-Cross into pr-2495 2025-06-23 14:13:00 +02:00
Bill Hollings beb9792a6b MSL: Support SPIR-V Fast Math execution modes and decorations.
- Add CompilerMSL::Options::use_fast_math_pragmas to direct whether the MSL
  should include pragma directives to control floating point compilation options.
- Add CompilerMSL::get_fp_fast_math_flags() to return a set of FPFastMathModeMask
  flags that are safe to be applied to all floating-point types, based on
  FPFastMathDefault and FPFastMathMode decorations on individual operations,
  or execution modes SignedZeroInfNanPreserve and ContractionOff.
- Add SPIREntryPoint::fp_fast_math_defaults to track FPFastMathDefault by type ID.
- Add Decoration::fp_fast_math_mode to support DecorationFPFastMathMode.
- Use add_pragma_line() for all emitted pragmas, to better control line spacing.
- Update numerous shader references that were affected by a reordering
  in emitted pragma lines, due to the consistent use of add_pragma_line().
2025-06-22 17:05:46 -04:00
Hans-Kristian Arntzen 071cefb9eb GLSL: Implement GL_EXT_float8. 2025-06-20 15:51:49 +02:00
Stephan Seitz cfeb34a489 Merge pull request #2488 from theHamsta/replicated-composites
glsl: Implement `SPV_EXT_replicated_composites`
2025-06-17 12:39:46 +02:00
Hans-Kristian Arntzen c4f82d10da GLSL: Implement GL_EXT_bfloat16 2025-04-22 12:20:51 +02:00
Hans-Kristian Arntzen de656c6a56 GLSL: Implement SPV_KHR_cooperative_matrix. 2025-03-31 13:19:25 +02:00
Hans-Kristian Arntzen da6231c10c Deal with OpExtInstWithForwardRefsKHR. 2025-02-12 12:58:33 +01:00
Hans-Kristian Arntzen 833c5936b0 Various nit fixes and improvements from review. 2023-12-07 14:31:36 +01:00
Hugo Devillers af92037acb fix a bunch of case where SPIRType::op is wrong/corrupted 2023-11-30 15:42:46 +01:00
Hugo Devillers 950cad5913 Added an Op field to SPIRType
This field allows telling what the 'head' of the type is, without having to look at parent types.
2023-11-30 12:28:50 +01:00
Hans-Kristian Arntzen bcbe33ad11 Also consider NonSemantic ExtInst in block_is_noop. 2023-01-12 12:41:53 +01:00
Hans-Kristian Arntzen e8a22a7cf6 Handle ShaderDebugInfo non-semantic extension. 2022-11-08 12:21:07 +01:00
Hans-Kristian Arntzen 4c345166dc GLSL: Implement task shaders.
Due to bugged glslang / spirv-tools w.r.t. terminator instructions,
add a hack to ignore invalid SPIR-V for the time being.
2022-09-05 12:31:22 +02:00
Hans-Kristian Arntzen 5762617729 GLSL: Implement GL_EXT_mesh_shader. 2022-09-05 11:25:04 +02:00
Hans-Kristian Arntzen be904dcc1e Handle collapsed loops similar to collapsed selections.
If we hit the deprecated scenario of selection with identical branches,
we need to collapse loops into direct branches if need be.
2022-07-22 14:37:46 +02:00
Hans-Kristian Arntzen d2a4f9842b GLSL: Support GL_EXT_debug_printf. 2022-04-19 12:07:54 +02:00
Hans-Kristian Arntzen b91ecf6077 Merge pull request #1880 from KhronosGroup/fix-1879
Handle OpTerminateInvocation.
2022-03-03 13:49:14 +01:00
Hans-Kristian Arntzen dc62cc792b Handle OpTerminateInvocation. 2022-03-03 10:36:07 +01:00
Daniel Thornburgh 44c3333a1c Qualify std::move.
Clang added -Wunqualified-std-cast-call in
https://reviews.llvm.org/D119670, which warns on unqualified std::move
and std::forward calls. This change qualifies these calls to allow the
project to build on HEAD Clang -Werror.
2022-03-02 23:17:58 +00:00
Hans-Kristian Arntzen 29cc18988c Fix regression from adding 64-bit switch support.
Missed some cases where we did not handle the loaded type width
properly.
2022-02-16 11:49:24 +01:00
Hans-Kristian Arntzen fe5a0aa72f Merge pull request #1839 from KhronosGroup/spv1.6
Add sanity test for SPIR-V 1.6 modules.
2022-01-06 15:51:11 +01:00
Hans-Kristian Arntzen 7c12228359 Add sanity test for SPIR-V 1.6 modules.
Just verify that we don't blow up on these modules.
2022-01-06 14:16:28 +01:00
Hans-Kristian Arntzen 7c83fc22fa Add support for LocalSizeId.
WorkgroupSize builtin is deprecated in 1.6 and LocalSizeId is supported
in Vulkan starting with maintenance4.
2022-01-06 13:57:10 +01:00
Sebastián Aedo 6d8302ef14 MSL: Add 64 bit switch support
Add 64 bit switch support for MSL version 2.2.

* Also fixes a wrong endianness conversion.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-26 15:54:56 -03:00
Hans-Kristian Arntzen 37dfb3f45f Merge pull request #1794 from etra0/master
Add 64 bit support for OpSwitch
2021-11-15 15:05:10 +01:00
Sebastián Aedo 5345051a85 Removed tracking of OpConstant and OpPhi.
We don't need to keep track of them because when the block.condition is
either a SPIRConstant or a SPIRVariable, we can get the type directly in
the get_case_list.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-13 14:13:30 -03:00
Sebastián Aedo 75e3752273 Added block.cases_32bit and reworked the cases fix
Now we added block.cases_32bit as requested and we only parse if the
remaining ops are a multiple of 2. None of them are mutable because we
return a reference of them depending of the op.condition width.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-12 12:50:39 -03:00
Sebastián Aedo 48046646ee Fixed wrong condition and formatting.
Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-08 15:21:19 -03:00
Hans-Kristian Arntzen 2714f5410c CFG: Handle degenerate selection constructs.
Apparently, it's legal to use a selection construct where both paths
branch to same location, but a different merge point is used.
This breaks many assumptions the variable scope analyzer makes.

The only logical way to generate code for this scenario is to treat the
selection construct as a trivial switch construct with only a default
case.
2021-11-07 13:32:29 +01:00
Sebastián Aedo 250a02967d Removed unnecessary tracking of types.
We don't need to keep track of the type itself, only its width since the
type check of the OpSwitch can be done at runtime. This also avoids
creating a dangling reference.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-03 16:12:14 -03:00
Sebastián Aedo f099d714f3 Removing logic in the parser
Moving out the logic from the parser as requested because it's sensitive
to try to keep the parsing the most simple process as said.

For that, the load_types is now tracked in the ParsedIR, which can be
accessed in the Compiler struct. The switch cases are fixed in the CFG
stage since that's the point where the nullptr is deref.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-11-02 17:17:13 -03:00
Sebastián Aedo 3eb5532979 Add 64 bit support for OpSwitch
According to the spec, if the `condition` has a type wider than 32 bits,
the literals to be compared with will be of that size as well.

This caused some misalignments if the `condition` was bigger than 32,
causing a nullptr return without further explanation.

Currently neither GLSL nor MSL supports uint64 as the condition but the
SPIRV allows it anyway.

This also fixes #1768.

Signed-off-by: Sebastián Aedo <[email protected]>
2021-10-29 11:02:16 -03:00
Jon Leech f2a65545b8 Finish adding SPDX tags and setup a reuse checked in Github Actions CI 2021-06-29 11:03:52 +02:00
Hans-Kristian Arntzen bc4cb1b3c5 Throw if SPIR-V module has no entry points. 2021-03-08 10:40:19 +01:00
Hans-Kristian Arntzen 4704482bbc meta: Update copyright headers to 2021. 2021-01-14 16:07:49 +01:00
Hans-Kristian Arntzen 2097c30985 GLSL: Support both SPV_KHR_ray_tracing and NV_ray_tracing.
Fairly minor differences, so can keep them side by side without too much
effort. NV support is effectively deprecated now however.

- Add OpConvertUToAccelerationStructureKHR
- Ignore/Terminate ray is now a terminator in KHR, but a call in NV.
- Fix some bugs with reportIntersection.
2021-01-08 14:59:04 +01:00
Hans-Kristian Arntzen 1a28a04333 GLSL: Update SPIR-V headers for modified ray tracing opcodes. 2021-01-06 11:38:27 +01:00
Hans-Kristian Arntzen cf1e9e0643 Add MIT dual license for the SPIRV-Cross API. 2020-12-01 16:47:08 +01:00
Hans-Kristian Arntzen 1f018b0fb8 Parser: Don't assume OpTypePointer will always take a SPIRType.
Possible to receive a function prototype here. Don't try to do anything
smart here, just don't crash during parsing.
2020-11-03 10:53:37 +01:00
Hans-Kristian Arntzen 58dad82fcb Handle physical pointers in reflection API. 2020-05-25 13:45:49 +02:00