[Vulkan] Workaround for glslang 11.6.0+ change in accesschain semantics
This commit is contained in:
@@ -32,6 +32,47 @@ class SpirvBuilder : public spv::Builder {
|
||||
// Make public rather than protected.
|
||||
using spv::Builder::createSelectionMerge;
|
||||
|
||||
// Backward compatibility wrapper for createBranch
|
||||
void createBranch(spv::Block* block) {
|
||||
spv::Builder::createBranch(true, block);
|
||||
}
|
||||
|
||||
// Backward compatibility wrapper for makeFunctionEntry
|
||||
// For shaders, we use LinkageType::Max which means no linkage decoration
|
||||
spv::Function* makeFunctionEntry(
|
||||
spv::Decoration precision, spv::Id returnType, const char* name,
|
||||
const std::vector<spv::Id>& paramTypes,
|
||||
const std::vector<std::vector<spv::Decoration>>& precisions,
|
||||
spv::Block** entry = nullptr) {
|
||||
// LinkageType::Max means no linkage decoration will be added (correct for
|
||||
// shader entry points)
|
||||
return spv::Builder::makeFunctionEntry(precision, returnType, name,
|
||||
spv::LinkageType::Max, paramTypes,
|
||||
precisions, entry);
|
||||
}
|
||||
|
||||
// Hide base class createAccessChain to workaround the way
|
||||
// glslang 11.6.0+ uses internal accessChain state instead of parameters.
|
||||
spv::Id createAccessChain(spv::StorageClass storage_class, spv::Id base,
|
||||
const std::vector<spv::Id>& offsets) {
|
||||
// glslang 11.6.0+ uses the accessChain member
|
||||
// in getResultingAccessChainType() but doesn't populate it from the
|
||||
// parameters. We need to set it up correctly before calling the parent.
|
||||
clearAccessChain();
|
||||
setAccessChainLValue(base);
|
||||
for (const auto& offset : offsets) {
|
||||
accessChainPush(offset, {}, 0);
|
||||
}
|
||||
|
||||
spv::Id result =
|
||||
spv::Builder::createAccessChain(storage_class, base, offsets);
|
||||
|
||||
// Clear the state again to avoid affecting subsequent operations
|
||||
clearAccessChain();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
spv::Id createQuadOp(spv::Op op_code, spv::Id type_id, spv::Id operand1,
|
||||
spv::Id operand2, spv::Id operand3, spv::Id operand4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user