Merge pull request #827 from amdrexu/feature4

Implement the extension SPV_KHR_16bit_storage
This commit is contained in:
John Kessenich
2017-04-08 10:03:45 -06:00
committed by GitHub
5 changed files with 31 additions and 0 deletions

View File

@@ -39,5 +39,6 @@ static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vo
static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
static const char* const E_SPV_KHR_16bit_storage = "SPV_KHR_16bit_storage";
#endif // #ifndef GLSLextKHR_H

View File

@@ -2074,6 +2074,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 = "";

View File

@@ -833,6 +833,11 @@ const char* CapabilityString(int info)
case 4437: return "DeviceGroup";
case 4439: return "MultiView";
case 4433: return "StorageUniformBufferBlock16";
case 4434: return "StorageUniform16";
case 4435: return "StoragePushConstant16";
case 4436: return "StorageInputOutput16";
#ifdef NV_EXTENSIONS
case 5251: return "GeometryShaderPassthroughNV";
case 5254: return "ShaderViewportIndexLayerNV";