Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2020-01-09 13:18:14 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2020-01-09 14:41:06 +0300
commitcc153f8d7f797988164e66df3055abe9be200c5f (patch)
tree4a40fb22fd92cec1de03fb13fb6ad62d8d1f4f57 /spirv_common.hpp
parent34ba8ea4f2947fdc56a76b17f352cb692499bcd7 (diff)
HLSL: Add a resource remapping API similar to MSL.
Allows more flexibility of how resources are assigned without having to remap decorations.
Diffstat (limited to 'spirv_common.hpp')
-rw-r--r--spirv_common.hpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/spirv_common.hpp b/spirv_common.hpp
index f25486a6..b3043cf6 100644
--- a/spirv_common.hpp
+++ b/spirv_common.hpp
@@ -1694,6 +1694,62 @@ static inline bool opcode_is_sign_invariant(spv::Op opcode)
return false;
}
}
+
+struct SetBindingPair
+{
+ uint32_t desc_set;
+ uint32_t binding;
+
+ inline bool operator==(const SetBindingPair &other) const
+ {
+ return desc_set == other.desc_set && binding == other.binding;
+ }
+
+ inline bool operator<(const SetBindingPair &other) const
+ {
+ return desc_set < other.desc_set || (desc_set == other.desc_set && binding < other.binding);
+ }
+};
+
+struct StageSetBinding
+{
+ spv::ExecutionModel model;
+ uint32_t desc_set;
+ uint32_t binding;
+
+ inline bool operator==(const StageSetBinding &other) const
+ {
+ return model == other.model && desc_set == other.desc_set && binding == other.binding;
+ }
+};
+
+struct InternalHasher
+{
+ inline size_t operator()(const SetBindingPair &value) const
+ {
+ // Quality of hash doesn't really matter here.
+ auto hash_set = std::hash<uint32_t>()(value.desc_set);
+ auto hash_binding = std::hash<uint32_t>()(value.binding);
+ return (hash_set * 0x10001b31) ^ hash_binding;
+ }
+
+ inline size_t operator()(const StageSetBinding &value) const
+ {
+ // Quality of hash doesn't really matter here.
+ auto hash_model = std::hash<uint32_t>()(value.model);
+ auto hash_set = std::hash<uint32_t>()(value.desc_set);
+ auto tmp_hash = (hash_model * 0x10001b31) ^ hash_set;
+ return (tmp_hash * 0x10001b31) ^ value.binding;
+ }
+};
+
+// Special constant used in a {MSL,HLSL}ResourceBinding desc_set
+// element to indicate the bindings for the push constants.
+static const uint32_t ResourceBindingPushConstantDescriptorSet = ~(0u);
+
+// Special constant used in a {MSL,HLSL}ResourceBinding binding
+// element to indicate the bindings for the push constants.
+static const uint32_t ResourceBindingPushConstantBinding = 0;
} // namespace SPIRV_CROSS_NAMESPACE
namespace std