Commit Graph

2683 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
00189b19a5
Merge pull request #1188 from KhronosGroup/missing-reference-ue4
MSL: Add missing reference output.
2019-10-29 12:36:01 +01:00
Hans-Kristian Arntzen
cd94f0c37e
Merge pull request #1187 from KhronosGroup/fix-1186
Fix broken access tracking for OpFunctionCall results.
2019-10-29 12:16:09 +01:00
Hans-Kristian Arntzen
42e6ce073b MSL: Add missing reference output. 2019-10-29 11:17:38 +01:00
Hans-Kristian Arntzen
e2155053c5 Fix broken access tracking for OpFunctionCall results.
We were looking at args[1] after incrementing args array, not before,
which means we tracked garbage.
This is also an out-of-bounds hazard.
2019-10-29 11:13:39 +01:00
Hans-Kristian Arntzen
40cc0a00df MSL: Avoid some fallthrough warnings. 2019-10-28 15:20:38 +01:00
Hans-Kristian Arntzen
123fa906ec Merge branch 'ue4-merge' 2019-10-28 15:14:42 +01:00
Hans-Kristian Arntzen
39bd5f1834 Run format_all.sh. 2019-10-28 12:55:14 +01:00
Hans-Kristian Arntzen
1d5eba67f8 MSL: Remove hacky workaround for patch constant passing.
There was a hack to workaround a bug in DXC where control point -> patch
constant phase was passed in Function storage, but we have to use
Workgroup here. We will not support these kinds of hacks for invalid
SPIR-V, so hack the reference files to use the "proper" fix and remove
the hack for time being.
2019-10-28 12:52:28 +01:00
Hans-Kristian Arntzen
8f13a3f4b1 MSL: Remove workaround for passing constant arrays to functions.
Arrays are value-types now, so remove the old workaround.
2019-10-28 12:14:43 +01:00
Hans-Kristian Arntzen
32bd1329b6 Remove another dead reference file. 2019-10-28 11:51:31 +01:00
Hans-Kristian Arntzen
8670f7cbab Remove some more dead reference files. 2019-10-28 11:49:57 +01:00
Hans-Kristian Arntzen
b2c6362c4b Remove another dead reference file. 2019-10-28 11:33:09 +01:00
Hans-Kristian Arntzen
93ceead289 Remove dead reference file. 2019-10-28 11:31:04 +01:00
Hans-Kristian Arntzen
e1919744e9 Hack some constants in UE4 tests.
Need to make output 100% exact for MSVC and GCC libc testing, but they are 1 ULP
off when converting fp32 to string in some weird corner cases.
Roundtrip should be correct though, but that outside the scope of
SPIRV-Cross.
2019-10-28 11:20:41 +01:00
Hans-Kristian Arntzen
648dfa5070 MSL: Ensure stable output for access chain CFG workarounds.
We had output dependent on complex_continue being set, but setting that
flag was dependent on unordered_set declaration order. Make it invariant
to ordering and change the implementation so it knows about the new
temporary hoisting for access chains.
2019-10-28 10:57:51 +01:00
Hans-Kristian Arntzen
ac8d335480 MSL: Fix integer cast. 2019-10-26 20:30:24 +02:00
Hans-Kristian Arntzen
fa011f8547 MSL: Declare arrays with proper type wrapper.
Need to construct with value type spvUnsafeArray<T, N>({ elem0, elem1 })
to make array initialization work in complex scenarios.
2019-10-26 17:57:34 +02:00
Hans-Kristian Arntzen
2745959646 MSL: Deal with chained access chains for tessellation IO variables.
Need to specially deal with this since we might have to split up access
chain and deal with indexing into IB struct.
2019-10-26 17:26:56 +02:00
Hans-Kristian Arntzen
e1acbd3dcf MSL: Declare struct type explicitly.
Disambiguates initializer list.
2019-10-26 16:21:46 +02:00
Hans-Kristian Arntzen
1fc3347873 MSL: Fix array of array declaration.
Arrays-of-arrays were declared in wrong order.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
27d6d45671 MSL: Rewrite tessellation_access_chain.
To support loading array of array properly in tessellation, we need a
rewrite of how tessellation access chains are handled.

The major change is to remove the implicit unflatten step inside
access_chain which does not take into account the case where you load
directly from a control point array variable.

We defer unflatten step until OpLoad time instead.
This fixes cases where we load array of {array,matrix,struct}.

Removes the hacky path for MSL access chain index workaround.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
bac2c34590 MSL: Slight cleanup in emit_tessellation_access_chain.
Hoist out some conditionals and make it clear that we go into this path
if strip_array is used when declaring resources, i.e. there was no
explicit unflatten step.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
d0953f6e4c MSL: Do not declare variables which will not be unflattened.
Non-patch arrays of IO variables in tesc/tese have their array index
stripped, and access chains are specially handled, we shouldn't attempt
to create "normal" arrays of these.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
028ffc26dd MSL: Report tess input array failures more accurately.
We cannot dynamically index into an array of inputs at the moment. Do
not fail with opaque "bad cast" error.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
f2eb940536 MSL: Revert hack with kBufferSizeBufferBinding 2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
62c4eaa7bf MSL: Remove stale code for TextureSwizzle.
Was probably added mistakenly during an old rebase.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
3f569ed5ec GLSL: Minor nit, check flushed_phi_variables with count(). 2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
9d18c82364 Clean up call to builtin_translates_to_nonarray.
get_decoration is better than poking in ir.meta manually.
2019-10-26 16:10:12 +02:00
Hans-Kristian Arntzen
3b5c4c7316 Implement constant empty struct correctly on all backends.
MSL actually supports empty structs, so enable that path as well.
2019-10-26 16:10:11 +02:00
Hans-Kristian Arntzen
8066d13599 MSL: Rewrite propagated depth comparison state handling.
Far cleaner, and more correct to run the traversal twice.
Fixes a case where we propagate depth state through multiple functions.
2019-10-26 16:10:11 +02:00
Hans-Kristian Arntzen
830e24c4ba MSL: Do read-only lookups of access_chain_children. 2019-10-26 16:10:11 +02:00
Hans-Kristian Arntzen
efc978177e MSL: Remove stray allow_id_rewrite().
Unclear why it's there, and tests do not break when removed.
2019-10-26 16:10:11 +02:00
Hans-Kristian Arntzen
2767257adc MSL: Do not declare array of UBO/SSBO as spvUnsafeArray<T>.
There is no need for these to be copied, and cuts down on template
stamping bloat.
2019-10-26 16:10:08 +02:00
Hans-Kristian Arntzen
b10f5d48c9
Merge pull request #1184 from billhollings/master
MSL: Support option for treating 1D textures as 2D textures of height 1.
2019-10-25 10:17:24 +02:00
Bill Hollings
53d0dd6741 MSL: Support option for treating 1D textures as 2D textures of height 1.
Fixes from feedback.

Change vertical sampling of 1D texture from 0.0 to 0.5 to avoid edge conditions.
2019-10-24 14:48:21 -04:00
Bill Hollings
4b5c6c188c MSL: Support option for treating 1D textures as 2D textures of height 1.
Add CompilerMSL::Options::texture_1D_as_2D.

Metal imposes significant restrictions on 1D textures, including not being
renderable, clearable, or permitting mipmaps. This option allows SPIR-V 1D
textures to be treated as 2D textures to permit this additional behaviour.
App must of course supply the textures to Metal as 2D textures.
2019-10-24 12:31:20 -04:00
Hans-Kristian Arntzen
a82ecbeba9 MSL: Enable proper value types for return and value-passing of arrays.
Now that we have spvUnsafeArray<T> there is no need to deal with these
special purpose cases.
2019-10-24 13:03:38 +02:00
Hans-Kristian Arntzen
4ac12594c9 MSL: Be a little clearer how needs_base_vertex_idx is implemented.
There is an implicit tristate with {-1, 0, +1} values, but it was not
obvious how this was supposed to work before studying the implementation,
so refactor into a tristate enum class.
2019-10-24 12:41:37 +02:00
Hans-Kristian Arntzen
6ca3fe22c3 MSL: Remove some dead code w.r.t. vertex/instance_idx. 2019-10-24 12:36:01 +02:00
Hans-Kristian Arntzen
d1479f871a MSL: Do not generate UnsafeArray<> for any array inside buffer objects.
This avoids a lot of huge code changes.
Arrays generally cannot be copied in and out of buffers, at least no
compiler frontend seems to do it.

Also avoids a lot of issues surrounding packed vectors and matrices.
2019-10-24 12:22:30 +02:00
Hans-Kristian Arntzen
b433836b08 MSL: Simplify framebuffer fetch implementation. 2019-10-24 11:48:29 +02:00
Hans-Kristian Arntzen
2ca725a78d MSL: Fall back to GLSL path for non-invariant matrix multiply as well. 2019-10-24 11:37:22 +02:00
Hans-Kristian Arntzen
ba4b31e46f MSL: Fall back to GLSL path for non-invariant FP implementation. 2019-10-24 11:34:52 +02:00
Hans-Kristian Arntzen
6edbf0c9e9 MSL: Minor cleanups for texture atomic emulation.
Storing pointers to internal objects is generally not done, IDs are
preferred.
2019-10-24 11:30:20 +02:00
Hans-Kristian Arntzen
43842cefb3 MSL: Cleanup decoration forwarding for SampleMask.
Don't want to create Meta instances unless we have to.
2019-10-24 11:15:35 +02:00
Hans-Kristian Arntzen
db55d474f9 MSL: Do not declare complex composite array in main for non-inlined.
Need to consider that complex composite arrays may be used in leaf
functions, and avoid the MSL library link fix unless everything is
nicely inlined.
2019-10-24 11:12:01 +02:00
Hans-Kristian Arntzen
8ad9584c2e Fix formatting in main.cpp. 2019-10-24 10:56:36 +02:00
Hans-Kristian Arntzen
b1fd6c1990 Add new UE4 folders to CMake testing as well. 2019-10-24 10:54:32 +02:00
Lukas Hermanns
c236ca4572 Moved all UE4 test shaders into 'shaders-ue4/' folder. 2019-10-23 17:39:05 -04:00
Lukas Hermanns
b0d616aa6d Removed 'argument_buffer_offset' and fixed packed matrix Metal output. 2019-10-23 16:28:32 -04:00