Commit Graph

2126 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
07bb1a53e0
Merge pull request #1089 from KhronosGroup/msl-packing-refactor
MSL: Refactor buffer packing logic from ground up.
2019-07-24 15:35:00 +02:00
Hans-Kristian Arntzen
d90eeddcf1 Fix some typos in comments. 2019-07-24 12:14:19 +02:00
Hans-Kristian Arntzen
c62503bca7 Do not attempt to pack types which are already scalar. 2019-07-24 11:52:28 +02:00
Hans-Kristian Arntzen
4bc8729c0e HLSL query lod cleanups. 2019-07-24 11:34:28 +02:00
Hans-Kristian Arntzen
461f1506e7 Do not eagerly invalidate all active variables on a branch.
This is not necessary, as we must emit an invalidating store before we
potentially consume an invalid expression. In fact, we're a bit
conservative here in this case for example:

int tmp = variable;
if (...)
{
    variable = 10;
}
else
{
    // Consuming tmp here is fine, but it was
    // invalidated while emitting other branch.
    // Technically, we need to study if there is an invalidating store
    // in the CFG between the loading block and this block, and the other
    // branch will not be a part of that analysis.
    int tmp2 = tmp * tmp;
}

Fixing this case means complex CFG traversal *everywhere*, and it feels like overkill.

Fixing this exposed a bug with access chains, so fix a bug where expression dependencies were not
inherited properly in access chains. Access chains are now considered forwarded if there
is at least one dependency which is also forwarded.
2019-07-24 11:17:30 +02:00
Hans-Kristian Arntzen
18bcc9b790 Do not disable temporary forwarding when we suppress usage tracking.
This subtle bug removed any expression validation for trivially swizzled
variables. Make usage suppression a more explicit concept rather than
just hacking off forwarded_temporaries.

There is some fallout here with loop generation since our expression
invalidation is currently a bit too naive to handle loops properly.
The forwarding bug masked this problem until now.

If part of the loop condition is also used in the body, we end up
reading an invalid expression, which in turn forces a temporary to be
generated in the condition block, not good. We'll need to be smarter
here ...
2019-07-23 19:18:44 +02:00
Hans-Kristian Arntzen
8ba0507a6d Add another test for unpacking without load forwarding. 2019-07-23 17:14:59 +02:00
Hans-Kristian Arntzen
1ece67a050 Look at pointee type when unpacking expressions.
We might be unpacking in OpLoad, so don't want any pointer types from
access chains creeping in.
2019-07-23 17:07:15 +02:00
Hans-Kristian Arntzen
646e04294a Fix some warnings when building in MoltenVK. 2019-07-23 16:39:13 +02:00
Hans-Kristian Arntzen
ebe109d91d Deal correctly with non-forwarded packed loads.
Need to unpack the expression if we're not forwarding.
2019-07-23 16:25:19 +02:00
Hans-Kristian Arntzen
79f533b662 Test CompositeInsert/Extract/VectorShuffle on packed vectors. 2019-07-23 15:44:35 +02:00
Hans-Kristian Arntzen
5582145549 Add test for array of scalar struct. 2019-07-23 15:30:03 +02:00
Hans-Kristian Arntzen
5c1cb7accf Recursively pack struct types when we find scalar packed structs. 2019-07-23 15:24:53 +02:00
Hans-Kristian Arntzen
3fa2b14634 Run format_all.sh. 2019-07-23 12:23:41 +02:00
Hans-Kristian Arntzen
ef1fa71bba Unpack vector expression in Matrix-Vector multiplies. 2019-07-23 12:22:40 +02:00
Hans-Kristian Arntzen
0f10601f27 Test matrix multiplies in more complex scenarios. 2019-07-23 12:12:24 +02:00
Hans-Kristian Arntzen
978253c804 Test implicit packing of struct members. 2019-07-23 12:04:15 +02:00
Hans-Kristian Arntzen
46e757b278 GLSL/HLSL: Verify member alignment for explicit offset as well. 2019-07-23 11:53:33 +02:00
Hans-Kristian Arntzen
fc741596d4 Add tests for struct padding and self-alignment. 2019-07-23 11:46:34 +02:00
Hans-Kristian Arntzen
7277c7ac46 Use to_unpacked_row_major_expression to unify row-major in MSL/GLSL. 2019-07-23 11:36:54 +02:00
Hans-Kristian Arntzen
47a18b9f1b Simplify row-major matrix/vector multiplies. 2019-07-23 10:56:57 +02:00
Hans-Kristian Arntzen
d584d833fa Test array of std140 vectors. 2019-07-23 10:38:32 +02:00
Hans-Kristian Arntzen
6224199c76 Add struct size padding tests. 2019-07-23 10:30:37 +02:00
Hans-Kristian Arntzen
82c819ee6c Add test for CompositeExtract from row-major loaded vector. 2019-07-22 16:32:22 +02:00
Hans-Kristian Arntzen
d7a5303cf2 Add test for split access chain into row-major matrix. 2019-07-22 16:28:05 +02:00
Hans-Kristian Arntzen
2172b19be2 Remove obsolete matrix workaround code. 2019-07-22 16:27:47 +02:00
Hans-Kristian Arntzen
609d087f8f Only transpose unpacked expressions. 2019-07-22 16:06:09 +02:00
Hans-Kristian Arntzen
6057ffcbb1 Deal correctly with complete stores to row_major matrices. 2019-07-22 15:49:17 +02:00
Hans-Kristian Arntzen
19f5cd3e90 Declare correct matrix type when unpacking. 2019-07-22 13:25:45 +02:00
Hans-Kristian Arntzen
f2d6a77c95 Don't forget to register a write to LHS expression in certain case. 2019-07-22 13:06:30 +02:00
Hans-Kristian Arntzen
745a2f7b0e Deal with swizzled stores to std140 matrices. 2019-07-22 13:05:23 +02:00
Hans-Kristian Arntzen
180a6b38c5 Fix some row-major column store cases. 2019-07-22 12:56:14 +02:00
Hans-Kristian Arntzen
4ab2829cf6 Fix more stray parens. 2019-07-22 12:13:07 +02:00
Hans-Kristian Arntzen
d6004bfc97 Fixup stray parent in output. 2019-07-22 12:08:56 +02:00
Hans-Kristian Arntzen
14afb968dd Correctly unpack row-major matrices when storing to LHS. 2019-07-22 12:03:12 +02:00
Hans-Kristian Arntzen
172185016f MSL: Add std140 and scalar matrix layouts. 2019-07-22 11:30:03 +02:00
Hans-Kristian Arntzen
6471236652 MSL: Add std430 matrix access test. 2019-07-22 11:23:06 +02:00
Hans-Kristian Arntzen
249f8e5180 MSL: Support storing to row-major column.
Defer transposes to actual Load or Store.
2019-07-22 11:13:44 +02:00
Hans-Kristian Arntzen
be2fccd837 Tests run clean. 2019-07-22 10:23:39 +02:00
Hans-Kristian Arntzen
6c1f97b4a9 Fix unpacking of packed but not remapped types on load. 2019-07-19 14:50:35 +02:00
Hans-Kristian Arntzen
b66a53a979 Traverse correct types when checking scalar layout. 2019-07-19 14:43:42 +02:00
Hans-Kristian Arntzen
e90d816cdd Deal with scalar layout of entire structs.
Mark all candidate struct types.
2019-07-19 14:18:14 +02:00
Hans-Kristian Arntzen
12c5020854 Pass down row-major state to unpacking functions. 2019-07-19 13:03:08 +02:00
Hans-Kristian Arntzen
27b75c2c5a Deal with all forms of matrix writes ... 2019-07-19 12:53:10 +02:00
Hans-Kristian Arntzen
f6251e4699 Can deal with std140 matrices now.
Refactor is coming together.
2019-07-19 11:21:02 +02:00
Hans-Kristian Arntzen
dd7ebaf9f7 Start considering how to emit physical type ID. 2019-07-19 10:06:19 +02:00
Hans-Kristian Arntzen
b09b8d3fa9 Deal more cleanly with matrices and row-major. 2019-07-19 10:06:19 +02:00
Hans-Kristian Arntzen
c160d5227f Reintroduce struct_member_* MSL queries.
Need to remap to physical type + packed qualifier, and this is handy to
do in a helper function.
2019-07-19 10:06:19 +02:00
Hans-Kristian Arntzen
a86308bce1 MSL: Begin rewrite of buffer packing logic. 2019-07-19 10:06:19 +02:00
Hans-Kristian Arntzen
98d8bcd64b
Merge pull request #1087 from cdavis5e/demote-to-helper
Support the SPV_EXT_demote_to_helper_invocation extension.
2019-07-19 10:05:53 +02:00