Commit Graph

1258 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
4c345166dc GLSL: Implement task shaders.
Due to bugged glslang / spirv-tools w.r.t. terminator instructions,
add a hack to ignore invalid SPIR-V for the time being.
2022-09-05 12:31:22 +02:00
Hans-Kristian Arntzen
5762617729 GLSL: Implement GL_EXT_mesh_shader. 2022-09-05 11:25:04 +02:00
Hans-Kristian Arntzen
6a73e68d30 Update glslang reference. 2022-09-05 11:18:44 +02:00
Hans-Kristian Arntzen
d24f41f1d5 Update dependencies. 2022-09-02 14:58:04 +02:00
Hans-Kristian Arntzen
bc3987e59a MSL: Fix various bugs with Ptr/U bitcasts. 2022-08-09 13:49:40 +02:00
Hans-Kristian Arntzen
05bbcc2d09 Do not optimize OpCompositeInsert for hoisted temporaries.
We cannot track uses that happens in subsequent loop iterations, so have
to be very careful.

Fixes regression introduced after this was added.
2022-08-09 12:44:57 +02:00
Chip Davis
fc4a12fd4f MSL: Use a wrapper type for matrices in workgroup storage.
The standard `matrix` type in MSL lacked a constructor in the
`threadgroup` AS. This means that it was impossible to declare a
`threadgroup` variable that contains a matrix. This appears to have been
an oversight that was corrected in macOS 13/Xcode 14 beta 4. This
workaround continues to be required, however, for older systems.

To avoid changing interfaces unnecessarily (which shouldn't be a problem
regardless because the old and new types take up the same amount of
storage), only do this for structs if the struct is positively
identified as being used for workgroup storage.

I'm entirely aware this is inconsistent with the way packed matrices are
handled. One of them should be changed to match the other. Not sure
which one.

Fixes 23 CTS tests under `dEQP-VK.memory_model.shared`.
2022-08-07 17:31:41 -07:00
Chip Davis
faea931de3 MSL: Also replace bool with short in structures.
Since `bool` is a logical type, it cannot be used in uniform or storage
buffers. Therefore, replacing it in structures should not change the
shader interface.

We leave it alone for builtins. (FIXME: Should we also leave it for
I/O varyings?)

Fixes 24 CTS tests under `dEQP-VK.memory_model.shared`.
2022-08-05 11:43:21 -07:00
Hans-Kristian Arntzen
4dfac510ed Handle multiple breaks out of switches.
Use a switch stack instead.
2022-07-22 15:31:40 +02:00
Hans-Kristian Arntzen
c24d5a7b90
Merge pull request #1985 from KhronosGroup/fix-1973
Handle collapsed loops similar to collapsed selections.
2022-07-22 15:28:54 +02:00
Hans-Kristian Arntzen
8ba0820c9d
Merge pull request #1984 from KhronosGroup/fix-1972
Avoid detection of false loop variables.
2022-07-22 14:55:06 +02:00
Hans-Kristian Arntzen
be904dcc1e Handle collapsed loops similar to collapsed selections.
If we hit the deprecated scenario of selection with identical branches,
we need to collapse loops into direct branches if need be.
2022-07-22 14:37:46 +02:00
Hans-Kristian Arntzen
f7e98c39db Avoid detection of false loop variables.
If the loop variable candidate has a dominating block that lives in an
unrelated loop, we have to reject the loop variable candidate.
2022-07-22 14:08:21 +02:00
Pedro J. Estébanez
1fe470b199 HLSL: Implement GroupOperation(Inclusive/Exclusive)Scan. 2022-07-22 13:39:37 +02:00
Hans-Kristian Arntzen
963fdfdf68 Handle PHI in collapsed switch constructs.
Collapsed switch constructs only branch directly to the merge block.
2022-07-04 13:55:00 +02:00
Bill Hollings
4185acc70d MSL: Fixes from review for SPV_KHR_physical_storage_buffer extension.
- Assign ulongn physical type to buffer pointers in short arrays
  when array stride is larger than pointer size.
- Support GL_EXT_buffer_reference_uvec2 casting
  buffer reference pointers to and from uvec2 values.
- When packing structs, include structs inside physical buffers.
- Update mechanism for traversing pointer arrays when calculating type sizes.
- Added unit test shaders.
2022-07-01 16:10:41 -04:00
Bill Hollings
78eb5043f9 MSL: Fixes from review for SPV_KHR_physical_storage_buffer extension.
- For physical storage pointers, emit forward reference
  declarations in addition to definitions.
- Minor syntax corrections.
2022-06-24 17:28:17 -04:00
Bill Hollings
52c7c2dab6 MSL: Add support for SPV_KHR_physical_storage_buffer extension.
- Determine sizing and alignments of pointers to types as
  distinct from the size and alignment of the types themselves.
- Declare all buffer pointers in the MSL device address space.
- Support struct pointer recursion, where structs can
  contain pointers to themselves or to a parent struct.
- Add SPIRType::was_forward_referenced to track if a type was forward
  referenced, to help emit MSL structs in the correct dependency order.
- Handle pointers to pointers that are not just arrays of arrays.
2022-06-20 20:21:00 -04:00
Hans-Kristian Arntzen
e08e0cf28d GLSL: Handle forced temporary OpConvertUToAccelerationStructureKHR.
Need to lower to temporary before casting to RTAS.
2022-06-17 13:38:45 +02:00
Hans-Kristian Arntzen
197a273fd4
Merge pull request #1959 from KhronosGroup/fix-1955-1956
GLSL: Add more extension ladder fallbacks for unusual integer sizes.
2022-06-10 10:42:51 +02:00
Hans-Kristian Arntzen
df21a99d1a GLSL: Add more extension ladder fallbacks for unusual integer sizes. 2022-06-07 18:30:10 +02:00
Hans-Kristian Arntzen
a97bbc24c5
Merge pull request #1958 from KhronosGroup/fix-1957
Fix control flow bug where we missed continue;
2022-06-07 16:00:54 +02:00
Hans-Kristian Arntzen
533aab00b6 GLSL: Add missing KHR barycentric references. 2022-06-07 15:17:34 +02:00
Hans-Kristian Arntzen
46e4b5a3c8 Fix control flow bug where we missed continue;
Case which caused failure:

if (cond)
{
    continue;
}
break;

Only allow tracing from inner selections if the outer header never
merges execution.
2022-06-07 15:04:01 +02:00
Hans-Kristian Arntzen
e45d01c41f Emit KHR barycentrics if source enables the KHR extension.
For roundtrip purposes, need to match KHR or NV extension.
2022-05-27 13:28:25 +02:00
Hans-Kristian Arntzen
0aedc7d128 Roll dependencies. 2022-05-27 13:28:25 +02:00
Hans-Kristian Arntzen
af223101c6
Merge pull request #1952 from KhronosGroup/fix-1944
GLSL: Add basic support for GL_EXT_shader_atomic_float.
2022-05-27 13:17:22 +02:00
Hans-Kristian Arntzen
88e583d062 GLSL: Add basic support for GL_EXT_shader_atomic_float. 2022-05-27 12:13:40 +02:00
Hans-Kristian Arntzen
1c88730e12 GLSL: Implement 1D texture emulation for ES.
ES does not support 1D images at all. Fake it by promoting 1D images to
2D.
2022-05-27 11:51:34 +02:00
Hans-Kristian Arntzen
b3ff97d0fe
Merge pull request #1946 from KhronosGroup/fix-1943
Promote Unreachable cases into break to avoid fallthrough.
2022-05-18 19:22:45 +02:00
Hans-Kristian Arntzen
d08ce828f4 Promote Unreachable cases into break to avoid fallthrough.
HLSL is very fussy about fallthrough in switch blocks, so promote
Unreachable blocks to breaks if they are inside a switch construct.

Some false positives are possible in weird multi-break scenarios, but
this is benign.
2022-05-18 18:36:32 +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
bfefb5f511
Merge pull request #1941 from KhronosGroup/fix-1934
MSL: Potentially cast loaded Input variables.
2022-05-13 14:17:59 +02:00
Hans-Kristian Arntzen
05206005ca MSL: Potentially cast loaded Input variables.
If the sign is rewritten for an input, we might have to fixup the sign
in OpLoad, similar to builtins.
2022-05-13 13:02:45 +02:00
Hans-Kristian Arntzen
92164d38d1 GLSL: Do not analyze precision for Undef variables.
Undefs won't have a chance to emit aliases, and any expression depending
on Undef will be garbage either way.
2022-05-13 12:18:10 +02:00
Hans-Kristian Arntzen
7a6c2da9aa GLSL: Handle more proper semantics for RelaxedPrecision.
GLSL and RelaxedPrecision are quite different in what they affect.
RelaxedPrecision affects operations, while this is merely implied in
GLSL based on inputs.

This leads to situations where we have to promote mediump inputs to
highp, and the simplest approach is to force highp temporaries for
inputs which are consumed in a highp context. For completeness, we also
demote RelaxedPrecision inputs to mediump variables.

PHI is handled by copying the PHI into a temporary.

We have to be very careful with hoisted temporaries, since the child
temporary will not be analyzed up-front. We inherit the hoisted-ness
state and emit the hoisted child temporary as necessary. When faking the
temporaries with OpCopyObject, we make sure to block any variable
hoisting.

Hoisting children of PHI variables is fine, since PHIs are not hoisted with
the same framework as other temporaries.
2022-05-02 15:11:24 +02:00
Hans-Kristian Arntzen
40b3053b4c Handle early reads from loop variables with initializers.
Need to consider that static_expression can be 0. Fallback as necessary.
Also need to clear the static expression.
2022-04-28 14:36:53 +02:00
Hans-Kristian Arntzen
c52333b984
Merge pull request #1924 from stefalie/master
cli: display missing memory qualifiers for reflect and dump-resources
2022-04-27 13:27:53 +02:00
Bill Hollings
3bca246ad2 MSL: Emit interface block members of array length 1 as arrays instead of scalars.
Test for array presence using is_array() instead of element count.
Add shaders-msl/vert/interface-block-single-element-array.vert regression test.

Fixes a regression error introduced in 3d4daab.
2022-04-26 20:39:18 -04:00
Stefan Lienhard
089cf27119 remove newline at eof 2022-04-26 19:15:51 +02:00
Stefan Lienhard
56fd17f552
add qualifiers to reference reflect json output 2022-04-26 14:30:17 +02:00
Hans-Kristian Arntzen
d7cae5e7cd
Merge pull request #1917 from KhronosGroup/fix-1906
GLSL: Support GL_EXT_debug_printf.
2022-04-19 13:08:30 +02:00
Hans-Kristian Arntzen
d2a4f9842b GLSL: Support GL_EXT_debug_printf. 2022-04-19 12:07:54 +02:00
Hans-Kristian Arntzen
5b18fb1bcd MSL: Pass down global RayQuery object to leaf functions. 2022-04-19 11:49:22 +02:00
Hans-Kristian Arntzen
17c52990d5 MSL: Fix goofy bugs in ray query. 2022-03-24 18:14:46 +01:00
Hans-Kristian Arntzen
d000b9e71c
Merge pull request #1898 from KhronosGroup/pr-1859
Merge PR #1859 with minor fixes
2022-03-22 13:50:43 +01:00
Hans-Kristian Arntzen
a7eefbc114 HLSL: Disable FXC testing for rayquery shaders.
Manually tested that it compiles on DXC.
2022-03-22 12:34:43 +01:00
Hans-Kristian Arntzen
cd209ff46d HLSL: Update test from review. 2022-03-22 12:31:52 +01:00
Hans-Kristian Arntzen
c95338e03e Merge branch 'ray_query' of https://github.com/k-payl/SPIRV-Cross into pr-1859 2022-03-22 12:29:49 +01:00