diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-02-04 16:25:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 16:25:19 +0300 |
commit | 131278458ea8eebe6a6e9c476fbcf71278726e1a (patch) | |
tree | 1e8528105b54205b5373c7c2e51c5e620c34e80c | |
parent | 1a36968e5d92e08ba38335ad00701da21c627a13 (diff) | |
parent | a8016a6470a3b9e47bbdbc3152efeb0c2b721505 (diff) |
Merge pull request #1860 from KhronosGroup/docs-update
Update documentation for descriptor set support in MSL/HLSL.
-rw-r--r-- | README.md | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -381,10 +381,28 @@ for (auto &remap : compiler->get_combined_image_samplers()) If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect. The command line client calls `Compiler::build_combined_image_samplers` automatically, but if you're calling the library, you'll need to do this yourself. -#### Descriptor sets (Vulkan GLSL) for backends which do not support them (HLSL/GLSL/Metal) +#### Descriptor sets (Vulkan GLSL) for backends which do not support them (pre HLSL 5.1 / GLSL) Descriptor sets are unique to Vulkan, so make sure that descriptor set + binding is remapped to a flat binding scheme (set always 0), so that other APIs can make sense of the bindings. -This can be done with `Compiler::set_decoration(id, spv::DecorationDescriptorSet)`. +This can be done with `Compiler::set_decoration(id, spv::DecorationDescriptorSet)`. For other backends like MSL and HLSL, descriptor sets +can be used, with some minor caveats, see below. + +##### MSL 2.0+ + +Metal supports indirect argument buffers (--msl-argument-buffers). In this case, descriptor sets become argument buffers, +and bindings are mapped to [[id(N)]] within the argument buffer. One quirk is that arrays of resources consume multiple ids, +where Vulkan does not. This can be worked around either from shader authoring stage +or remapping bindings as needed to avoid the overlap. +There is also a rich API to declare remapping schemes which is intended to work like +the pipeline layout in Vulkan. See `CompilerMSL::add_msl_resource_binding`. Remapping combined image samplers for example +must be split into two bindings in MSL, so it's possible to declare an id for the texture and sampler binding separately. + +##### HLSL - SM 5.1+ + +In SM 5.1+, descriptor set bindings are interpreted as register spaces directly. In HLSL however, arrays of resources consume +multiple binding slots where Vulkan does not, so there might be overlap if the SPIR-V was not authored with this in mind. +This can be worked around either from shader authoring stage (don't assign overlapping bindings) +or remap bindings in SPIRV-Cross as needed to avoid the overlap. #### Linking by name for targets which do not support explicit locations (legacy GLSL/ESSL) |