@@ -1040,64 +1040,30 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
1040
1040
// Note: callers are responsible for other aspects of shape,
1041
1041
// like vector and matrix sizes.
1042
1042
1043
- TBasicType promoteTo;
1044
- // GL_EXT_shader_16bit_storage can't do OpConstantComposite with
1045
- // 16-bit types, so disable promotion for those types.
1046
- bool canPromoteConstant = true ;
1047
-
1048
1043
switch (op) {
1049
1044
//
1050
1045
// Explicit conversions (unary operations)
1051
1046
//
1052
1047
case EOpConstructBool:
1053
- promoteTo = EbtBool;
1054
- break ;
1055
1048
case EOpConstructFloat:
1056
- promoteTo = EbtFloat;
1057
- break ;
1058
1049
case EOpConstructInt:
1059
- promoteTo = EbtInt;
1060
- break ;
1061
1050
case EOpConstructUint:
1062
- promoteTo = EbtUint;
1063
- break ;
1064
1051
#ifndef GLSLANG_WEB
1065
1052
case EOpConstructDouble:
1066
- promoteTo = EbtDouble;
1067
- break ;
1068
1053
case EOpConstructFloat16:
1069
- promoteTo = EbtFloat16;
1070
- canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1071
- extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_float16);
1072
- break ;
1073
1054
case EOpConstructInt8:
1074
- promoteTo = EbtInt8;
1075
- canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1076
- extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int8);
1077
- break ;
1078
1055
case EOpConstructUint8:
1079
- promoteTo = EbtUint8;
1080
- canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1081
- extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int8);
1082
- break ;
1083
1056
case EOpConstructInt16:
1084
- promoteTo = EbtInt16;
1085
- canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1086
- extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int16);
1087
- break ;
1088
1057
case EOpConstructUint16:
1089
- promoteTo = EbtUint16;
1090
- canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1091
- extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int16);
1092
- break ;
1093
1058
case EOpConstructInt64:
1094
- promoteTo = EbtInt64;
1095
- break ;
1096
1059
case EOpConstructUint64:
1097
- promoteTo = EbtUint64;
1098
1060
break ;
1061
+
1099
1062
#endif
1100
1063
1064
+ //
1065
+ // Implicit conversions
1066
+ //
1101
1067
case EOpLogicalNot:
1102
1068
1103
1069
case EOpFunctionCall:
@@ -1152,9 +1118,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
1152
1118
if (type.getBasicType () == node->getType ().getBasicType ())
1153
1119
return node;
1154
1120
1155
- if (canImplicitlyPromote (node->getBasicType (), type.getBasicType (), op))
1156
- promoteTo = type.getBasicType ();
1157
- else
1121
+ if (! canImplicitlyPromote (node->getBasicType (), type.getBasicType (), op))
1158
1122
return nullptr ;
1159
1123
break ;
1160
1124
@@ -1164,9 +1128,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
1164
1128
case EOpLeftShiftAssign:
1165
1129
case EOpRightShiftAssign:
1166
1130
{
1167
- if (getSource () == EShSourceHlsl && node->getType ().getBasicType () == EbtBool)
1168
- promoteTo = type.getBasicType ();
1169
- else {
1131
+ if (!(getSource () == EShSourceHlsl && node->getType ().getBasicType () == EbtBool)) {
1170
1132
if (isTypeInt (type.getBasicType ()) && isTypeInt (node->getBasicType ()))
1171
1133
return node;
1172
1134
else
@@ -1184,13 +1146,42 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
1184
1146
return nullptr ;
1185
1147
}
1186
1148
1149
+ bool canPromoteConstant = true ;
1150
+ #ifndef GLSLANG_WEB
1151
+ // GL_EXT_shader_16bit_storage can't do OpConstantComposite with
1152
+ // 16-bit types, so disable promotion for those types.
1153
+ // Many issues with this, from JohnK:
1154
+ // - this isn't really right to discuss SPIR-V here
1155
+ // - this could easily be entirely about scalars, so is overstepping
1156
+ // - we should be looking at what the shader asked for, and saying whether or
1157
+ // not it can be done, in the parser, by calling requireExtensions(), not
1158
+ // changing language sementics on the fly by asking what extensions are in use
1159
+ // - at the time of this writing (14-Aug-2020), no test results are changed by this.
1160
+ switch (op) {
1161
+ case EOpConstructFloat16:
1162
+ canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1163
+ extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_float16);
1164
+ break ;
1165
+ case EOpConstructInt8:
1166
+ case EOpConstructUint8:
1167
+ canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1168
+ extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int8);
1169
+ break ;
1170
+ case EOpConstructInt16:
1171
+ case EOpConstructUint16:
1172
+ canPromoteConstant = extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types) ||
1173
+ extensionRequested (E_GL_EXT_shader_explicit_arithmetic_types_int16);
1174
+ break ;
1175
+ }
1176
+ #endif
1177
+
1187
1178
if (canPromoteConstant && node->getAsConstantUnion ())
1188
- return promoteConstantUnion (promoteTo , node->getAsConstantUnion ());
1179
+ return promoteConstantUnion (type. getBasicType () , node->getAsConstantUnion ());
1189
1180
1190
1181
//
1191
1182
// Add a new newNode for the conversion.
1192
1183
//
1193
- TIntermTyped* newNode = createConversion (promoteTo , node);
1184
+ TIntermTyped* newNode = createConversion (type. getBasicType () , node);
1194
1185
1195
1186
return newNode;
1196
1187
}
0 commit comments