Commit Graph

84 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
c27e1efbf1 HLSL: Add option to always treat SSBO as UAV, even with readonly.
This can make codegen more predictable since ByteAddressBuffer is SRV
and not UAV.
2020-03-04 16:42:31 +01:00
Hans-Kristian Arntzen
01968c4486 Add option to disable storage image qualifier deduction. 2020-03-04 16:42:31 +01:00
Hans-Kristian Arntzen
16796e92be MSL: Add C API for force native arrays. 2020-02-24 13:51:08 +01:00
Chip Davis
fedbc35315 MSL: Support inline uniform blocks in argument buffers.
Here, the inline uniform block is explicit: we instantiate the buffer
block itself in the argument buffer, instead of a pointer to the buffer.
I just hope this will work with the `MTLArgumentDescriptor` API...

Note that Metal recursively assigns individual members of embedded
structs IDs. This means for automatic assignment that we have to
calculate the binding stride for a given buffer block. For MoltenVK,
we'll simply increment the ID by the size of the inline uniform block.
Then the later IDs will never conflict with the inline uniform block. We
can get away with this because Metal doesn't require that IDs be
contiguous, only monotonically increasing.
2020-01-24 18:51:24 -06:00
Hans-Kristian Arntzen
f9818f0804 Update license headers to 2020. 2020-01-16 15:24:37 +01:00
Hans-Kristian Arntzen
c3bd136df1 MSL: Add support for force-activating IAB resources.
Important for ABI compatibility on MSL in certain cases.
2020-01-16 11:12:06 +01:00
Hans-Kristian Arntzen
cc153f8d7f HLSL: Add a resource remapping API similar to MSL.
Allows more flexibility of how resources are assigned without having to
remap decorations.
2020-01-09 12:41:06 +01:00
Hans-Kristian Arntzen
b9e5fe01b0 HLSL: Add support to remove register() bindings.
Sometimes it's useful to get automatic binding assignment from the D3D
compiler instead.
2019-11-11 11:23:21 +01:00
Hans-Kristian Arntzen
e8ed10d445 Add spvc_type_get_base_type_id.
Wraps SPIRType::self which is necessary for advanced reflection.
2019-11-04 10:53:09 +01:00
Hans-Kristian Arntzen
e9ad6398de C API: Add missing boolean options. 2019-11-04 10:42:20 +01:00
Hans-Kristian Arntzen
4bb673a626 MSL: Add opt-in support for huge IABs.
If there are enough members in an IAB, we cannot use the constant
address space as MSL compiler complains about there being too many
members. Support emitting the device address space instead.
2019-10-14 16:20:34 +02:00
Hans-Kristian Arntzen
afa5480210 Add dynamic offsets to C API. 2019-09-06 10:17:31 +02:00
Chip Davis
39dce88d3b MSL: Add support for sampler Y'CbCr conversion.
This change introduces functions and in one case, a class, to support
the `VK_KHR_sampler_ycbcr_conversion` extension. Except in the case of
GBGR8 and BGRG8 formats, for which Metal natively supports implicit
chroma reconstruction, we're on our own here. We have to do everything
ourselves. Much of the complexity comes from the need to support
multiple planes, which must now be passed to functions that use the
corresponding combined image-samplers. The rest is from the actual
Y'CbCr conversion itself, which requires additional post-processing of
the sample retrieved from the image.

Passing sampled images to a function was a particular problem. To
support this, I've added a new class which is emitted to MSL shaders
that pass sampled images with Y'CbCr conversions attached around. It
can handle sampled images with or without Y'CbCr conversion. This is an
awful abomination that should not exist, but I'm worried that there's
some shader out there which does this. This support requires Metal 2.0
to work properly, because it uses default-constructed texture objects,
which were only added in MSL 2. I'm not even going to get into arrays of
combined image-samplers--that's a whole other can of worms.  They are
deliberately unsupported in this change.

I've taken the liberty of refactoring the support for texture swizzling
while I'm at it. It's now treated as a post-processing step similar to
Y'CbCr conversion. I'd like to think this is cleaner than having
everything in `to_function_name()`/`to_function_args()`. It still looks
really hairy, though. I did, however, get rid of the explicit type
arguments to `spvGatherSwizzle()`/`spvGatherCompareSwizzle()`.

Update the C API. In addition to supporting this new functionality, add
some compiler options that I added in previous changes, but for which I
neglected to update the C API.
2019-09-01 18:35:53 -05:00
Hans-Kristian Arntzen
656d129c00 Add C API for get_declared_struct_member_size. 2019-06-26 19:12:32 +02:00
Hans-Kristian Arntzen
048f2380f3 MSL: Support custom bindings for argument buffer itself. 2019-06-24 11:10:20 +02:00
Hans-Kristian Arntzen
3a4a9acac9 MSL: Add C API for querying automatic resource bindings. 2019-06-21 13:19:59 +02:00
Hans-Kristian Arntzen
30bb197a5d MSL: Support remapping constexpr samplers by set/binding.
Older API was oriented around IDs which are not available unless you're
doing full reflection, which is awkward for certain use cases which know
their set/bindings up front.

Optimize resource bindings to be hashmap rather than doing linear seeks
all the time.
2019-06-10 15:41:36 +02:00
Hans-Kristian Arntzen
65af09d2d1 Support emitting OpLine directive.
Facilitates easier mapping from source language to cross-compiled output
in tooling.
2019-05-28 13:44:24 +02:00
Hans-Kristian Arntzen
7b9e0fb428 MSL: Implement OpArrayLength.
This gets rather complicated because MSL does not support OpArrayLength
natively. We need to pass down a buffer which contains buffer sizes, and
we compute the array length on-demand.

Support both discrete descriptors as well as argument buffers.
2019-05-27 16:13:09 +02:00
Hans-Kristian Arntzen
0b9a884f3f Add Git/timestamp --revision support. 2019-05-24 15:24:41 +02:00
Hans-Kristian Arntzen
09c01c2d45 Fix formatting, update C ABI version.
There are some issues with clang-format which require auto-formatting to
be disabled for this file.
2019-05-18 10:47:02 +02:00
Hans-Kristian Arntzen
e04bbd0948 Merge git://github.com/stuartcarnie/SPIRV-Cross 2019-05-18 10:37:38 +02:00
Hans-Kristian Arntzen
eaf7afed97 MSL: Support argument buffers and image swizzling.
Change aux buffer to swizzle buffer.
There is no good reason to expand the aux buffer, so name it
appropriately.

Make the code cleaner by emitting a straight pointer to uint rather than
a dummy struct which only contains a single unsized array member anyways.

This will also end up being very similar to how we implement swizzle
buffers for argument buffers.

Do not use implied binding if it overflows int32_t.
2019-05-18 10:30:06 +02:00
Stuart Carnie
72a8c9f35a
Add get_member_name and active_buffer_ranges to C APIs 2019-05-17 17:45:12 -07:00
Laszlo Agocs
7bc31491be GLSL: Add option to disable buffer blocks regardless of version 2019-05-13 21:29:06 +02:00
Hans-Kristian Arntzen
ae3783c725 Add texture_buffer_native option to C API. 2019-04-23 12:25:42 +02:00
Hans-Kristian Arntzen
6b69fe65f8 Make build system more modular.
Allow user to disable individual backends.
Disallow this for CLI builds for now, but should be useful for
library-only builds, and particularly for C API.
2019-03-27 13:21:11 +01:00
Hans-Kristian Arntzen
88ce958a51 Add ray-tracing reflection to main.cpp and C API. 2019-03-27 10:21:30 +01:00
Hans-Kristian Arntzen
0474848d4a GLSL: Support emitting push constant block as a plain UBO. 2019-03-19 10:58:52 +01:00
Hans-Kristian Arntzen
e2aadf8995 Rename "push descriptor set" to "discrete descriptor set".
Check for case where iOS doesn't support writable argument buffer
textures.
2019-03-15 21:53:21 +01:00
Hans-Kristian Arntzen
b3380ec9dd MSL: Support VK_KHR_push_descriptor.
If we have argument buffers, we also need to support using plain
descriptor sets for certain cases where API wants it.
2019-03-15 14:08:47 +01:00
Hans-Kristian Arntzen
e47a77d596 MSL: Implement Metal 2.0 indirect argument buffers. 2019-03-15 11:01:27 +01:00
Hans-Kristian Arntzen
e74c21a39b Review fixups. 2019-03-04 10:08:31 +01:00
Hans-Kristian Arntzen
9bbdccddb7 Add a stable C API for SPIRV-Cross.
This adds a new C API for SPIRV-Cross which is intended to be stable,
both API and ABI wise.

The C++ API has been refactored a bit to make the C wrapper easier and
cleaner to write. Especially the vertex attribute / resource interfaces
for MSL has been rewritten to avoid taking mutable pointers into the
interface. This would be very annoying to wrap and it didn't fit well
with the rest of the C++ API to begin with. While doing this, I went
ahead and removed all the old deprecated interfaces.

The CMake build system has also seen an overhaul.
It is now possible to build static/shared/CLI separately with -D
options.
The shared library only exposes the C API, as it is the only ABI-stable
API. pkg-configs as well as CMake modules are exported and installed for
the shared library configuration.
2019-03-01 11:53:51 +01:00