SPV: Fix #1487: Only declare AMD int16/half_float extensions when needed.
This commit is contained in:
12
SPIRV/GlslangToSpv.cpp
Normal file → Executable file
12
SPIRV/GlslangToSpv.cpp
Normal file → Executable file
@@ -2729,10 +2729,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
spvType = builder.makeFloatType(64);
|
||||
break;
|
||||
case glslang::EbtFloat16:
|
||||
#if AMD_EXTENSIONS
|
||||
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
|
||||
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
|
||||
#endif
|
||||
spvType = builder.makeFloatType(16);
|
||||
break;
|
||||
case glslang::EbtBool:
|
||||
@@ -2750,17 +2746,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
spvType = builder.makeUintType(8);
|
||||
break;
|
||||
case glslang::EbtInt16:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
|
||||
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
|
||||
#endif
|
||||
spvType = builder.makeIntType(16);
|
||||
break;
|
||||
case glslang::EbtUint16:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
|
||||
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
|
||||
#endif
|
||||
spvType = builder.makeUintType(16);
|
||||
break;
|
||||
case glslang::EbtInt:
|
||||
|
||||
19
SPIRV/SpvPostProcess.cpp
Normal file → Executable file
19
SPIRV/SpvPostProcess.cpp
Normal file → Executable file
@@ -120,6 +120,25 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
|
||||
case OpSConvert:
|
||||
case OpUConvert:
|
||||
break;
|
||||
case OpExtInst:
|
||||
switch (inst.getImmediateOperand(1)) {
|
||||
#if AMD_EXTENSIONS
|
||||
case GLSLstd450Frexp:
|
||||
case GLSLstd450FrexpStruct:
|
||||
if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeInt, 16))
|
||||
addExtension(spv::E_SPV_AMD_gpu_shader_int16);
|
||||
break;
|
||||
case GLSLstd450InterpolateAtCentroid:
|
||||
case GLSLstd450InterpolateAtSample:
|
||||
case GLSLstd450InterpolateAtOffset:
|
||||
if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeFloat, 16))
|
||||
addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (basicTypeOp == OpTypeFloat && width == 16)
|
||||
addCapability(CapabilityFloat16);
|
||||
|
||||
Reference in New Issue
Block a user