Commit 22f23024 by Alexander Galazin

Restore original canImplicitlyPromote implementation

This change restores original canImplicitlyPromote implementation in case the explicit type extension wasn't requested.
parent d55c2d9b
......@@ -12,6 +12,7 @@ spv.int64.frag
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_ARB_gpu_shader_int64"
SourceExtension "GL_KHX_shader_explicit_arithmetic_types_int64"
Name 4 "main"
Name 6 "literal("
Name 8 "typeCast("
......
#version 450
#extension GL_ARB_gpu_shader_int64: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
layout(binding = 0) uniform Uniforms
{
......
......@@ -1429,6 +1429,7 @@ bool TIntermediate::isFPIntegralConversion(TBasicType from, TBasicType to) const
}
return false;
}
//
// See if the 'from' type is allowed to be implicitly converted to the
// 'to' type. This is not about vector/array/struct, only about basic type.
......@@ -1474,36 +1475,161 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
}
}
bool explicitTypesEnabled = extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_int8) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_int16) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_int32) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_int64) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_float16) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_float32) ||
extensionRequested(E_GL_KHX_shader_explicit_arithmetic_types_float64);
// integral promotions
if (isIntegralPromotion(from, to)) {
return true;
}
if(explicitTypesEnabled)
{
// floating-point promotions
if (isFPPromotion(from, to)) {
return true;
}
// integral promotions
if (isIntegralPromotion(from, to)) {
return true;
}
// integral conversions
if (isIntegralConversion(from, to)) {
return true;
}
// floating-point promotions
if (isFPPromotion(from, to)) {
return true;
}
// floating-point conversions
if (isFPConversion(from, to)) {
return true;
}
// integral conversions
if (isIntegralConversion(from, to)) {
return true;
}
// floating-integral conversions
if (isFPIntegralConversion(from, to)) {
return true;
}
// floating-point conversions
if (isFPConversion(from, to)) {
return true;
}
// hlsl supported conversions
if (source == EShSourceHlsl) {
if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
return true;
// floating-integral conversions
if (isFPIntegralConversion(from, to)) {
return true;
}
// hlsl supported conversions
if (source == EShSourceHlsl) {
if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
return true;
}
} else {
switch (to) {
case EbtDouble:
switch (from) {
case EbtInt:
case EbtUint:
case EbtInt64:
case EbtUint64:
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
#endif
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
return true;
default:
return false;
}
case EbtFloat:
switch (from) {
case EbtInt:
case EbtUint:
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
#endif
case EbtFloat:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
return true;
case EbtBool:
return (source == EShSourceHlsl);
default:
return false;
}
case EbtUint:
switch (from) {
case EbtInt:
return version >= 400 || (source == EShSourceHlsl);
case EbtUint:
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
#endif
return true;
case EbtBool:
return (source == EShSourceHlsl);
default:
return false;
}
case EbtInt:
switch (from) {
case EbtInt:
#ifdef AMD_EXTENSIONS
case EbtInt16:
#endif
return true;
case EbtBool:
return (source == EShSourceHlsl);
default:
return false;
}
case EbtUint64:
switch (from) {
case EbtInt:
case EbtUint:
case EbtInt64:
case EbtUint64:
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
#endif
return true;
default:
return false;
}
case EbtInt64:
switch (from) {
case EbtInt:
case EbtInt64:
#ifdef AMD_EXTENSIONS
case EbtInt16:
#endif
return true;
default:
return false;
}
#ifdef AMD_EXTENSIONS
case EbtFloat16:
switch (from) {
case EbtInt16:
case EbtUint16:
case EbtFloat16:
return true;
default:
return false;
}
case EbtUint16:
switch (from) {
case EbtInt16:
case EbtUint16:
return true;
default:
return false;
}
#endif
default:
return false;
}
}
return false;
......
......@@ -647,6 +647,7 @@ protected:
bool isConversionAllowed(TOperator op, TIntermTyped* node) const;
TIntermUnary* createConversion(TBasicType convertTo, TIntermTyped* node) const;
std::tuple<TBasicType, TBasicType> getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const;
bool extensionRequested(const char *extension) const {return requestedExtensions.find(extension) != requestedExtensions.end();}
const EShLanguage language; // stage, known at construction time
EShSource source; // source language, known a bit later
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment