Add a SPIR-V editor helper to register a constant with a pre-given ID

This commit is contained in:
baldurk
2023-10-30 10:24:30 +00:00
parent 3ac150d273
commit f87c50af25
@@ -179,9 +179,15 @@ public:
// helper for AddConstant
template <typename T>
Id AddConstantImmediate(T t)
{
return AddConstantImmediate<T>(t, MakeId());
}
template <typename T>
Id AddConstantImmediate(T t, rdcspv::Id constantId)
{
Id typeId = DeclareType(scalar<T>());
rdcarray<uint32_t> words = {typeId.value(), MakeId().value()};
rdcarray<uint32_t> words = {typeId.value(), constantId.value()};
words.resize(words.size() + (sizeof(T) + 3) / 4);