Commit Graph

1331 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
5b322555d6 GLSL: Fix bug with mixed precision on PHI variables. 2023-06-07 15:31:29 +02:00
Hans-Kristian Arntzen
bf752edaa4 Update test output for preserve structured. 2023-05-19 11:38:12 +02:00
Hans-Kristian Arntzen
6df60be69f Merge remote-tracking branch 'epic/fixes_hlsl' 2023-05-19 11:10:24 +02:00
Laura Hermanns
578bdf410b Added tests for HLSL structured buffers. 2023-05-17 13:52:24 -04: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
54b48a2f3a
Merge pull request #2133 from georgeouzou/main
GLSL: Support GL_KHR_shader_subgroup_arithmetic (WIP)
2023-05-10 11:32:00 +02:00
George Ouzounoudis
ff962261d4 GLSL: Add tests for subgroup iadd, fadd, imul, fmul 2023-05-01 15:51:54 +03:00
Hans-Kristian Arntzen
a5ec818d41 HLSL: Add test for straddling + holes in struct. 2023-04-27 17:40:02 +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
1d4e063788 HLSL: Add missing test reference. 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
Hans-Kristian Arntzen
50623e13c8 GLSL: Fix expression reorder bug with legacy FMA fallback. 2023-03-30 17:24:11 +02:00
Hans-Kristian Arntzen
09e60d74f6
Merge pull request #2124 from Try/hlsl-task-shader
HLSL: Add task(amplification) shader support
2023-03-22 12:36:47 +01:00
Hans-Kristian Arntzen
8c509fec7b HLSL: Update rayquery reference. 2023-03-21 12:23:40 +01:00
Try
dd8839c6f9 task shader initial 2023-03-18 17:20:16 +01: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
8e20860b9e added tests and added msl3 to test_shaders.py 2023-02-15 00:04:44 -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
rdb
c356dd6220 GLSL: Fix missing precision qualifier in spvDeterminant return value
Follow-up to #2100
2023-01-27 21:44:47 +01:00
rdb
20981666cc GLSL: Legacy matrix inverse/determinant polyfills, outerProduct()
Also refactors polyfill mechanism in GLSL and fixes transpose() lowering precision.
2023-01-27 13:51:47 +01:00
Hans-Kristian Arntzen
86a985f28c
Merge pull request #2093 from rdb/emulate-unsupported-hyperbolic-funcs
GLSL/HLSL: Add emulated fallbacks for hyperbolic math functions
2023-01-27 12:15:28 +01:00
rdb
53974b4fae GLSL/HLSL: Add emulated fallbacks for sinh/cosh/tanh/asinh/acosh/atanh
The inverse hyperbolic functions are not supported in HLSL, and none of them are supported in legacy GLSL.
2023-01-26 19:40:42 +01:00
rdb
d10044b23e GLSL: Add support for modf, isnan and isinf in legacy GLSL 2023-01-26 19:14:25 +01:00
Hans-Kristian Arntzen
9de5abaf78 GLSL: Minor fixes for shader clock implementation. 2023-01-26 15:41:51 +01:00
Hans-Kristian Arntzen
f575b89436
Merge pull request #2091 from LDeakin/shader-clock
GLSL: Support OpReadClockKHR
2023-01-26 15:41:40 +01:00
rdb
dff276989b GLSL: Multiplying matrix with scalar shouldn't force transpose 2023-01-21 11:42:55 +01:00
Lachlan Deakin
3335835fad GLSL: Support OpReadClockKHR 2023-01-19 22:28:38 +11: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
rdb
26da9c58a6 HLSL: Support PointSize output in vertex shader in SM 3.0 2023-01-17 23:42:04 +01:00
rdb
4ba13e0c1a GLSL/HLSL: Add legacy handling for int vertex attributes 2023-01-14 18:57:24 +01:00
Hans-Kristian Arntzen
1047c13d40 GLSL: Handle textureGatherOffsets properly.
We forgot to pass down the offset ID, clean up coffset vs offset jank
while we're at it.
2023-01-12 16:27:11 +01:00
Hans-Kristian Arntzen
bcbe33ad11 Also consider NonSemantic ExtInst in block_is_noop. 2023-01-12 12:41:53 +01:00
Hans-Kristian Arntzen
9d8ef6b36c Update test for updated block_is_noop check. 2023-01-11 15:21:58 +01:00
Hans-Kristian Arntzen
457fd3db70 Add tests for loops compiled with debug semantics. 2023-01-11 15:18:19 +01:00
Hans-Kristian Arntzen
a89dea3c49
Merge pull request #2071 from KhronosGroup/fix-2068
CFG: Handle implied access to opaque loaded values.
2022-12-13 17:16:31 +01:00
Hans-Kristian Arntzen
68a012a4f2 CFG: Handle implied access to opaque loaded values.
Similar concern as access chains. Objects that we cannot lower to
temporaries must implicitly access all expression dependencies when they
are themselves accessed.
2022-12-13 16:34:00 +01:00
Hans-Kristian Arntzen
03b1f66ef1 GLSL: Fix row-major workaround wrapper for ES.
By default, the matrix would be declared as mediump, causing precision
issues. Need to dispatch to two separate functions since GLSL does not
support overload based on precision.
2022-12-13 15:44:03 +01: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
061cdd2052 MSL: Don't dereference forwarded copies of OpVariable pointers.
Fixes two more CTS tests under
`dEQP-VK.spirv_assembly.instruction.compute.empty_struct.copying`.
2022-11-20 02:08:37 -08: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
06ef3de002 GLSL, MSL: Handle OpUndef as part of a constant composite.
Fixes the CTS test
`dEQP-VK.spirv_assembly.instruction.compute.opundef.undefined_constant_composite`
and helps with another,
`dEQP-VK.spirv_assembly.instruction.compute.opundef.undefined_spec_constant_composite`.
Unfortunately, fixing the latter requires another change.
2022-11-20 02:08:33 -08:00
Chip Davis
aa5a8c482e MSL: Prevent stores to storage resources in discarded fragments.
Some Metal devices have a bug where storage resources can still be
written to even if the fragment is discarded. This is obviously a bug in
Metal, but bothering Apple to fix it will only fix it for newer
versions; therefore, a workaround is needed for older versions. I have
made this an option so that, in case the bug is ever fixed, the
workaround can be disabled.

This workaround is simple: if a fragment shader may discard its fragment
and writes to a storage resource, a variable representing the
`HelperInvocation` built-in is created and passed to all functions. The
flag is checked on all resource writes; writes do not occur when
`HelperInvocation` is `true`. This relies on the earlier workaround to
update `HelperInvocation` when the fragment is discarded.

Fixes at least 3 failures in the CTS.
2022-11-20 01:29:41 -08:00
Chip Davis
51d2dfe02a MSL: Add missing casts to Op?MulExtended.
It is possible to pass unsigned integers to `OpSMulExtended`. In that
case, we want to do a signed multiply with sign extension, so make sure
the operands are forced to be interpreted as signed.

This was an oversight on my part when I added these instructions.

Fixes the CTS test
`dEQP-VK.spirv_assembly.instruction.compute.signed_op.uint_smulextended`.
2022-11-20 00:20:49 -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
b606e4f752 HLSL: Fix test for non-block per-primitive IO.
Force gl_in_out path for HLSL as well when mesh shaders are used.
2022-11-02 13:41:32 +01:00