Non-functional: Remove reinventing the scalar type, note code issues
The scalar type was already the basic type passed in. Also factored out of this the checking of extensions for 8/16-bit stuff. This code seems wrong in several ways, but for now just documenting it.
This commit is contained in:
parent
b58f308ba4
commit
bdf9e647f5
1 changed files with 37 additions and 46 deletions
|
|
@ -1040,64 +1040,30 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
// Note: callers are responsible for other aspects of shape,
|
// Note: callers are responsible for other aspects of shape,
|
||||||
// like vector and matrix sizes.
|
// like vector and matrix sizes.
|
||||||
|
|
||||||
TBasicType promoteTo;
|
|
||||||
// GL_EXT_shader_16bit_storage can't do OpConstantComposite with
|
|
||||||
// 16-bit types, so disable promotion for those types.
|
|
||||||
bool canPromoteConstant = true;
|
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
//
|
//
|
||||||
// Explicit conversions (unary operations)
|
// Explicit conversions (unary operations)
|
||||||
//
|
//
|
||||||
case EOpConstructBool:
|
case EOpConstructBool:
|
||||||
promoteTo = EbtBool;
|
|
||||||
break;
|
|
||||||
case EOpConstructFloat:
|
case EOpConstructFloat:
|
||||||
promoteTo = EbtFloat;
|
|
||||||
break;
|
|
||||||
case EOpConstructInt:
|
case EOpConstructInt:
|
||||||
promoteTo = EbtInt;
|
|
||||||
break;
|
|
||||||
case EOpConstructUint:
|
case EOpConstructUint:
|
||||||
promoteTo = EbtUint;
|
|
||||||
break;
|
|
||||||
#ifndef GLSLANG_WEB
|
#ifndef GLSLANG_WEB
|
||||||
case EOpConstructDouble:
|
case EOpConstructDouble:
|
||||||
promoteTo = EbtDouble;
|
|
||||||
break;
|
|
||||||
case EOpConstructFloat16:
|
case EOpConstructFloat16:
|
||||||
promoteTo = EbtFloat16;
|
|
||||||
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
|
||||||
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16);
|
|
||||||
break;
|
|
||||||
case EOpConstructInt8:
|
case EOpConstructInt8:
|
||||||
promoteTo = EbtInt8;
|
|
||||||
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
|
||||||
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
|
|
||||||
break;
|
|
||||||
case EOpConstructUint8:
|
case EOpConstructUint8:
|
||||||
promoteTo = EbtUint8;
|
|
||||||
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
|
||||||
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
|
|
||||||
break;
|
|
||||||
case EOpConstructInt16:
|
case EOpConstructInt16:
|
||||||
promoteTo = EbtInt16;
|
|
||||||
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
|
||||||
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
|
|
||||||
break;
|
|
||||||
case EOpConstructUint16:
|
case EOpConstructUint16:
|
||||||
promoteTo = EbtUint16;
|
|
||||||
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
|
||||||
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
|
|
||||||
break;
|
|
||||||
case EOpConstructInt64:
|
case EOpConstructInt64:
|
||||||
promoteTo = EbtInt64;
|
|
||||||
break;
|
|
||||||
case EOpConstructUint64:
|
case EOpConstructUint64:
|
||||||
promoteTo = EbtUint64;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implicit conversions
|
||||||
|
//
|
||||||
case EOpLogicalNot:
|
case EOpLogicalNot:
|
||||||
|
|
||||||
case EOpFunctionCall:
|
case EOpFunctionCall:
|
||||||
|
|
@ -1152,9 +1118,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
if (type.getBasicType() == node->getType().getBasicType())
|
if (type.getBasicType() == node->getType().getBasicType())
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
if (canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
|
if (! canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
|
||||||
promoteTo = type.getBasicType();
|
|
||||||
else
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1164,9 +1128,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
case EOpLeftShiftAssign:
|
case EOpLeftShiftAssign:
|
||||||
case EOpRightShiftAssign:
|
case EOpRightShiftAssign:
|
||||||
{
|
{
|
||||||
if (getSource() == EShSourceHlsl && node->getType().getBasicType() == EbtBool)
|
if (!(getSource() == EShSourceHlsl && node->getType().getBasicType() == EbtBool)) {
|
||||||
promoteTo = type.getBasicType();
|
|
||||||
else {
|
|
||||||
if (isTypeInt(type.getBasicType()) && isTypeInt(node->getBasicType()))
|
if (isTypeInt(type.getBasicType()) && isTypeInt(node->getBasicType()))
|
||||||
return node;
|
return node;
|
||||||
else
|
else
|
||||||
|
|
@ -1184,13 +1146,42 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool canPromoteConstant = true;
|
||||||
|
#ifndef GLSLANG_WEB
|
||||||
|
// GL_EXT_shader_16bit_storage can't do OpConstantComposite with
|
||||||
|
// 16-bit types, so disable promotion for those types.
|
||||||
|
// Many issues with this, from JohnK:
|
||||||
|
// - this isn't really right to discuss SPIR-V here
|
||||||
|
// - this could easily be entirely about scalars, so is overstepping
|
||||||
|
// - we should be looking at what the shader asked for, and saying whether or
|
||||||
|
// not it can be done, in the parser, by calling requireExtensions(), not
|
||||||
|
// changing language sementics on the fly by asking what extensions are in use
|
||||||
|
// - at the time of this writing (14-Aug-2020), no test results are changed by this.
|
||||||
|
switch (op) {
|
||||||
|
case EOpConstructFloat16:
|
||||||
|
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
||||||
|
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16);
|
||||||
|
break;
|
||||||
|
case EOpConstructInt8:
|
||||||
|
case EOpConstructUint8:
|
||||||
|
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
||||||
|
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
|
||||||
|
break;
|
||||||
|
case EOpConstructInt16:
|
||||||
|
case EOpConstructUint16:
|
||||||
|
canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
|
||||||
|
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (canPromoteConstant && node->getAsConstantUnion())
|
if (canPromoteConstant && node->getAsConstantUnion())
|
||||||
return promoteConstantUnion(promoteTo, node->getAsConstantUnion());
|
return promoteConstantUnion(type.getBasicType(), node->getAsConstantUnion());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add a new newNode for the conversion.
|
// Add a new newNode for the conversion.
|
||||||
//
|
//
|
||||||
TIntermTyped* newNode = createConversion(promoteTo, node);
|
TIntermTyped* newNode = createConversion(type.getBasicType(), node);
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue