platform/upstream/SPIRV-Cross.git
3 years agoMSL: Support padding Metal argument buffer entries based on argument index.
Bill Hollings [Tue, 13 Apr 2021 23:01:20 +0000 (19:01 -0400)]
MSL: Support padding Metal argument buffer entries based on argument index.

If CompilerMSL::Options::pad_argument_buffer_resources enabled, Metal argument buffer
struct members are positionally aligned to their argument indexes by adding synthetic
padding members when needed. The types and sizes of these synthetic members are
identified in the resource_bindings vector provided through the API.

Add CompilerMSL::Options::pad_argument_buffer_resources to enable padding
Metal argument buffer structs to positionally match members to argument indexes.
Add MSLResourceBinding::base_type to identify resource type through API.

3 years agoFix Github CI in PRs.
Hans-Kristian Arntzen [Fri, 26 Mar 2021 17:40:43 +0000 (18:40 +0100)]
Fix Github CI in PRs.

3 years agoMerge pull request #1642 from mehmetoguzderin/msl-long-ulong-member
Hans-Kristian Arntzen [Fri, 26 Mar 2021 17:02:25 +0000 (18:02 +0100)]
Merge pull request #1642 from mehmetoguzderin/msl-long-ulong-member

MSL: Support long ulong types in buffers in 2.3+.

3 years agoMove condition to default block
Mehmet Oguz Derin [Fri, 26 Mar 2021 13:29:44 +0000 (16:29 +0300)]
Move condition to default block

3 years agoMSL: Support long ulong types in buffers in 2.3+.
Mehmet Oguz Derin [Thu, 25 Mar 2021 23:41:26 +0000 (02:41 +0300)]
MSL: Support long ulong types in buffers in 2.3+.

[Metal Shading Language Specification](https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf) states that:

> Note: As of Metal 2.3, Metal supports buffers that contain long or ulong data types.

This PR aims to support long and ulong data types in buffers for Metal 2.3+.

3 years agoUse Github actions CI tag.
Hans-Kristian Arntzen [Fri, 12 Mar 2021 14:36:03 +0000 (15:36 +0100)]
Use Github actions CI tag.

3 years agoAdd GitHub Actions script.
Hans-Kristian Arntzen [Fri, 12 Mar 2021 11:51:53 +0000 (12:51 +0100)]
Add GitHub Actions script.

3 years agoMerge pull request #1633 from KhronosGroup/fix-1626
Hans-Kristian Arntzen [Tue, 9 Mar 2021 14:17:21 +0000 (15:17 +0100)]
Merge pull request #1633 from KhronosGroup/fix-1626

GLSL: Handle complex load/store scenarios to gl_SampleMask.

3 years agoGLSL: Handle complex load/store scenarios to gl_SampleMask.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 10:51:51 +0000 (11:51 +0100)]
GLSL: Handle complex load/store scenarios to gl_SampleMask.

Need special workarounds to handle array load/store since array size is
unsized in GLSL, and array copy is not possible.
Also, consider bitcast for scalar loads and stores.

3 years agoMerge pull request #1635 from KhronosGroup/fix-1627
Hans-Kristian Arntzen [Tue, 9 Mar 2021 09:21:35 +0000 (10:21 +0100)]
Merge pull request #1635 from KhronosGroup/fix-1627

Handle edge cases in OpCopyMemory.

3 years agoMerge pull request #1634 from KhronosGroup/fix-1625
Hans-Kristian Arntzen [Tue, 9 Mar 2021 09:21:24 +0000 (10:21 +0100)]
Merge pull request #1634 from KhronosGroup/fix-1625

Handle logical subgroup arithmetic ops

3 years agoMerge pull request #1632 from KhronosGroup/fix-1629
Hans-Kristian Arntzen [Tue, 9 Mar 2021 09:21:10 +0000 (10:21 +0100)]
Merge pull request #1632 from KhronosGroup/fix-1629

Throw if SPIR-V module has no entry points.

3 years agoHandle edge cases in OpCopyMemory.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 13:09:32 +0000 (14:09 +0100)]
Handle edge cases in OpCopyMemory.

Implement this by synthesizing an OpLoad/OpStore pair instead.

3 years agoMSL: Add test for logical subgroup arith ops.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 11:57:37 +0000 (12:57 +0100)]
MSL: Add test for logical subgroup arith ops.

3 years agoHLSL: Support logical subgroup ops.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 11:52:03 +0000 (12:52 +0100)]
HLSL: Support logical subgroup ops.

3 years agoGLSL: Add support for Logical subgroup ops.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 11:06:46 +0000 (12:06 +0100)]
GLSL: Add support for Logical subgroup ops.

Completely missed these ...

3 years agoThrow if SPIR-V module has no entry points.
Hans-Kristian Arntzen [Mon, 8 Mar 2021 09:39:59 +0000 (10:39 +0100)]
Throw if SPIR-V module has no entry points.

3 years agoMerge pull request #1630 from KhronosGroup/fix-1628
Hans-Kristian Arntzen [Fri, 26 Feb 2021 14:51:52 +0000 (15:51 +0100)]
Merge pull request #1630 from KhronosGroup/fix-1628

MSL: Deal with pointer-to-pointer qualifier ordering.

3 years agoMSL: Deal with pointer-to-pointer qualifier ordering.
Hans-Kristian Arntzen [Fri, 26 Feb 2021 11:50:24 +0000 (12:50 +0100)]
MSL: Deal with pointer-to-pointer qualifier ordering.

3 years agoMerge pull request #1622 from KhronosGroup/fix-1619
Hans-Kristian Arntzen [Wed, 17 Feb 2021 19:46:06 +0000 (20:46 +0100)]
Merge pull request #1622 from KhronosGroup/fix-1619

MSL: Handle load and store to TessLevel array in TESC.

3 years agoMerge pull request #1623 from phuang/patch-2
Hans-Kristian Arntzen [Wed, 17 Feb 2021 19:45:57 +0000 (20:45 +0100)]
Merge pull request #1623 from phuang/patch-2

Add two missing source files

3 years agoAdd two missing source files
Peng Huang [Wed, 17 Feb 2021 16:14:04 +0000 (11:14 -0500)]
Add two missing source files

3 years agoMerge pull request #1621 from KhronosGroup/fix-1618
Hans-Kristian Arntzen [Wed, 17 Feb 2021 15:59:30 +0000 (16:59 +0100)]
Merge pull request #1621 from KhronosGroup/fix-1618

MSL: Fix automatic assign of builtin attributes in tessellation

3 years agoMSL: Handle load and store to TessLevel array in TESC.
Hans-Kristian Arntzen [Wed, 17 Feb 2021 12:18:47 +0000 (13:18 +0100)]
MSL: Handle load and store to TessLevel array in TESC.

More edge cases ... :(

3 years agoMSL: Gracefully assign automatic input locations to builtin attributes.
Hans-Kristian Arntzen [Wed, 17 Feb 2021 11:21:21 +0000 (12:21 +0100)]
MSL: Gracefully assign automatic input locations to builtin attributes.

3 years agoMSL: Refactor out location consumption count computation.
Hans-Kristian Arntzen [Wed, 17 Feb 2021 10:29:33 +0000 (11:29 +0100)]
MSL: Refactor out location consumption count computation.

3 years agoAdd comment where aux image atomic buffers are reflected from.
Hans-Kristian Arntzen [Wed, 17 Feb 2021 09:42:58 +0000 (10:42 +0100)]
Add comment where aux image atomic buffers are reflected from.

They also use secondary bindings, not just samplers.

3 years agoMerge pull request #1620 from phuang/patch-1
Hans-Kristian Arntzen [Wed, 17 Feb 2021 09:30:10 +0000 (10:30 +0100)]
Merge pull request #1620 from phuang/patch-1

Fix build errors on Windows

3 years agoFix build errors on Windows
Peng Huang [Wed, 17 Feb 2021 01:42:00 +0000 (20:42 -0500)]
Fix build errors on Windows

error:
clang-cl: error: unknown argument ignored in clang-cl: '-fno-exceptions'

3 years agoMerge pull request #1617 from KhronosGroup/fix-1608
Hans-Kristian Arntzen [Tue, 16 Feb 2021 10:10:07 +0000 (11:10 +0100)]
Merge pull request #1617 from KhronosGroup/fix-1608

MSL: Fixup type when using tessellation levels in TESC functions.

3 years agoMerge pull request #1616 from KhronosGroup/fix-1609
Hans-Kristian Arntzen [Mon, 15 Feb 2021 17:19:55 +0000 (18:19 +0100)]
Merge pull request #1616 from KhronosGroup/fix-1609

MSL: Always return [[position]] when required.

3 years agoMSL: Fixup type when using tessellation levels in TESC functions.
Hans-Kristian Arntzen [Mon, 15 Feb 2021 12:28:11 +0000 (13:28 +0100)]
MSL: Fixup type when using tessellation levels in TESC functions.

Need to rewrite array size depending on execution mode.

3 years agoMSL: Always return [[position]] when required.
Hans-Kristian Arntzen [Mon, 15 Feb 2021 11:49:37 +0000 (12:49 +0100)]
MSL: Always return [[position]] when required.

3 years agoMerge pull request #1615 from KhronosGroup/fix-1612
Hans-Kristian Arntzen [Mon, 15 Feb 2021 10:45:20 +0000 (11:45 +0100)]
Merge pull request #1615 from KhronosGroup/fix-1612

c: Add missing IOS_SUPPORT_BASE_VERTEX_INSTANCE option.

3 years agoc: Add missing IOS_SUPPORT_BASE_VERTEX_INSTANCE option.
Hans-Kristian Arntzen [Mon, 15 Feb 2021 10:43:46 +0000 (11:43 +0100)]
c: Add missing IOS_SUPPORT_BASE_VERTEX_INSTANCE option.

3 years agoMerge pull request #1614 from KhronosGroup/fix-1610
Hans-Kristian Arntzen [Mon, 15 Feb 2021 10:40:25 +0000 (11:40 +0100)]
Merge pull request #1614 from KhronosGroup/fix-1610

HLSL: Add vector to illegal names list.

3 years agoHLSL: Add vector to illegal names list.
Hans-Kristian Arntzen [Mon, 15 Feb 2021 10:38:14 +0000 (11:38 +0100)]
HLSL: Add vector to illegal names list.

3 years agoMerge pull request #1606 from billhollings/position-invariance
Bill Hollings [Fri, 29 Jan 2021 18:36:15 +0000 (13:36 -0500)]
Merge pull request #1606 from billhollings/position-invariance

Expose position invariance.

3 years agoExpose position invariance.
Bill Hollings [Thu, 28 Jan 2021 21:13:20 +0000 (16:13 -0500)]
Expose position invariance.

Used with MSL to determine whether to compile with invariance preserved.

3 years agoMerge pull request #1603 from KhronosGroup/small-improvements
Hans-Kristian Arntzen [Fri, 22 Jan 2021 15:30:57 +0000 (16:30 +0100)]
Merge pull request #1603 from KhronosGroup/small-improvements

Various small improvements and fixes

3 years agoCheck entry point variables in is_hidden_variables.
Hans-Kristian Arntzen [Fri, 22 Jan 2021 12:48:16 +0000 (13:48 +0100)]
Check entry point variables in is_hidden_variables.

Need to be careful not to emit globals we're not supposed to.

3 years agoHandle nonuniformEXT qualifier for acceleration structures.
Hans-Kristian Arntzen [Fri, 22 Jan 2021 12:13:56 +0000 (13:13 +0100)]
Handle nonuniformEXT qualifier for acceleration structures.

3 years agoDeal better with CompositeExtract from constant composite.
Hans-Kristian Arntzen [Fri, 22 Jan 2021 11:17:05 +0000 (12:17 +0100)]
Deal better with CompositeExtract from constant composite.

There is no good reason for applications to emit this kind of code, but
some do. Special case this scenario.

3 years agoGLSL: Handle tracing against incoming payload/callable.
Hans-Kristian Arntzen [Fri, 22 Jan 2021 10:22:10 +0000 (11:22 +0100)]
GLSL: Handle tracing against incoming payload/callable.

3 years agoMerge pull request #1594 from KhronosGroup/fix-1591
Hans-Kristian Arntzen [Fri, 15 Jan 2021 09:46:23 +0000 (10:46 +0100)]
Merge pull request #1594 from KhronosGroup/fix-1591

Fix pathological complexity explosion for certain shaders.

3 years agoMerge pull request #1595 from KhronosGroup/copyright-update
Hans-Kristian Arntzen [Thu, 14 Jan 2021 15:10:07 +0000 (16:10 +0100)]
Merge pull request #1595 from KhronosGroup/copyright-update

meta: Update copyright headers to 2021.

3 years agometa: Update copyright headers to 2021.
Hans-Kristian Arntzen [Thu, 14 Jan 2021 15:07:49 +0000 (16:07 +0100)]
meta: Update copyright headers to 2021.

3 years agoFix pathological complexity explosion for certain shaders.
Hans-Kristian Arntzen [Thu, 14 Jan 2021 14:58:19 +0000 (15:58 +0100)]
Fix pathological complexity explosion for certain shaders.

Certain shaders where functions have a *ton* of merging control flow
will end up with exponential time complexity to figure out parameter
preservation semantics.

The trivial fix to make it O(1) again is to terminate recursive traversal early if we've seen
the path before. Simple oversight :(

3 years agoMerge pull request #1590 from KhronosGroup/fix-1584
Hans-Kristian Arntzen [Sat, 9 Jan 2021 21:28:19 +0000 (22:28 +0100)]
Merge pull request #1590 from KhronosGroup/fix-1584

Update ray-tracing support to include SPV_KHR_ray_tracing

3 years agoGLSL: Support both SPV_KHR_ray_tracing and NV_ray_tracing.
Hans-Kristian Arntzen [Fri, 8 Jan 2021 10:37:29 +0000 (11:37 +0100)]
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.

3 years agoMerge pull request #1589 from KhronosGroup/roll-deps
Hans-Kristian Arntzen [Fri, 8 Jan 2021 13:58:44 +0000 (14:58 +0100)]
Merge pull request #1589 from KhronosGroup/roll-deps

Roll dependencies.

3 years agoCLI: Fix silly regression with handling of -V.
Hans-Kristian Arntzen [Fri, 8 Jan 2021 09:47:46 +0000 (10:47 +0100)]
CLI: Fix silly regression with handling of -V.

3 years agoRoll dependencies.
Hans-Kristian Arntzen [Fri, 8 Jan 2021 09:37:46 +0000 (10:37 +0100)]
Roll dependencies.

3 years agoMerge pull request #1588 from KhronosGroup/fix-1582
Hans-Kristian Arntzen [Fri, 8 Jan 2021 09:37:19 +0000 (10:37 +0100)]
Merge pull request #1588 from KhronosGroup/fix-1582

MSL: Fix some edge cases in input attachment handling.

3 years agoMSL: Fix various bugs with framebuffer fetch on macOS and argument buffers.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 14:00:45 +0000 (15:00 +0100)]
MSL: Fix various bugs with framebuffer fetch on macOS and argument buffers.

Introduce a helper to make it clearer if a resource can be
considered for argument buffers or not.

3 years agoMSL: Always use input_attachment_index for framebuffer fetch binding.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 13:30:35 +0000 (14:30 +0100)]
MSL: Always use input_attachment_index for framebuffer fetch binding.

--msl-decoration-binding would end up overriding the input attachment
index to binding which is very unexpected and broken.

3 years agoMerge pull request #1587 from KhronosGroup/refactor-active-variable-consideration
Hans-Kristian Arntzen [Fri, 8 Jan 2021 09:16:22 +0000 (10:16 +0100)]
Merge pull request #1587 from KhronosGroup/refactor-active-variable-consideration

Refactor active variable consideration

3 years agoAdd test for pure initializer gl_FragDepth.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 11:18:07 +0000 (12:18 +0100)]
Add test for pure initializer gl_FragDepth.

Tests that the builtin is considered active.

3 years agoGLSL: Force block declaration if clip/cull is used in tesc.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 11:14:49 +0000 (12:14 +0100)]
GLSL: Force block declaration if clip/cull is used in tesc.

3 years agoMSL: Make sure initialized output builtins are considered active.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 11:00:21 +0000 (12:00 +0100)]
MSL: Make sure initialized output builtins are considered active.

3 years agoMSL: Always enable Outputs in vertex stages.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 10:20:10 +0000 (11:20 +0100)]
MSL: Always enable Outputs in vertex stages.

Subsequent stages can legally attempt to read from these variables,
which causes compilation failure.

Always make sure we emit user outputs in vertex shaders if they are
active in the entry point.

3 years agoMSL: Only consider builtin variables if they are part of IO interface.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 09:28:06 +0000 (10:28 +0100)]
MSL: Only consider builtin variables if they are part of IO interface.

3 years agoMSL: Very slight refactor.
Hans-Kristian Arntzen [Thu, 7 Jan 2021 09:27:14 +0000 (10:27 +0100)]
MSL: Very slight refactor.

3 years agoMerge pull request #1585 from KhronosGroup/fix-1569
Hans-Kristian Arntzen [Thu, 7 Jan 2021 08:51:37 +0000 (09:51 +0100)]
Merge pull request #1585 from KhronosGroup/fix-1569

GLSL: Update SPIR-V headers for modified ray tracing opcodes.

3 years agoMerge pull request #1583 from KhronosGroup/fix-1567
Hans-Kristian Arntzen [Thu, 7 Jan 2021 08:51:22 +0000 (09:51 +0100)]
Merge pull request #1583 from KhronosGroup/fix-1567

CLI: Add stdin support.

3 years agoMerge pull request #1581 from KhronosGroup/fix-1554
Hans-Kristian Arntzen [Thu, 7 Jan 2021 08:51:09 +0000 (09:51 +0100)]
Merge pull request #1581 from KhronosGroup/fix-1554

GLSL/MSL: Handle more complicated tessellation Output initializers

3 years agoGLSL: Fix -Wshadow error.
Hans-Kristian Arntzen [Wed, 6 Jan 2021 11:59:57 +0000 (12:59 +0100)]
GLSL: Fix -Wshadow error.

3 years agoGLSL: Update SPIR-V headers for modified ray tracing opcodes.
Hans-Kristian Arntzen [Wed, 6 Jan 2021 10:32:26 +0000 (11:32 +0100)]
GLSL: Update SPIR-V headers for modified ray tracing opcodes.

3 years agoCLI: Add stdin support.
Hans-Kristian Arntzen [Wed, 6 Jan 2021 10:06:41 +0000 (11:06 +0100)]
CLI: Add stdin support.

3 years agoMSL: Fix initializer for tess level outputs.
Hans-Kristian Arntzen [Wed, 6 Jan 2021 09:39:39 +0000 (10:39 +0100)]
MSL: Fix initializer for tess level outputs.

It's an array, not vector.

3 years agoMSL: Don't flatten builtin arrays unless they're part of IO interface.
Hans-Kristian Arntzen [Wed, 6 Jan 2021 09:33:17 +0000 (10:33 +0100)]
MSL: Don't flatten builtin arrays unless they're part of IO interface.

3 years agoMSL: Emit correct initializer for tessellation control points.
Hans-Kristian Arntzen [Tue, 5 Jan 2021 12:57:15 +0000 (13:57 +0100)]
MSL: Emit correct initializer for tessellation control points.

3 years agoMSL: Handle initializers for tess levels.
Hans-Kristian Arntzen [Tue, 5 Jan 2021 12:25:50 +0000 (13:25 +0100)]
MSL: Handle initializers for tess levels.

3 years agoGLSL: Refactor out Output variable initialization.
Hans-Kristian Arntzen [Tue, 5 Jan 2021 11:50:36 +0000 (12:50 +0100)]
GLSL: Refactor out Output variable initialization.

3 years agoGLSL: Add test for initializing tess level output.
Hans-Kristian Arntzen [Tue, 5 Jan 2021 11:12:26 +0000 (12:12 +0100)]
GLSL: Add test for initializing tess level output.

3 years agoGLSL: Handle some extreme edge cases in Output variable initialization.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 15:48:35 +0000 (16:48 +0100)]
GLSL: Handle some extreme edge cases in Output variable initialization.

Deal with patch blocks, arrays of patch blocks, arrays of blocks, etc.

3 years agoMerge pull request #1578 from KhronosGroup/fix-1568
Hans-Kristian Arntzen [Tue, 5 Jan 2021 09:12:40 +0000 (10:12 +0100)]
Merge pull request #1578 from KhronosGroup/fix-1568

Improve handling of complex variable initialization

3 years agoMinor redundant nit.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 11:07:48 +0000 (12:07 +0100)]
Minor redundant nit.

3 years agoMore robust handling of initialized output builtin variables.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 10:58:50 +0000 (11:58 +0100)]
More robust handling of initialized output builtin variables.

3 years agoHandle output IO block initializers more robustly.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 10:16:58 +0000 (11:16 +0100)]
Handle output IO block initializers more robustly.

3 years agoMerge pull request #1577 from KhronosGroup/fix-1574
Hans-Kristian Arntzen [Mon, 4 Jan 2021 15:37:49 +0000 (16:37 +0100)]
Merge pull request #1577 from KhronosGroup/fix-1574

CMake: Disable compiler extensions explicitly.

3 years agoMerge pull request #1576 from KhronosGroup/fix-1571
Hans-Kristian Arntzen [Mon, 4 Jan 2021 14:05:06 +0000 (15:05 +0100)]
Merge pull request #1576 from KhronosGroup/fix-1571

MSL: Fix broken reserved identifier handling for entry points

3 years agoCMake: Disable compiler extensions explicitly.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 09:17:24 +0000 (10:17 +0100)]
CMake: Disable compiler extensions explicitly.

Compiles fine with just -std=c++11.

3 years agoHandle reserved identifiers for functions.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 08:59:26 +0000 (09:59 +0100)]
Handle reserved identifiers for functions.

gl_ identifiers are already handled by fixups, so remove redundant code.

3 years agoMSL: Handle reserved identifiers for entry point.
Hans-Kristian Arntzen [Mon, 4 Jan 2021 08:40:11 +0000 (09:40 +0100)]
MSL: Handle reserved identifiers for entry point.

We only considered invalid names, and overwrote the alias for the
function. The correct fix is to replace illegal names early, do the
reserved fixup, then copy back alias to entry point name.

3 years agoMerge pull request #1566 from KhronosGroup/subgroup-table-fix
Hans-Kristian Arntzen [Fri, 11 Dec 2020 13:38:13 +0000 (14:38 +0100)]
Merge pull request #1566 from KhronosGroup/subgroup-table-fix

GLSL: Fix KHR subgroup extension table for subgroups.

3 years agoGLSL: Fix KHR subgroup extension table for subgroups.
Hans-Kristian Arntzen [Fri, 11 Dec 2020 11:24:34 +0000 (12:24 +0100)]
GLSL: Fix KHR subgroup extension table for subgroups.

3 years agoMerge pull request #1564 from KhronosGroup/fix-1558
Hans-Kristian Arntzen [Mon, 7 Dec 2020 13:07:38 +0000 (14:07 +0100)]
Merge pull request #1564 from KhronosGroup/fix-1558

GLSL: Emit nonuniformEXT in correct place for late-combined samplers.

3 years agoMerge pull request #1563 from KhronosGroup/fix-1559
Hans-Kristian Arntzen [Mon, 7 Dec 2020 12:13:52 +0000 (13:13 +0100)]
Merge pull request #1563 from KhronosGroup/fix-1559

GLSL/HLSL: Disallow VariablePointers capability outright.

3 years agoGLSL: Emit nonuniformEXT in correct place for late-combined samplers.
Hans-Kristian Arntzen [Mon, 7 Dec 2020 12:00:15 +0000 (13:00 +0100)]
GLSL: Emit nonuniformEXT in correct place for late-combined samplers.

Need to emit nonuniformEXT(sampler2D()) since constructor expressions in
Vulkan GLSL do not propgate the nonuniform qualifier.

3 years agoGLSL/HLSL: Disallow VariablePointers capability outright.
Hans-Kristian Arntzen [Mon, 7 Dec 2020 11:16:02 +0000 (12:16 +0100)]
GLSL/HLSL: Disallow VariablePointers capability outright.

Cannot be supported, error out early.

3 years agoMerge pull request #1553 from comex/no-subgroups-in-vertex-shaders
Hans-Kristian Arntzen [Wed, 2 Dec 2020 18:29:19 +0000 (19:29 +0100)]
Merge pull request #1553 from comex/no-subgroups-in-vertex-shaders

msl: Don't try to use [[thread_index_in_simdgroup]] in vertex shaders.

3 years agoMerge pull request #1557 from KhronosGroup/mit-dual-license-api
Hans-Kristian Arntzen [Tue, 1 Dec 2020 15:50:11 +0000 (16:50 +0100)]
Merge pull request #1557 from KhronosGroup/mit-dual-license-api

Add MIT dual license for the SPIRV-Cross API and CLI.

3 years agoAdd MIT dual license for the SPIRV-Cross API.
Hans-Kristian Arntzen [Wed, 25 Nov 2020 14:22:08 +0000 (15:22 +0100)]
Add MIT dual license for the SPIRV-Cross API.

3 years agoMerge branch 'master' of git://github.com/js6i/SPIRV-Cross
Hans-Kristian Arntzen [Tue, 1 Dec 2020 13:17:35 +0000 (14:17 +0100)]
Merge branch 'master' of git://github.com/js6i/SPIRV-Cross

3 years agoMSL: Added fmin3 and fmax3 library functions to the illegal name list.
Jan Sikorski [Fri, 27 Nov 2020 13:55:44 +0000 (14:55 +0100)]
MSL: Added fmin3 and fmax3 library functions to the illegal name list.

3 years agomsl: Don't try to use [[thread_index_in_simdgroup]] in vertex shaders.
comex [Thu, 26 Nov 2020 22:12:06 +0000 (17:12 -0500)]
msl: Don't try to use [[thread_index_in_simdgroup]] in vertex shaders.

According to the Metal Shading Language Specification, it's not
supported for vertex functions in any Metal version, only fragment and
kernel functions.

3 years agoMerge branch 'unused' of git://github.com/comex/SPIRV-Cross
Hans-Kristian Arntzen [Wed, 25 Nov 2020 22:06:28 +0000 (23:06 +0100)]
Merge branch 'unused' of git://github.com/comex/SPIRV-Cross

3 years agospirv_msl: Don't add fixup hooks for builtin variables if they're unused.
comex [Wed, 25 Nov 2020 17:43:01 +0000 (12:43 -0500)]
spirv_msl: Don't add fixup hooks for builtin variables if they're unused.

This is necessary to avoid invalid output because of how implicit
dependencies on builtins work.

For example, the fixup for `BuiltInSubgroupEqMask` initializes the
variable based on `builtin_subgroup_invocation_id_id`, a field storing
the ID for a variable with decoration `BuiltInSubgroupLocalInvocationId`.
This could be either a variable that already exists in the input
(spirv_msl.cpp:300) or, if necessary, a newly created one
(spirv_msl.cpp:621).  In both cases, though,
`builtin_subgroup_invocation_id_id` is only set under the condition
`need_subgroup_mask || needs_subgroup_invocation_id`.
`need_subgroup_mask` is true if any of the `BuiltInSubgroupXXMask` are
set in `active_input_builtins`.

Normally, if the program contains `BuiltInSubgroupEqMask`,
`Compiler::ActiveBuiltinHandler` will set it in `active_input_builtins`.
But this only happens if the variable is actually used, whereas
`fix_up_shader_inputs_outputs` loops over all variables in the program
regardless of whether they're used.

If `BuiltInSubgroupEqMask` is not used,
`builtin_subgroup_invocation_id_id` is never set, but before this patch
the fixup hook would try to use it anyway, producing MSL that references
a nonexistent variable named `_0`.

Avoid this by changing `fix_up_shader_inputs_outputs` to skip builtins
which are not set in `active_input_builtins` or
`active_output_builtins`.  And add a test case.

3 years agoMerge pull request #1551 from cdavis5e/msl-subgroup-inactive-ballot-mask
Hans-Kristian Arntzen [Wed, 25 Nov 2020 16:00:53 +0000 (17:00 +0100)]
Merge pull request #1551 from cdavis5e/msl-subgroup-inactive-ballot-mask

MSL: Don't mask off inactive bits in ballot masks.