HLSL: Implement bit casts between Half and UShort.

This commit is contained in:
Pedro J. Estébanez 2022-06-08 22:13:51 +02:00
parent 50b4d5389b
commit d8c5e39436

View File

@ -3598,6 +3598,18 @@ string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i
}
return "spvPackFloat2x16";
}
else if (out_type.basetype == SPIRType::UShort && in_type.basetype == SPIRType::Half)
{
if (hlsl_options.shader_model < 40)
SPIRV_CROSS_THROW("Half to UShort requires Shader Model 4.");
return "(" + type_to_glsl(out_type) + ")f32tof16";
}
else if (out_type.basetype == SPIRType::Half && in_type.basetype == SPIRType::UShort)
{
if (hlsl_options.shader_model < 40)
SPIRV_CROSS_THROW("UShort to Half requires Shader Model 4.");
return "(" + type_to_glsl(out_type) + ")f16tof32";
}
else
return "";
}