Commit Graph

276 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
e9851cc6aa MSL: Fix misc sign issues with dot product impl and add more coverage. 2024-01-16 16:17:43 +01:00
Hans-Kristian Arntzen
ec42cb1c41 Roll deps. 2024-01-05 13:36:34 +01:00
Hans-Kristian Arntzen
2603fbe520 MSL: Remove special case for threadgroup array wrapper.
I cannot find any evidence that this does not actually work.
The original case here was from Epic's PR series in 2019, but I cannot see why it doesn't work.
It might have been a bug in a very old compiler at some point.
2023-12-07 14:41:42 +01:00
Hans-Kristian Arntzen
e3d1b9afbb Merge branch 'spirtype-refactor' of https://github.com/Hugobros3/SPIRV-Cross into pr-2238 2023-12-07 12:05:48 +01:00
Hans-Kristian Arntzen
e6b013a492
Merge pull request #2214 from KhronosGroup/fix-2206
MSL: Use powr instead of pow.
2023-12-07 11:39:26 +01:00
Hans-Kristian Arntzen
9da5f7ce45
Merge pull request #2242 from KhronosGroup/fix-2221
MSL: Improve PtrAccessChain handling.
2023-12-06 17:17:21 +01:00
Hans-Kristian Arntzen
4e3f66b5d5 MSL: Add test for vector-to-scalar variable pointer. 2023-12-06 17:09:25 +01:00
Hans-Kristian Arntzen
e2886f0946 MSL: Consider PtrAccessChain on array types. 2023-12-06 16:18:58 +01:00
Try
8f58b84761 MSL: add ray-cull mask 2023-12-05 20:56:48 +01:00
Hugo Devillers
af92037acb fix a bunch of case where SPIRType::op is wrong/corrupted 2023-11-30 15:42:46 +01:00
Hans-Kristian Arntzen
f3573b9f1e MSL: Throw on emulated image array atomics. 2023-11-29 14:17:57 +01:00
Hans-Kristian Arntzen
2e022dbff5 MSL: Move test files to packing/. 2023-11-27 16:54:27 +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
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
56bdcfaf0e Add test for sample mask bulk load/store. 2023-10-23 12:45:08 +02:00
Hans-Kristian Arntzen
09ba765844 MSL: Use powr instead of pow.
powr's additional UB rules match SPIR-V.
2023-10-11 12:55:12 +02: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
Chip Davis
68f0257f26 Use --preserve-numeric-ids when assembling test shaders.
This makes it easier to debug codegen for these shaders.
2023-06-23 14:54:16 -07:00
Hans-Kristian Arntzen
13e6981cc8 MSL: Consider changed array types for array-of-constant-bool in struct. 2023-06-07 13:54:50 +02:00
Hans-Kristian Arntzen
8735108609 MSL: Consider bool-short remapping for constant expressions as well. 2023-06-07 12:33:37 +02:00
Hans-Kristian Arntzen
b0b2fd8d90 MSL: Add test for bool-in-struct edge cases. 2023-06-06 15:17:23 +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
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
e57b901dd1 MSL: Use name_id consistently in argument declaration. 2023-04-11 17:06:56 +02:00
Hans-Kristian Arntzen
884e5c0e06 MSL: Add test for block IO output with function use. 2023-03-30 18:30:44 +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
Chip Davis
2a9091ce53 MSL: Use rint() instead of round() to round array coordinates.
Vulkan specifies round-to-nearest-even mode to round array coordinates.
But we were using `round()`, which is round-to-nearest-away-from-zero.
Instead, use `rint()`, which is specified to perform nearest-even
rounding in MSL.
2023-01-18 19:34:29 -08:00
Hans-Kristian Arntzen
c77b09b57c
Merge pull request #2063 from KhronosGroup/fix-2060
Merge #2061
2022-11-21 14:29:47 +01:00
Hans-Kristian Arntzen
451ed10e91
Merge pull request #2062 from cdavis5e/msl-spirv-assembly-fixes
MSL: SPIR-V assembly fixes
2022-11-21 13:53:17 +01:00
Hans-Kristian Arntzen
df76a14056 MSL: Refactor member reference in terms of one boolean.
ptr_chain was really just masking the proper i == 0 check.
Be more explicit about what the check is actually doing and comment
this.
2022-11-21 13:40:27 +01:00
Chip Davis
5547b25afe Interleave undef values with constants and types.
Undef values may be of struct type and may be used in constants.
Therefore, they must be interleaved with constants and types.

Fixes the rest of the Vulkan CTS test
`dEQP-VK.spirv_assembly.instruction.compute.opundef.undefined_spec_constant_composite`.

(Please excuse the churn in the reference output; it's an inevitable
result of this change.)
2022-11-20 02:08:37 -08:00
Chip Davis
c7ce92a95b MSL: Manually update BuiltInHelperInvocation when a fragment is discarded.
Some Metal devices have a bug where `simd_is_helper_thread()` won't
return true after a fragment has been discarded. We can work around this
by manually setting `gl_HelperInvocation` upon discarding a fragment.
This is fairly unintrusive, so it is enabled by default. I've made it an
option so that, when the bug is fixed, we can disable it.
2022-11-19 23:48:26 -08:00
Hans-Kristian Arntzen
4de9d6c2b6 MSL: Handle implicit integer promotion rules.
MSL inherits the behavior of C where arithmetic on small types are
implicitly converted to int. SPIR-V does not have this behavior, so make
sure that arithmetic results are handled correctly.
2022-10-31 13:33:46 +01:00
Hans-Kristian Arntzen
2a49f7e82d MSL: Fix restrict vs __restrict incompatibility.
restrict was supported, but it broke in MSL 3.0. __restrict works on all
versions, so opt for that instead.

Also check for RestrictPointer decoration and refactor to_restrict() to
not take optional parameter to make it more obvious when implied space
character is added.
2022-10-26 17:52:47 +02:00
Hans-Kristian Arntzen
04af769e85 MSL: Handle partial access chains with array-of-UBO/SSBO.
Need to consider the backing variable, not just plain SPIRVariable.
2022-10-26 11:33:04 +02:00
Chip Davis
a171087180 MSL: Support "raw" buffer input in tessellation evaluation shaders.
Using vertex-style stage input is complex, and it doesn't support
nesting of structures or arrays. By using raw buffer input instead, we
get this support "for free," and everything becomes much simpler.
Arguably, this is the way I should've done this in the first place.

Eventually, I'd like to make this the default, and then remove the
option altogether. (And I still need to do that with
`multi_patch_workgroup`...)

Should help fix 66 tests in the Vulkan CTS, under the following trees:

 - `dEQP-VK.pipeline.*.interface_matching.*`
 - `dEQP-VK.tessellation.user_defined_io.*`
 - `dEQP-VK.clipping.user_defined.*`
2022-10-18 14:58:59 -07:00
Bill Hollings
0a1127aa50 MSL: Emit correct address space when casting during OpStore.
When storing to local variable (eg. OpCopyLogical), the
default device address space used during casts is illegal.
Determine correct address space based on variable type.
2022-09-22 21:28:42 -04:00
Bill Hollings
5493b3030e MSL: Support OpPtrEqual, OpPtrNotEqual, and OpPtrDiff.
- Add CompilerMSL::emit_binary_ptr_op() and to_ptr_expression()
  to emit binary pointer op. Compare matrix addresses without automatic
  transpose() conversion, to avoid error taking address of temporary copy.
- Add Compiler::add_active_interface_variable() to also track active
  interface vars in the entry point for SPIR-V 1.4 and above.
- For OpPtrAccessChain that ends in array element, use Element
  as offset to existing index, otherwise it will access into
  array dimension that doesn't exist.
- Dereference pointer function call arguments. Ultimately, this
  dereferencing is actually backwards, and in future, we should aim
  to properly support passing pointer variables between functions,
  but such a refactoring was beyond the scope here.
- Use [] to declare array of pointers, as array<T*> is not supported in MSL.
- Add unit test shaders.
2022-09-14 15:19:15 -04:00
Hans-Kristian Arntzen
bc3987e59a MSL: Fix various bugs with Ptr/U bitcasts. 2022-08-09 13:49:40 +02:00
Hans-Kristian Arntzen
4b9e60273c Add tests for OpCompositeInsert edge cases. 2022-05-18 16:43:32 +02:00
Hans-Kristian Arntzen
23662668dd Attempt more optimal codegen for OpCompositeInsert.
Speculate that we can modify the SSA value in-place. As long as it is
not used after the modify, this is fine.

Also need to make sure we don't attempt to RMW something that is
impossible to modify.
2022-05-18 16:37:33 +02:00
Hans-Kristian Arntzen
7b9eaf0b5e MSL: Handle awkward mix and match of Offset / ArrayStride in constants.
In normal buffer blocks, every member must be declared, but for
constants, you can technically mix and match, causing much pain and
suffering ...
2022-03-22 12:25:09 +01:00
Hans-Kristian Arntzen
4ab5bbb4e5 Fixup names of anonymous inner structs.
Just like we try to fixup struct names for block types, inner structs
can be "anonymous" structs. HLSL codegen from DXC tends to emit this,
and emitting dummy struct names tends to break GL linkage on some
drivers.
2022-03-10 15:45:38 +01:00
Hans-Kristian Arntzen
1ec9d018fd MSL: Handle aliased variable names for resources placed in IB struct.
Just remember to register the names.
2022-03-07 12:00:40 +01:00
Bill Hollings
0c0fd98322 MSL: Use var name instead of var-type name for flattened interface members.
This allows two variables of the same struct type to be flattened
into the same interface struct without a member name conflict.

Add shaders-msl/frag/in_block_with_multiple_structs_of_same_type.frag
unit test shader to demonstrate this.
2022-03-04 11:38:53 -05:00