Merge branch 'fix_uint2int64' into 'master'
Restore original canImplicitlyPromote implementation
See merge request !26
diff --git a/Test/baseResults/spv.int64.frag.out b/Test/baseResults/spv.int64.frag.out
index c41a2fd..0cd8f3d 100644
--- a/Test/baseResults/spv.int64.frag.out
+++ b/Test/baseResults/spv.int64.frag.out
@@ -12,6 +12,7 @@
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("
diff --git a/Test/spv.int64.frag b/Test/spv.int64.frag
index 8021b7e..bcbb24b 100644
--- a/Test/spv.int64.frag
+++ b/Test/spv.int64.frag
@@ -1,6 +1,7 @@
#version 450
#extension GL_ARB_gpu_shader_int64: enable
+#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
layout(binding = 0) uniform Uniforms
{
diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp
index 80d5be9..6b89456 100644
--- a/glslang/MachineIndependent/Intermediate.cpp
+++ b/glslang/MachineIndependent/Intermediate.cpp
@@ -1429,6 +1429,7 @@
}
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 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 conversions
- if (isIntegralConversion(from, to)) {
- return true;
- }
-
- // floating-point conversions
- if (isFPConversion(from, to)) {
- 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))
+ // integral promotions
+ if (isIntegralPromotion(from, to)) {
return true;
+ }
+
+ // floating-point promotions
+ if (isFPPromotion(from, to)) {
+ return true;
+ }
+
+ // integral conversions
+ if (isIntegralConversion(from, to)) {
+ return true;
+ }
+
+ // floating-point conversions
+ if (isFPConversion(from, to)) {
+ 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;
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index 1e62e9b..8be3a13 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -647,6 +647,7 @@
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