Commit Graph

3843 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
e406fb215c Fixup invalid shader that should not pass. 2024-05-21 14:04:20 +02:00
Hans-Kristian Arntzen
1f68d0f420
Merge pull request #2327 from KhronosGroup/pr-2324
Land PR 2324
2024-05-21 11:36:55 +02:00
Hans-Kristian Arntzen
485b4c6e27 Update C API minor version. 2024-05-21 11:26:18 +02:00
Aitor Camacho
cd8865deab Add option to enforce fragment execution with side effects in MSL
Metal will incorrectly discard fragments with side effects under
certain circumstances prematurely. The conditions are the following:
 - Fragment will always be discarded after side effect operation
 - Pre fragment depth fails
 - Modifies depth value for a constant value in the fragment shader.
   This constant value will also fail the depth test.

However, Metal will also discard the fragment even if it has
operations with side effects inside the fragment shader before the
discard operation.

Vulkan states the graphics pipeline to execute in the following
order:
 - Pre fragment depth test (cannot discard here due to modifying
   depth value in fragment shader)
 - Fragment shader (where the depth is modified and fragment
   discarded)
 - Post fragment depth test

Therefore, we need to enforce fragment shader execution and not
let Metal discard the fragment before that for such cases. This
change adds an option to provide such utility.
2024-05-21 11:24:56 +02:00
Hans-Kristian Arntzen
e2204e3fe9
Merge pull request #2326 from KhronosGroup/pr-2325
Land PR 2325.
2024-05-21 11:23:42 +02:00
Hans-Kristian Arntzen
641b92fa8f MSL: Clean up some nits for review. 2024-05-21 11:10:55 +02:00
Bill Hollings
ab1f9f4d7f MSL: Support ConstOffsets on image gather.
- Add TextureFunctionArguments::has_array_offsets.
- Add support functions spvGatherConstOffsets() &
  spvGatherCompareConstOffsets().
- Add SPVFuncImpl::SPVFuncImplGatherConstOffsets &
  SPVFuncImplGatherCompareConstOffsets.
- Add unit tests.
2024-05-20 12:10:35 -04:00
Hans-Kristian Arntzen
1ddd8b629c
Merge pull request #2321 from KhronosGroup/control-dependent-function
Mark function call results as control dependent as necessary.
2024-05-10 15:21:42 +02:00
Hans-Kristian Arntzen
04ddb9a809 Mark function call results as control dependent as necessary.
Inner function calls can contain flow-control sensitive code.
In this case, the function call itself must inherit the
control-dependence.

Rarely happens in practice since optimized code with SSA tends to
inline.
2024-05-10 14:52:24 +02:00
Hans-Kristian Arntzen
476f384eb7 Fix unused variable warning on GCC 14. 2024-05-09 12:26:58 +02:00
Bill Hollings
84cdc3b68e MSL: Fix argument buffer padding.
- After padding a resource, retrieve either the next padded slot,
  or the next resource, in order to correctly offset the slot index.
2024-05-06 09:57:31 +02:00
Hans-Kristian Arntzen
2ccc81fd82
Merge pull request #2317 from KhronosGroup/fix-2309
MSL: Handle missing FP16 trancendental overloads.
2024-04-29 12:02:51 +02:00
Hans-Kristian Arntzen
cbaa86982a MSL: Handle missing FP16 trancendental overloads. 2024-04-29 11:49:28 +02:00
Hans-Kristian Arntzen
71fe131ed0
Merge pull request #2314 from js6i/gpu-crash
Remove spvDescriptor wrapper in spvDescriptorArray
2024-04-29 10:17:43 +02:00
Jan Sikorski
84b4a54b0d Updated tests. 2024-04-18 09:19:01 +02:00
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
cb956675fd
Merge pull request #2312 from KhronosGroup/fix-2305
MSL: Inherit interpolation qualifiers through recursive composites.
2024-04-15 16:40:47 +02:00
Hans-Kristian Arntzen
dc6db52356 MSL: Inherit interpolation qualifiers through recursive composites. 2024-04-15 15:44:21 +02:00
Hans-Kristian Arntzen
8edbda4206
Merge pull request #2311 from KhronosGroup/fix-2303
MSL: Handle Atomic{S,U}{Min,Max} with mismatched image sign.
2024-04-15 14:47:18 +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
25b7772102
Merge pull request #2310 from KhronosGroup/fix-2300
MSL: Fix SUMulExtended for 64-bit inputs.
2024-04-15 13:55:25 +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
06407561ec
Merge pull request #2306 from KhronosGroup/pr-2292
MSL: Implement support for EXT_mutable_descriptor_type and general aliasing with argument buffers
2024-04-03 15:16:49 +02:00
Hans-Kristian Arntzen
061bf6b445 Fix tabbing nits. 2024-04-03 13:49:41 +02:00
Hans-Kristian Arntzen
8219ccf706 MSL: Reassign bindings so they work with decoration binding in test. 2024-04-03 13:45:18 +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
ffb2c9bb6f MSL: Added tests for overlapping bindings. 2024-04-02 12:01:07 +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
Hans-Kristian Arntzen
7d92d7d879
Merge pull request #2299 from KhronosGroup/fix-2285
Block loop optimization if Phi is used.
2024-03-18 12:31:21 +01:00
Hans-Kristian Arntzen
b4c84bb135 Block loop optimization if Phi is used.
Somehow this hasn't been caught until now. Impressive.

We'll have to emit side effects in condition block to make this work,
which breaks loop conditionals.
2024-03-18 12:09:38 +01:00
Hans-Kristian Arntzen
1e3f31e69c
Merge pull request #2298 from KhronosGroup/pr-2297
Land PR 2297
2024-03-18 11:56:15 +01:00
Hans-Kristian Arntzen
48aba6ab03 Add test for multi-function Private LUT. 2024-03-18 11:25:59 +01:00
Hans-Kristian Arntzen
48bede6a2a Smaller cleanups on multi-function Private LUTs. 2024-03-18 11:25:38 +01:00
Hans-Kristian Arntzen
6ee80151e4 Merge branch 'global-luts' of https://github.com/js6i/SPIRV-Cross into pr-2297 2024-03-18 11:04:53 +01:00
Hans-Kristian Arntzen
326199641d
Merge pull request #2296 from KhronosGroup/vulkan-sdk-1.3.280-moltenvk
MSL: Merge `vulkan-sdk-1.3.280-moltenvk` branch into `main` branch.
2024-03-18 10:50:37 +01:00
Jan Sikorski
8465ec8109 Support cases of LUTs which are not function local.
Prevent cases where arrays that are globally defined constants are redeclared
on stack. On Intel macs, declaring a large, statically initialized
spvUnsafeArray on stack may cause an internal compiler error.
2024-03-15 17:19:49 +01:00
Bill Hollings
de0e72a0db
Merge pull request #2293 from billhollings/atomic_compare_exchange_weak-texture_1D_as_2D
MSL: atomic_compare_exchange_weak() support CompilerMSL:msl_options.texture_1D_as_2D.
2024-03-11 23:27:25 -04: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
2a7c818492
Merge pull request #2290 from KhronosGroup/fix-2287
MSL: Fix type hierarchy for extended vectors.
2024-03-06 15:26:57 +01:00
Hans-Kristian Arntzen
261589a5b2 MSL: Fix type hierarchy for extended vectors. 2024-03-06 14:33:02 +01:00
Hans-Kristian Arntzen
c2eb27c172
Merge pull request #2289 from KhronosGroup/fix-2279
Fix crash when traversing PtrAccessChain to OpTypeStruct.
2024-03-06 14:32:27 +01:00
Hans-Kristian Arntzen
572c413176 Fix crash when traversing PtrAccessChain to OpTypeStruct. 2024-03-06 13:14:54 +01:00