Commit Graph

15 Commits

Author SHA1 Message Date
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
e1a6729df7 Enable -Wshadow and silence warnings 2019-11-27 05:46:03 -03:00
ReinUsesLisp
22cc6f6c1b cmake: Always treat warnings as errors
Enable cast warnings in gcc and clang and always treat warnings as
errors.

GetWordCount now returns std::size_t for simplicity and the word count
is asserted and casted in WordCount (now called CalculateTotalWords.

Silence warnings.
2019-11-27 05:25:35 -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
60a856d266 Relicense to The BSD 3-clause license 2019-07-14 18:50:44 -03:00
Lioncash
f7c4b07a7e stream: Insert supplied string in one operation
Like the other overloads, we can insert the whole string within one
operation instead of doing a byte-by-byte append.

We only do byte-by-byte appending when padding is necessary.
2019-03-16 02:51:35 -03:00
Lioncash
59f795bd6d stream: Change std::string overload for Write to use a std::string_view
Allows various string types to be used with the overload without
constructing a std::string (such as const char* etc).
2019-03-16 02:51:35 -03:00
Lioncash
326c69896b stream: Get rid of undefined behavior
It's undefined behavior to cast down to any other type and dereference
that pointer unless:

1. It's similar (*extremely* vague definition at face value, see below
   for clarification)

2. The casted to type is either the signed/unsigned variant of the
   original type. (e.g. it's fine to cast an int* to an unsigned int*
   and vice-versa).

3. The casted to pointer type is either std::byte*, char*, or unsigned
   char*.

With regards to type similarity, two types (X and Y) are considered
"similar" if:

1. They're the same type (naturally)

2. They're both pointers and the pointed-to types are similar (basically
   1. but for pointers)

3. They're both pointers to members of the same class and the types of
   the pointed-to members are similar in type.

4. They're both arrays of the same size or both arrays of unknown size
   *and* the array element types are similar.

Plus, doing it this way doesn't do a byte-by-byte appending to the
underlying std::vector and instead allocates all the necessary memory up
front and slaps the elements at the end of it.
2019-03-14 21:44:37 -03:00
ReinUsesLisp
73595f4588 Change clang-format settings 2019-03-11 03:26:21 -03:00
ReinUsesLisp
f5944d61a6 Upgrade from LGPLv2.1 to LGPLv3 2018-11-16 04:10:10 -03:00
ReinUsesLisp
c0aaf8989e Remove tailing "_" in constructor arguments 2018-10-17 03:44:48 -03:00
ReinUsesLisp
0485e1877c Use some C++17 features 2018-10-03 00:32:45 -03:00
ReinUsesLisp
f68dbb20fc Fixup License header 2 -> 2.1 2018-08-26 23:28:39 -03:00
ReinUsesLisp
c0d61d32d4 Fixup License 2018-08-26 22:27:33 -03:00
ReinUsesLisp
34d215d3d8 Implement stuff 2018-08-25 20:16:37 -03:00