Commit Graph

909 Commits

Author SHA1 Message Date
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
Sebastián Aedo
6d8302ef14 MSL: Add 64 bit switch support
Add 64 bit switch support for MSL version 2.2.

* Also fixes a wrong endianness conversion.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-11-26 15:54:56 -03:00
xinhou
4b0584ce70 ESSL: Vertex shader input doesn't support array types. 2021-11-26 10:06:42 +08:00
Hans-Kristian Arntzen
37dfb3f45f
Merge pull request #1794 from etra0/master
Add 64 bit support for OpSwitch
2021-11-15 15:05:10 +01:00
Sebastián Aedo
75e3752273 Added block.cases_32bit and reworked the cases fix
Now we added block.cases_32bit as requested and we only parse if the
remaining ops are a multiple of 2. None of them are mutable because we
return a reference of them depending of the op.condition width.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-11-12 12:50:39 -03:00
Sebastián Aedo
03f678dec4 Cast the switch selector in GLSL to uint32_t
We can safely cast the value since we check previously that we're not
using a uint64_t as the selector.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-11-11 09:58:46 -03:00
Bill Hollings
fd252b21ff Separate (partially) the tracking of depth images from depth compare ops.
SPIR-V allows an image to be marked as a depth image, but with a non-depth
format. Such images should be read or sampled as vectors instead of scalars,
except when they are subject to compare operations.

Don't mark an OpSampledImage as using a compare operation just because the
image contains a depth marker. Instead, require that a compare operation
is actually used on that image.

Compiler::image_is_comparison() was really testing whether an image is a
depth image, since it incorporates the depth marker. Rename that function
to is_depth_image(), to clarify what it is really testing.

In Compiler::is_depth_image(), do not treat an image  as a depth image
if it has been explicitly marked with a color format, unless the image
is subject to compare operations.

In CompilerMSL::to_function_name(), test for compare operations
specifically, rather than assuming them from the depth-image marker.

CompilerGLSL and CompilerMSL still contain a number of internal tests that
use is_depth_image() both for testing for a depth image, and for testing
whether compare operations are being used. I've left these as they are
for now, but these should be cleaned up at some point.

Add unit tests for fetch/sample depth images with color formats and no compare ops.
2021-11-08 15:59:45 -05:00
Hans-Kristian Arntzen
f1b411c9e8 GLSL: Deal with buffer_reference_align.
This is somewhat awkward to support, but the best effort we can do here
is to analyze various Load/Store opcodes and deduce the ideal overall
alignment based on this. This is not a 100% perfect solution, but should
be correct for any reasonable use case.

Also fix various nitpicks with BDA support while I'm at it.
2021-11-07 17:11:46 +01:00
Bill Hollings
76cb807c19 MSL: Fix type redirection when struct members are reordered to align with offsets.
Populate member_type_index_redirection as reverse lookup, not forward lookup.
Move use of member_type_index_redirection from CompilerMSL::to_member_reference()
to CompilerGLSL::access_chain_internal() to access all redirected type info,
not just name.
2021-10-28 10:16:34 -04:00
Hans-Kristian Arntzen
edf247fb1c MSL: Workaround compiler crashes when using threadgroup bool.
Promote to short instead and do simple casts on load/store instead.

Not 100% complete fix since structs can contain booleans, but this is
getting into pretty ridiculously complicated territory.
2021-10-25 10:55:11 +02:00
Erfan Ahmadi
43eecb2360 SPIRV-Cross contribution needed for INTEL_fragment_shader_ordering 2021-10-25 10:50:10 +02:00
Bill Hollings
974a0818b8 MSL: Support more usecases for unpacked vectors.
Additional usecases include array and vector indexing, variable declarations,
loop initializers, function return values, switch statement evaluations,
and various specialized MSL operations.

Ultimately, we might consider refactoring CompilerMSL::to_expression()
to always take into consideration possible unpacking behavior.

Refactor CompilerGLSL::to_enclosed_unpacked_expression()
for conciseness and consistency with similar functionality.
2021-10-21 16:11:33 -04:00
Bill Hollings
595eb0c21d Per spec, support undefined behavior for out-of-bounds swizzles.
Per spec, instead of throwing exception for out-of-bounds swizzles,
engage undefined behavior by defaulting to the .x swizzle.
2021-10-20 14:46:30 -04:00
Hans-Kristian Arntzen
6382f15470 Test behavior around OpSelect with matrices. 2021-10-13 16:08:29 +02:00
Hans-Kristian Arntzen
6071df5840 Fix wrong detection of trivial_mix_op.
Effectively, only the last component of the select was considered, need
to correctly early out if any case is hit.
2021-10-13 15:34:00 +02:00
Hans-Kristian Arntzen
f72bb3c6f5 Improve handling of INT_MIN/INT64_MIN literals.
We cannot naively convert these to decimal literals. C/C++ (and thus
MSL) has extremely awkward literal promotion rules.
2021-09-30 16:29:30 +02:00
Bill Hollings
35e92e6ffb MSL: Return fragment function value even when last SPIR-V Op is discard (OpKill).
Add test shader for new functionality.
Add legacy test reference shader for unrelated buffer-bitcast
test, that doesn't seem to have been added previously.
2021-09-12 16:28:21 -04:00
Bill Hollings
5fb1ca4f0d Add support for additional ops in OpSpecConstantOp.
MSL: Support op OpQuantizeToF16 in OpSpecConstantOp.
All: Support op OpSRem in OpSpecConstantOp.
2021-09-03 18:20:49 -04:00
Hans-Kristian Arntzen
b8f1e71907 GLSL: Emit GL_EXT_buffer_reference_uvec2 as required. 2021-09-02 13:17:13 +02:00
Hans-Kristian Arntzen
23c4480d8e Fix switch fallthrough case in some cases. 2021-08-31 17:24:09 +02:00
Hans-Kristian Arntzen
ac11a91792 GLSL: Emit precise for fp16/fp64 types as well. 2021-07-26 22:05:55 +02:00
Hans-Kristian Arntzen
18f3cd6810 GLSL: Ensure ray query object decls are flushed if allocated in Function.
glslang always emits Private variables, but DXC not so much.
2021-07-20 12:04:00 +02:00
Hans-Kristian Arntzen
5b227cc57c GLSL: Implement GL_EXT_ray_query. 2021-07-19 14:01:21 +02:00
Hans-Kristian Arntzen
1ae2b58f19
Merge pull request #1700 from pkasting/master
Fix -Wunreachable-code-aggressive.
2021-06-30 22:16:02 +02:00
Peter Kasting
7cdab07efe Fix -Wunreachable-code-aggressive.
Bug: chromium:1066980
2021-06-30 09:17:59 -07:00
Hans-Kristian Arntzen
206ee8f171 GLSL: Support pervertexNV in NV barycentric extension. 2021-06-30 16:27:46 +02:00
Jon Leech
f2a65545b8 Finish adding SPDX tags and setup a reuse checked in Github Actions CI 2021-06-29 11:03:52 +02:00
Hans-Kristian Arntzen
d6b29ab017 HLSL: Rewrite how block IO is emitted.
Emit block members directly in the IO structs and sort them.
Ensures we can get some kind of stable order between stages.

To complete the story, we'll need to be able to inject unused inputs /
builtins, or eliminate unused outputs (probably easiest solution).
2021-06-28 15:04:49 +02:00
Hans-Kristian Arntzen
9338996f3b
Merge pull request #1697 from KhronosGroup/fix-1693
GLSL: Emit num_views for OVR_multiview2.
2021-06-28 14:26:29 +02:00
Hans-Kristian Arntzen
d75666b170 GLSL: Emit num_views for OVR_multiview2. 2021-06-28 12:56:27 +02:00
Hans-Kristian Arntzen
8216e87f02 Handle SPIR-V 1.4 selection constructs.
Fix bug in to_trivial_mix_op, where we made a pre-1.4 assumption that
component count of selector is equal to value component count.
2021-06-28 12:23:44 +02:00