Commit Graph

1069 Commits

Author SHA1 Message Date
Jan Sikorski
298c2315f5 MSL: Remove pointer wrapper stored in spvDescriptorArray.
This works around what looks like a compiler bug which can cause GPU crashes.
2024-04-18 09:13:29 +02:00
Hans-Kristian Arntzen
dc6db52356 MSL: Inherit interpolation qualifiers through recursive composites. 2024-04-15 15:44:21 +02:00
Hans-Kristian Arntzen
4f17bf76b1 MSL: Handle Atomic{S,U}{Min,Max} with mismatched image sign.
Gross reinterpret_cast, but gotta do what you gotta do.
2024-04-15 14:29:01 +02:00
Hans-Kristian Arntzen
eef4c2af9c MSL: Fix SUMulExtended for 64-bit inputs. 2024-04-15 13:37:00 +02:00
Hans-Kristian Arntzen
56f24d86ec
Merge pull request #2304 from etang-cw/ArrayCleanup
Use recursive template for spvArrayCopy
2024-04-15 11:47:10 +02:00
Hans-Kristian Arntzen
ee77265ae5 MSL: Workaround compiler issue with image fence when used as reference. 2024-04-03 13:28:12 +02:00
Hans-Kristian Arntzen
218a8bfd86 MSL: Improve argument buffer descriptor aliasing implementation. 2024-04-03 13:15:51 +02:00
Hans-Kristian Arntzen
32e33e40b5 Cleanup overlap tag from review. 2024-04-02 12:42:12 +02:00
Jan Sikorski
221a517be5 MSL: Pass variable id when emitting image entry point declarations. 2024-04-02 12:01:07 +02:00
Jan Sikorski
064186e474 MSL: Check for device argument buffers for overlapping bindings. 2024-04-02 12:01:07 +02:00
Jan Sikorski
760a659f5c MSL: Avoid emitting multiple declaration of the same variable. 2024-04-02 12:01:07 +02:00
Jan Sikorski
44a5f1fc3e MSL: Add support for overlapping bindings.
This adds support for bindings which share the same DescriptorSet/Binding pair.

The motivating example is vkd3d, which uses overlapping arrays of resources to
emulate D3D12 descriptor tables. The generated MSL argument buffer only
includes the first resource (in this example 't0'):

struct spvDescriptorSetBuffer2
{
    array<texture2d<float>, 499968> t0 [[id(0)]];
    // Overlapping binding: array<texture3d<float>, 499968> t2 [[id(0)]];
};

When t2 is referenced, we cast the instantiated member:

float4 r1 = spvDescriptorSet2.t0[_79].sample(...);
float4 r2 = (*(constant array<texture3d<float>, 499968>*)&spvDescriptorSet2.t0)[_97].sample(...);
2024-04-02 12:01:07 +02:00
Hans-Kristian Arntzen
f9393f44d3 MSL: Get rid of obsolete "is pointer" methods.
Just use the common ones.
2024-04-02 11:47:54 +02:00
Evan Tang
cc542f8147 Use recursive template for spvArrayCopy
Comment claims we can't, but I tested a number of older Metal compilers (Xcode 8 targeting macOS 10.11, macOS 10.13 online compiler, Xcode 14 targeting iOS 8) and none of them had any issues with it
2024-04-01 17:11:31 -05:00
Bill Hollings
5e6500466c MSL: atomic_compare_exchange_weak() support CompilerMSL:msl_options.texture_1D_as_2D.
CompilerMSL:msl_options.texture_1D_as_2D emulates a Metal 1D texture
as a 2D texture in order to expand features available for 1D textures.
Support accessing such textures as 2D for atomic_compare_exchange_weak().
2024-03-11 22:42:43 -04:00
Hans-Kristian Arntzen
261589a5b2 MSL: Fix type hierarchy for extended vectors. 2024-03-06 14:33:02 +01:00
Hans-Kristian Arntzen
c524e3396f MSL: Improve handling of BDA + atomics. 2024-03-05 14:30:46 +01:00
Hans-Kristian Arntzen
7e0c9ab9ed MSL: Nit from review. 2024-02-26 15:51:32 +01:00
Jan Sikorski
052c57e2f2 MSL: Pass texture array index separately to atomic texture operations. 2024-02-26 15:51:32 +01:00
Try
ed7a3e3ebb fix codegen for shader with only bindless ssbo 2024-02-04 23:28:58 +01:00
Hans-Kristian Arntzen
9d87a014f0 MSL: Handle volatile properly for emulated image atomics. 2024-01-23 13:09:41 +01:00
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
b9abac5024 Fix nits from review. 2024-01-16 14:46:16 +01:00
sean
6c24be197f MSL: Add support for SPV_EXT_integer_dot_product 2024-01-16 14:42:56 +01:00
Hans-Kristian Arntzen
57e28e3f58 MSL: Implement spvDescriptorArray path for SSBO/UBO. 2024-01-08 14:15:23 +01:00
Hans-Kristian Arntzen
e10bf53324 MSL: Support variable sized descriptor array in argument buffer. 2024-01-08 12:37:01 +01:00
Hans-Kristian Arntzen
ec87a03655 MSL: Plumb through member state to image/sampler types. 2024-01-05 16:08:29 +01:00
Bill Hollings
d47183c0db MSL: Ensure discrete runtime arrays of buffers have known length.
An entry-point array of buffers, that is not part of a Metal argument
buffer, requires a known length, so it can be emitted as discrete buffers.
For runtime arrays of resources, this can be retrieved from the resource
binding information added via add_msl_resource_binding().

- Redefine get_resource_array_size() to consolidate array sizing using both var
  type, and runtime array sizing from resource bindings, if not found in type.
- Use get_resource_array_size() to fix issue for runtime arrays of buffers.
- Update runtime arrays of images and samplers to use get_resource_array_size().
- Add .DS_Store to .gitignore (unrelated).
2023-12-22 09:12:44 -05: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
833c5936b0 Various nit fixes and improvements from review. 2023-12-07 14:31:36 +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
Hugo Devillers
5065781b15 fix more spirtype::op instances 2023-12-06 18:04:59 +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
ed7ba43062 MSL: Use LHS expression to determine whether or not to do array copy.
Makes a difference when using variable pointers.
2023-12-06 16:18:58 +01:00
Try
8f58b84761 MSL: add ray-cull mask 2023-12-05 20:56:48 +01:00
Chip Davis
c0760eb91f MSL: Fix patch vertex count with raw buffer tese input.
We can no longer rely on the `patch_control_point<>` array being
present, so the best we can do is use the value given us at compile
time.

This was an oversight on my part when I initially implemented the
raw-buffer tessellation evaluation input mode. The lack of tests for the
`PatchVertices` built-in almost certainly contributed, so I fixed that
in this patch.

Fixes the test
`dEQP-VK.tessellation.shader_input_output.patch_vertices_in_tes`. This
is the last failing test under `dEQP-VK.tessellation`.
2023-12-04 14:24:16 -08:00
Hugo Devillers
7c7b6e600f msl: look at the pointee type in emit_tessellation_access_chain 2023-12-04 18:49:22 +01:00
Hugo Devillers
8632f67109 msl: look at the actual variable element type in to_member_reference 2023-12-04 18:36:39 +01:00
Hugo Devillers
5b1881041e msl: make build_extended_vector_type deal with compound types better 2023-12-04 18:33:53 +01:00
Hugo Devillers
2c3734df75 msl: fix many instances of SPIRType.self being incorrectly set 2023-12-04 18:33:27 +01:00
Hugo Devillers
ee7aaaf662 msl: fix two more instances of the wrong op in SPIRType 2023-12-04 18:32:56 +01:00
Hugo Devillers
738bfd49e3 msl: fix test regressions with samplemask 2023-12-04 12:47:15 +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
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