Implement the extension SPV_KHR_16bit_storage

This commit is contained in:
Rex Xu
2017-04-07 23:22:33 +08:00
parent 38a425355b
commit f89ad98013
5 changed files with 31 additions and 0 deletions

View File

@@ -2075,6 +2075,24 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
spv::StorageClass storageClass = TranslateStorageClass(node->getType());
spv::Id spvType = convertGlslangToSpvType(node->getType());
#ifdef AMD_EXTENSIONS
const bool contains16BitType = node->getType().containsBasicType(glslang::EbtFloat16);
if (contains16BitType) {
if (storageClass == spv::StorageClassInput || storageClass == spv::StorageClassOutput) {
builder.addExtension(spv::E_SPV_KHR_16bit_storage);
builder.addCapability(spv::CapabilityStorageInputOutput16);
} else if (storageClass == spv::StorageClassPushConstant) {
builder.addExtension(spv::E_SPV_KHR_16bit_storage);
builder.addCapability(spv::CapabilityStoragePushConstant16);
} else if (storageClass == spv::StorageClassUniform) {
builder.addExtension(spv::E_SPV_KHR_16bit_storage);
builder.addCapability(spv::CapabilityStorageUniform16);
if (node->getType().getQualifier().storage == glslang::EvqBuffer)
builder.addCapability(spv::CapabilityStorageUniformBufferBlock16);
}
}
#endif
const char* name = node->getName().c_str();
if (glslang::IsAnonymous(name))
name = "";