Commit Graph

3122 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
7c3cb0b12c
Merge pull request #1810 from billhollings/early-frag-tests-depth-out
MSL: Don't output depth and stencil values with explicit early fragment tests.
2021-11-13 16:25:51 +01:00
Bill Hollings
248e9ae9ed MSL: Don't output depth and stencil values with explicit early fragment tests.
Fragment shaders that require explicit early fragment tests are incompatible
with specifying depth and stencil values within the shader. If explicit early
fragment tests is specified, remove the depth and stencil outputs from the
output structure, and replace them with dummy local variables.

Add CompilerMSL:uses_explicit_early_fragment_test() function to consolidate
testing for whether early fragment tests are required.

Add two unit tests for depth-out with, and without, early fragment tests.
2021-11-12 14:17:00 -05:00
Hans-Kristian Arntzen
401296d3b8
Merge pull request #1808 from billhollings/depth-img-vs-depth-cmp
Separate (partially) the tracking of depth images from depth compare ops.
2021-11-12 10:41:28 +01: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
2e0fb3a778
Merge pull request #1807 from KhronosGroup/fix-1801
GLSL: Deal with buffer_reference_align.
2021-11-07 18:15:21 +01: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
Hans-Kristian Arntzen
1adc53b107
Merge pull request #1806 from KhronosGroup/fix-1777
CFG: Handle degenerate selection constructs.
2021-11-07 14:10:48 +01:00
Hans-Kristian Arntzen
21a15b90e5
Merge pull request #1804 from KhronosGroup/fix-1759
MSL: Handle non-thread storage class in Modf/Frexp pointer versions.
2021-11-07 13:36:32 +01:00
Hans-Kristian Arntzen
2714f5410c CFG: Handle degenerate selection constructs.
Apparently, it's legal to use a selection construct where both paths
branch to same location, but a different merge point is used.
This breaks many assumptions the variable scope analyzer makes.

The only logical way to generate code for this scenario is to treat the
selection construct as a trivial switch construct with only a default
case.
2021-11-07 13:32:29 +01:00
Hans-Kristian Arntzen
e40d19bdbf MSL: Handle non-thread storage class in Modf/Frexp pointer versions. 2021-11-07 12:51:15 +01:00
Hans-Kristian Arntzen
f1d4aff85e
Merge pull request #1805 from KhronosGroup/fix-1776
Handle Modf/Frexp in more cases.
2021-11-07 12:36:42 +01:00
Hans-Kristian Arntzen
2c53d30664
Merge pull request #1803 from KhronosGroup/fix-1802
Correctly reflect declared buffer size for out of order members.
2021-11-07 12:35:03 +01:00
Hans-Kristian Arntzen
4561ecddbd Handle Modf/Frexp in more cases.
Consider it a write to a variable, similar to OpStore.
2021-11-07 11:36:44 +01:00
Hans-Kristian Arntzen
d295c2a046
Merge pull request #1800 from EddeDev/master
Fixed potential compilation error in spirv_cross_containers.hpp
2021-11-07 10:36:05 +01:00
Hans-Kristian Arntzen
849978653a
Merge pull request #1798 from billhollings/tess-output-clip
MSL: Correctly emit user(clip/cullN) for clip/cull builtins in tess output struct.
2021-11-07 10:35:24 +01:00
Hans-Kristian Arntzen
05e8e5a953 Correctly reflect declared buffer size for out of order members.
Need to deduce size based on member with highest offset, not highest
index.
2021-11-07 10:08:17 +01:00
Edvin Pettersson
4dcf64a99b
Fixed potential compilation error in spirv_cross_containers.hpp 2021-11-05 01:39:35 +01:00
Bill Hollings
4ebd56bf9e MSL: Correctly emit user(clip/cullN) for clip/cull builtins in tess output struct.
Only emit user(locnN) for tess builtin input variables, and allow output builtin
to emit user(clip/cullN). Previously, output builtin would emit location if
input builtin also existed.
2021-11-03 00:03:26 -04:00
Hans-Kristian Arntzen
04293e03fd
Merge pull request #1797 from KhronosGroup/clone-protocol
Always use https protocol when cloning external test deps.
2021-11-02 18:00:59 +01:00
Hans-Kristian Arntzen
0d03516382 Always use https protocol when cloning external test deps.
git:// is deprecated now and is starting to fail.
2021-11-02 17:36:22 +01:00
Hans-Kristian Arntzen
061397e32e
Merge pull request #1792 from billhollings/uniform-struct-packing-nested
MSL: Remove over-zealous check for struct packing compatibility.
2021-11-01 13:02:16 +01:00
Bill Hollings
be812c45e5 MSL: Remove over-zealous check for struct packing compatibility.
Previous test for SPIRVCrossDecorationPhysicalTypePacked on parent struct
when unpacking member struct was too restrictive, and not needed as long
as padding compensates.
2021-10-28 19:36:32 -04:00
Hans-Kristian Arntzen
66adba17a8
Merge pull request #1791 from billhollings/msl-out-of-order-struct-offsets
MSL: Fix type redirection when struct members are reordered to align with offsets.
2021-10-28 18:03:54 +02: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
29632959d2
Merge pull request #1787 from KhronosGroup/fix-1786
MSL: Workaround compiler crashes when using threadgroup bool.
2021-10-25 12:30:01 +02: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
Hans-Kristian Arntzen
94dea2507e
Merge pull request #1769 from audulus/spm2
Add support for SPM without modifying directory structure
2021-10-21 23:49:28 +02:00
Taylor Holliday
f5219f47c3 Add Package.swift.
This makes it really easy to add SPIRV-Cross to an Xcode project.
2021-10-21 14:06:04 -07:00
Hans-Kristian Arntzen
2a56c2bc04
Merge pull request #1783 from billhollings/more-unpacked-vectors
MSL: Support more usecases for unpacked vectors.
2021-10-21 23:00:14 +02:00
Hans-Kristian Arntzen
ab640bc3d3
Merge pull request #1782 from KhronosGroup/fix-1781
MSL: Fix some build regressions
2021-10-21 22:39:32 +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
Hans-Kristian Arntzen
2b5e17eca5 MSL: Never used templated array for RayQuery objects.
Not supported and compiler derps out.
2021-10-21 22:02:01 +02:00
Hans-Kristian Arntzen
bc338710e1 MSL: Remove some redundant breaks. 2021-10-21 22:01:50 +02:00
Hans-Kristian Arntzen
5afb3d313f MSL: Fix some trivial bugs not caught by CI when adding ray query. 2021-10-21 21:53:41 +02:00
Hans-Kristian Arntzen
345a7d171c
Merge pull request #1773 from congyue1977/master
Support Metal 2.4 Intersection Query, Implement GL_EXT_ray_query.
2021-10-21 15:56:15 +02:00
丛越
2895a43274 Fix unsupported exceptions for ConvertUToAccelerationStructure & BindingTableRecordOffset. 2021-10-21 19:01:38 +08:00
丛越
d52ec1e196 Fix all requested changes, test_shaders.py supports compiling MSL 2.4 shaders, and the Intersection Query currently only supports MSL 2.4 on the iOS platform. 2021-10-21 17:46:45 +08:00
Hans-Kristian Arntzen
6d13c99273
Merge pull request #1780 from billhollings/out-of-bounds-swizzle-fix
Per spec, support undefined behavior for out-of-bounds swizzles.
2021-10-20 22:24:18 +02: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
丛越
597f29d09d Support Metal 2.4 Intersection Query, Implement GL_EXT_ray_query. 2021-10-19 18:45:10 +08:00
Hans-Kristian Arntzen
e4243b898c
Merge pull request #1766 from KhronosGroup/fix-1765
Fix some silly bugs in trivial mix op detection.
2021-10-13 16:46:53 +02: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
97a438d214
Merge pull request #1757 from KhronosGroup/fix-1754
Improve handling of INT_MIN/INT64_MIN literals.
2021-09-30 17:04:30 +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
Hans-Kristian Arntzen
457c00bd07
Merge pull request #1756 from KhronosGroup/fix-1753
HLSL: Fix NumWorkgroups for SPIR-V 1.4+
2021-09-30 16:22:51 +02:00
Hans-Kristian Arntzen
91c25e8473
Merge pull request #1755 from KhronosGroup/fix-1751
MSVC: Workaround crtdbg macroing free().
2021-09-30 16:22:34 +02:00
Hans-Kristian Arntzen
9b2a8c7622 HLSL: Ensure synthetic NumWorkgroups variable is considered active.
In SPIR-V 1.4+, active global variables must be marked as such.
2021-09-30 14:39:42 +02:00
Hans-Kristian Arntzen
bb04156d3c CLI/HLSL: Don't set explicit binding for synthesized NumWorkgroups CBV. 2021-09-30 14:30:49 +02:00