Commit Graph

939 Commits

Author SHA1 Message Date
Yuwen Wu
f40dba4919 GLSL: added an option to disable row-major-load workaround. 2022-08-24 11:07:12 +08:00
Yuwen Wu
9afa82e7b8 GLSL: disable row major load around on GLES. 2022-08-23 19:27:01 +08: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
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
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
Hans-Kristian Arntzen
f46745095d
Merge pull request #1965 from billhollings/msl-physical_storage_buffer
MSL: Add support for SPV_KHR_physical_storage_buffer extension.
2022-07-04 12:59:42 +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
Frédéric Wang
9c44a97faa address more review comments 2022-06-23 11:40:02 +02:00
Frédéric Wang
1310f5ba4d Keep using sprintf on windows. 2022-06-23 11:34:51 +02:00
Frédéric Wang
99f8613847 Fix compilation errors with deprecated sprintf function
This commit modifies sprintf calls to fix the following compilation
errors using XCode 14.0 beta on MacOS:

> 'sprintf' is deprecated: This function is provided for compatibility
> reasons only.  Due to security concerns inherent in the design of
> sprintf(3), it is highly recommended that you use snprintf(3) instead.
2022-06-21 16:28:16 +02: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
df21a99d1a GLSL: Add more extension ladder fallbacks for unusual integer sizes. 2022-06-07 18:30:10 +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
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
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
a3c4177324 GLSL: Don't apply Grad LOD workarounds for fetch. 2022-05-13 15:47:38 +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
7eb5ced2a0 Refactor out query for operation type/result IDs. 2022-05-02 15:27:09 +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
d28136cc7a GLSL: Clean up some ways of querying decoration flags. 2022-04-29 13:47:49 +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
d2a4f9842b GLSL: Support GL_EXT_debug_printf. 2022-04-19 12:07:54 +02:00
Bill Hollings
85f98eb0c5 Allow volatile vars that are not builtins to be forwarded.
This fixes a regression introduced by 93b0dc7, where all volatile variables
were not allowed to be forwarded. This doesn't work well for volatile memory
object variables like images or buffer blocks, because it forces local variables
to be defined, which is unnecessary, and sometimes results in wrong types.

This patch restricts volatile builtin variables (eg. HelperInvocation) from
being forwarded, but allows other volatile variables to be forwarded, as before.
2022-03-23 14:48:22 -04: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
93b0dc7718 Consider Volatile in should_forward().
Never forward these variables.
2022-03-04 11:08:55 +01:00
Hans-Kristian Arntzen
476b6541fa Remove forwardable bit in SPIRVariable.
Was never really used for anything. It's always true.
2022-03-04 11:05:21 +01:00
Hans-Kristian Arntzen
005c14ad6a HLSL: Implement HelperInvocationEXT.
It is volatile by nature and must not be forwarded.
2022-03-04 10:54:31 +01:00
Hans-Kristian Arntzen
31be74a853 Add relax_nan_checks options.
Makes codegen from typical D3D emulation SPIR-V more readable.
Also makes cross compilation with NotEqual more sensible.
It's very rare to actually need the strict NaN-checks in practice.

Also, glslang now emits UnordNotEqual by default it seems, so give up
trying to assume OrdNotEqual. Harmonize for UnordNotEqual as the sane
default.
2022-03-03 14:50:56 +01:00
Daniel Thornburgh
44c3333a1c Qualify std::move.
Clang added -Wunqualified-std-cast-call in
https://reviews.llvm.org/D119670, which warns on unqualified std::move
and std::forward calls. This change qualifies these calls to allow the
project to build on HEAD Clang -Werror.
2022-03-02 23:17:58 +00:00
Hans-Kristian Arntzen
188dc8b13c
Merge pull request #1862 from flokart-world/feature/flatten-ubo-for-hlsl
HLSL: Make --flatten-ubo work correctly
2022-02-16 16:39:45 +01:00
Shintaro Sakahara
ed4ded040e HLSL: Make --flatten-ubo work correctly 2022-02-16 21:53:24 +09:00
Hans-Kristian Arntzen
a56b22bf4e Add more scenarios where we can guarantee forward progress.
The patterns where we force temporary due to invalid/overused expression -> recompile
should be seen as making forward progress, and there are very rare scenarios where
these recompiles can cascade into many loops.

Refactor this style of logic into a new function which is equivalent to handle_invalid_expression().
2022-02-16 12:12:58 +01:00
Hans-Kristian Arntzen
c716a9a5dd Add debug option to modify maximum number of compile iterations.
Should be seen as a hack, but it's pragmatic in some scenarios.
2022-02-16 12:12:27 +01:00
Hans-Kristian Arntzen
339e61a0e0 Do not emit hoisted access chain temporaries unless backend supports it.
This can happen for access chains into buffer objects which were marked
as potentially hoisted, but it's benign in almost all cases.
2022-02-16 11:36:38 +01:00
Hans-Kristian Arntzen
5d9a95370f GLSL: Ensure correct signed integer type for more texture functions. 2022-02-16 11:14:07 +01:00
Hans-Kristian Arntzen
48b5a9069f Handle aliased names in spec constants.
Need to register resource name.
2022-01-18 12:31:28 +01:00
Hans-Kristian Arntzen
9b25581d49 MSL: Handle constant construct of block-like array types.
Need this to be context sensitive, since array of block-like struct is
template, but struct of block-like array is C-style.

Also, test a mix and match, so we have constant array of block-like
struct with array inside. :v
2022-01-17 18:28:25 +01:00
Hans-Kristian Arntzen
7dd974b9db
Merge pull request #1847 from KhronosGroup/fix-1775
Rework how loop iteration counts are validated.
2022-01-17 14:55:56 +01:00
Hans-Kristian Arntzen
1d13a3e36a Rework how loop iteration counts are validated.
Introduces an idea of a recompilation making forward progress.

There are some extreme edge cases where we need more than 3 loops, but
only allow this in specific circumstances where we can reason about
forward progress being made.
2022-01-17 14:12:01 +01:00
Hans-Kristian Arntzen
ef6bde6580 Do not forward expressions which carry a huge amount of dependencies.
Need to force temporaries eventually, or compilers have a tendency to
explode.
2022-01-17 13:45:12 +01:00
miomioreimu
4407c0dd14 fix: GL_EXT_texture_buffer is more common than GL_OES_texture_buffer 2022-01-10 16:49:45 +08:00
Hans-Kristian Arntzen
7c83fc22fa Add support for LocalSizeId.
WorkgroupSize builtin is deprecated in 1.6 and LocalSizeId is supported
in Vulkan starting with maintenance4.
2022-01-06 13:57:10 +01:00
Sebastián Aedo
905b8244e7 Clamp vector element access to vector size.
In cases where we know the size of the vector and the index at compile
time, we can check if it's accessing in bounds and rely in undefined
behavior otherwise.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-12-07 16:00:06 -03:00
Hans-Kristian Arntzen
e9cc640334
Merge pull request #1815 from etra0/fix-1768
MSL: Add 64 bit switch support
2021-11-30 14:21:40 +01:00