Commit Graph

1024 Commits

Author SHA1 Message Date
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
f3573b9f1e MSL: Throw on emulated image array atomics. 2023-11-29 14:17:57 +01:00
Hans-Kristian Arntzen
9c054b1f34 MSL: Implement Metal 3.1 image atomics natively.
The check_discard code was too annoying to deal with,
and there is no requirement to return anything meaningful.
Vulkan specs state that values returned by atomic instructions are undefined.
2023-11-29 13:53:23 +01:00
Hans-Kristian Arntzen
50e90dd74e
Merge pull request #2233 from cdavis5e/agx-cube-grad-fixup
MSL: Work around broken cube texture gradients on Apple Silicon.
2023-11-28 12:05:55 +01:00
Chip Davis
7ef52b04c3 MSL: Work around broken cube texture gradients on Apple Silicon.
To date, all released Apple Silicon GPUs incorrectly interpret the
gradient vectors when sampling a cube texture. Specifically, they ignore
one of the three partial derivatives in each gradient depending on the
selected major axis, and they expect the remaining derivatives to be
partially transformed.

h/t @lexaknyazev for the code used in the `spvGradientCube()` function.

Fixes 8 tests under `dEQP-VK.glsl.texture_functions.texturegrad.*`.
2023-11-27 15:03:26 -08:00
Hans-Kristian Arntzen
3717660e14
Merge pull request #2234 from KhronosGroup/fix-2226
MSL: Support std140 half matrices and arrays.
2023-11-27 17:17:13 +01:00
Hans-Kristian Arntzen
3872dcd68f MSL: Don't use swizzle if we have wrapper. 2023-11-27 16:52:32 +01:00
Hans-Kristian Arntzen
81c047c3ed MSL: Use more appropriate padded types. 2023-11-27 16:30:24 +01:00
Hans-Kristian Arntzen
57dbfa0400 MSL: Support std140 half matrices and arrays.
Super awkward since there is no clean way to express this.
2023-11-27 15:28:20 +01:00
Hans-Kristian Arntzen
dddabb9c11 MSL: Add divide to reserved function names. 2023-11-27 12:14:30 +01:00
chirsz-ever
20dd53b312
Allow to customize float literals in output 2023-11-22 22:17:24 +08:00
Bill Hollings
4a42191240 MSL: Fix regression error in argument buffer runtime arrays.
Argument buffers can contain multiple runtime arrays if they have fixed
lengths as specified by the binding API. Regression error had assumed each
runtime array is in separate argument buffer with undefined array length.

- Add CompilerMSL::is_var_runtime_size_array() to include test for
  setting of array length via CompilerMSL::add_msl_resource_binding().

- Fixed unrelated test case MSL compile syntax failure when acceleration
  structure is the first entry point function argument (unrelated).
2023-11-02 23:53:59 -04:00
Hans-Kristian Arntzen
2fba284b4e MSL: Improve handling of sample masks. 2023-10-23 14:40:28 +02:00
Hans-Kristian Arntzen
a4b8553982 Style fixups. 2023-10-16 11:55:41 +02:00
Bill Hollings
16fbf8872a MSL: Workaround Metal 3.1 regression bug on recursive input structs.
Metal 3.1 introduced a Metal regression bug which causes an infinite recursion
crash during Metal's analysis of an entry point input structure that itself
contains internal recursion. This patch works around this by replacing the
recursive input declaration with a alternate variable of type void*, and
then casting to the correct type at the top of the entry point function.

- Add CompilerMSL::Options::replace_recursive_inputs to enable
  replacing recursive input.
- Add Compiler::type_contains_recursion() to determine if a struct
  contains internal recursion, and add custom Decorations to mark
  such structs, to short-cut future similar checks.
- Replace recursive input struct declarations with void*,
  and emit a recast to correct type at top of entry function.
- Add unit test.
- Compiler::type_is_top_level_block() remove hardcode reference to spirv_cross
  namespace, as it interferes with configurable namespaces (unrelated).
2023-10-14 14:46:47 -04:00
Hans-Kristian Arntzen
6e1fb9b09e
Merge pull request #2203 from Try/msl-atomics-fix
MSL: fix extraction of global variables, in case of atomics
2023-09-25 10:39:13 +02:00
Try
43a59b7cff fix extraction of global variables, in case of atomics 2023-09-19 21:44:57 +02:00
Try
da9c861ed0 MSL: fix mutability for rayQueryEXT parameters 2023-09-16 19:33:27 +02:00
Try
8af391ec5d check for SPVFuncImplVariableSizedDescriptor 2023-09-06 22:32:42 +02:00
Hans-Kristian Arntzen
b17dd5895a MSL: Workaround bizarre crash on macOS. 2023-08-28 11:54:58 +02:00
Hans-Kristian Arntzen
44966e5000 MSL: Fixup nits from review. 2023-08-17 12:01:26 +02:00
Try
844cb59cd6 MSL: runtime array over argument buffers 2023-08-17 11:37:29 +02:00
Evan Tang
894113f55b MSL: Make rw texture fences optional 2023-08-15 11:32:33 -05:00
Evan Tang
4405dd6b28 MSL: Prevent RAW hazards on read_write textures 2023-08-15 11:32:33 -05:00
Bill Hollings
05524e7f82 Fix argument buffer padding when content includes arrays.
- When determining need for arg buffer padding, use the descriptor count provided
  by the app, rather than the shader, to determine the number of slots consumed,
  as the shader may only be accessing part, or even one element, of the array.
2023-07-14 18:57:34 -04:00
Try
62331b6ac6 + spvMakeIntersectionParams
#2115
2023-07-03 19:57:46 +02:00
Hans-Kristian Arntzen
61d5ae9caa
Apply suggestions from code review 2023-06-26 12:23:34 +02:00
Chip Davis
00f14ce74f MSL: Support SPV_KHR_shader_ballot and SPV_KHR_subgroup_vote.
Normally, I wouldn't have bothered with this, given that we already
support the Vulkan 1.1 subgroup functionality, but a client asked for
the legacy extensions.
2023-06-24 15:53:04 -07:00
Hans-Kristian Arntzen
74702f5077
Merge pull request #2161 from KhronosGroup/fix-2151
Fix more edge cases in bool <-> short remapping
2023-06-07 15:30:10 +02:00
Hans-Kristian Arntzen
74bae9a06c Minor cleanup in constant_expression(). 2023-06-07 12:30:57 +02:00
Hans-Kristian Arntzen
bbcd8de9a3 MSL: Handle more complex array copy scenarios with bool <-> short. 2023-06-06 15:05:56 +02:00
Hans-Kristian Arntzen
01b98264ce MSL: Handle stores to struct bool[]. 2023-06-06 13:55:29 +02:00
Hans-Kristian Arntzen
c4eb2317a4 MSL: Consider bool/short remapping when dealing with composites. 2023-06-06 13:19:21 +02:00
rcombs
17ddd5912e
MSL: fix function constant deduplication misfire
Previously, if a constant without DecorationSpecId occurred before the constant with DecorationSpecId 0, it would be inserted into the unique_func_constants map with key 0 (the default return value from get_decoration). This prevented us from ever emitting the declaration with [[function_constant(0)]], which produced some bizarre MSL compilation errors.

Instead, we now only insert into unique_func_constants when we know we're going to emit a [[function_constant(…)]] line.

This regressed in 41007cdc7d.
2023-05-27 22:25:02 -05:00
Hans-Kristian Arntzen
28b11e010a
Merge pull request #2148 from etang-cw/FixDref
MSL: Fix dref lod workaround on combined texture/samplers
2023-05-16 17:05:19 +02:00
Evan Tang
34cd230e5e MSL: Fix dref lod workaround on combined texture/samplers 2023-05-11 19:39:38 -05:00
Hans-Kristian Arntzen
71fe651e43 Be more precise in usage of pointer/array mixing. 2023-05-11 11:42:32 +02:00
Hans-Kristian Arntzen
cfd1618e31 MSL: Use templated array type when emitting BDA to arrays.
Handling native array types is not really feasible since we need to fuse
the variable declaration with the type declaration.

This is feasible in something like variable_decl, but for plain SSA
pointers, this breaks down.
2023-05-10 13:33:54 +02:00
Hans-Kristian Arntzen
193ca867ca MSL: Don't hit array copy path for pointer to array.
Pointee type of load and store pointers must be a top-level array type.
2023-05-10 12:46:35 +02:00
Hans-Kristian Arntzen
e57b901dd1 MSL: Use name_id consistently in argument declaration. 2023-04-11 17:06:56 +02:00
Hans-Kristian Arntzen
1f6653ec07 MSL: Do not override variable name late.
If we have emitted block IO lowering at the end of vertex shader, we
will end up using the wrong name. Forcing a v_ prefix does not solve any
actual problems since the intentifier already has to be valid.
2023-03-30 18:30:44 +02:00
John Wells
42a89a5885 Add code braces 2023-03-29 13:52:42 -04:00
John Wells
4a4ac7f946 Fix for argument buffer index compare when invalid 2023-03-23 19:04:50 -04:00
Hans-Kristian Arntzen
3550a54ae0
Merge pull request #2105 from goki/main
add support for OpAtomicFAddEXT atomic add, and also Min, Max
2023-02-21 13:05:31 +01:00
Chip Davis
41007cdc7d MSL: Deduplicate function constants.
It is possible in SPIR-V to declare multiple specialization constants
with the same constant ID. The most common cause of this in GLSL is
defining a spec constant, then declaring the workgroup size to use that
spec constant by its ID. But, MSL forbids defining multiple function
constants with the same function constant ID. So, we must only emit one
definition of the actual function constant (with the
`[[function_constant(id)]]` attribute); but we can point the other
variables at this one definition.

Fixes three tests in the Vulkan CTS under
`dEQP-VK.compute.basic.max_local_size_*`.
2023-02-17 10:43:50 -08:00
Randall C. O'Reilly
bff7680cc4 revert FMinEXT, FMaxExt 2023-02-14 16:43:50 -08:00
Randall C. O'Reilly
c4b7ec105d add OpAtomicFMinEXT and Max as well, while we're at it -- I didn't test those but presumably work the same. 2023-02-04 21:52:07 -08:00
Randall C. O'Reilly
a57dba530c add support for OpAtomicFAddEXT atomic add on float types, now avail in metal 3.0 2023-02-04 21:47:08 -08:00
Hans-Kristian Arntzen
388431604a
Merge pull request #2103 from cdavis5e/msl-sample-dref-lod-array-workaround
MSL: Add a workaround for broken `level()` arguments.
2023-02-03 16:36:44 +01:00
Chip Davis
e8d419854f MSL: Add a workaround for broken level() arguments.
Some Metal devices have a bug with depth array textures using comparison
with explicit LoD, where the LoD given will be biased by some amount.
For these devices, we can use a gradient instead, which does not exhibit
this problem. As with the fragment demote workaround, this is only
expected to be needed until the bug is fixed in Metal.
2023-02-02 22:01:46 -08:00