Commit Graph

25 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
f7e98c39db Avoid detection of false loop variables.
If the loop variable candidate has a dominating block that lives in an
unrelated loop, we have to reject the loop variable candidate.
2022-07-22 14:08:21 +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
4704482bbc meta: Update copyright headers to 2021. 2021-01-14 16:07:49 +01:00
Hans-Kristian Arntzen
cf1e9e0643 Add MIT dual license for the SPIRV-Cross API. 2020-12-01 16:47:08 +01:00
Hans-Kristian Arntzen
f9818f0804 Update license headers to 2020. 2020-01-16 15:24:37 +01:00
Hans-Kristian Arntzen
333980ae91 Refactor into stronger types in public API.
Some fallout where internal functions are using stronger types.
Overkill to move everything over to strong types right now, but perhaps
move over to it slowly over time.
2019-09-06 12:29:47 +02:00
Hans-Kristian Arntzen
5d97dae1eb Move branchless analysis to CFG.
Traverse backwards instead, far more robust. Should elide basically all
redundant continue; statements now.
2019-08-27 10:19:19 +02:00
Hans-Kristian Arntzen
fc9fe4e480 Fix variable scope when an if or else block dominates a variable.
Just like loops, we need complicated hoisting again to make this work.
2019-07-03 11:18:50 +02:00
Hans-Kristian Arntzen
03d93abc1a Deal with case where a variable is dominated by inner part of a loop.
There is a risk that we try to preserve a loop variable through multiple
iterations, even though the dominating block is inside a loop.

Fix this by analyzing if a block starts off by writing to a variable. In
that case, there cannot be any preservation going on. If we don't, pretend the
loop header is reading the variable, which moves the variable to an
appropriate scope.
2019-06-06 11:11:44 +02:00
Hans-Kristian Arntzen
a489ba7fd1 Reduce pressure on global allocation.
- Replace ostringstream with custom implementation.
  ~30% performance uplift on vector-shuffle-oom test.
  Allocations are measurably reduced in Valgrind.

- Replace std::vector with SmallVector.
  Classic malloc optimization, small vectors are backed by inline data.
  ~ 7-8% gain on vector-shuffle-oom on GCC 8 on Linux.

- Use an object pool for IVariant type.
  We generally allocate a lot of SPIR* objects. We can amortize these
  allocations neatly by pooling them.

- ~15% overall uplift on ./test_shaders.py --iterations 10000 shaders/.
2019-04-09 15:09:44 +02:00
Hans-Kristian Arntzen
9b92e68d71 Add an option to override the namespace used for spirv_cross.
This is a pragmatic trick to avoid symbol collision where a project
links against SPIRV-Cross statically, while linking to other projects
which also use SPIRV-Cross statically. We can end up with very awkward
symbol collisions which can resolve themselves silently because
SPIRV-Cross is pulled in as necessary. To fix this, we must use
different symbols and embed two copies of SPIRV-Cross in this scenario,
now with different namespaces, which in turn leads to different symbols.
2019-03-29 10:29:44 +01:00
Hans-Kristian Arntzen
57be90321b Use hashmaps in CFG as well.
The arrays are incredibly sparse for the most part as we only need
entires per basic block.

For a small shader with ID bound of 8 million, we now have about 30x
uplift.
2019-01-10 14:35:34 +01:00
Hans-Kristian Arntzen
318c17cbb2 Nonfunctional: Update copyright headers for 2019. 2019-01-04 12:38:35 +01:00
Hans-Kristian Arntzen
382101bd05 Run format_all.sh. 2018-04-04 09:26:53 +02:00
Bill Hollings
1c94715350 Update copyright dates to 2018 in main files. 2018-01-31 17:08:43 -05:00
Hans-Kristian Arntzen
b3f6e3de8e Fix CFG::update_common_dominator.
The algorithm was too conservative causing lots of unnecessary
temporaries to be created.
2018-01-24 20:32:11 +01:00
Hans-Kristian Arntzen
f0c50a618d Fix parsing time explosion for huge shaders.
Need to prune already walked blocks.
2017-07-25 18:22:15 +02:00
Hans-Kristian Arntzen
bf5c07532c Run format_all.sh. 2017-03-25 16:28:44 +01:00
Hans-Kristian Arntzen
b2c2e6483b Analyze parameter preservation for functions.
This is kinda tricky, because if we only conditionally write to a
function parameter variable it is implicitly preserved in SPIR-V, so we must force
an in qualifier on the parameter to get the same behavior in GLSL.
2017-03-25 16:25:30 +01:00
Hans-Kristian Arntzen
18c37bcdab Update license headers for 2017. 2017-01-28 09:00:40 +01:00
Hans-Kristian Arntzen
4f07a32c29 Begin implementing for loop initializer propagation. 2016-12-15 17:44:47 +01:00
Hans-Kristian Arntzen
5ff11cc689 Handle more corner cases with the CFG traversal. 2016-11-18 16:45:11 +01:00
Hans-Kristian Arntzen
0c9683cd85 Distinguish between cross edges and back edges.
Handle the weird opcodes CopyMemory/CopyObject.
2016-11-18 09:59:54 +01:00
Hans-Kristian Arntzen
edbe867b74 Improve handling of dead blocks.
All tests pass now.
Still need to handle OpFunction, atomics, OpPhi, etc ...
2016-11-17 22:15:07 +01:00
Hans-Kristian Arntzen
dad4a34072 Start adding CFG analysis.
Not complete yet, but partly working ...
2016-11-17 16:58:05 +01:00