Commit graph

106 commits

Author SHA1 Message Date
ReinUsesLisp
84fab90024 Add OpFunctionParameter 2021-03-28 18:52:32 -03:00
ReinUsesLisp
0ef6e807ab Add DemoteToHelperInvocation support 2021-03-19 18:46:11 -03:00
ReinUsesLisp
4b1ff612c4 Add support for sparse texture instructions 2021-03-08 18:31:00 -03:00
ReinUsesLisp
f6a7130486 Add support for self-referencing phi nodes 2021-02-24 18:30:10 -03:00
ReinUsesLisp
f819ade0ef Add support for forward declarations 2021-02-14 22:45:31 -03:00
ReinUsesLisp
c374bfd9fd Add Phi support 2021-02-12 21:08:46 -03:00
ReinUsesLisp
cae2725cc0 Add overload for decorating with enums
Skip an explicit cast on the caller, allowing code like:
Decorate(some_op, spv::Decoration::BuiltIn, spv::BuiltIn::WorkgroupId)
2021-02-07 23:52:40 -03:00
comex
ab567491e1 Add support for OpGroupNonUniform{All,Any,AllEqual,Ballot}, and fix OpGroupNonUniformShuffleXor.
These Vulkan 1.1 operations can be used in place of
`OpSubgroup{All,Any,AllEqual,Ballot}KHR`, among other things.

For `OpGroupNonUniformShuffleXor`, which was already implemented, turns
out the scope argument needs to be encoded not as an immediate, but as
an id that points to a constant integer.
2020-11-26 17:20:01 -03:00
comex
13396c96ac Use requires clauses to better disambiguate variadic and non-variadic overloads
Suppose you try to call, say, `AddEntryPoint` with a `std::vector<Id>`
as the `interfaces` argument - something that yuzu does.  This can match
the non-variadic overload, since `std::vector<Id>` is implicitly
convertible to the argument type `std::span<const Id>`.  But it can also
match the variadic overload, and the compiler sees that as a 'better'
match because it doesn't require implicit conversion.  So it picks that
overload and promptly errors out trying to convert `std::vector<Id>` to
`Id`.

To make the compiler pick the right overload, you would have to
explicitly convert to `std::span<const Id>`, which is annoyingly
verbose.

To avoid this, add `requires` clauses to all variadic convenience
overloads, requiring each of the variadic arguments to be convertible to
the corresponding element type.  If you pass a vector/array/etc., this
rules out the variadic overload as a candidate, and the call goes
through with the non-variadic overload.

Also, use slightly different code to forward to the non-variadic
overloads, that works even if the arguments need to be converted.

Note: I used this in a WIP branch updating yuzu to the latest version of
sirit.

Note 2: I tried to run clang-format on this, but it mangled the requires
clauses pretty horribly, so I didn't accept its changes.  I googled it,
and apparently clang-format doesn't properly support concepts yet...
2020-11-25 20:02:04 -03:00
ReinUsesLisp
0b9ee36247 Stream SPIR-V instructions directly to a binary
Before this commit sirit generated a stream of tokens that would then be
inserted to the final SPIR-V binary. This design was carried from the
initial design of manually inserting opcodes into the code. Now that
all instructions but labels are inserted when their respective function
is called, the old design can be dropped in favor of generating a valid
stream of SPIR-V opcodes.

The API for variables is broken, but adopting the new one is trivial.
Instead of calling OpVariable and then adding a global or local
variable, OpVariable was removed and global or local variables are
generated when they are called.

Avoiding duplicates is now done with an std::unordered_set instead of
using a linear search jumping through vtables.
2020-08-01 01:50:01 -03:00
ReinUsesLisp
c4ea8f4b76 Upgrade to C++20 and use std::span 2020-07-29 05:46:50 -03:00
ReinUsesLisp
eefca56afd memory: Add OpImageTexelPointer 2020-06-02 02:13:37 -03:00
ReinUsesLisp
a62c5bbc10 barrier: Add OpControlBarrier 2020-05-15 02:54:06 -03:00
ReinUsesLisp
414fc4dbd2 arithmetic: Add IAddCarry 2020-04-25 21:54:10 -03:00
ReinUsesLisp
15bacd3b1b atomic: Add memory atomic instructions 2020-01-19 16:36:33 -03:00
ReinUsesLisp
9f4d057aa2 image: Remove assumed lod in image samples
This commits breaks the API. Depth image samples assumed a lod operand,
this made using Grad samples clumsy to use.
2019-12-15 18:23:59 -03:00
ReinUsesLisp
12f40a8032 Add OpMemoryBarrier 2019-12-09 21:44:36 -03:00
ReinUsesLisp
71b53b855a Add OpSubgroupBallotKHR and vote instructions 2019-11-10 21:15:45 -03:00
ReinUsesLisp
688d6d9799 Add OpSubgroupReadInvocationKHR 2019-11-03 00:32:35 -03:00
ReinUsesLisp
9b897c3541 Add OpGroupNonUniformShuffleXor 2019-11-02 19:39:41 -03:00
ReinUsesLisp
3067893923 Add EmitVertex and EndPrimitive 2019-11-01 17:28:32 -03:00
ReinUsesLisp
42248408a9 Remove Emit entry in favor of auto-emitting code
All instructions but OpVariable and OpLabel are automatically emitted.
These functions have to call AddLocalVariable/AddGlobalVariable or
AddLabel respectively.
2019-10-18 04:27:52 -03:00
ReinUsesLisp
8cf3d225db Assemble uint32_t instead of uint8_t
Vulkan receives SPIR-V modules with a uint32_t alignment. Returning
uint8_t forced users to invoke undefined behaviour (reinterpret_cast)
or copy.
2019-10-18 03:46:47 -03:00
ReinUsesLisp
d24685ebd3 Revert "operand: Implement operand hashing and use hashed set for declarations"
This reverts commit 1e665afa36.
2019-09-09 16:48:05 -03:00
ReinUsesLisp
58c5406436 Revert "Fix declarations hashing"
This reverts commit bb6a3421d2.
2019-09-09 16:47:58 -03:00
ReinUsesLisp
bb6a3421d2 Fix declarations hashing 2019-09-09 16:46:46 -03:00
ReinUsesLisp
ae7c664016 Add OpAny and OpAll 2019-09-09 16:46:36 -03:00
ReinUsesLisp
4a0c6e03e1 Add OpVectorExtractDynamic and OpVectorInsertDynamic 2019-09-09 15:42:47 -03:00
ReinUsesLisp
60a856d266 Relicense to The BSD 3-clause license 2019-07-14 18:50:44 -03:00
ReinUsesLisp
1e665afa36 operand: Implement operand hashing and use hashed set for declarations
Instead of manually searching each element in the declarations vector,
use an unordered_set to emplace new declarations avoiding repetition.
2019-06-08 05:23:15 -03:00
Lioncash
47d85b81a7 CMakeLists: Apply compilation flags to the sirit target
Previously this wasn't utilizing any of the compiler flags, meaning it
wasn't applying any of the specified warnings.

Since applying the warnings to the target, this uncovered a few warning
cases, such as shadowing class variables on MSVC, etc, which have been fixed.
2019-03-14 19:30:54 -03:00
Lioncash
6fd44e494c Pass std::string by value where applicable.
By taking the std::string by value in the constructor, this allows for
certain situations where copies can be elided entirely (when moving an
instance into the constructor)

e.g.

std::string var = ...

...

... = LiteralString(std::move(var)) // Or whatever other initialization
                                    // is done.

No copy will be done in this case, the move transfers it into the
constructor, and then the move within the initializer list transfers it
into the member variable.

tl;dr: This allows the calling code to potentially construct less
std::string instances by allowing moving into the parameters themselves.
2019-03-14 04:30:39 -03:00
Lioncash
59867b7907 sirit: Add missing reference argument specifier for OpLabel 2019-03-14 02:31:18 -04:00
ReinUsesLisp
1c06f8530e Remove Op prefix on Type instructions 2019-03-13 18:32:38 -03:00
ReinUsesLisp
3fa70013b8 Add missing instruction commentaries 2019-03-11 05:13:35 -03:00
ReinUsesLisp
4b1c1d1e38 Add ellipsis overloads for instructions ending in vectors 2019-03-11 04:38:09 -03:00
ReinUsesLisp
ee4ce61e62 Add name overload to OpLabel 2019-03-11 03:48:39 -03:00
ReinUsesLisp
73595f4588 Change clang-format settings 2019-03-11 03:26:21 -03:00
ReinUsesLisp
b23716087a Add OpExtension 2019-03-08 21:09:11 -03:00
ReinUsesLisp
2b0a59d890 Add OpSwitch 2019-01-05 23:58:43 -03:00
ReinUsesLisp
e7971b4451 Add OpExecutionMode 2018-12-04 21:30:32 -03:00
ReinUsesLisp
3641e1de45 Add OpKill 2018-12-02 22:57:55 -03:00
ReinUsesLisp
f5944d61a6 Upgrade from LGPLv2.1 to LGPLv3 2018-11-16 04:10:10 -03:00
ReinUsesLisp
174263d906
Merge pull request #5 from FernandoS27/image
Implemented Image Instructions
2018-11-13 20:06:13 -03:00
FernandoS27
0318449d65 Implemented Image Instructions 2018-11-13 19:04:43 -04:00
FernandoS27
a6c435dcb7 Implement main conversion instructions 2018-11-12 14:37:54 -04:00
FernandoS27
aa2eaab480 Implemented ALL the logical instructions 2018-11-11 21:14:59 -04:00
ReinUsesLisp
bdf538bd64
Merge pull request #3 from FernandoS27/bit
Implemented the rest of the bitwise operations
2018-11-11 21:06:01 -03:00
FernandoS27
26a40708d7 Implemented a bunch of glsl functions 2018-11-11 20:03:29 -04:00
FernandoS27
aa3d1adbbd Implemented the rest of the bitwise operations 2018-11-11 18:51:08 -04:00